mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-21 15:53:47 +00:00
Add bullet creation and viewer dialogs with 2D/3D support
- Implement BulletCreatorDialog for configuring bullet parameters. - Introduce BulletViewer to display bullets in a grid format. - Add filtering options for 2D and 3D bullets in the viewer. - Enhance WeaponCreatorDock to include bullet creation functionality.
This commit is contained in:
parent
4787cd6691
commit
ac96dabf2e
8 changed files with 1045 additions and 76 deletions
|
|
@ -2,15 +2,17 @@
|
|||
extends PanelContainer
|
||||
|
||||
# UI dock for the Weapon Creator plugin
|
||||
# Provides a button to open the creation dialog and displays creation logs
|
||||
# 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 open_dialog_button: Button
|
||||
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
|
||||
|
|
@ -35,40 +37,7 @@ func _build_ui() -> void:
|
|||
vbox.add_theme_constant_override("separation", 8)
|
||||
margin.add_child(vbox)
|
||||
|
||||
# Title
|
||||
var title = Label.new()
|
||||
title.text = "3D Weapon Creator"
|
||||
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
vbox.add_child(title)
|
||||
|
||||
vbox.add_child(HSeparator.new())
|
||||
|
||||
# Buttons
|
||||
var button_hbox = HBoxContainer.new()
|
||||
button_hbox.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
button_hbox.add_theme_constant_override("separation", 8)
|
||||
vbox.add_child(button_hbox)
|
||||
|
||||
open_dialog_button = Button.new()
|
||||
open_dialog_button.text = "Create Weapon (2D)"
|
||||
open_dialog_button.custom_minimum_size = Vector2(150, 0)
|
||||
open_dialog_button.pressed.connect(_on_open_dialog_pressed.bind(false))
|
||||
button_hbox.add_child(open_dialog_button)
|
||||
|
||||
var open_dialog_button_3d = Button.new()
|
||||
open_dialog_button_3d.text = "Create Weapon (3D)"
|
||||
open_dialog_button_3d.custom_minimum_size = Vector2(150, 0)
|
||||
open_dialog_button_3d.pressed.connect(_on_open_dialog_pressed.bind(true))
|
||||
button_hbox.add_child(open_dialog_button_3d)
|
||||
|
||||
clear_button = Button.new()
|
||||
clear_button.text = "Clear Log"
|
||||
clear_button.pressed.connect(_on_clear_button_pressed)
|
||||
button_hbox.add_child(clear_button)
|
||||
|
||||
vbox.add_child(HSeparator.new())
|
||||
|
||||
# Horizontal split container for weapon viewer and log
|
||||
# Horizontal split container for tabs and log
|
||||
var hsplit = HSplitContainer.new()
|
||||
hsplit.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
vbox.add_child(hsplit)
|
||||
|
|
@ -79,23 +48,50 @@ func _build_ui() -> void:
|
|||
log_vbox.add_theme_constant_override("separation", 4)
|
||||
hsplit.add_child(log_vbox)
|
||||
|
||||
# Weapon Viewer (right side)
|
||||
# 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.custom_minimum_size = Vector2(300, 0)
|
||||
weapon_viewer.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
# Connect duplicate weapon signal
|
||||
weapon_viewer.name = "Weapons"
|
||||
weapon_viewer.duplicate_weapon_requested.connect(_on_weapon_data_confirmed)
|
||||
hsplit.add_child(weapon_viewer)
|
||||
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)
|
||||
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_vbox.add_child(log_label)
|
||||
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
|
||||
|
|
@ -110,49 +106,48 @@ func _build_ui() -> void:
|
|||
log_output.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
log_scroll.add_child(log_output)
|
||||
|
||||
func _on_open_dialog_pressed(is_3d: bool) -> void:
|
||||
# Open the weapon creation dialog window
|
||||
var dialog_script = load("res://addons/weapon_creator/WeaponCreatorDialog.gd")
|
||||
var dialog = Window.new()
|
||||
dialog.set_script(dialog_script)
|
||||
|
||||
# Add to scene tree first
|
||||
get_tree().root.add_child(dialog)
|
||||
|
||||
# Setup editor interface and mode using call_deferred to ensure script is ready
|
||||
if _editor_interface:
|
||||
dialog.call_deferred("setup", _editor_interface, is_3d)
|
||||
|
||||
# Connect to the confirmation signal using call_deferred
|
||||
dialog.call_deferred("connect", "weapon_data_confirmed", _on_weapon_data_confirmed)
|
||||
|
||||
# Show the dialog
|
||||
dialog.call_deferred("popup_centered")
|
||||
|
||||
func _on_weapon_data_confirmed(weapon_data: Dictionary) -> void:
|
||||
# Receive weapon data from dialog and forward to plugin
|
||||
if _is_creating:
|
||||
return
|
||||
|
||||
_is_creating = true
|
||||
open_dialog_button.disabled = true
|
||||
log_output.clear()
|
||||
|
||||
# Emit signal to plugin
|
||||
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:
|
||||
# Re-enable the create button after creation is complete
|
||||
_is_creating = false
|
||||
open_dialog_button.disabled = false
|
||||
|
||||
# Refresh weapon viewer to show newly created weapon
|
||||
if weapon_viewer:
|
||||
weapon_viewer.call("refresh_weapons")
|
||||
if bullet_viewer:
|
||||
bullet_viewer.call("refresh_bullets")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue