mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-03-12 22:35:18 +00: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
|
@ -714,6 +714,12 @@ func disable_button(button : BaseButton, disable : bool) -> void:
|
|||
break
|
||||
|
||||
|
||||
func change_button_texturerect(texture_button : TextureRect, new_file_name : String) -> void:
|
||||
var file_name := texture_button.texture.resource_path.get_basename().get_file()
|
||||
var directory_path := texture_button.texture.resource_path.get_basename().replace(file_name, "")
|
||||
texture_button.texture = load(directory_path.plus_file(new_file_name))
|
||||
|
||||
|
||||
func animation_tags_changed(value : Array) -> void:
|
||||
animation_tags = value
|
||||
for child in tag_container.get_children():
|
||||
|
|
12
src/Main.gd
12
src/Main.gd
|
@ -597,18 +597,16 @@ func _on_Tool_pressed(tool_pressed : BaseButton, mouse_press := true, key_for_le
|
|||
|
||||
for t in tools:
|
||||
var tool_name : String = t[0].name
|
||||
var theme_type := Global.theme_type
|
||||
if theme_type == "Gold":
|
||||
theme_type = "Dark"
|
||||
var texture_button : TextureRect = t[0].get_child(0)
|
||||
|
||||
if tool_name == Global.current_left_tool and tool_name == Global.current_right_tool:
|
||||
t[0].get_child(0).texture = load("res://assets/graphics/%s_themes/tools/%s_l_r.png" % [theme_type.to_lower(), tool_name.to_lower()])
|
||||
Global.change_button_texturerect(texture_button, "%s_l_r.png" % tool_name.to_lower())
|
||||
elif tool_name == Global.current_left_tool:
|
||||
t[0].get_child(0).texture = load("res://assets/graphics/%s_themes/tools/%s_l.png" % [theme_type.to_lower(), tool_name.to_lower()])
|
||||
Global.change_button_texturerect(texture_button, "%s_l.png" % tool_name.to_lower())
|
||||
elif tool_name == Global.current_right_tool:
|
||||
t[0].get_child(0).texture = load("res://assets/graphics/%s_themes/tools/%s_r.png" % [theme_type.to_lower(), tool_name.to_lower()])
|
||||
Global.change_button_texturerect(texture_button, "%s_r.png" % tool_name.to_lower())
|
||||
else:
|
||||
t[0].get_child(0).texture = load("res://assets/graphics/%s_themes/tools/%s.png" % [theme_type.to_lower(), tool_name.to_lower()])
|
||||
Global.change_button_texturerect(texture_button, "%s.png" % tool_name.to_lower())
|
||||
|
||||
Global.left_cursor_tool_texture.create_from_image(load("res://assets/graphics/cursor_icons/%s_cursor.png" % Global.current_left_tool.to_lower()), 0)
|
||||
Global.right_cursor_tool_texture.create_from_image(load("res://assets/graphics/cursor_icons/%s_cursor.png" % Global.current_right_tool.to_lower()), 0)
|
||||
|
|
|
@ -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
Reference in a new issue