mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
Added a "Link Cel" option when right clicking on a cel, if the cel isn't already linked
This should make cel linking be more user friendly.
This commit is contained in:
parent
f7b9d22991
commit
2d4d40c213
|
@ -35,7 +35,7 @@ __meta__ = {
|
||||||
margin_right = 20.0
|
margin_right = 20.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
mouse_default_cursor_shape = 2
|
mouse_default_cursor_shape = 2
|
||||||
items = [ "Remove Frame", null, 0, false, true, -1, 0, null, "", false, "Clone Frame", null, 0, false, false, -1, 0, null, "", false, "Move Left", null, 0, false, true, -1, 0, null, "", false, "Move Right", null, 0, false, true, -1, 0, null, "", false, "Unlink Cel", null, 0, false, true, -1, 0, null, "", false ]
|
items = [ "Remove Frame", null, 0, false, true, -1, 0, null, "", false, "Clone Frame", null, 0, false, false, -1, 0, null, "", false, "Move Left", null, 0, false, true, -1, 0, null, "", false, "Move Right", null, 0, false, true, -1, 0, null, "", false, "Link Cel", null, 0, false, false, -1, 0, null, "", false ]
|
||||||
|
|
||||||
[node name="LinkedIndicator" type="Polygon2D" parent="."]
|
[node name="LinkedIndicator" type="Polygon2D" parent="."]
|
||||||
visible = false
|
visible = false
|
||||||
|
|
|
@ -3,17 +3,19 @@ extends Button
|
||||||
var frame := 0
|
var frame := 0
|
||||||
var layer := 0
|
var layer := 0
|
||||||
|
|
||||||
onready var popup_menu := $PopupMenu
|
onready var popup_menu : PopupMenu = $PopupMenu
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
hint_tooltip = "Frame: %s, Layer: %s" % [frame + 1, layer]
|
hint_tooltip = "Frame: %s, Layer: %s" % [frame + 1, layer]
|
||||||
if Global.canvases[frame] in Global.layers[layer][5]:
|
if Global.canvases[frame] in Global.layers[layer][5]:
|
||||||
get_node("LinkedIndicator").visible = true
|
get_node("LinkedIndicator").visible = true
|
||||||
popup_menu.set_item_disabled(4, false) # Unlink cel
|
popup_menu.set_item_text(4, "Unlink Cel")
|
||||||
|
popup_menu.set_item_metadata(4, "Unlink Cel")
|
||||||
else:
|
else:
|
||||||
get_node("LinkedIndicator").visible = false
|
get_node("LinkedIndicator").visible = false
|
||||||
popup_menu.set_item_disabled(4, true) # Unlink cel
|
popup_menu.set_item_text(4, "Link Cel")
|
||||||
|
popup_menu.set_item_metadata(4, "Link Cel")
|
||||||
|
|
||||||
|
|
||||||
func _on_FrameButton_pressed() -> void:
|
func _on_FrameButton_pressed() -> void:
|
||||||
|
@ -56,24 +58,41 @@ func _on_PopupMenu_id_pressed(ID : int) -> void:
|
||||||
var new_layers := Global.layers.duplicate(true)
|
var new_layers := Global.layers.duplicate(true)
|
||||||
var new_canvas_layers : Array = c.layers.duplicate(true)
|
var new_canvas_layers : Array = c.layers.duplicate(true)
|
||||||
|
|
||||||
new_layers[layer][5].remove(cel_index)
|
if popup_menu.get_item_metadata(4) == "Unlink Cel":
|
||||||
var sprite := Image.new()
|
new_layers[layer][5].remove(cel_index)
|
||||||
sprite.copy_from(Global.canvases[frame].layers[layer][0])
|
var sprite := Image.new()
|
||||||
sprite.lock()
|
sprite.copy_from(Global.canvases[frame].layers[layer][0])
|
||||||
var tex := ImageTexture.new()
|
sprite.lock()
|
||||||
tex.create_from_image(sprite, 0)
|
var tex := ImageTexture.new()
|
||||||
new_canvas_layers[layer][0] = sprite
|
tex.create_from_image(sprite, 0)
|
||||||
new_canvas_layers[layer][1] = tex
|
new_canvas_layers[layer][0] = sprite
|
||||||
|
new_canvas_layers[layer][1] = tex
|
||||||
|
|
||||||
Global.undo_redo.create_action("Unlink Cel")
|
Global.undo_redo.create_action("Unlink Cel")
|
||||||
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
||||||
Global.undo_redo.add_do_property(c, "layers", new_canvas_layers)
|
Global.undo_redo.add_do_property(c, "layers", new_canvas_layers)
|
||||||
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
|
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
|
||||||
Global.undo_redo.add_undo_property(c, "layers", c.layers)
|
Global.undo_redo.add_undo_property(c, "layers", c.layers)
|
||||||
|
|
||||||
Global.undo_redo.add_undo_method(Global, "undo", [Global.canvases[frame]], layer)
|
Global.undo_redo.add_undo_method(Global, "undo", [Global.canvases[frame]], layer)
|
||||||
Global.undo_redo.add_do_method(Global, "redo", [Global.canvases[frame]], layer)
|
Global.undo_redo.add_do_method(Global, "redo", [Global.canvases[frame]], layer)
|
||||||
Global.undo_redo.commit_action()
|
Global.undo_redo.commit_action()
|
||||||
|
elif popup_menu.get_item_metadata(4) == "Link Cel":
|
||||||
|
new_layers[layer][5].append(Global.canvases[frame])
|
||||||
|
Global.undo_redo.create_action("Link Cel")
|
||||||
|
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
||||||
|
if new_layers[layer][5].size() > 1:
|
||||||
|
# If there are already linked cels, set the current cel's image
|
||||||
|
# to the first linked cel's image
|
||||||
|
new_canvas_layers[layer][0] = new_layers[layer][5][0].layers[layer][0]
|
||||||
|
new_canvas_layers[layer][1] = new_layers[layer][5][0].layers[layer][1]
|
||||||
|
Global.undo_redo.add_do_property(c, "layers", new_canvas_layers)
|
||||||
|
Global.undo_redo.add_undo_property(c, "layers", c.layers)
|
||||||
|
|
||||||
|
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
|
||||||
|
Global.undo_redo.add_undo_method(Global, "undo", [Global.canvases[frame]], layer)
|
||||||
|
Global.undo_redo.add_do_method(Global, "redo", [Global.canvases[frame]], layer)
|
||||||
|
Global.undo_redo.commit_action()
|
||||||
|
|
||||||
|
|
||||||
func change_frame_order(rate : int) -> void:
|
func change_frame_order(rate : int) -> void:
|
||||||
|
|
|
@ -460,7 +460,7 @@ func general_redo() -> void:
|
||||||
func undo(_canvases : Array, layer_index : int = -1) -> void:
|
func undo(_canvases : Array, layer_index : int = -1) -> void:
|
||||||
general_undo()
|
general_undo()
|
||||||
var action_name := undo_redo.get_current_action_name()
|
var action_name := undo_redo.get_current_action_name()
|
||||||
if action_name == "Draw" or action_name == "Rectangle Select" or action_name == "Scale" or action_name == "Merge Layer" or action_name == "Unlink Cel":
|
if action_name == "Draw" or action_name == "Rectangle Select" or action_name == "Scale" or action_name == "Merge Layer" or action_name == "Link Cel" or action_name == "Unlink Cel":
|
||||||
for c in _canvases:
|
for c in _canvases:
|
||||||
if layer_index > -1:
|
if layer_index > -1:
|
||||||
c.update_texture(layer_index)
|
c.update_texture(layer_index)
|
||||||
|
@ -493,7 +493,7 @@ func undo(_canvases : Array, layer_index : int = -1) -> void:
|
||||||
func redo(_canvases : Array, layer_index : int = -1) -> void:
|
func redo(_canvases : Array, layer_index : int = -1) -> void:
|
||||||
general_redo()
|
general_redo()
|
||||||
var action_name := undo_redo.get_current_action_name()
|
var action_name := undo_redo.get_current_action_name()
|
||||||
if action_name == "Draw" or action_name == "Rectangle Select" or action_name == "Scale" or action_name == "Merge Layer" or action_name == "Unlink Cel":
|
if action_name == "Draw" or action_name == "Rectangle Select" or action_name == "Scale" or action_name == "Merge Layer" or action_name == "Link Cel" or action_name == "Unlink Cel":
|
||||||
for c in _canvases:
|
for c in _canvases:
|
||||||
if layer_index > -1:
|
if layer_index > -1:
|
||||||
c.update_texture(layer_index)
|
c.update_texture(layer_index)
|
||||||
|
|
|
@ -761,6 +761,9 @@ msgstr ""
|
||||||
msgid "Add Frame Tag"
|
msgid "Add Frame Tag"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Link Cel"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Unlink Cel"
|
msgid "Unlink Cel"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue