mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-25 22:44:42 -04:00
Changing a button's texturerect child no longer requires the theme in its file path
Instead, it automatically finds its path, adds the new file name and loads the new texture.
This commit is contained in:
parent
9ce7bae2f9
commit
55e7178e1f
4 changed files with 28 additions and 43 deletions
|
@ -178,14 +178,11 @@ func _on_FrameTagButton_pressed() -> void:
|
|||
func _on_OnionSkinning_pressed() -> void:
|
||||
Global.onion_skinning = !Global.onion_skinning
|
||||
Global.canvas.update()
|
||||
var theme_type := Global.theme_type
|
||||
if theme_type == "Gold":
|
||||
theme_type = "Dark"
|
||||
var texture_button : TextureRect = Global.onion_skinning_button.get_child(0)
|
||||
if Global.onion_skinning:
|
||||
texture_button.texture = load("res://assets/graphics/%s_themes/timeline/onion_skinning.png" % theme_type.to_lower())
|
||||
Global.change_button_texturerect(texture_button, "onion_skinning.png")
|
||||
else:
|
||||
texture_button.texture = load("res://assets/graphics/%s_themes/timeline/onion_skinning_off.png" % theme_type.to_lower())
|
||||
Global.change_button_texturerect(texture_button, "onion_skinning_off.png")
|
||||
|
||||
|
||||
func _on_OnionSkinningSettings_pressed() -> void:
|
||||
|
@ -194,44 +191,35 @@ func _on_OnionSkinningSettings_pressed() -> void:
|
|||
|
||||
func _on_LoopAnim_pressed() -> void:
|
||||
var texture_button : TextureRect = Global.loop_animation_button.get_child(0)
|
||||
var theme_type := Global.theme_type
|
||||
if theme_type == "Gold":
|
||||
theme_type = "Dark"
|
||||
match animation_loop:
|
||||
0: # Make it loop
|
||||
animation_loop = 1
|
||||
texture_button.texture = load("res://assets/graphics/%s_themes/timeline/loop.png" % theme_type.to_lower())
|
||||
Global.change_button_texturerect(texture_button, "loop.png")
|
||||
Global.loop_animation_button.hint_tooltip = "Cycle loop"
|
||||
1: # Make it ping-pong
|
||||
animation_loop = 2
|
||||
texture_button.texture = load("res://assets/graphics/%s_themes/timeline/loop_pingpong.png" % theme_type.to_lower())
|
||||
Global.change_button_texturerect(texture_button, "loop_pingpong.png")
|
||||
Global.loop_animation_button.hint_tooltip = "Ping-pong loop"
|
||||
2: # Make it stop
|
||||
animation_loop = 0
|
||||
texture_button.texture = load("res://assets/graphics/%s_themes/timeline/loop_none.png" % theme_type.to_lower())
|
||||
Global.change_button_texturerect(texture_button, "loop_none.png")
|
||||
Global.loop_animation_button.hint_tooltip = "No loop"
|
||||
|
||||
|
||||
func _on_PlayForward_toggled(button_pressed : bool) -> void:
|
||||
var theme_type := Global.theme_type
|
||||
if theme_type == "Gold":
|
||||
theme_type = "Dark"
|
||||
if button_pressed:
|
||||
Global.play_forward.get_child(0).texture = load("res://assets/graphics/%s_themes/timeline/pause.png" % theme_type.to_lower())
|
||||
Global.change_button_texturerect(Global.play_forward.get_child(0), "pause.png")
|
||||
else:
|
||||
Global.play_forward.get_child(0).texture = load("res://assets/graphics/%s_themes/timeline/play.png" % theme_type.to_lower())
|
||||
Global.change_button_texturerect(Global.play_forward.get_child(0), "play.png")
|
||||
|
||||
play_animation(button_pressed, true)
|
||||
|
||||
|
||||
func _on_PlayBackwards_toggled(button_pressed : bool) -> void:
|
||||
var theme_type := Global.theme_type
|
||||
if theme_type == "Gold":
|
||||
theme_type = "Dark"
|
||||
if button_pressed:
|
||||
Global.play_backwards.get_child(0).texture = load("res://assets/graphics/%s_themes/timeline/pause.png" % theme_type.to_lower())
|
||||
Global.change_button_texturerect(Global.play_backwards.get_child(0), "pause.png")
|
||||
else:
|
||||
Global.play_backwards.get_child(0).texture = load("res://assets/graphics/%s_themes/timeline/play_backwards.png" % theme_type.to_lower())
|
||||
Global.change_button_texturerect(Global.play_backwards.get_child(0), "play_backwards.png")
|
||||
|
||||
play_animation(button_pressed, false)
|
||||
|
||||
|
@ -269,19 +257,15 @@ func _on_AnimationTimer_timeout() -> void:
|
|||
|
||||
|
||||
func play_animation(play : bool, forward_dir : bool) -> void:
|
||||
var theme_type := Global.theme_type
|
||||
if theme_type == "Gold":
|
||||
theme_type = "Dark"
|
||||
|
||||
if forward_dir:
|
||||
Global.play_backwards.disconnect("toggled", self, "_on_PlayBackwards_toggled")
|
||||
Global.play_backwards.pressed = false
|
||||
Global.play_backwards.get_child(0).texture = load("res://assets/graphics/%s_themes/timeline/play_backwards.png" % theme_type.to_lower())
|
||||
Global.change_button_texturerect(Global.play_backwards.get_child(0), "play_backwards.png")
|
||||
Global.play_backwards.connect("toggled", self, "_on_PlayBackwards_toggled")
|
||||
else:
|
||||
Global.play_forward.disconnect("toggled", self, "_on_PlayForward_toggled")
|
||||
Global.play_forward.pressed = false
|
||||
Global.play_forward.get_child(0).texture = load("res://assets/graphics/%s_themes/timeline/play.png" % theme_type.to_lower())
|
||||
Global.change_button_texturerect(Global.play_forward.get_child(0), "play.png")
|
||||
Global.play_forward.connect("toggled", self, "_on_PlayForward_toggled")
|
||||
if Global.canvases.size() == 1:
|
||||
if forward_dir:
|
||||
|
|
|
@ -15,28 +15,25 @@ func _ready() -> void:
|
|||
linked_button = Global.find_node_by_name(self, "LinkButton")
|
||||
label = Global.find_node_by_name(self, "Label")
|
||||
line_edit = Global.find_node_by_name(self, "LineEdit")
|
||||
var theme_type := Global.theme_type
|
||||
if theme_type == "Gold":
|
||||
theme_type = "Dark"
|
||||
|
||||
if Global.layers[i][1]:
|
||||
visibility_button.get_child(0).texture = load("res://assets/graphics/%s_themes/layers/layer_visible.png" % theme_type.to_lower())
|
||||
Global.change_button_texturerect(visibility_button.get_child(0), "layer_visible.png")
|
||||
visibility_button.get_child(0).rect_size = Vector2(24, 14)
|
||||
visibility_button.get_child(0).rect_position = Vector2(4, 9)
|
||||
else:
|
||||
visibility_button.get_child(0).texture = load("res://assets/graphics/%s_themes/layers/layer_invisible.png" % theme_type.to_lower())
|
||||
Global.change_button_texturerect(visibility_button.get_child(0), "layer_invisible.png")
|
||||
visibility_button.get_child(0).rect_size = Vector2(24, 8)
|
||||
visibility_button.get_child(0).rect_position = Vector2(4, 12)
|
||||
|
||||
if Global.layers[i][2]:
|
||||
lock_button.get_child(0).texture = load("res://assets/graphics/%s_themes/layers/lock.png" % theme_type.to_lower())
|
||||
Global.change_button_texturerect(lock_button.get_child(0), "lock.png")
|
||||
else:
|
||||
lock_button.get_child(0).texture = load("res://assets/graphics/%s_themes/layers/unlock.png" % theme_type.to_lower())
|
||||
Global.change_button_texturerect(lock_button.get_child(0), "unlock.png")
|
||||
|
||||
if Global.layers[i][4]: # If new layers will be linked
|
||||
linked_button.get_child(0).texture = load("res://assets/graphics/%s_themes/layers/linked_layer.png" % theme_type.to_lower())
|
||||
Global.change_button_texturerect(linked_button.get_child(0), "linked_layer.png")
|
||||
else:
|
||||
linked_button.get_child(0).texture = load("res://assets/graphics/%s_themes/layers/unlinked_layer.png" % theme_type.to_lower())
|
||||
Global.change_button_texturerect(linked_button.get_child(0), "unlinked_layer.png")
|
||||
|
||||
|
||||
func _input(event : InputEvent) -> void:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue