From 7838ea6ad9fbdd5d4428cde3aaf261d2a7908827 Mon Sep 17 00:00:00 2001 From: danielnaoexiste Date: Wed, 23 Oct 2019 18:01:52 -0300 Subject: [PATCH 1/2] FAdded flip Horizontal/Vertical --- Main.tscn | 26 +++++++++++++++++--------- Scripts/Canvas.gd | 4 +++- Scripts/Main.gd | 16 +++++++++++++++- project.godot | 18 +++++++++++------- 4 files changed, 46 insertions(+), 18 deletions(-) diff --git a/Main.tscn b/Main.tscn index e773a9e72..f7c0ac9b8 100644 --- a/Main.tscn +++ b/Main.tscn @@ -22,6 +22,7 @@ size_flags_horizontal = 3 custom_constants/separation = 0 [node name="ToolPanel" type="Panel" parent="UI"] +editor/display_folded = true margin_right = 230.0 margin_bottom = 600.0 rect_min_size = Vector2( 230, 0 ) @@ -71,11 +72,13 @@ mouse_default_cursor_shape = 2 text = "Help" [node name="PaintToolsContainer" type="HBoxContainer" parent="UI/ToolPanel/Tools/MenusAndTools"] +editor/display_folded = true margin_top = 24.0 margin_right = 230.0 margin_bottom = 44.0 [node name="Pencil" type="Button" parent="UI/ToolPanel/Tools/MenusAndTools/PaintToolsContainer"] +editor/display_folded = true margin_right = 51.0 margin_bottom = 20.0 hint_tooltip = "P for left mouse button @@ -91,6 +94,7 @@ centered = false offset = Vector2( 0, -10 ) [node name="Eraser" type="Button" parent="UI/ToolPanel/Tools/MenusAndTools/PaintToolsContainer"] +editor/display_folded = true margin_left = 55.0 margin_right = 106.0 margin_bottom = 20.0 @@ -117,6 +121,7 @@ button_mask = 3 text = "Bucket" [node name="ColorToolsContainer" type="HBoxContainer" parent="UI/ToolPanel/Tools/MenusAndTools"] +editor/display_folded = true margin_top = 48.0 margin_right = 230.0 margin_bottom = 68.0 @@ -143,6 +148,7 @@ button_mask = 3 text = "Lighten/Darken" [node name="SelectionToolsContainer2" type="HBoxContainer" parent="UI/ToolPanel/Tools/MenusAndTools"] +editor/display_folded = true margin_top = 72.0 margin_right = 230.0 margin_bottom = 92.0 @@ -163,6 +169,7 @@ margin_right = 230.0 margin_bottom = 274.0 [node name="ToolOptions" type="HBoxContainer" parent="UI/ToolPanel/Tools"] +editor/display_folded = true margin_top = 278.0 margin_right = 230.0 margin_bottom = 544.0 @@ -342,6 +349,7 @@ margin_right = 230.0 margin_bottom = 552.0 [node name="BrushesContainer" type="ScrollContainer" parent="UI/ToolPanel/Tools"] +editor/display_folded = true margin_top = 556.0 margin_right = 230.0 margin_bottom = 592.0 @@ -378,7 +386,6 @@ margin_bottom = 600.0 size_flags_horizontal = 3 [node name="HBoxContainer" type="HBoxContainer" parent="UI/CanvasAndTimeline"] -editor/display_folded = true margin_right = 634.0 margin_bottom = 464.0 size_flags_horizontal = 3 @@ -439,6 +446,7 @@ zoom = Vector2( 0.15, 0.15 ) script = ExtResource( 6 ) [node name="AnimationTimeline" type="Panel" parent="UI/CanvasAndTimeline"] +editor/display_folded = true margin_top = 468.0 margin_right = 634.0 margin_bottom = 600.0 @@ -834,8 +842,8 @@ resizable = true mode = 0 access = 2 filters = PoolStringArray( "*.pxo ; Pixelorama Project" ) -current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama" -current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/" +current_dir = "/home/danielnaoexiste/Documents/Prog/Pixelorama" +current_path = "/home/danielnaoexiste/Documents/Prog/Pixelorama/" [node name="SaveSprite" type="FileDialog" parent="."] anchor_left = 0.5 @@ -849,8 +857,8 @@ margin_bottom = 48.0 resizable = true access = 2 filters = PoolStringArray( "*.pxo ; Pixelorama Project" ) -current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama" -current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/" +current_dir = "/home/danielnaoexiste/Documents/Prog/Pixelorama" +current_path = "/home/danielnaoexiste/Documents/Prog/Pixelorama/" [node name="ImportSprites" type="FileDialog" parent="."] margin_right = 515.0 @@ -860,8 +868,8 @@ resizable = true mode = 1 access = 2 filters = PoolStringArray( "*jpg, *.png ; JPG, PNG Images" ) -current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama" -current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/" +current_dir = "/home/danielnaoexiste/Documents/Prog/Pixelorama" +current_path = "/home/danielnaoexiste/Documents/Prog/Pixelorama/" [node name="ExportSprites" type="FileDialog" parent="."] anchor_left = 0.5 @@ -876,8 +884,8 @@ window_title = "Export sprite" resizable = true access = 2 filters = PoolStringArray( "*.png ; PNG Image" ) -current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama" -current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/" +current_dir = "/home/danielnaoexiste/Documents/Prog/Pixelorama" +current_path = "/home/danielnaoexiste/Documents/Prog/Pixelorama/" [node name="ScaleImage" type="ConfirmationDialog" parent="."] editor/display_folded = true diff --git a/Scripts/Canvas.gd b/Scripts/Canvas.gd index 93e18a5cc..b1d13563f 100644 --- a/Scripts/Canvas.gd +++ b/Scripts/Canvas.gd @@ -192,6 +192,7 @@ func _process(delta) -> void: if sprite_changed_this_frame: update_texture(current_layer_index) + func update_texture(layer_index : int) -> void: layers[layer_index][1].create_from_image(layers[layer_index][0], 0) @@ -507,4 +508,5 @@ func rectangle_center(pos : Vector2, size : Vector2) -> Vector2: return (pos - size / 2).floor() func _on_Timer_timeout() -> void: - Global.can_draw = true \ No newline at end of file + Global.can_draw = true + \ No newline at end of file diff --git a/Scripts/Main.gd b/Scripts/Main.gd index fd6a7182f..0938da890 100644 --- a/Scripts/Main.gd +++ b/Scripts/Main.gd @@ -33,7 +33,9 @@ func _ready() -> void: var edit_menu_items := { "Scale Image" : 0, "Crop Image" : 0, - "Clear Selection" : 0 + "Clear Selection" : 0, + "Flip Horizontal": KEY_MASK_SHIFT + KEY_H, + "Flip Vertical": KEY_MASK_SHIFT + KEY_V #"Undo" : KEY_MASK_CTRL + KEY_Z, #"Redo" : KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_Z, } @@ -182,6 +184,18 @@ func edit_menu_id_pressed(id : int) -> void: Global.selection_rectangle.polygon[2] = Vector2.ZERO Global.selection_rectangle.polygon[3] = Vector2.ZERO Global.selected_pixels.clear() + 3: # Flip Horizontal + var canvas = Global.canvas + canvas.layers[canvas.current_layer_index][0].unlock() + canvas.layers[canvas.current_layer_index][0].flip_x() + canvas.layers[canvas.current_layer_index][0].lock() + canvas.update_texture(canvas.current_layer_index) + 4: # Flip Vertical + var canvas = Global.canvas + canvas.layers[canvas.current_layer_index][0].unlock() + canvas.layers[canvas.current_layer_index][0].flip_y() + canvas.layers[canvas.current_layer_index][0].lock() + canvas.update_texture(canvas.current_layer_index) func view_menu_id_pressed(id : int) -> void: match id: diff --git a/project.godot b/project.godot index e1f8e30c1..115ce82e6 100644 --- a/project.godot +++ b/project.godot @@ -13,15 +13,9 @@ _global_script_classes=[ { "class": "Canvas", "language": "GDScript", "path": "res://Scripts/Canvas.gd" -}, { -"base": "Node2D", -"class": "CanvasOLD", -"language": "GDScript", -"path": "res://Scripts/Old/Canvas.gd" } ] _global_script_class_icons={ -"Canvas": "", -"CanvasOLD": "" +"Canvas": "" } [application] @@ -137,6 +131,16 @@ right_lightdark_tool={ "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":true,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":85,"unicode":0,"echo":false,"script":null) ] } +flip_h={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":true,"control":false,"meta":false,"command":false,"pressed":false,"scancode":72,"unicode":0,"echo":false,"script":null) + ] +} +flip_v={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":true,"control":false,"meta":false,"command":false,"pressed":false,"scancode":86,"unicode":0,"echo":false,"script":null) + ] +} [rendering] From 918eec30ce966dcba3678c5c0a028d4d380a0b5e Mon Sep 17 00:00:00 2001 From: danielnaoexiste Date: Wed, 23 Oct 2019 18:01:52 -0300 Subject: [PATCH 2/2] git push origin master --force Added flip Horizontal/Vertical --- Main.tscn | 26 +++++++++++++++++--------- Scripts/Canvas.gd | 4 +++- Scripts/Main.gd | 16 +++++++++++++++- project.godot | 18 +++++++++++------- 4 files changed, 46 insertions(+), 18 deletions(-) diff --git a/Main.tscn b/Main.tscn index e773a9e72..f7c0ac9b8 100644 --- a/Main.tscn +++ b/Main.tscn @@ -22,6 +22,7 @@ size_flags_horizontal = 3 custom_constants/separation = 0 [node name="ToolPanel" type="Panel" parent="UI"] +editor/display_folded = true margin_right = 230.0 margin_bottom = 600.0 rect_min_size = Vector2( 230, 0 ) @@ -71,11 +72,13 @@ mouse_default_cursor_shape = 2 text = "Help" [node name="PaintToolsContainer" type="HBoxContainer" parent="UI/ToolPanel/Tools/MenusAndTools"] +editor/display_folded = true margin_top = 24.0 margin_right = 230.0 margin_bottom = 44.0 [node name="Pencil" type="Button" parent="UI/ToolPanel/Tools/MenusAndTools/PaintToolsContainer"] +editor/display_folded = true margin_right = 51.0 margin_bottom = 20.0 hint_tooltip = "P for left mouse button @@ -91,6 +94,7 @@ centered = false offset = Vector2( 0, -10 ) [node name="Eraser" type="Button" parent="UI/ToolPanel/Tools/MenusAndTools/PaintToolsContainer"] +editor/display_folded = true margin_left = 55.0 margin_right = 106.0 margin_bottom = 20.0 @@ -117,6 +121,7 @@ button_mask = 3 text = "Bucket" [node name="ColorToolsContainer" type="HBoxContainer" parent="UI/ToolPanel/Tools/MenusAndTools"] +editor/display_folded = true margin_top = 48.0 margin_right = 230.0 margin_bottom = 68.0 @@ -143,6 +148,7 @@ button_mask = 3 text = "Lighten/Darken" [node name="SelectionToolsContainer2" type="HBoxContainer" parent="UI/ToolPanel/Tools/MenusAndTools"] +editor/display_folded = true margin_top = 72.0 margin_right = 230.0 margin_bottom = 92.0 @@ -163,6 +169,7 @@ margin_right = 230.0 margin_bottom = 274.0 [node name="ToolOptions" type="HBoxContainer" parent="UI/ToolPanel/Tools"] +editor/display_folded = true margin_top = 278.0 margin_right = 230.0 margin_bottom = 544.0 @@ -342,6 +349,7 @@ margin_right = 230.0 margin_bottom = 552.0 [node name="BrushesContainer" type="ScrollContainer" parent="UI/ToolPanel/Tools"] +editor/display_folded = true margin_top = 556.0 margin_right = 230.0 margin_bottom = 592.0 @@ -378,7 +386,6 @@ margin_bottom = 600.0 size_flags_horizontal = 3 [node name="HBoxContainer" type="HBoxContainer" parent="UI/CanvasAndTimeline"] -editor/display_folded = true margin_right = 634.0 margin_bottom = 464.0 size_flags_horizontal = 3 @@ -439,6 +446,7 @@ zoom = Vector2( 0.15, 0.15 ) script = ExtResource( 6 ) [node name="AnimationTimeline" type="Panel" parent="UI/CanvasAndTimeline"] +editor/display_folded = true margin_top = 468.0 margin_right = 634.0 margin_bottom = 600.0 @@ -834,8 +842,8 @@ resizable = true mode = 0 access = 2 filters = PoolStringArray( "*.pxo ; Pixelorama Project" ) -current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama" -current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/" +current_dir = "/home/danielnaoexiste/Documents/Prog/Pixelorama" +current_path = "/home/danielnaoexiste/Documents/Prog/Pixelorama/" [node name="SaveSprite" type="FileDialog" parent="."] anchor_left = 0.5 @@ -849,8 +857,8 @@ margin_bottom = 48.0 resizable = true access = 2 filters = PoolStringArray( "*.pxo ; Pixelorama Project" ) -current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama" -current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/" +current_dir = "/home/danielnaoexiste/Documents/Prog/Pixelorama" +current_path = "/home/danielnaoexiste/Documents/Prog/Pixelorama/" [node name="ImportSprites" type="FileDialog" parent="."] margin_right = 515.0 @@ -860,8 +868,8 @@ resizable = true mode = 1 access = 2 filters = PoolStringArray( "*jpg, *.png ; JPG, PNG Images" ) -current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama" -current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/" +current_dir = "/home/danielnaoexiste/Documents/Prog/Pixelorama" +current_path = "/home/danielnaoexiste/Documents/Prog/Pixelorama/" [node name="ExportSprites" type="FileDialog" parent="."] anchor_left = 0.5 @@ -876,8 +884,8 @@ window_title = "Export sprite" resizable = true access = 2 filters = PoolStringArray( "*.png ; PNG Image" ) -current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama" -current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/" +current_dir = "/home/danielnaoexiste/Documents/Prog/Pixelorama" +current_path = "/home/danielnaoexiste/Documents/Prog/Pixelorama/" [node name="ScaleImage" type="ConfirmationDialog" parent="."] editor/display_folded = true diff --git a/Scripts/Canvas.gd b/Scripts/Canvas.gd index 93e18a5cc..b1d13563f 100644 --- a/Scripts/Canvas.gd +++ b/Scripts/Canvas.gd @@ -192,6 +192,7 @@ func _process(delta) -> void: if sprite_changed_this_frame: update_texture(current_layer_index) + func update_texture(layer_index : int) -> void: layers[layer_index][1].create_from_image(layers[layer_index][0], 0) @@ -507,4 +508,5 @@ func rectangle_center(pos : Vector2, size : Vector2) -> Vector2: return (pos - size / 2).floor() func _on_Timer_timeout() -> void: - Global.can_draw = true \ No newline at end of file + Global.can_draw = true + \ No newline at end of file diff --git a/Scripts/Main.gd b/Scripts/Main.gd index fd6a7182f..0938da890 100644 --- a/Scripts/Main.gd +++ b/Scripts/Main.gd @@ -33,7 +33,9 @@ func _ready() -> void: var edit_menu_items := { "Scale Image" : 0, "Crop Image" : 0, - "Clear Selection" : 0 + "Clear Selection" : 0, + "Flip Horizontal": KEY_MASK_SHIFT + KEY_H, + "Flip Vertical": KEY_MASK_SHIFT + KEY_V #"Undo" : KEY_MASK_CTRL + KEY_Z, #"Redo" : KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_Z, } @@ -182,6 +184,18 @@ func edit_menu_id_pressed(id : int) -> void: Global.selection_rectangle.polygon[2] = Vector2.ZERO Global.selection_rectangle.polygon[3] = Vector2.ZERO Global.selected_pixels.clear() + 3: # Flip Horizontal + var canvas = Global.canvas + canvas.layers[canvas.current_layer_index][0].unlock() + canvas.layers[canvas.current_layer_index][0].flip_x() + canvas.layers[canvas.current_layer_index][0].lock() + canvas.update_texture(canvas.current_layer_index) + 4: # Flip Vertical + var canvas = Global.canvas + canvas.layers[canvas.current_layer_index][0].unlock() + canvas.layers[canvas.current_layer_index][0].flip_y() + canvas.layers[canvas.current_layer_index][0].lock() + canvas.update_texture(canvas.current_layer_index) func view_menu_id_pressed(id : int) -> void: match id: diff --git a/project.godot b/project.godot index e1f8e30c1..115ce82e6 100644 --- a/project.godot +++ b/project.godot @@ -13,15 +13,9 @@ _global_script_classes=[ { "class": "Canvas", "language": "GDScript", "path": "res://Scripts/Canvas.gd" -}, { -"base": "Node2D", -"class": "CanvasOLD", -"language": "GDScript", -"path": "res://Scripts/Old/Canvas.gd" } ] _global_script_class_icons={ -"Canvas": "", -"CanvasOLD": "" +"Canvas": "" } [application] @@ -137,6 +131,16 @@ right_lightdark_tool={ "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":true,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":85,"unicode":0,"echo":false,"script":null) ] } +flip_h={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":true,"control":false,"meta":false,"command":false,"pressed":false,"scancode":72,"unicode":0,"echo":false,"script":null) + ] +} +flip_v={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":true,"control":false,"meta":false,"command":false,"pressed":false,"scancode":86,"unicode":0,"echo":false,"script":null) + ] +} [rendering]