mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-12-19 04:04:43 -05:00
"SpriteSheet as layer" and "Replace Frame" import options (#453)
* fixed some more bugs * Removed some more bugs * Added "Replace Frame" option It was originally made to use primarily in "Spritesheet (new layer)" but it thought it could also be useful to put it there as an import option * Update PreviewDialog.tscn * Update PreviewDialog.gd * Update OpenSave.gd * added import option for SpriteSheet and Frame Now we can add SpriteSheets in current project and Replace frames in current project * added functions for SpriteSheet and Frames I added functions that would allow me to add SpriteSheet as new Layer. I also added an option for "Replace frame" (the function "open_image_at_frame()" is originally being used in "open_image_as_spritesheet_layer()" method but i decided to use it as an import option as well) * Changed contribution name * Changed contribution name * Fixed some lines * fixed sprite lines not updating
This commit is contained in:
parent
45be4ee6b7
commit
f9c275d0a4
5 changed files with 180 additions and 21 deletions
|
|
@ -140,7 +140,7 @@ func create_contributors() -> void:
|
|||
contributors.create_item(contributor_root).set_text(0, " Vriska Weaver (henlo-birb)")
|
||||
contributors.create_item(contributor_root).set_text(0, " Rémi Verschelde (akien-mga)")
|
||||
contributors.create_item(contributor_root).set_text(0, " gschwind")
|
||||
contributors.create_item(contributor_root).set_text(0, " Variable-ind")
|
||||
contributors.create_item(contributor_root).set_text(0, " Fayez Akhtar (Variable)")
|
||||
|
||||
|
||||
func create_translators() -> void:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
extends ConfirmationDialog
|
||||
|
||||
|
||||
enum ImageImportOptions {NEW_TAB, SPRITESHEET, NEW_FRAME, NEW_LAYER, PALETTE, BRUSH, PATTERN}
|
||||
enum ImageImportOptions {NEW_TAB, SPRITESHEET_TAB, SPRITESHEET_LAYER, NEW_FRAME, REPLACE_FRAME, NEW_LAYER, PALETTE, BRUSH, PATTERN}
|
||||
enum BrushTypes {FILE, PROJECT, RANDOM}
|
||||
|
||||
var path : String
|
||||
|
|
@ -14,19 +14,34 @@ var brush_type : int = BrushTypes.FILE
|
|||
onready var texture_rect : TextureRect = $VBoxContainer/CenterContainer/TextureRect
|
||||
onready var image_size_label : Label = $VBoxContainer/SizeContainer/ImageSizeLabel
|
||||
onready var frame_size_label : Label = $VBoxContainer/SizeContainer/FrameSizeLabel
|
||||
onready var spritesheet_options = $VBoxContainer/HBoxContainer/SpritesheetOptions
|
||||
onready var spritesheet_tab_options = $VBoxContainer/HBoxContainer/SpritesheetTabOptions
|
||||
onready var spritesheet_layer_options = $VBoxContainer/HBoxContainer/SpritesheetLayerOptions
|
||||
onready var new_frame_options = $VBoxContainer/HBoxContainer/NewFrameOptions
|
||||
onready var replace_frame_options = $VBoxContainer/HBoxContainer/ReplaceFrameOptions
|
||||
onready var new_layer_options = $VBoxContainer/HBoxContainer/NewLayerOptions
|
||||
onready var new_brush_options = $VBoxContainer/HBoxContainer/NewBrushOptions
|
||||
onready var new_brush_name = $VBoxContainer/HBoxContainer/NewBrushOptions/BrushName
|
||||
|
||||
|
||||
func _on_PreviewDialog_about_to_show() -> void:
|
||||
var import_options :OptionButton= get_node("VBoxContainer/HBoxContainer/ImportOption")
|
||||
|
||||
# # order as in ImageImportOptions enum
|
||||
import_options.add_item("New tab")
|
||||
import_options.add_item("Spritesheet (new tab)")
|
||||
import_options.add_item("Spritesheet (new layer)")
|
||||
import_options.add_item("New frame")
|
||||
import_options.add_item("Replace Frame")
|
||||
import_options.add_item("New layer")
|
||||
import_options.add_item("New palette")
|
||||
import_options.add_item("New brush")
|
||||
import_options.add_item("New pattern")
|
||||
|
||||
var img_texture := ImageTexture.new()
|
||||
img_texture.create_from_image(image, 0)
|
||||
texture_rect.texture = img_texture
|
||||
spritesheet_options.get_node("HorizontalFrames").max_value = min(spritesheet_options.get_node("HorizontalFrames").max_value, image.get_size().x)
|
||||
spritesheet_options.get_node("VerticalFrames").max_value = min(spritesheet_options.get_node("VerticalFrames").max_value, image.get_size().y)
|
||||
spritesheet_tab_options.get_node("HorizontalFrames").max_value = min(spritesheet_tab_options.get_node("HorizontalFrames").max_value, image.get_size().x)
|
||||
spritesheet_tab_options.get_node("VerticalFrames").max_value = min(spritesheet_tab_options.get_node("VerticalFrames").max_value, image.get_size().y)
|
||||
image_size_label.text = tr("Image Size") + ": " + str(image.get_size().x) + "×" + str(image.get_size().y)
|
||||
frame_size_label.text = tr("Frame Size") + ": " + str(image.get_size().x) + "×" + str(image.get_size().y)
|
||||
|
||||
|
|
@ -44,13 +59,22 @@ func _on_PreviewDialog_confirmed() -> void:
|
|||
if current_import_option == ImageImportOptions.NEW_TAB:
|
||||
OpenSave.open_image_as_new_tab(path, image)
|
||||
|
||||
elif current_import_option == ImageImportOptions.SPRITESHEET:
|
||||
OpenSave.open_image_as_spritesheet(path, image, spritesheet_horizontal, spritesheet_vertical)
|
||||
elif current_import_option == ImageImportOptions.SPRITESHEET_TAB:
|
||||
OpenSave.open_image_as_spritesheet_tab(path, image, spritesheet_horizontal, spritesheet_vertical)
|
||||
|
||||
elif current_import_option == ImageImportOptions.SPRITESHEET_LAYER:
|
||||
var frame_index : int = spritesheet_layer_options.get_node("AtFrameSpinbox").value - 1
|
||||
OpenSave.open_image_as_spritesheet_layer(path, image, path.get_basename().get_file(), spritesheet_horizontal, spritesheet_vertical, frame_index)
|
||||
|
||||
elif current_import_option == ImageImportOptions.NEW_FRAME:
|
||||
var layer_index : int = new_frame_options.get_node("AtLayerSpinbox").value
|
||||
OpenSave.open_image_as_new_frame(image, layer_index)
|
||||
|
||||
elif current_import_option == ImageImportOptions.REPLACE_FRAME:
|
||||
var layer_index : int = replace_frame_options.get_node("AtLayerSpinbox").value
|
||||
var frame_index : int = replace_frame_options.get_node("AtFrameSpinbox").value - 1
|
||||
OpenSave.open_image_at_frame(image, layer_index, frame_index)
|
||||
|
||||
elif current_import_option == ImageImportOptions.NEW_LAYER:
|
||||
var frame_index : int = new_layer_options.get_node("AtFrameSpinbox").value - 1
|
||||
OpenSave.open_image_as_new_layer(image, path.get_basename().get_file(), frame_index)
|
||||
|
|
@ -77,23 +101,41 @@ func _on_PreviewDialog_confirmed() -> void:
|
|||
func _on_ImportOption_item_selected(id : int) -> void:
|
||||
current_import_option = id
|
||||
frame_size_label.visible = false
|
||||
spritesheet_options.visible = false
|
||||
spritesheet_tab_options.visible = false
|
||||
spritesheet_layer_options.visible = false
|
||||
new_frame_options.visible = false
|
||||
replace_frame_options.visible = false
|
||||
new_layer_options.visible = false
|
||||
new_brush_options.visible = false
|
||||
texture_rect.get_child(0).visible = false
|
||||
texture_rect.get_child(1).visible = false
|
||||
rect_size.x = 550
|
||||
|
||||
if id == ImageImportOptions.SPRITESHEET:
|
||||
if id == ImageImportOptions.SPRITESHEET_TAB:
|
||||
frame_size_label.visible = true
|
||||
spritesheet_options.visible = true
|
||||
spritesheet_tab_options.visible = true
|
||||
texture_rect.get_child(0).visible = true
|
||||
texture_rect.get_child(1).visible = true
|
||||
rect_size.x = spritesheet_tab_options.rect_size.x
|
||||
|
||||
elif id == ImageImportOptions.SPRITESHEET_LAYER:
|
||||
frame_size_label.visible = true
|
||||
spritesheet_tab_options.visible = true
|
||||
spritesheet_layer_options.visible = true
|
||||
spritesheet_layer_options.get_node("AtFrameSpinbox").max_value = Global.current_project.frames.size()
|
||||
texture_rect.get_child(0).visible = true
|
||||
texture_rect.get_child(1).visible = true
|
||||
rect_size.x = spritesheet_layer_options.rect_size.x
|
||||
|
||||
elif id == ImageImportOptions.NEW_FRAME:
|
||||
new_frame_options.visible = true
|
||||
new_frame_options.get_node("AtLayerSpinbox").max_value = Global.current_project.layers.size() - 1
|
||||
|
||||
elif id == ImageImportOptions.REPLACE_FRAME:
|
||||
replace_frame_options.visible = true
|
||||
replace_frame_options.get_node("AtLayerSpinbox").max_value = Global.current_project.layers.size() - 1
|
||||
replace_frame_options.get_node("AtFrameSpinbox").max_value = Global.current_project.frames.size()
|
||||
|
||||
elif id == ImageImportOptions.NEW_LAYER:
|
||||
new_layer_options.visible = true
|
||||
new_layer_options.get_node("AtFrameSpinbox").max_value = Global.current_project.frames.size()
|
||||
|
|
|
|||
|
|
@ -82,22 +82,20 @@ margin_right = 151.0
|
|||
margin_bottom = 20.0
|
||||
mouse_default_cursor_shape = 2
|
||||
text = "New tab"
|
||||
items = [ "New tab", null, false, 0, null, "Spritesheet (new tab)", null, false, 1, null, "New frame", null, false, 2, null, "New layer", null, false, 3, null, "New palette", null, false, 4, null, "New brush", null, false, 5, null, "New pattern", null, false, 6, null ]
|
||||
selected = 0
|
||||
|
||||
[node name="SpritesheetOptions" type="HBoxContainer" parent="VBoxContainer/HBoxContainer"]
|
||||
[node name="SpritesheetTabOptions" type="HBoxContainer" parent="VBoxContainer/HBoxContainer"]
|
||||
visible = false
|
||||
margin_left = 155.0
|
||||
margin_right = 533.0
|
||||
margin_bottom = 24.0
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer/SpritesheetOptions"]
|
||||
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer/SpritesheetTabOptions"]
|
||||
margin_top = 5.0
|
||||
margin_right = 118.0
|
||||
margin_bottom = 19.0
|
||||
text = "Horizontal frames:"
|
||||
|
||||
[node name="HorizontalFrames" type="SpinBox" parent="VBoxContainer/HBoxContainer/SpritesheetOptions"]
|
||||
[node name="HorizontalFrames" type="SpinBox" parent="VBoxContainer/HBoxContainer/SpritesheetTabOptions"]
|
||||
margin_left = 122.0
|
||||
margin_right = 196.0
|
||||
margin_bottom = 24.0
|
||||
|
|
@ -105,14 +103,14 @@ mouse_default_cursor_shape = 2
|
|||
min_value = 1.0
|
||||
value = 1.0
|
||||
|
||||
[node name="Label2" type="Label" parent="VBoxContainer/HBoxContainer/SpritesheetOptions"]
|
||||
[node name="Label2" type="Label" parent="VBoxContainer/HBoxContainer/SpritesheetTabOptions"]
|
||||
margin_left = 200.0
|
||||
margin_top = 5.0
|
||||
margin_right = 300.0
|
||||
margin_bottom = 19.0
|
||||
text = "Vertical frames:"
|
||||
|
||||
[node name="VerticalFrames" type="SpinBox" parent="VBoxContainer/HBoxContainer/SpritesheetOptions"]
|
||||
[node name="VerticalFrames" type="SpinBox" parent="VBoxContainer/HBoxContainer/SpritesheetTabOptions"]
|
||||
margin_left = 304.0
|
||||
margin_right = 378.0
|
||||
margin_bottom = 24.0
|
||||
|
|
@ -120,6 +118,26 @@ mouse_default_cursor_shape = 2
|
|||
min_value = 1.0
|
||||
value = 1.0
|
||||
|
||||
[node name="SpritesheetLayerOptions" type="HBoxContainer" parent="VBoxContainer/HBoxContainer"]
|
||||
visible = false
|
||||
margin_left = 155.0
|
||||
margin_right = 692.0
|
||||
margin_bottom = 24.0
|
||||
|
||||
[node name="Label3" type="Label" parent="VBoxContainer/HBoxContainer/SpritesheetLayerOptions"]
|
||||
margin_left = 382.0
|
||||
margin_top = 5.0
|
||||
margin_right = 459.0
|
||||
margin_bottom = 19.0
|
||||
text = "Start Frame:"
|
||||
|
||||
[node name="AtFrameSpinbox" type="SpinBox" parent="VBoxContainer/HBoxContainer/SpritesheetLayerOptions"]
|
||||
margin_left = 463.0
|
||||
margin_right = 537.0
|
||||
margin_bottom = 24.0
|
||||
min_value = 1.0
|
||||
value = 1.0
|
||||
|
||||
[node name="NewFrameOptions" type="HBoxContainer" parent="VBoxContainer/HBoxContainer"]
|
||||
visible = false
|
||||
margin_left = 155.0
|
||||
|
|
@ -139,6 +157,41 @@ margin_bottom = 24.0
|
|||
mouse_default_cursor_shape = 2
|
||||
max_value = 0.0
|
||||
|
||||
[node name="ReplaceFrameOptions" type="HBoxContainer" parent="VBoxContainer/HBoxContainer"]
|
||||
visible = false
|
||||
margin_left = 155.0
|
||||
margin_right = 433.0
|
||||
margin_bottom = 24.0
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer/ReplaceFrameOptions"]
|
||||
margin_top = 5.0
|
||||
margin_right = 56.0
|
||||
margin_bottom = 19.0
|
||||
text = "At Layer:"
|
||||
|
||||
[node name="AtLayerSpinbox" type="SpinBox" parent="VBoxContainer/HBoxContainer/ReplaceFrameOptions"]
|
||||
margin_left = 60.0
|
||||
margin_right = 134.0
|
||||
margin_bottom = 24.0
|
||||
mouse_default_cursor_shape = 2
|
||||
max_value = 0.0
|
||||
|
||||
[node name="Label2" type="Label" parent="VBoxContainer/HBoxContainer/ReplaceFrameOptions"]
|
||||
margin_left = 138.0
|
||||
margin_top = 5.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 19.0
|
||||
text = "At Frame:"
|
||||
|
||||
[node name="AtFrameSpinbox" type="SpinBox" parent="VBoxContainer/HBoxContainer/ReplaceFrameOptions"]
|
||||
margin_left = 204.0
|
||||
margin_right = 278.0
|
||||
margin_bottom = 24.0
|
||||
mouse_default_cursor_shape = 2
|
||||
min_value = 1.0
|
||||
max_value = 0.0
|
||||
value = 1.0
|
||||
|
||||
[node name="NewLayerOptions" type="HBoxContainer" parent="VBoxContainer/HBoxContainer"]
|
||||
visible = false
|
||||
margin_left = 155.0
|
||||
|
|
@ -201,6 +254,6 @@ margin_bottom = 24.0
|
|||
[connection signal="confirmed" from="." to="." method="_on_PreviewDialog_confirmed"]
|
||||
[connection signal="popup_hide" from="." to="." method="_on_PreviewDialog_popup_hide"]
|
||||
[connection signal="item_selected" from="VBoxContainer/HBoxContainer/ImportOption" to="." method="_on_ImportOption_item_selected"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/SpritesheetOptions/HorizontalFrames" to="." method="_on_HorizontalFrames_value_changed"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/SpritesheetOptions/VerticalFrames" to="." method="_on_VerticalFrames_value_changed"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/SpritesheetTabOptions/HorizontalFrames" to="." method="_on_HorizontalFrames_value_changed"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/SpritesheetTabOptions/VerticalFrames" to="." method="_on_VerticalFrames_value_changed"]
|
||||
[connection signal="item_selected" from="VBoxContainer/HBoxContainer/NewBrushOptions/BrushTypeOption" to="." method="_on_BrushTypeOption_item_selected"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue