mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-10 18:55:54 +00:00
111 lines
3.2 KiB
GDScript
111 lines
3.2 KiB
GDScript
@tool
|
|
extends PanelContainer
|
|
|
|
# UI dock for the Weapon Creator plugin
|
|
# Provides a button to open the creation dialog and displays creation logs
|
|
|
|
signal create_weapon_requested(weapon_data: Dictionary)
|
|
|
|
# UI elements
|
|
var open_dialog_button: Button
|
|
var clear_button: Button
|
|
var log_output: RichTextLabel
|
|
|
|
var _is_creating: bool = false
|
|
|
|
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)
|
|
|
|
# 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 New Weapon"
|
|
open_dialog_button.custom_minimum_size = Vector2(150, 0)
|
|
open_dialog_button.pressed.connect(_on_open_dialog_pressed)
|
|
button_hbox.add_child(open_dialog_button)
|
|
|
|
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())
|
|
|
|
# Log section
|
|
var log_label = Label.new()
|
|
log_label.text = "Output Log:"
|
|
vbox.add_child(log_label)
|
|
|
|
var log_scroll = ScrollContainer.new()
|
|
log_scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
|
vbox.add_child(log_scroll)
|
|
|
|
log_output = RichTextLabel.new()
|
|
log_output.bbcode_enabled = true
|
|
log_output.scroll_following = 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_open_dialog_pressed() -> 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)
|
|
|
|
# Connect to the confirmation signal
|
|
dialog.weapon_data_confirmed.connect(_on_weapon_data_confirmed)
|
|
|
|
# Add to scene tree and show
|
|
get_tree().root.add_child(dialog)
|
|
dialog.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 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
|