mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-19 22:23: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
|
|
@ -7,18 +7,22 @@ extends PanelContainer
|
|||
|
||||
signal weapon_selected(weapon_resource_path: String)
|
||||
signal duplicate_weapon_requested(weapon_data: Dictionary)
|
||||
signal weapon_deleted(weapon_name: String, weapon_path: String, item_path: String)
|
||||
signal weapon_duplication_started(weapon_name: String, is_3d: bool)
|
||||
|
||||
var _editor_interface: EditorInterface
|
||||
var _grid_container: HFlowContainer
|
||||
var _items_database_path := "res://Resources/ItemsDatabase.tres"
|
||||
var _show_2d_checkbox: CheckBox
|
||||
var _show_3d_checkbox: CheckBox
|
||||
var _dock: PanelContainer # Reference to the dock for logging
|
||||
|
||||
const SETTING_SHOW_2D = "weapon_creator/filter_show_2d"
|
||||
const SETTING_SHOW_3D = "weapon_creator/filter_show_3d"
|
||||
|
||||
func setup(editor_interface: EditorInterface) -> void:
|
||||
func setup(editor_interface: EditorInterface, dock: PanelContainer = null) -> void:
|
||||
_editor_interface = editor_interface
|
||||
_dock = dock
|
||||
# Load saved filter settings after editor interface is available
|
||||
if _show_2d_checkbox:
|
||||
_show_2d_checkbox.button_pressed = _load_filter_setting(SETTING_SHOW_2D, true)
|
||||
|
|
@ -49,10 +53,20 @@ func _build_ui() -> void:
|
|||
var header_hbox = HBoxContainer.new()
|
||||
vbox.add_child(header_hbox)
|
||||
|
||||
var title = Label.new()
|
||||
title.text = "Weapons"
|
||||
title.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
header_hbox.add_child(title)
|
||||
var create_2d_button = Button.new()
|
||||
create_2d_button.text = "Create (2D)"
|
||||
create_2d_button.pressed.connect(_on_create_weapon_pressed.bind(false))
|
||||
header_hbox.add_child(create_2d_button)
|
||||
|
||||
var create_3d_button = Button.new()
|
||||
create_3d_button.text = "Create (3D)"
|
||||
create_3d_button.pressed.connect(_on_create_weapon_pressed.bind(true))
|
||||
header_hbox.add_child(create_3d_button)
|
||||
|
||||
# Spacer
|
||||
var spacer = Control.new()
|
||||
spacer.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
header_hbox.add_child(spacer)
|
||||
|
||||
_show_2d_checkbox = CheckBox.new()
|
||||
_show_2d_checkbox.text = "2D"
|
||||
|
|
@ -318,6 +332,20 @@ func _duplicate_weapon(loot_item: Resource, weapon_data: Resource, is_3d: bool)
|
|||
push_error("Editor interface not available")
|
||||
return
|
||||
|
||||
var weapon_name = loot_item.get("ItemName") if loot_item else "Unknown"
|
||||
var dimension = "3D" if is_3d else "2D"
|
||||
|
||||
# Log to dock
|
||||
if _dock:
|
||||
_dock.call("add_log", "=== Duplicating Weapon (" + dimension + ") ===", Color.CYAN)
|
||||
_dock.call("add_log", "Source: " + weapon_name, Color.CYAN)
|
||||
_dock.call("add_log", "Opening creation dialog with prefilled data...", Color.CYAN)
|
||||
|
||||
# Also log to Godot console
|
||||
print("Duplicating weapon (", dimension, "): ", weapon_name)
|
||||
|
||||
weapon_duplication_started.emit(weapon_name, is_3d)
|
||||
|
||||
# Extract all weapon data into a prefill dictionary
|
||||
var prefill_data = {}
|
||||
|
||||
|
|
@ -413,6 +441,7 @@ func _confirm_delete(loot_item: Resource, weapon_data: Resource) -> void:
|
|||
func _perform_delete(loot_item: Resource, weapon_data: Resource, dialog: ConfirmationDialog) -> void:
|
||||
var weapon_path = weapon_data.resource_path
|
||||
var loot_item_path = loot_item.resource_path
|
||||
var weapon_name = loot_item.get("ItemName") if loot_item else "Unknown"
|
||||
|
||||
if not weapon_path or not loot_item_path:
|
||||
push_error("Cannot delete built-in resources")
|
||||
|
|
@ -440,13 +469,18 @@ func _perform_delete(loot_item: Resource, weapon_data: Resource, dialog: Confirm
|
|||
|
||||
var file_system = _editor_interface.get_resource_filesystem()
|
||||
|
||||
var weapon_deleted_success = false
|
||||
var item_deleted_success = false
|
||||
|
||||
if DirAccess.remove_absolute(weapon_path) == OK:
|
||||
print("Deleted weapon resource: ", weapon_path)
|
||||
weapon_deleted_success = true
|
||||
else:
|
||||
push_error("Failed to delete weapon resource: ", weapon_path)
|
||||
|
||||
if DirAccess.remove_absolute(loot_item_path) == OK:
|
||||
print("Deleted loot item resource: ", loot_item_path)
|
||||
item_deleted_success = true
|
||||
else:
|
||||
push_error("Failed to delete loot item resource: ", loot_item_path)
|
||||
|
||||
|
|
@ -455,6 +489,18 @@ func _perform_delete(loot_item: Resource, weapon_data: Resource, dialog: Confirm
|
|||
|
||||
dialog.queue_free()
|
||||
|
||||
# Emit deletion signal and log if both files were deleted successfully
|
||||
if weapon_deleted_success and item_deleted_success:
|
||||
weapon_deleted.emit(weapon_name, weapon_path, loot_item_path)
|
||||
|
||||
# Log to dock
|
||||
if _dock:
|
||||
_dock.call("add_log", "=== Weapon Deleted ===", Color.ORANGE)
|
||||
_dock.call("add_log", "Weapon: " + weapon_name, Color.ORANGE)
|
||||
_dock.call("add_log", "✓ Deleted WeaponResource: " + weapon_path, Color.GREEN)
|
||||
_dock.call("add_log", "✓ Deleted LootItem: " + loot_item_path, Color.GREEN)
|
||||
_dock.call("add_log", "✓ Removed from ItemsDatabase", Color.GREEN)
|
||||
|
||||
refresh_weapons()
|
||||
|
||||
func _add_error_label(error_message: String) -> void:
|
||||
|
|
@ -464,3 +510,18 @@ func _add_error_label(error_message: String) -> void:
|
|||
label.modulate = Color.ORANGE_RED
|
||||
_grid_container.add_child(label)
|
||||
|
||||
func _on_create_weapon_pressed(is_3d: bool) -> void:
|
||||
if not _editor_interface:
|
||||
push_error("Editor interface not available")
|
||||
return
|
||||
|
||||
var dialog_script = load("res://addons/weapon_creator/WeaponCreatorDialog.gd")
|
||||
var dialog = Window.new()
|
||||
dialog.set_script(dialog_script)
|
||||
|
||||
get_tree().root.add_child(dialog)
|
||||
|
||||
dialog.call_deferred("setup", _editor_interface, is_3d)
|
||||
dialog.call_deferred("connect", "weapon_data_confirmed", _on_duplicate_weapon_confirmed)
|
||||
dialog.call_deferred("popup_centered")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue