diff --git a/Main.tscn b/Main.tscn index f71660ca5..310d8834c 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1541,6 +1541,7 @@ margin_bottom = 17.0 rect_min_size = Vector2( 106, 0 ) size_flags_vertical = 1 value = 100.0 +ticks_on_borders = false [node name="OpacitySpinBox" type="SpinBox" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc/LayerVBoxContainer/OpacityCenter/OpacityContainer"] margin_left = 158.0 @@ -1736,6 +1737,7 @@ current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρι [node name="ImportSprites" parent="." instance=ExtResource( 61 )] [node name="ExportSprites" parent="." instance=ExtResource( 62 )] +visible = false [node name="ScaleImage" type="ConfirmationDialog" parent="."] editor/display_folded = true diff --git a/Prefabs/Dialogs/ExportSprites.tscn b/Prefabs/Dialogs/ExportSprites.tscn index ad9fbc766..7968be807 100644 --- a/Prefabs/Dialogs/ExportSprites.tscn +++ b/Prefabs/Dialogs/ExportSprites.tscn @@ -19,10 +19,35 @@ current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρι script = ExtResource( 1 ) [node name="ExportOption" type="OptionButton" parent="."] -margin_right = 41.0 -margin_bottom = 20.0 +margin_left = 8.0 +margin_top = 8.0 +margin_right = 507.0 +margin_bottom = 312.0 text = "Export current frame" -items = [ "Export current frame", null, false, 0, null, "Export all frames as multiple files", null, false, 1, null, "Export all frames as a horizontal spritesheet (single file)", null, false, 2, null, "Export all frames as a vertical spritesheet (single file)", null, false, 3, null ] +items = [ "Export current frame", null, false, 0, null, "Export all frames as multiple files", null, false, 1, null, "Export all frames as a spritesheet (single file)", null, false, 2, null ] selected = 0 + +[node name="Spritesheet" type="HBoxContainer" parent="."] +visible = false +margin_left = 8.0 +margin_top = 8.0 +margin_right = 507.0 +margin_bottom = 312.0 + +[node name="Label" type="Label" parent="Spritesheet"] +margin_left = 200.0 +margin_top = 145.0 +margin_right = 300.0 +margin_bottom = 159.0 +text = "Columns:" + +[node name="VerticalFrames" type="SpinBox" parent="Spritesheet"] +margin_left = 304.0 +margin_right = 378.0 +margin_bottom = 304.0 +mouse_default_cursor_shape = 2 +min_value = 1.0 +value = 1.0 [connection signal="file_selected" from="." to="." method="_on_ExportSprites_file_selected"] [connection signal="item_selected" from="ExportOption" to="." method="_on_ExportOption_item_selected"] +[connection signal="value_changed" from="Spritesheet/VerticalFrames" to="." method="_on_VerticalFrames_value_changed"] diff --git a/Prefabs/Dialogs/ImportSprites.tscn b/Prefabs/Dialogs/ImportSprites.tscn index 5b580a4e7..cbd05bea4 100644 --- a/Prefabs/Dialogs/ImportSprites.tscn +++ b/Prefabs/Dialogs/ImportSprites.tscn @@ -21,14 +21,14 @@ margin_right = 507.0 margin_bottom = 312.0 [node name="ImportAsNewFrame" type="CheckBox" parent="HBoxContainer2"] -margin_right = 130.0 -margin_bottom = 40.0 +margin_right = 156.0 +margin_bottom = 304.0 text = "IMPORT_FILE_LABEL" [node name="ImportSpritesheet" type="CheckBox" parent="HBoxContainer2"] -margin_left = 134.0 -margin_right = 268.0 -margin_bottom = 40.0 +margin_left = 160.0 +margin_right = 327.0 +margin_bottom = 304.0 text = "Import as spritesheet" [node name="Spritesheet" type="HBoxContainer" parent="."] @@ -48,6 +48,7 @@ text = "Horizontal frames:" margin_left = 105.0 margin_right = 159.0 margin_bottom = 17.0 +mouse_default_cursor_shape = 2 min_value = 1.0 value = 1.0 @@ -62,6 +63,7 @@ text = "Vertical frames:" margin_left = 252.0 margin_right = 306.0 margin_bottom = 17.0 +mouse_default_cursor_shape = 2 min_value = 1.0 value = 1.0 [connection signal="files_selected" from="." to="." method="_on_ImportSprites_files_selected"] diff --git a/Scripts/Dialogs/ExportSprites.gd b/Scripts/Dialogs/ExportSprites.gd index e7178401e..819efc906 100644 --- a/Scripts/Dialogs/ExportSprites.gd +++ b/Scripts/Dialogs/ExportSprites.gd @@ -2,6 +2,8 @@ extends FileDialog var current_export_path := "" var export_option := 0 +var spritesheet_rows = 1 +var spritesheet_columns = 1 func _ready() -> void: var children := [] @@ -15,6 +17,19 @@ func _ready() -> void: func _on_ExportOption_item_selected(ID : int) -> void: export_option = ID + var spritesheet_container = Global.find_node_by_name(self, "Spritesheet") + if ID > 1: + spritesheet_container.visible = true + else: + spritesheet_container.visible = false + +func _on_VerticalFrames_value_changed(value) -> void: + value = min(value, Global.canvases.size()) + spritesheet_rows = ceil(Global.canvases.size() / value) + spritesheet_columns = value + + var vertical_frames : SpinBox = Global.find_node_by_name(self, "VerticalFrames") + vertical_frames.value = spritesheet_columns func _on_ExportSprites_file_selected(path : String) -> void: current_export_path = path @@ -32,8 +47,8 @@ func export_project() -> void: path = "%s.png" % path save_sprite(canvas, path) i += 1 - else: # Export all frames as a spritesheet (single file) - save_spritesheet(export_option == 2) + elif export_option == 2: # Export all frames as a spritesheet (single file) + save_spritesheet() Global.notification_label("File exported") @@ -57,29 +72,26 @@ func save_sprite(canvas : Canvas, path : String) -> void: if err != OK: OS.alert("Can't save file") -func save_spritesheet(horizontal : bool) -> void: - var width - var height - if horizontal: # Horizontal spritesheet - width = 0 - height = Global.canvas.size.y - for canvas in Global.canvases: - width += canvas.size.x - if canvas.size.y > height: - height = canvas.size.y - else: # Vertical spritesheet - width = Global.canvas.size.x - height = 0 - for canvas in Global.canvases: - height += canvas.size.y - if canvas.size.x > width: - width = canvas.size.x +func save_spritesheet() -> void: + var width = Global.canvas.size.x * spritesheet_rows + var height = Global.canvas.size.y * spritesheet_columns var whole_image := Image.new() whole_image.create(width, height, false, Image.FORMAT_RGBA8) whole_image.lock() var dst := Vector2.ZERO + var hh := 0 + var vv := 0 for canvas in Global.canvases: + if hh < spritesheet_rows: + dst.x = canvas.size.x * hh + hh += 1 + else: + vv += 1 + dst.x = 0 + hh = 1 + dst.y = canvas.size.y * vv + for layer in canvas.layers: var img : Image = layer[0] img.lock() @@ -93,10 +105,6 @@ func save_spritesheet(horizontal : bool) -> void: canvas.blend_rect(whole_image, img, Rect2(canvas.position, canvas.size), dst) layer[0].lock() - if horizontal: - dst += Vector2(canvas.size.x, 0) - else: - dst += Vector2(0, canvas.size.y) var err = whole_image.save_png(current_export_path) if err != OK: diff --git a/Themes & Styles/Dark Theme/Dark Theme.tres b/Themes & Styles/Dark Theme/Dark Theme.tres index e796a3209..225e8226d 100644 --- a/Themes & Styles/Dark Theme/Dark Theme.tres +++ b/Themes & Styles/Dark Theme/Dark Theme.tres @@ -2,8 +2,6 @@ [ext_resource path="res://Assets/Fonts/Roboto-Regular.tres" type="DynamicFont" id=1] - - [sub_resource type="StyleBoxFlat" id=1] bg_color = Color( 0.517647, 0.517647, 0.517647, 1 ) border_width_left = 4 diff --git a/Themes & Styles/Gold Theme/Gold Theme.tres b/Themes & Styles/Gold Theme/Gold Theme.tres index 95213413a..2ff1159dd 100644 --- a/Themes & Styles/Gold Theme/Gold Theme.tres +++ b/Themes & Styles/Gold Theme/Gold Theme.tres @@ -2,8 +2,6 @@ [ext_resource path="res://Assets/Fonts/Roboto-Regular.tres" type="DynamicFont" id=1] - - [sub_resource type="StyleBoxFlat" id=1] bg_color = Color( 0.219608, 0.211765, 0.168627, 1 ) diff --git a/Themes & Styles/Gray Theme/Gray Theme.tres b/Themes & Styles/Gray Theme/Gray Theme.tres index 0df6657fb..6d2b960c3 100644 --- a/Themes & Styles/Gray Theme/Gray Theme.tres +++ b/Themes & Styles/Gray Theme/Gray Theme.tres @@ -2,8 +2,6 @@ [ext_resource path="res://Assets/Fonts/Roboto-Regular.tres" type="DynamicFont" id=1] - - [sub_resource type="StyleBoxFlat" id=1] bg_color = Color( 0.517647, 0.517647, 0.517647, 1 ) border_width_left = 4 diff --git a/Themes & Styles/Light Theme/Light Theme.tres b/Themes & Styles/Light Theme/Light Theme.tres index ece7d9180..c12736c5c 100644 --- a/Themes & Styles/Light Theme/Light Theme.tres +++ b/Themes & Styles/Light Theme/Light Theme.tres @@ -2,8 +2,6 @@ [ext_resource path="res://Assets/Fonts/Roboto-Regular.tres" type="DynamicFont" id=1] - - [sub_resource type="StyleBoxFlat" id=1] bg_color = Color( 0.803922, 0.803922, 0.803922, 1 ) border_width_left = 4