diff --git a/Main.tscn b/Main.tscn index 880660cc7..7c4a125d4 100644 --- a/Main.tscn +++ b/Main.tscn @@ -57,6 +57,7 @@ anchor_bottom = 1.0 custom_constants/separation = 0 [node name="MenuContainer" type="Panel" parent="MenuAndUI"] +editor/display_folded = true margin_right = 1152.0 margin_bottom = 28.0 rect_min_size = Vector2( 0, 28 ) @@ -121,6 +122,7 @@ text = "[64×64]" align = 2 [node name="UI" type="HBoxContainer" parent="MenuAndUI"] +editor/display_folded = true margin_top = 28.0 margin_right = 1152.0 margin_bottom = 648.0 @@ -129,6 +131,7 @@ size_flags_vertical = 3 custom_constants/separation = 0 [node name="ToolPanel" type="Panel" parent="MenuAndUI/UI"] +editor/display_folded = true margin_right = 242.0 margin_bottom = 620.0 rect_min_size = Vector2( 242, 0 ) @@ -512,6 +515,7 @@ enabled_focus_mode = 0 script = ExtResource( 8 ) [node name="ViewportandVerticalRuler" type="HBoxContainer" parent="MenuAndUI/UI/CanvasAndTimeline/HViewportContainer/ViewportAndRulers"] +editor/display_folded = true margin_top = 16.0 margin_right = 686.0 margin_bottom = 478.0 @@ -566,17 +570,16 @@ margin_right = 319.0 margin_bottom = 464.0 [node name="ViewportContainer2" type="ViewportContainer" parent="MenuAndUI/UI/CanvasAndTimeline/HViewportContainer"] -editor/display_folded = true visible = false -margin_left = 319.0 -margin_right = 634.0 -margin_bottom = 464.0 +margin_left = 345.0 +margin_right = 686.0 +margin_bottom = 478.0 size_flags_horizontal = 3 size_flags_vertical = 3 stretch = true [node name="Viewport" type="Viewport" parent="MenuAndUI/UI/CanvasAndTimeline/HViewportContainer/ViewportContainer2"] -size = Vector2( 315, 464 ) +size = Vector2( 341, 478 ) handle_input_locally = false render_target_update_mode = 0 script = ExtResource( 13 ) diff --git a/Scripts/HorizontalRuler.gd b/Scripts/HorizontalRuler.gd index 27a143bf2..a23f822a5 100644 --- a/Scripts/HorizontalRuler.gd +++ b/Scripts/HorizontalRuler.gd @@ -58,10 +58,10 @@ func _on_HorizontalRuler_pressed() -> void: var mouse_pos := get_local_mouse_position() if mouse_pos.x < RULER_WIDTH: #For double guides Global.vertical_ruler._on_VerticalRuler_pressed() - var line_2d := Guide.new() - line_2d.type = line_2d.TYPE.HORIZONTAL - line_2d.default_color = Color.purple - line_2d.add_point(Vector2(-99999, Global.canvas.current_pixel.y)) - line_2d.add_point(Vector2(99999, Global.canvas.current_pixel.y)) - Global.canvas.add_child(line_2d) + var guide := Guide.new() + guide.type = guide.TYPE.HORIZONTAL + guide.default_color = Color.purple + guide.add_point(Vector2(-99999, Global.canvas.current_pixel.y)) + guide.add_point(Vector2(99999, Global.canvas.current_pixel.y)) + Global.canvas.add_child(guide) Global.has_focus = false diff --git a/Scripts/Main.gd b/Scripts/Main.gd index c3167a8ec..0b5c1e4e0 100644 --- a/Scripts/Main.gd +++ b/Scripts/Main.gd @@ -296,14 +296,14 @@ func _on_OpenSprite_file_selected(path : String) -> void: var frame := 0 var frame_line := file.get_line() clear_canvases() - while frame_line == "--": + while frame_line == "--": #Load frames var canvas : Canvas = load("res://Prefabs/Canvas.tscn").instance() Global.canvas = canvas var width := file.get_16() var height := file.get_16() - var layer_line := file.get_line() - while layer_line == "-": + var layer_line := file.get_line() + while layer_line == "-": #Load layers var buffer := file.get_buffer(width * height * 4) var layer_name := file.get_line() var image := Image.new() @@ -314,6 +314,21 @@ func _on_OpenSprite_file_selected(path : String) -> void: canvas.layers.append([image, tex, layer_name, true]) layer_line = file.get_line() + var guide_line := file.get_line() + while guide_line == "|": #Load guides + var guide := Guide.new() + guide.default_color = Color.purple + guide.type = file.get_8() + if guide.type == guide.TYPE.HORIZONTAL: + guide.add_point(Vector2(-99999, file.get_16())) + guide.add_point(Vector2(99999, file.get_16())) + else: + guide.add_point(Vector2(file.get_16(), -99999)) + guide.add_point(Vector2(file.get_16(), 99999)) + guide.has_focus = false + canvas.add_child(guide) + guide_line = file.get_line() + canvas.size = Vector2(width, height) Global.canvases.append(canvas) canvas.frame = frame @@ -337,7 +352,6 @@ func _on_OpenSprite_file_selected(path : String) -> void: Global.right_color_picker.get_picker().add_preset(color) #Load custom brushes - #Global.custom_brushes.clear() Global.custom_brushes.resize(Global.brushes_from_files) Global.remove_brush_buttons() @@ -364,15 +378,27 @@ func _on_SaveSprite_file_selected(path) -> void: var err := file.open(path, File.WRITE) if err == 0: file.store_line(ProjectSettings.get_setting("application/config/Version")) - for canvas in Global.canvases: + for canvas in Global.canvases: #Store frames file.store_line("--") file.store_16(canvas.size.x) file.store_16(canvas.size.y) - for layer in canvas.layers: + for layer in canvas.layers: #Store layers file.store_line("-") file.store_buffer(layer[0].get_data()) file.store_line(layer[2]) file.store_line("END_LAYERS") + + for child in canvas.get_children(): #Store guides + if child is Guide: + file.store_line("|") + file.store_8(child.type) + if child.type == child.TYPE.HORIZONTAL: + file.store_16(child.points[0].y) + file.store_16(child.points[1].y) + else: + file.store_16(child.points[1].x) + file.store_16(child.points[0].x) + file.store_line("END_GUIDES") file.store_line("END_FRAMES") #Save tool options diff --git a/Scripts/VerticalRuler.gd b/Scripts/VerticalRuler.gd index b7581fd55..fb49622a9 100644 --- a/Scripts/VerticalRuler.gd +++ b/Scripts/VerticalRuler.gd @@ -55,10 +55,10 @@ func _draw() -> void: draw_line(Vector2(RULER_WIDTH * 0.66, position.y), Vector2(RULER_WIDTH, position.y), Color.white) func _on_VerticalRuler_pressed() -> void: - var line_2d := Guide.new() - line_2d.type = line_2d.TYPE.VERTICAL - line_2d.default_color = Color.purple - line_2d.add_point(Vector2(Global.canvas.current_pixel.x, -99999)) - line_2d.add_point(Vector2(Global.canvas.current_pixel.x, 99999)) - Global.canvas.add_child(line_2d) + var guide := Guide.new() + guide.type = guide.TYPE.VERTICAL + guide.default_color = Color.purple + guide.add_point(Vector2(Global.canvas.current_pixel.x, -99999)) + guide.add_point(Vector2(Global.canvas.current_pixel.x, 99999)) + Global.canvas.add_child(guide) Global.has_focus = false