Use a new Layer class to handle layer information

This replaces the old Global.layers nested array mess, and makes the code easier to read and to understand.
This commit is contained in:
OverloadedOrama 2020-06-01 16:42:53 +03:00
parent 1762383c6b
commit a9ca858303
13 changed files with 100 additions and 86 deletions

View file

@ -75,9 +75,7 @@ func _on_CreateNewImage_confirmed() -> void:
var fill_color : Color = fill_color_node.color
Global.clear_canvases()
Global.layers.clear()
# Store [Layer name (0), Layer visibility boolean (1), Layer lock boolean (2), Frame container (3),
# will new frames be linked boolean (4), Array of linked frames (5)]
Global.layers.append([tr("Layer") + " 0", true, false, HBoxContainer.new(), false, []])
Global.layers.append(Layer.new())
Global.canvas = load("res://src/Canvas.tscn").instance()
Global.canvas.size = Vector2(width, height).floor()

View file

@ -365,7 +365,7 @@ func blend_layers(image: Image, canvas: Canvas, origin: Vector2 = Vector2(0, 0))
image.lock()
var layer_i := 0
for layer in canvas.layers:
if Global.layers[layer_i][1]:
if Global.layers[layer_i].visible:
var layer_image := Image.new()
layer_image.copy_from(layer[0])
layer_image.lock()

View file

@ -41,7 +41,7 @@ func _on_ImportSprites_files_selected(paths : PoolStringArray) -> void:
Global.layers.clear()
# Store [Layer name (0), Layer visibility boolean (1), Layer lock boolean (2), Frame container (3),
# will new frames be linked boolean (4), Array of linked frames (5)]
Global.layers.append([tr("Layer") + " 0", true, false, HBoxContainer.new(), false, []])
Global.layers.append(Layer.new())
Global.current_layer = 0
var first_path : String = paths[0]