mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-07-01 19:21:17 +00:00
Add item creation and viewer dialogs with filtering options for 2D/3D items
This commit is contained in:
parent
670a37140f
commit
1b572e82bf
8 changed files with 1236 additions and 0 deletions
|
|
@ -20,6 +20,8 @@ func _enter_tree() -> void:
|
|||
dock_instance.create_weapon_requested.connect(_on_create_weapon_requested)
|
||||
if dock_instance.has_signal("create_bullet_requested"):
|
||||
dock_instance.create_bullet_requested.connect(_on_create_bullet_requested)
|
||||
if dock_instance.has_signal("create_item_requested"):
|
||||
dock_instance.create_item_requested.connect(_on_create_item_requested)
|
||||
|
||||
# Add the dock to the editor (bottom dock area)
|
||||
add_control_to_bottom_panel(dock_instance, "Weapon Creator")
|
||||
|
|
@ -281,6 +283,89 @@ func _on_create_bullet_requested(bullet_data: Dictionary) -> void:
|
|||
|
||||
get_editor_interface().get_resource_filesystem().scan()
|
||||
|
||||
func _on_create_item_requested(item_data: Dictionary) -> void:
|
||||
var item_name: String = item_data.get("item_name", "New Item")
|
||||
var item_key: String = item_data.get("item_key", "NEW_ITEM")
|
||||
var short_name: String = item_data.get("short_name", "NI")
|
||||
var description: String = item_data.get("description", "A new item")
|
||||
var sprite_resource: Texture2D = item_data.get("sprite_resource", null)
|
||||
var item_type: int = item_data.get("item_type", 0)
|
||||
var tier: int = item_data.get("tier", 0)
|
||||
var price: int = item_data.get("price", 0)
|
||||
var amount: int = item_data.get("amount", 1)
|
||||
var max: int = item_data.get("max", 1)
|
||||
var pickup_if_maxed: bool = item_data.get("pickup_if_maxed", false)
|
||||
var consume_on_use: bool = item_data.get("consume_on_use", false)
|
||||
var selectable: bool = item_data.get("selectable", false)
|
||||
|
||||
var item_resource_path: String = "res://Resources/Items/" + item_key + "_Item.tres"
|
||||
var items_database_path: String = "res://Resources/ItemsDatabase.tres"
|
||||
|
||||
dock_instance.call("add_log", "=== Starting Item Creation ===")
|
||||
dock_instance.call("add_log", "Item Name: " + item_name)
|
||||
dock_instance.call("add_log", "Item Key: " + item_key)
|
||||
|
||||
if _create_loot_item_only(item_resource_path, item_name, short_name, description,
|
||||
item_key, sprite_resource, item_type, tier, price,
|
||||
amount, max, pickup_if_maxed, consume_on_use, selectable):
|
||||
dock_instance.call("add_log", "✓ Created LootItem at: " + item_resource_path, Color.GREEN)
|
||||
else:
|
||||
dock_instance.call("add_log", "✗ Failed to create LootItem", Color.RED)
|
||||
dock_instance.call("set_creation_complete")
|
||||
return
|
||||
|
||||
if _add_to_items_database(items_database_path, item_resource_path):
|
||||
dock_instance.call("add_log", "✓ Added to ItemsDatabase", Color.GREEN)
|
||||
else:
|
||||
dock_instance.call("add_log", "✗ Failed to add to ItemsDatabase", Color.RED)
|
||||
dock_instance.call("set_creation_complete")
|
||||
return
|
||||
|
||||
dock_instance.call("add_log", "=== Item Creation Complete ===", Color.CYAN)
|
||||
dock_instance.call("set_creation_complete")
|
||||
|
||||
get_editor_interface().get_resource_filesystem().scan()
|
||||
|
||||
func _create_loot_item_only(path: String, item_name: String, short_name: String,
|
||||
description: String, item_key: String, sprite_resource: Texture2D,
|
||||
item_type: int, tier: int, price: int, amount: int, max: int,
|
||||
pickup_if_maxed: bool, consume_on_use: bool, selectable: bool) -> bool:
|
||||
if ResourceLoader.exists(path):
|
||||
dock_instance.call("add_log", "Warning: LootItem already exists at " + path, Color.YELLOW)
|
||||
return false
|
||||
|
||||
var loot_item_script = load("res://Scripts/Resources/LootItem.cs")
|
||||
if loot_item_script == null:
|
||||
dock_instance.call("add_log", "Error: Could not load LootItem.cs script", Color.RED)
|
||||
return false
|
||||
|
||||
var loot_item = Resource.new()
|
||||
loot_item.set_script(loot_item_script)
|
||||
|
||||
loot_item.set("ItemName", item_name)
|
||||
loot_item.set("ShortName", short_name)
|
||||
loot_item.set("ItemDescription", description)
|
||||
loot_item.set("ItemKey", item_key)
|
||||
loot_item.set("Item", item_type)
|
||||
loot_item.set("Tier", tier)
|
||||
loot_item.set("Price", price)
|
||||
loot_item.set("Amount", amount)
|
||||
loot_item.set("Max", max)
|
||||
loot_item.set("PickupIfMaxed", pickup_if_maxed)
|
||||
loot_item.set("ConsumeOnUse", consume_on_use)
|
||||
loot_item.set("Selectable", selectable)
|
||||
|
||||
if sprite_resource != null:
|
||||
loot_item.set("InventorySprite", sprite_resource)
|
||||
|
||||
var err = ResourceSaver.save(loot_item, path)
|
||||
if err != OK:
|
||||
dock_instance.call("add_log", "Error saving LootItem: " + str(err), Color.RED)
|
||||
return false
|
||||
|
||||
return true
|
||||
|
||||
|
||||
func _create_bullet_resource(path: String, bullet_data: Dictionary) -> bool:
|
||||
if ResourceLoader.exists(path):
|
||||
dock_instance.call("add_log", "Warning: BulletResource already exists at " + path, Color.YELLOW)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue