Added renaming layers on right click, removed a lot of old debug logging

This commit is contained in:
2025-07-21 08:29:11 +10:00
parent 85a208a729
commit e8620611df
19 changed files with 184 additions and 360 deletions

View File

@@ -1,82 +0,0 @@
## Example implementation showing how to replace legacy wobble controls
## with the new WobbleControlPanel component
extends Node2D
## This demonstrates the integration approach for the sprite viewer
## Legacy slider references (to be replaced)
@onready var legacy_wobble_control = $LegacyWobbleControl
## New component system
@onready var wobble_panel: WobbleControlPanel = $WobbleControlPanel
var slider_manager: SliderManager
func _ready():
# Initialize slider management
slider_manager = SliderManager.new(self)
# Set up the wobble panel
if wobble_panel:
# The panel will automatically configure its sliders
print("WobbleControlPanel initialized")
# Hide legacy controls when using new system
if legacy_wobble_control:
legacy_wobble_control.visible = false
## Updated setImage function using new components
func setImage_new_system():
if Global.heldSprite == null:
return
print("Setting image with new component system")
# Update wobble panel with current sprite
if wobble_panel:
wobble_panel.set_target_sprite(Global.heldSprite)
wobble_panel.update_from_sprite()
# Update sync feedback
updateWobbleControlStates_new_system()
## Updated wobble control states using new system
func updateWobbleControlStates_new_system():
if Global.heldSprite == null:
return
if wobble_panel:
wobble_panel.update_sync_feedback()
## Migration helper - gradually replace sections
func migrate_to_new_system():
print("Migrating wobble controls to new component system...")
# Step 1: Hide old controls
if has_node("WobbleControl"):
$WobbleControl.visible = false
# Step 2: Show new panel
if wobble_panel:
wobble_panel.visible = true
# Step 3: Update with current sprite
if Global.heldSprite:
setImage_new_system()
print("Migration complete!")
## Demonstration of component benefits
func demonstrate_consistency():
print("=== Component System Benefits ===")
if wobble_panel:
print("All wobble sliders have consistent:")
print("- Visual styling")
print("- Value formatting")
print("- Label positioning")
print("- Signal handling")
print("- Sync state feedback")
print("Components are easily reusable across scenes")
print("Centralized management through SliderManager")
print("Type-safe with proper class inheritance")

View File

@@ -61,7 +61,6 @@ func _on_parameter_value_changed(new_value: float):
if not target_sprite or sprite_property == "":
return
print("DEBUG: ParameterSlider ", sprite_property, " changed to: ", new_value)
target_sprite.set(sprite_property, new_value)

View File

@@ -45,7 +45,6 @@ func _on_wobble_value_changed(new_value: float):
if not target_sprite or parameter_name == "":
return
print("DEBUG: WobbleSlider ", parameter_name, " changed to: ", new_value)
target_sprite.updateWobbleParameter(parameter_name, new_value)
# Update visual feedback for sync status

View File

@@ -6,6 +6,8 @@ var type = "sprite"
var imageData = null
var tex = null
@export var path = ""
## Custom display name for the sprite (separate from file path)
var displayName = ""
var loadedImageData = null
@@ -319,8 +321,6 @@ func calculateParentOpacityMultiplier():
## Update wobble parameters and sync to group if needed
func updateWobbleParameter(parameter: String, value: float):
print("DEBUG: updateWobbleParameter called - parameter: ", parameter, ", value: ", value, ", sprite ID: ", id)
print("DEBUG: Current wobbleSyncGroup: '", wobbleSyncGroup, "'")
# Update this sprite's parameter first
match parameter:
@@ -331,17 +331,15 @@ func updateWobbleParameter(parameter: String, value: float):
"rFrq": rFrq = value
"rAmp": rAmp = value
print("DEBUG: Parameter updated on sprite. New values - xFrq:", xFrq, " xAmp:", xAmp, " yFrq:", yFrq, " yAmp:", yAmp, " rFrq:", rFrq, " rAmp:", rAmp)
# If this sprite is in a sync group, update the entire group
if wobbleSyncGroup != "" and WobbleSyncManager:
print("DEBUG: Sprite is in sync group '", wobbleSyncGroup, "' - updating group wobble parameters")
WobbleSyncManager.updateGroupWobble(wobbleSyncGroup, xFrq, xAmp, yFrq, yAmp, rFrq, rAmp)
# Don't refresh UI immediately - let the sync process complete first
# The wobble sync control will handle UI updates when needed
else:
print("DEBUG: Sprite not in sync group or WobbleSyncManager not available")
pass # Individual sprite update - no sync needed
## Check if this sprite is synced to a group
func isSynced() -> bool:

View File

@@ -211,7 +211,6 @@ func _on_stream_deck_check_toggled(button_pressed):
func _on_experimental_mic_loudness_toggle(checked):
Global.experimentalMicLoudness = checked
Saving.settings["experimentalMicLoudness"] = checked
print("Experimental mic loudness: ", checked)
func _process(delta):

View File

@@ -24,8 +24,6 @@ func _ready():
# Find the wobble sync control node
wobbleSyncControl = find_child("WobbleSyncControl")
if wobbleSyncControl == null:
print("Warning: WobbleSyncControl node not found in sprite viewer")
# Set up blend mode dropdown
setupBlendModeDropdown()

View File

@@ -55,11 +55,10 @@ func updateGroupDropdown():
# Add existing groups
if WobbleSyncManager:
var groups = WobbleSyncManager.getGroupNames()
print("DEBUG: updateGroupDropdown - available groups: ", groups)
for group_name in groups:
groupDropdown.add_item(group_name)
else:
print("DEBUG: updateGroupDropdown - WobbleSyncManager not available")
pass # WobbleSyncManager not available
# Add "Create New..." option
groupDropdown.add_separator()
@@ -67,7 +66,6 @@ func updateGroupDropdown():
# Select current group if sprite is synced
if currentSprite != null and currentSprite.wobbleSyncGroup != "":
print("DEBUG: updateGroupDropdown - sprite has group '", currentSprite.wobbleSyncGroup, "'")
var group_index = -1
for i in range(groupDropdown.get_item_count()):
if groupDropdown.get_item_text(i) == currentSprite.wobbleSyncGroup:
@@ -75,13 +73,10 @@ func updateGroupDropdown():
break
if group_index != -1:
print("DEBUG: updateGroupDropdown - selecting group at index ", group_index)
groupDropdown.selected = group_index
else:
print("DEBUG: updateGroupDropdown - group '", currentSprite.wobbleSyncGroup, "' not found in dropdown")
groupDropdown.selected = 0 # Select "None"
else:
print("DEBUG: updateGroupDropdown - sprite has no group, selecting 'None'")
groupDropdown.selected = 0 # Select "None"
updating_dropdown = false
@@ -100,11 +95,9 @@ func updateSyncIndicator():
## Set the current sprite to manage
func setSprite(sprite):
print("DEBUG: WobbleSyncControl.setSprite called with sprite ID: ", sprite.id if sprite else "null")
currentSprite = sprite
if currentSprite:
print("DEBUG: Current sprite wobbleSyncGroup: '", currentSprite.wobbleSyncGroup, "'")
print("DEBUG: Current sprite isSynced(): ", currentSprite.isSynced())
pass # Sprite is valid
updateUI()
## Get available groups for the dropdown (excluding "None" and "Create New...")
@@ -120,18 +113,15 @@ func _on_group_dropdown_selected(index: int):
return
var selected_text = groupDropdown.get_item_text(index)
print("DEBUG: Dropdown selected: '", selected_text, "' at index ", index)
match selected_text:
"None":
# Remove sprite from any group
if currentSprite.wobbleSyncGroup != "" and WobbleSyncManager:
print("DEBUG: Removing sprite ID ", currentSprite.id, " from group '", currentSprite.wobbleSyncGroup, "'")
WobbleSyncManager.removeSpriteFromAllGroups(currentSprite.id)
Global.pushUpdate("Removed sprite from wobble sync group")
"Create New...":
print("DEBUG: User selected 'Create New...' from dropdown")
# Show create group dialog
groupNameInput.text = ""
groupNameInput.placeholder_text = "Enter group name..."
@@ -143,45 +133,39 @@ func _on_group_dropdown_selected(index: int):
_:
# Join selected group
if WobbleSyncManager and WobbleSyncManager.hasGroup(selected_text):
print("DEBUG: Adding sprite ID ", currentSprite.id, " to group '", selected_text, "'")
WobbleSyncManager.addSpriteToGroup(currentSprite.id, selected_text)
# Refresh sprite editor to show updated wobble values
if Global.spriteEdit:
Global.spriteEdit.setImage()
else:
print("DEBUG: Group '", selected_text, "' not found or WobbleSyncManager not available")
pass # Group doesn't exist
updateSyncIndicator()
## Handle create group dialog confirmation
func _on_create_group_confirmed():
var group_name = groupNameInput.text.strip_edges()
print("DEBUG: Create group confirmed with name: '", group_name, "'")
if group_name == "":
print("DEBUG: Group name is empty")
Global.pushUpdate("Group name cannot be empty")
return
if WobbleSyncManager and WobbleSyncManager.hasGroup(group_name):
print("DEBUG: Group '", group_name, "' already exists")
Global.pushUpdate("Group \"" + group_name + "\" already exists")
return
# Create group with current sprite
if currentSprite != null and WobbleSyncManager:
print("DEBUG: Creating group '", group_name, "' with sprite ID ", currentSprite.id)
if WobbleSyncManager.createGroup(group_name, currentSprite.id):
print("DEBUG: Group created successfully")
createGroupDialog.hide()
updateUI()
# Refresh sprite editor to show sync status
if Global.spriteEdit:
Global.spriteEdit.setImage()
else:
print("DEBUG: Failed to create group")
pass # Failed to create group
else:
print("DEBUG: No current sprite to add to group")
pass # No sprite or WobbleSyncManager not available
## Handle create group dialog cancellation
func _on_create_group_cancelled():
@@ -203,5 +187,4 @@ func canSync() -> bool:
## Force refresh the UI - useful after loading saves
func forceRefresh():
print("DEBUG: WobbleSyncControl.forceRefresh called")
updateUI()

View File

@@ -2,9 +2,9 @@ extends NinePatchRect
@onready var spritePreview = $SpritePreview/Sprite2D
@onready var outline = $Selected
@onready var fade = $Fade
@onready var button = $Button
@onready var label = $Label
var sprite = null
var parent = null
@@ -14,9 +14,23 @@ var indent = 0
var childrenTags = []
var parentTag = null
## Context menu for right-click actions
var context_menu: PopupMenu = null
## Line edit for renaming
var rename_edit: LineEdit = null
## Track if we're currently in rename mode
var is_renaming: bool = false
func _ready():
var count = spritePath.get_slice_count("/") - 1
$Label.text = spritePath.get_slice("/",count)
# Use displayName if available, otherwise fallback to path
var display_text = ""
if sprite.displayName != "":
display_text = sprite.displayName
else:
var count = spritePath.get_slice_count("/") - 1
display_text = spritePath.get_slice("/",count)
label.text = display_text
$Line2D.visible = false
spritePreview.texture = sprite.sprite.texture
@@ -25,6 +39,105 @@ func _ready():
spritePreview.scale = Vector2(1,1) * (60.0/displaySize)
spritePreview.offset = sprite.sprite.offset
# Set up right-click detection
button.gui_input.connect(_on_button_gui_input)
# Create context menu
_setup_context_menu()
## Set up the right-click context menu
func _setup_context_menu():
context_menu = PopupMenu.new()
add_child(context_menu)
# Add rename option
context_menu.add_item("Rename", 0)
context_menu.id_pressed.connect(_on_context_menu_selected)
## Handle GUI input events on the button
func _on_button_gui_input(event: InputEvent):
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_RIGHT and event.pressed:
# Show context menu at cursor position
var global_pos = get_global_mouse_position()
context_menu.position = Vector2i(global_pos)
context_menu.popup()
## Handle context menu selections
func _on_context_menu_selected(id: int):
match id:
0: # Rename
_start_rename()
## Start the rename process
func _start_rename():
if is_renaming:
return
is_renaming = true
# Create line edit for renaming
rename_edit = LineEdit.new()
add_child(rename_edit)
# Position and size the line edit over the label
rename_edit.position = label.position
rename_edit.size = label.size
rename_edit.text = label.text
# Hide the original label
label.visible = false
# Focus the line edit and select all text
rename_edit.grab_focus()
rename_edit.select_all()
# Connect signals
rename_edit.text_submitted.connect(_on_rename_submitted)
rename_edit.focus_exited.connect(_on_rename_focus_lost)
## Handle rename submission (Enter key)
func _on_rename_submitted(new_name: String):
if rename_edit != null:
_finish_rename(new_name)
## Handle losing focus (clicking elsewhere)
func _on_rename_focus_lost():
if rename_edit != null:
_finish_rename(rename_edit.text)
## Finish the rename process
func _finish_rename(new_name: String):
if not is_renaming:
return
is_renaming = false
# Clean up the line edit
if rename_edit:
rename_edit.queue_free()
rename_edit = null
# Show the label again
label.visible = true
# Validate and apply the new name
new_name = new_name.strip_edges()
if new_name != "" and new_name != label.text:
_apply_rename(new_name)
## Apply the rename to the sprite
func _apply_rename(new_name: String):
# Update the display name (without file extension)
label.text = new_name
sprite.displayName = new_name # Store display name separately
# Update the global sprite list
Global.spriteList.updateData()
# Show feedback to user
Global.pushUpdate("Renamed sprite to: " + new_name)
func updateChildren():
for child in childrenTags: