Add item creation and viewer dialogs with filtering options for 2D/3D items

This commit is contained in:
MaddoScientisto 2026-02-08 19:07:20 +01:00
commit 1b572e82bf
8 changed files with 1236 additions and 0 deletions

View file

@ -6,12 +6,14 @@ extends PanelContainer
signal create_weapon_requested(weapon_data: Dictionary)
signal create_bullet_requested(bullet_data: Dictionary)
signal create_item_requested(item_data: Dictionary)
# UI elements
var clear_button: Button
var log_output: RichTextLabel
var weapon_viewer: PanelContainer
var bullet_viewer: PanelContainer
var item_viewer: PanelContainer
var tab_container: TabContainer
var _is_creating: bool = false
@ -74,10 +76,21 @@ func _build_ui() -> void:
bullet_viewer.bullet_duplication_started.connect(_on_bullet_duplication_started)
tab_container.add_child(bullet_viewer)
# Item Viewer Tab
var item_viewer_script = load("res://addons/weapon_creator/ItemViewer.gd")
item_viewer = PanelContainer.new()
item_viewer.set_script(item_viewer_script)
item_viewer.name = "Items"
item_viewer.duplicate_item_requested.connect(_on_item_data_confirmed)
item_viewer.item_deleted.connect(_on_item_deleted)
item_viewer.item_duplication_started.connect(_on_item_duplication_started)
tab_container.add_child(item_viewer)
# Setup after adding to scene tree
if _editor_interface:
weapon_viewer.setup(_editor_interface, self)
bullet_viewer.setup(_editor_interface, self)
item_viewer.setup(_editor_interface, self)
# Log header with label and clear button
var log_header_hbox = HBoxContainer.new()
@ -140,6 +153,21 @@ func _on_bullet_duplication_started(bullet_name: String, is_3d: bool) -> void:
# Logging is handled directly in BulletViewer
pass
func _on_item_data_confirmed(item_data: Dictionary) -> void:
if _is_creating:
return
_is_creating = true
log_output.clear()
create_item_requested.emit(item_data)
func _on_item_deleted(item_name: String, item_path: String) -> void:
pass
func _on_item_duplication_started(item_name: String) -> void:
pass
func add_log(message: String, color: Color = Color.WHITE) -> void:
# Add colored message to log output
log_output.append_text("[color=#" + color.to_html(false) + "]" + message + "[/color]\n")
@ -151,3 +179,5 @@ func set_creation_complete() -> void:
weapon_viewer.call("refresh_weapons")
if bullet_viewer:
bullet_viewer.call("refresh_bullets")
if item_viewer:
item_viewer.call("refresh_items")