feat: adding the skin_shader_generator, and gacha base barebone
This commit is contained in:
@@ -40,6 +40,7 @@ var _form_star: SpinBox
|
||||
var _form_category: OptionButton
|
||||
var _form_rarity: OptionButton
|
||||
var _slots_vbox: VBoxContainer
|
||||
var _duplicate_btn: Button
|
||||
var _delete_btn: Button
|
||||
var _save_btn: Button
|
||||
|
||||
@@ -77,6 +78,12 @@ func _build_ui() -> void:
|
||||
add_btn.pressed.connect(_on_add_pressed)
|
||||
top.add_child(add_btn)
|
||||
|
||||
_duplicate_btn = Button.new()
|
||||
_duplicate_btn.text = "📋 Duplicate"
|
||||
_duplicate_btn.disabled = true
|
||||
_duplicate_btn.pressed.connect(_on_duplicate_pressed)
|
||||
top.add_child(_duplicate_btn)
|
||||
|
||||
_delete_btn = Button.new()
|
||||
_delete_btn.text = "✕ Delete"
|
||||
_delete_btn.disabled = true
|
||||
@@ -247,7 +254,9 @@ func _refresh_list() -> void:
|
||||
c.queue_free()
|
||||
for i in _data.size():
|
||||
var entry: Dictionary = _data[i]
|
||||
var btn := Button.new()
|
||||
var btn := SkinListItem.new()
|
||||
btn.index = i
|
||||
btn.editor = self
|
||||
var cat: String = entry.get("category", "?")
|
||||
var iid: String = entry.get("item_id", "?")
|
||||
btn.text = "[%s]\n%s" % [cat, iid]
|
||||
@@ -273,11 +282,13 @@ func _populate_form() -> void:
|
||||
if _selected_idx < 0 or _selected_idx >= _data.size():
|
||||
_form_panel.visible = false
|
||||
_no_sel_label.visible = true
|
||||
_duplicate_btn.disabled = true
|
||||
_delete_btn.disabled = true
|
||||
return
|
||||
|
||||
_form_panel.visible = true
|
||||
_no_sel_label.visible = false
|
||||
_duplicate_btn.disabled = false
|
||||
_delete_btn.disabled = false
|
||||
|
||||
var e: Dictionary = _data[_selected_idx]
|
||||
@@ -388,6 +399,20 @@ func _on_add_pressed() -> void:
|
||||
_set_status("New skin created. Fill in the form and Save & Generate.", Color.YELLOW)
|
||||
|
||||
|
||||
func _on_duplicate_pressed() -> void:
|
||||
if _selected_idx < 0:
|
||||
return
|
||||
_commit_form()
|
||||
var original = _data[_selected_idx]
|
||||
var duplicate = original.duplicate(true)
|
||||
duplicate["item_id"] += "_copy"
|
||||
_data.insert(_selected_idx + 1, duplicate)
|
||||
_selected_idx += 1
|
||||
_refresh_list()
|
||||
_populate_form()
|
||||
_set_status("Skin duplicated.", Color.YELLOW)
|
||||
|
||||
|
||||
func _on_delete_pressed() -> void:
|
||||
if _selected_idx < 0:
|
||||
return
|
||||
@@ -399,6 +424,19 @@ func _on_delete_pressed() -> void:
|
||||
_set_status("Deleted: " + removed, Color.YELLOW)
|
||||
|
||||
|
||||
func move_item(from_idx: int, to_idx: int) -> void:
|
||||
if from_idx == to_idx:
|
||||
return
|
||||
_commit_form()
|
||||
var item = _data[from_idx]
|
||||
_data.remove_at(from_idx)
|
||||
_data.insert(to_idx, item)
|
||||
_selected_idx = to_idx
|
||||
_refresh_list()
|
||||
_populate_form()
|
||||
_set_status("Reordered: %s" % item.get("item_id", "?"), Color.WHITE)
|
||||
|
||||
|
||||
func _on_add_slot_pressed() -> void:
|
||||
if _selected_idx < 0:
|
||||
return
|
||||
@@ -534,3 +572,22 @@ func _set_status(msg: String, color: Color = Color.WHITE) -> void:
|
||||
return
|
||||
_status_label.add_theme_color_override("font_color", color)
|
||||
_status_label.text = msg
|
||||
|
||||
|
||||
# ─── Inner Classes ───────────────────────────────────────────────────────────
|
||||
class SkinListItem extends Button:
|
||||
var index: int
|
||||
var editor: Control
|
||||
|
||||
func _get_drag_data(_at_position: Vector2) -> Variant:
|
||||
var preview := Button.new()
|
||||
preview.text = text
|
||||
preview.modulate.a = 0.5
|
||||
set_drag_preview(preview)
|
||||
return index
|
||||
|
||||
func _can_drop_data(_at_position: Vector2, data: Variant) -> bool:
|
||||
return typeof(data) == TYPE_INT
|
||||
|
||||
func _drop_data(_at_position: Vector2, data: Variant) -> void:
|
||||
editor.move_item(data, index)
|
||||
|
||||
Reference in New Issue
Block a user