@tool extends PanelContainer # UI dock for the Weapon Creator plugin # Provides tabs for weapons and bullets, with creation dialogs and logs signal create_weapon_requested(weapon_data: Dictionary) signal create_bullet_requested(bullet_data: Dictionary) # UI elements var clear_button: Button var log_output: RichTextLabel var weapon_viewer: PanelContainer var bullet_viewer: PanelContainer var tab_container: TabContainer var _is_creating: bool = false var _editor_interface: EditorInterface func setup(editor_interface: EditorInterface) -> void: _editor_interface = editor_interface func _ready() -> void: _build_ui() func _build_ui() -> void: # Main margin container var margin = MarginContainer.new() margin.add_theme_constant_override("margin_left", 8) margin.add_theme_constant_override("margin_top", 8) margin.add_theme_constant_override("margin_right", 8) margin.add_theme_constant_override("margin_bottom", 8) add_child(margin) # Main vbox var vbox = VBoxContainer.new() vbox.add_theme_constant_override("separation", 8) margin.add_child(vbox) # Horizontal split container for tabs and log var hsplit = HSplitContainer.new() hsplit.size_flags_vertical = Control.SIZE_EXPAND_FILL vbox.add_child(hsplit) # Log section (left side) var log_vbox = VBoxContainer.new() log_vbox.size_flags_horizontal = Control.SIZE_EXPAND_FILL log_vbox.add_theme_constant_override("separation", 4) hsplit.add_child(log_vbox) # Tab Container for Weapons and Bullets (right side) tab_container = TabContainer.new() tab_container.custom_minimum_size = Vector2(300, 0) tab_container.size_flags_horizontal = Control.SIZE_EXPAND_FILL hsplit.add_child(tab_container) # Weapon Viewer Tab var weapon_viewer_script = load("res://addons/weapon_creator/WeaponViewer.gd") weapon_viewer = PanelContainer.new() weapon_viewer.set_script(weapon_viewer_script) weapon_viewer.name = "Weapons" weapon_viewer.duplicate_weapon_requested.connect(_on_weapon_data_confirmed) weapon_viewer.weapon_deleted.connect(_on_weapon_deleted) weapon_viewer.weapon_duplication_started.connect(_on_weapon_duplication_started) tab_container.add_child(weapon_viewer) # Bullet Viewer Tab var bullet_viewer_script = load("res://addons/weapon_creator/BulletViewer.gd") bullet_viewer = PanelContainer.new() bullet_viewer.set_script(bullet_viewer_script) bullet_viewer.name = "Bullets" bullet_viewer.duplicate_bullet_requested.connect(_on_bullet_data_confirmed) bullet_viewer.bullet_deleted.connect(_on_bullet_deleted) bullet_viewer.bullet_duplication_started.connect(_on_bullet_duplication_started) tab_container.add_child(bullet_viewer) # Setup after adding to scene tree if _editor_interface: weapon_viewer.setup(_editor_interface, self) bullet_viewer.setup(_editor_interface, self) # Log header with label and clear button var log_header_hbox = HBoxContainer.new() log_vbox.add_child(log_header_hbox) var log_label = Label.new() log_label.text = "Output Log:" log_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL log_header_hbox.add_child(log_label) clear_button = Button.new() clear_button.text = "Clear Log" clear_button.pressed.connect(_on_clear_button_pressed) log_header_hbox.add_child(clear_button) var log_scroll = ScrollContainer.new() log_scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL log_vbox.add_child(log_scroll) log_output = RichTextLabel.new() log_output.bbcode_enabled = true log_output.scroll_following = true log_output.selection_enabled = true log_output.context_menu_enabled = true log_output.size_flags_horizontal = Control.SIZE_EXPAND_FILL log_output.size_flags_vertical = Control.SIZE_EXPAND_FILL log_scroll.add_child(log_output) func _on_weapon_data_confirmed(weapon_data: Dictionary) -> void: if _is_creating: return _is_creating = true log_output.clear() create_weapon_requested.emit(weapon_data) func _on_clear_button_pressed() -> void: log_output.clear() func _on_weapon_deleted(weapon_name: String, weapon_path: String, item_path: String) -> void: pass func _on_weapon_duplication_started(weapon_name: String, is_3d: bool) -> void: pass func _on_bullet_data_confirmed(bullet_data: Dictionary) -> void: if _is_creating: return _is_creating = true create_bullet_requested.emit(bullet_data) func _on_bullet_deleted(bullet_name: String, bullet_path: String) -> void: # Logging is handled directly in BulletViewer pass func _on_bullet_duplication_started(bullet_name: String, is_3d: bool) -> void: # Logging is handled directly in BulletViewer 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") func set_creation_complete() -> void: _is_creating = false if weapon_viewer: weapon_viewer.call("refresh_weapons") if bullet_viewer: bullet_viewer.call("refresh_bullets")