mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Added Onion Skinning & Custom .pxo File
- Onion skinning for animations. Choose past and future steps and toggle blue-red mode. - Custom .pxo file. If you save your project as a .pxo file, it remembers all of your frames, their layers, brush sizes, brush colors and color palletes! - Ping-pong loop type. When the animation finishes, it plays backwards. - Ability to import new frames in the timeline as additions, without deleting the previous frames.
This commit is contained in:
parent
4331a0232e
commit
dd9bfc1c33
Binary file not shown.
|
@ -1,3 +1,3 @@
|
|||
source_md5="4c6be4fbf792fca422d20d3708852deb"
|
||||
dest_md5="3f5ec639e0b1538d10f32d07e82950fc"
|
||||
source_md5="f455fa104282b0fb31b168b668bb509b"
|
||||
dest_md5="c8a263d7b4be7177025be77fb2ec15d3"
|
||||
|
||||
|
|
155
Main.tscn
155
Main.tscn
|
@ -13,6 +13,7 @@ anchor_bottom = 1.0
|
|||
script = ExtResource( 1 )
|
||||
|
||||
[node name="UI" type="HBoxContainer" parent="."]
|
||||
editor/display_folded = true
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
|
@ -30,6 +31,7 @@ size_flags_horizontal = 3
|
|||
size_flags_vertical = 3
|
||||
|
||||
[node name="MenusAndTools" type="VBoxContainer" parent="UI/ToolPanel/Tools"]
|
||||
editor/display_folded = true
|
||||
margin_right = 320.0
|
||||
margin_bottom = 294.0
|
||||
size_flags_vertical = 3
|
||||
|
@ -105,6 +107,7 @@ margin_right = 320.0
|
|||
margin_bottom = 302.0
|
||||
|
||||
[node name="ToolOptions" type="HBoxContainer" parent="UI/ToolPanel/Tools"]
|
||||
editor/display_folded = true
|
||||
margin_top = 306.0
|
||||
margin_right = 320.0
|
||||
margin_bottom = 600.0
|
||||
|
@ -219,14 +222,14 @@ size_flags_horizontal = 3
|
|||
|
||||
[node name="ViewportContainer" type="ViewportContainer" parent="UI/CanvasAndTimeline"]
|
||||
margin_right = 536.0
|
||||
margin_bottom = 448.0
|
||||
margin_bottom = 464.0
|
||||
mouse_default_cursor_shape = 3
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
stretch = true
|
||||
|
||||
[node name="Viewport" type="Viewport" parent="UI/CanvasAndTimeline/ViewportContainer"]
|
||||
size = Vector2( 536, 448 )
|
||||
size = Vector2( 536, 464 )
|
||||
handle_input_locally = false
|
||||
render_target_update_mode = 3
|
||||
|
||||
|
@ -238,10 +241,10 @@ zoom = Vector2( 0.15, 0.15 )
|
|||
script = ExtResource( 6 )
|
||||
|
||||
[node name="AnimationTimeline" type="Panel" parent="UI/CanvasAndTimeline"]
|
||||
margin_top = 452.0
|
||||
margin_top = 468.0
|
||||
margin_right = 536.0
|
||||
margin_bottom = 600.0
|
||||
rect_min_size = Vector2( 0, 148 )
|
||||
rect_min_size = Vector2( 0, 132 )
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="TimelineContainer" type="VBoxContainer" parent="UI/CanvasAndTimeline/AnimationTimeline"]
|
||||
|
@ -250,34 +253,42 @@ anchor_bottom = 1.0
|
|||
size_flags_horizontal = 3
|
||||
|
||||
[node name="ButtonContainer" type="CenterContainer" parent="UI/CanvasAndTimeline/AnimationTimeline/TimelineContainer"]
|
||||
editor/display_folded = true
|
||||
margin_right = 536.0
|
||||
margin_bottom = 40.0
|
||||
margin_bottom = 24.0
|
||||
|
||||
[node name="AnimationButtons" type="HBoxContainer" parent="UI/CanvasAndTimeline/AnimationTimeline/TimelineContainer/ButtonContainer"]
|
||||
margin_left = 69.0
|
||||
margin_right = 467.0
|
||||
margin_bottom = 40.0
|
||||
margin_left = 90.0
|
||||
margin_right = 446.0
|
||||
margin_bottom = 24.0
|
||||
|
||||
[node name="LoopAnim" type="CheckButton" parent="UI/CanvasAndTimeline/AnimationTimeline/TimelineContainer/ButtonContainer/AnimationButtons"]
|
||||
margin_right = 111.0
|
||||
margin_bottom = 40.0
|
||||
[node name="LoopLabel" type="Label" parent="UI/CanvasAndTimeline/AnimationTimeline/TimelineContainer/ButtonContainer/AnimationButtons"]
|
||||
margin_top = 5.0
|
||||
margin_right = 35.0
|
||||
margin_bottom = 19.0
|
||||
text = "Loop:"
|
||||
|
||||
[node name="LoopAnim" type="Button" parent="UI/CanvasAndTimeline/AnimationTimeline/TimelineContainer/ButtonContainer/AnimationButtons"]
|
||||
margin_left = 39.0
|
||||
margin_right = 69.0
|
||||
margin_bottom = 24.0
|
||||
hint_tooltip = "Should the animation loop (play again after it reached the end)?"
|
||||
mouse_default_cursor_shape = 2
|
||||
text = "Loop"
|
||||
text = "No"
|
||||
|
||||
[node name="PlayBackwards" type="Button" parent="UI/CanvasAndTimeline/AnimationTimeline/TimelineContainer/ButtonContainer/AnimationButtons"]
|
||||
margin_left = 115.0
|
||||
margin_right = 224.0
|
||||
margin_bottom = 40.0
|
||||
margin_left = 73.0
|
||||
margin_right = 182.0
|
||||
margin_bottom = 24.0
|
||||
hint_tooltip = "Play the animation backwards (from end to beggining)"
|
||||
mouse_default_cursor_shape = 2
|
||||
toggle_mode = true
|
||||
text = "Play Backwards"
|
||||
|
||||
[node name="PlayForward" type="Button" parent="UI/CanvasAndTimeline/AnimationTimeline/TimelineContainer/ButtonContainer/AnimationButtons"]
|
||||
margin_left = 228.0
|
||||
margin_right = 320.0
|
||||
margin_bottom = 40.0
|
||||
margin_left = 186.0
|
||||
margin_right = 278.0
|
||||
margin_bottom = 24.0
|
||||
hint_tooltip = "Play the animation forward (from beggining to end)"
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 0
|
||||
|
@ -285,9 +296,9 @@ toggle_mode = true
|
|||
text = "Play Forward"
|
||||
|
||||
[node name="FPSValue" type="SpinBox" parent="UI/CanvasAndTimeline/AnimationTimeline/TimelineContainer/ButtonContainer/AnimationButtons"]
|
||||
margin_left = 324.0
|
||||
margin_right = 398.0
|
||||
margin_bottom = 40.0
|
||||
margin_left = 282.0
|
||||
margin_right = 356.0
|
||||
margin_bottom = 24.0
|
||||
hint_tooltip = "How many frames per second should the animation preview be? The more FPS, the faster the animation plays."
|
||||
mouse_default_cursor_shape = 2
|
||||
min_value = 1.0
|
||||
|
@ -295,14 +306,15 @@ value = 1.0
|
|||
suffix = "FPS"
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="UI/CanvasAndTimeline/AnimationTimeline/TimelineContainer"]
|
||||
margin_top = 44.0
|
||||
margin_top = 28.0
|
||||
margin_right = 536.0
|
||||
margin_bottom = 48.0
|
||||
margin_bottom = 32.0
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="UI/CanvasAndTimeline/AnimationTimeline/TimelineContainer"]
|
||||
margin_top = 52.0
|
||||
editor/display_folded = true
|
||||
margin_top = 36.0
|
||||
margin_right = 536.0
|
||||
margin_bottom = 72.0
|
||||
margin_bottom = 56.0
|
||||
|
||||
[node name="FrameButtons" type="HBoxContainer" parent="UI/CanvasAndTimeline/AnimationTimeline/TimelineContainer/CenterContainer"]
|
||||
margin_left = 209.0
|
||||
|
@ -354,14 +366,14 @@ size_flags_horizontal = 0
|
|||
text = "Cl"
|
||||
|
||||
[node name="HSeparator2" type="HSeparator" parent="UI/CanvasAndTimeline/AnimationTimeline/TimelineContainer"]
|
||||
margin_top = 76.0
|
||||
margin_top = 60.0
|
||||
margin_right = 536.0
|
||||
margin_bottom = 80.0
|
||||
margin_bottom = 64.0
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="UI/CanvasAndTimeline/AnimationTimeline/TimelineContainer"]
|
||||
margin_top = 84.0
|
||||
margin_top = 68.0
|
||||
margin_right = 536.0
|
||||
margin_bottom = 148.0
|
||||
margin_bottom = 132.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
scroll_vertical_enabled = false
|
||||
|
@ -379,8 +391,9 @@ anchor_right = 1.0
|
|||
anchor_bottom = 1.0
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="UI/LayerPanel/LayersAndMisc"]
|
||||
editor/display_folded = true
|
||||
margin_right = 160.0
|
||||
margin_bottom = 520.0
|
||||
margin_bottom = 375.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
|
@ -460,6 +473,45 @@ disabled = true
|
|||
text = "M"
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="UI/LayerPanel/LayersAndMisc"]
|
||||
margin_top = 379.0
|
||||
margin_right = 160.0
|
||||
margin_bottom = 383.0
|
||||
|
||||
[node name="OnionSkinningButtons" type="VBoxContainer" parent="UI/LayerPanel/LayersAndMisc"]
|
||||
editor/display_folded = true
|
||||
margin_top = 387.0
|
||||
margin_right = 160.0
|
||||
margin_bottom = 520.0
|
||||
|
||||
[node name="OnionSkinning" type="Label" parent="UI/LayerPanel/LayersAndMisc/OnionSkinningButtons"]
|
||||
margin_right = 160.0
|
||||
margin_bottom = 31.0
|
||||
text = "Onion Skinning:
|
||||
Past Steps"
|
||||
|
||||
[node name="PastOnionSkinning" type="SpinBox" parent="UI/LayerPanel/LayersAndMisc/OnionSkinningButtons"]
|
||||
margin_top = 35.0
|
||||
margin_right = 160.0
|
||||
margin_bottom = 59.0
|
||||
|
||||
[node name="OnionSkinningFuture" type="Label" parent="UI/LayerPanel/LayersAndMisc/OnionSkinningButtons"]
|
||||
margin_top = 63.0
|
||||
margin_right = 160.0
|
||||
margin_bottom = 77.0
|
||||
text = "Future Steps"
|
||||
|
||||
[node name="FutureOnionSkinning" type="SpinBox" parent="UI/LayerPanel/LayersAndMisc/OnionSkinningButtons"]
|
||||
margin_top = 81.0
|
||||
margin_right = 160.0
|
||||
margin_bottom = 105.0
|
||||
|
||||
[node name="BlueRedMode" type="CheckBox" parent="UI/LayerPanel/LayersAndMisc/OnionSkinningButtons"]
|
||||
margin_top = 109.0
|
||||
margin_right = 160.0
|
||||
margin_bottom = 133.0
|
||||
text = "Blue-Red Mode"
|
||||
|
||||
[node name="HSeparator3" type="HSeparator" parent="UI/LayerPanel/LayersAndMisc"]
|
||||
margin_top = 524.0
|
||||
margin_right = 160.0
|
||||
margin_bottom = 528.0
|
||||
|
@ -546,6 +598,32 @@ suffix = "px"
|
|||
[node name="OpenSprite" type="FileDialog" parent="."]
|
||||
margin_right = 515.0
|
||||
margin_bottom = 348.0
|
||||
window_title = "Open a File"
|
||||
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/"
|
||||
|
||||
[node name="SaveSprite" type="FileDialog" parent="."]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -512.0
|
||||
margin_top = -300.0
|
||||
margin_right = 3.0
|
||||
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/"
|
||||
|
||||
[node name="ImportSprites" type="FileDialog" parent="."]
|
||||
margin_right = 515.0
|
||||
margin_bottom = 348.0
|
||||
window_title = "Open File(s)"
|
||||
resizable = true
|
||||
mode = 1
|
||||
|
@ -554,7 +632,7 @@ 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/"
|
||||
|
||||
[node name="SaveSprite" type="FileDialog" parent="."]
|
||||
[node name="ExportSprites" type="FileDialog" parent="."]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
|
@ -644,7 +722,7 @@ margin_left = 91.0
|
|||
margin_right = 182.0
|
||||
margin_bottom = 20.0
|
||||
text = "Nearest"
|
||||
items = [ "Nearest", null, false, 0, null, "Bilinear", null, false, 1, null, "Cubic", null, false, 2, null, "Trilinear", null, false, 3, null ]
|
||||
items = [ "Nearest", null, false, 0, null, "Bilinear", null, false, 1, null, "Cubic", null, false, 2, null, "Trilinear", null, false, 3, null, "Lanczos", null, true, 4, null ]
|
||||
selected = 0
|
||||
|
||||
[node name="AnimationTimer" type="Timer" parent="."]
|
||||
|
@ -658,7 +736,7 @@ selected = 0
|
|||
[connection signal="value_changed" from="UI/ToolPanel/Tools/ToolOptions/RightToolOptions/BrushSize/RightBrushSizeEdit" to="." method="_on_RightBrushSizeEdit_value_changed"]
|
||||
[connection signal="mouse_entered" from="UI/CanvasAndTimeline/ViewportContainer" to="." method="_on_ViewportContainer_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="UI/CanvasAndTimeline/ViewportContainer" to="." method="_on_ViewportContainer_mouse_exited"]
|
||||
[connection signal="toggled" from="UI/CanvasAndTimeline/AnimationTimeline/TimelineContainer/ButtonContainer/AnimationButtons/LoopAnim" to="." method="_on_LoopAnim_toggled"]
|
||||
[connection signal="pressed" from="UI/CanvasAndTimeline/AnimationTimeline/TimelineContainer/ButtonContainer/AnimationButtons/LoopAnim" to="." method="_on_LoopAnim_pressed"]
|
||||
[connection signal="toggled" from="UI/CanvasAndTimeline/AnimationTimeline/TimelineContainer/ButtonContainer/AnimationButtons/PlayBackwards" to="." method="_on_PlayBackwards_toggled"]
|
||||
[connection signal="toggled" from="UI/CanvasAndTimeline/AnimationTimeline/TimelineContainer/ButtonContainer/AnimationButtons/PlayForward" to="." method="_on_PlayForward_toggled"]
|
||||
[connection signal="value_changed" from="UI/CanvasAndTimeline/AnimationTimeline/TimelineContainer/ButtonContainer/AnimationButtons/FPSValue" to="." method="_on_FPSValue_value_changed"]
|
||||
|
@ -673,12 +751,19 @@ selected = 0
|
|||
[connection signal="pressed" from="UI/LayerPanel/LayersAndMisc/ScrollContainer/VBoxLayerContainer/CenterContainer/LayerButtons/MoveDownLayer" to="." method="_on_MoveDownLayer_pressed"]
|
||||
[connection signal="pressed" from="UI/LayerPanel/LayersAndMisc/ScrollContainer/VBoxLayerContainer/CenterContainer/LayerButtons/CloneLayer" to="." method="_on_CloneLayer_pressed"]
|
||||
[connection signal="pressed" from="UI/LayerPanel/LayersAndMisc/ScrollContainer/VBoxLayerContainer/CenterContainer/LayerButtons/MergeDownLayer" to="." method="_on_MergeLayer_pressed"]
|
||||
[connection signal="value_changed" from="UI/LayerPanel/LayersAndMisc/OnionSkinningButtons/PastOnionSkinning" to="." method="_on_PastOnionSkinning_value_changed"]
|
||||
[connection signal="value_changed" from="UI/LayerPanel/LayersAndMisc/OnionSkinningButtons/FutureOnionSkinning" to="." method="_on_FutureOnionSkinning_value_changed"]
|
||||
[connection signal="toggled" from="UI/LayerPanel/LayersAndMisc/OnionSkinningButtons/BlueRedMode" to="." method="_on_BlueRedMode_toggled"]
|
||||
[connection signal="confirmed" from="CreateNewImage" to="." method="_on_CreateNewImage_confirmed"]
|
||||
[connection signal="popup_hide" from="CreateNewImage" to="." method="_can_draw_true"]
|
||||
[connection signal="files_selected" from="OpenSprite" to="." method="_on_OpenSprite_files_selected"]
|
||||
[connection signal="popup_hide" from="OpenSprite" to="." method="_on_OpenSprite_popup_hide"]
|
||||
[connection signal="file_selected" from="OpenSprite" to="." method="_on_OpenSprite_file_selected"]
|
||||
[connection signal="popup_hide" from="OpenSprite" to="." method="_on_ImportSprites_popup_hide"]
|
||||
[connection signal="file_selected" from="SaveSprite" to="." method="_on_SaveSprite_file_selected"]
|
||||
[connection signal="popup_hide" from="SaveSprite" to="." method="_can_draw_true"]
|
||||
[connection signal="files_selected" from="ImportSprites" to="." method="_on_ImportSprites_files_selected"]
|
||||
[connection signal="popup_hide" from="ImportSprites" to="." method="_on_ImportSprites_popup_hide"]
|
||||
[connection signal="file_selected" from="ExportSprites" to="." method="_on_ExportSprites_file_selected"]
|
||||
[connection signal="popup_hide" from="ExportSprites" to="." method="_can_draw_true"]
|
||||
[connection signal="confirmed" from="ScaleImage" to="." method="_on_ScaleImage_confirmed"]
|
||||
[connection signal="popup_hide" from="ScaleImage" to="." method="_can_draw_true"]
|
||||
[connection signal="timeout" from="AnimationTimer" to="." method="_on_AnimationTimer_timeout"]
|
||||
|
|
|
@ -106,6 +106,8 @@ func update_texture(layer_index : int) -> void:
|
|||
layers[layer_index][1].create_from_image(layers[layer_index][0], 0)
|
||||
get_layer_container(layer_index).get_child(0).get_child(1).texture = layers[layer_index][1]
|
||||
|
||||
#This code is used to update the texture in the animation timeline frame button
|
||||
#but blend_rect causes major performance issues on large images
|
||||
var whole_image := Image.new()
|
||||
whole_image.create(size.x, size.y, false, Image.FORMAT_RGBA8)
|
||||
for layer in layers:
|
||||
|
@ -122,8 +124,37 @@ func get_layer_container(layer_index : int) -> PanelContainer:
|
|||
return null
|
||||
|
||||
func _draw() -> void:
|
||||
draw_texture_rect(trans_background, Rect2(location, size), true)
|
||||
#for texture in layer_textures:
|
||||
draw_texture_rect(trans_background, Rect2(location, size), true) #Draw transparent background
|
||||
|
||||
#Onion Skinning
|
||||
#Past
|
||||
if Global.onion_skinning_past_rate > 0:
|
||||
var color : Color
|
||||
if Global.onion_skinning_blue_red:
|
||||
color = Color.blue
|
||||
else:
|
||||
color = Color.white
|
||||
for i in range(1, Global.onion_skinning_past_rate + 1):
|
||||
if Global.current_frame >= i:
|
||||
for texture in Global.canvases[Global.current_frame - i].layers:
|
||||
color.a = 0.6/i
|
||||
draw_texture(texture[1], location, color)
|
||||
|
||||
#Future
|
||||
if Global.onion_skinning_future_rate > 0:
|
||||
var color : Color
|
||||
if Global.onion_skinning_blue_red:
|
||||
color = Color.red
|
||||
else:
|
||||
color = Color.white
|
||||
for i in range(1, Global.onion_skinning_future_rate + 1):
|
||||
#print(i)
|
||||
if Global.current_frame < Global.canvases.size() - i:
|
||||
for texture in Global.canvases[Global.current_frame + i].layers:
|
||||
color.a = 0.6/i
|
||||
draw_texture(texture[1], location, color)
|
||||
|
||||
#Draw current frame layers
|
||||
for texture in layers:
|
||||
if texture[3]: #if it's visible
|
||||
draw_texture(texture[1], location)
|
||||
|
@ -275,6 +306,7 @@ func flood_fill(pos : Vector2, target_color : Color, replace_color : Color) -> v
|
|||
east += Vector2.RIGHT
|
||||
for px in range(west.x + 1, east.x):
|
||||
var p := Vector2(px, n.y)
|
||||
#print(point_in_rectangle(p, location, size))
|
||||
draw_pixel(p, replace_color, 1)
|
||||
var north := p + Vector2.UP
|
||||
var south := p + Vector2.DOWN
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
extends Node
|
||||
|
||||
# warning-ignore:unused_class_variable
|
||||
var current_frame := 0 setget set_current_frame_label
|
||||
# warning-ignore:unused_class_variable
|
||||
var can_draw := false
|
||||
# warning-ignore:unused_class_variable
|
||||
var has_focus := true
|
||||
# warning-ignore:unused_class_variable
|
||||
var onion_skinning_past_rate := 0
|
||||
# warning-ignore:unused_class_variable
|
||||
var onion_skinning_future_rate := 0
|
||||
# warning-ignore:unused_class_variable
|
||||
var onion_skinning_blue_red := false
|
||||
# warning-ignore:unused_class_variable
|
||||
var draw_grid := false
|
||||
var canvases := []
|
||||
var canvas : Canvas
|
||||
|
@ -20,12 +25,16 @@ var left_brush_size := 1
|
|||
# warning-ignore:unused_class_variable
|
||||
var right_brush_size := 1
|
||||
var camera : Camera2D
|
||||
var left_color_picker : ColorPickerButton
|
||||
var right_color_picker : ColorPickerButton
|
||||
|
||||
var file_menu : MenuButton
|
||||
var edit_menu : MenuButton
|
||||
var left_indicator : Sprite
|
||||
var right_indicator : Sprite
|
||||
var left_color_picker : ColorPickerButton
|
||||
var right_color_picker : ColorPickerButton
|
||||
var left_brush_size_edit : SpinBox
|
||||
var right_brush_size_edit : SpinBox
|
||||
var loop_animation_button : Button
|
||||
var play_forward : Button
|
||||
var play_backwards : Button
|
||||
var frame_container : HBoxContainer
|
||||
|
@ -51,12 +60,17 @@ func _ready() -> void:
|
|||
canvases.append(canvas)
|
||||
canvas_parent = canvas.get_parent()
|
||||
camera = find_node_by_name(canvas_parent, "Camera2D")
|
||||
left_color_picker = find_node_by_name(root, "LeftColorPickerButton")
|
||||
right_color_picker = find_node_by_name(root, "RightColorPickerButton")
|
||||
|
||||
file_menu = find_node_by_name(root, "FileMenu")
|
||||
edit_menu = find_node_by_name(root, "EditMenu")
|
||||
left_indicator = find_node_by_name(root, "LeftIndicator")
|
||||
right_indicator = find_node_by_name(root, "RightIndicator")
|
||||
left_color_picker = find_node_by_name(root, "LeftColorPickerButton")
|
||||
right_color_picker = find_node_by_name(root, "RightColorPickerButton")
|
||||
left_brush_size_edit = find_node_by_name(root, "LeftBrushSizeEdit")
|
||||
right_brush_size_edit = find_node_by_name(root, "RightBrushSizeEdit")
|
||||
|
||||
loop_animation_button = find_node_by_name(root, "LoopAnim")
|
||||
play_forward = find_node_by_name(root, "PlayForward")
|
||||
play_backwards = find_node_by_name(root, "PlayBackwards")
|
||||
frame_container = find_node_by_name(root, "FrameContainer")
|
||||
|
|
261
Scripts/Main.gd
261
Scripts/Main.gd
|
@ -1,27 +1,33 @@
|
|||
extends Control
|
||||
|
||||
var current_path := ""
|
||||
var current_save_path := ""
|
||||
var current_export_path := ""
|
||||
var opensprite_file_selected := false
|
||||
var pencil_tool
|
||||
var eraser_tool
|
||||
var fill_tool
|
||||
var export_all_frames : CheckButton
|
||||
var export_as_single_file : CheckButton
|
||||
var export_vertical_spritesheet : CheckButton
|
||||
var import_as_new_frame : CheckBox
|
||||
var export_all_frames : CheckBox
|
||||
var export_as_single_file : CheckBox
|
||||
var export_vertical_spritesheet : CheckBox
|
||||
var fps := 1.0
|
||||
var animation_loop := false
|
||||
var animation_loop := 0 #0 is no loop, 1 is cycle loop, 2 is ping-pong loop
|
||||
var animation_forward := true
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
# Set a minimum window size to prevent UI elements from collapsing on each other.
|
||||
# This property is only available in 3.2alpha or later, so use `set()` to fail gracefully if it doesn't exist.
|
||||
OS.set("min_window_size", Vector2(1024, 600))
|
||||
|
||||
var file_menu_items := {
|
||||
"New..." : KEY_MASK_CTRL + KEY_N,
|
||||
#The import and export key shortcuts will change,
|
||||
#and they will be bound to Open and Save/Save as once I
|
||||
#make a custom file for Pixelorama projects
|
||||
"Import..." : KEY_MASK_CTRL + KEY_O,
|
||||
"Export..." : KEY_MASK_CTRL + KEY_S,
|
||||
"Export as..." : KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_S,
|
||||
"Open..." : KEY_MASK_CTRL + KEY_O,
|
||||
"Save..." : KEY_MASK_CTRL + KEY_S,
|
||||
"Save as..." : KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_S,
|
||||
"Import..." : KEY_MASK_CTRL + KEY_I,
|
||||
"Export..." : KEY_MASK_CTRL + KEY_E,
|
||||
"Export as..." : KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_E,
|
||||
"Quit" : KEY_MASK_CTRL + KEY_Q
|
||||
}
|
||||
var edit_menu_items := {
|
||||
|
@ -51,15 +57,22 @@ func _ready() -> void:
|
|||
eraser_tool.connect("pressed", self, "_on_Tool_pressed", [eraser_tool])
|
||||
fill_tool.connect("pressed", self, "_on_Tool_pressed", [fill_tool])
|
||||
|
||||
export_all_frames = CheckButton.new()
|
||||
#Options for Import
|
||||
import_as_new_frame = CheckBox.new()
|
||||
import_as_new_frame.text = "Import as new frame?"
|
||||
$ImportSprites.get_vbox().add_child(import_as_new_frame)
|
||||
|
||||
#Options for Export
|
||||
export_all_frames = CheckBox.new()
|
||||
export_all_frames.text = "Export all frames?"
|
||||
export_as_single_file = CheckButton.new()
|
||||
export_as_single_file = CheckBox.new()
|
||||
export_as_single_file.text = "Export frames as a single file?"
|
||||
export_vertical_spritesheet = CheckButton.new()
|
||||
export_vertical_spritesheet = CheckBox.new()
|
||||
export_vertical_spritesheet.text = "Vertical spritesheet?"
|
||||
$SaveSprite.get_vbox().add_child(export_all_frames)
|
||||
$SaveSprite.get_vbox().add_child(export_as_single_file)
|
||||
$SaveSprite.get_vbox().add_child(export_vertical_spritesheet)
|
||||
$ExportSprites.get_vbox().add_child(export_all_frames)
|
||||
$ExportSprites.get_vbox().add_child(export_as_single_file)
|
||||
$ExportSprites.get_vbox().add_child(export_vertical_spritesheet)
|
||||
|
||||
|
||||
func _input(event):
|
||||
#Handle tool shortcuts
|
||||
|
@ -82,20 +95,33 @@ func file_menu_id_pressed(id : int) -> void:
|
|||
0: #New
|
||||
$CreateNewImage.popup_centered()
|
||||
Global.can_draw = false
|
||||
1: #Import
|
||||
1: #Open
|
||||
$OpenSprite.popup_centered()
|
||||
Global.can_draw = false
|
||||
opensprite_file_selected = false
|
||||
2: #Export
|
||||
if current_path == "":
|
||||
2: #Save
|
||||
if current_save_path == "":
|
||||
$SaveSprite.popup_centered()
|
||||
Global.can_draw = false
|
||||
else:
|
||||
export_project()
|
||||
3: #Export as
|
||||
_on_SaveSprite_file_selected(current_save_path)
|
||||
3: #Save as
|
||||
$SaveSprite.popup_centered()
|
||||
Global.can_draw = false
|
||||
4: #Quit
|
||||
4: #Import
|
||||
$ImportSprites.popup_centered()
|
||||
Global.can_draw = false
|
||||
opensprite_file_selected = false
|
||||
5: #Export
|
||||
if current_export_path == "":
|
||||
$ExportSprites.popup_centered()
|
||||
Global.can_draw = false
|
||||
else:
|
||||
export_project()
|
||||
6: #Export as
|
||||
$ExportSprites.popup_centered()
|
||||
Global.can_draw = false
|
||||
7: #Quit
|
||||
get_tree().quit()
|
||||
|
||||
func edit_menu_id_pressed(id : int) -> void:
|
||||
|
@ -111,30 +137,97 @@ func _on_CreateNewImage_confirmed() -> void:
|
|||
var height = float($CreateNewImage/VBoxContainer/HeightCont/HeightValue.value)
|
||||
new_canvas(Vector2(width, height).floor())
|
||||
|
||||
#func _on_OpenSprite_file_selected(path : String) -> void:
|
||||
# var image = Image.new()
|
||||
# var err = image.load(path)
|
||||
# if err == OK:
|
||||
# opensprite_file_selected = true
|
||||
# new_canvas(image.get_size(), image)
|
||||
# else:
|
||||
# OS.alert("Can't load file")
|
||||
func _on_OpenSprite_file_selected(path) -> void:
|
||||
var file := File.new()
|
||||
var err := file.open(path, File.READ)
|
||||
if err == 0:
|
||||
var version := file.get_line()
|
||||
var frame := 0
|
||||
var frame_line := file.get_line()
|
||||
clear_canvases()
|
||||
while frame_line == "--":
|
||||
var canvas : Canvas = load("res://Canvas.tscn").instance()
|
||||
Global.canvas = canvas
|
||||
var width := file.get_16()
|
||||
var height := file.get_16()
|
||||
|
||||
var layer := 0
|
||||
var layer_line := file.get_line()
|
||||
|
||||
while layer_line == "-":
|
||||
var buffer := file.get_buffer(width * height * 4)
|
||||
var image := Image.new()
|
||||
image.create_from_data(width, height, false, Image.FORMAT_RGBA8, buffer)
|
||||
image.lock()
|
||||
var tex := ImageTexture.new()
|
||||
tex.create_from_image(image, 0)
|
||||
canvas.layers.append([image, tex, "Layer %s" % layer, true])
|
||||
layer_line = file.get_line()
|
||||
layer += 1
|
||||
|
||||
canvas.size = Vector2(width, height)
|
||||
Global.canvases.append(canvas)
|
||||
canvas.frame = frame
|
||||
Global.canvas_parent.add_child(canvas)
|
||||
frame_line = file.get_line()
|
||||
frame += 1
|
||||
|
||||
Global.current_frame = frame - 1
|
||||
#Load tool options
|
||||
Global.left_color_picker.color = file.get_var()
|
||||
Global.right_color_picker.color = file.get_var()
|
||||
Global.left_brush_size = file.get_8()
|
||||
Global.left_brush_size_edit.value = Global.left_brush_size
|
||||
Global.right_brush_size = file.get_8()
|
||||
Global.right_brush_size_edit.value = Global.right_brush_size
|
||||
var left_palette = file.get_var()
|
||||
var right_palette = file.get_var()
|
||||
for color in left_palette:
|
||||
Global.left_color_picker.get_picker().add_preset(color)
|
||||
for color in right_palette:
|
||||
Global.right_color_picker.get_picker().add_preset(color)
|
||||
|
||||
file.close()
|
||||
|
||||
func _on_OpenSprite_files_selected(paths) -> void:
|
||||
for child in Global.vbox_layer_container.get_children():
|
||||
if child is PanelContainer:
|
||||
child.queue_free()
|
||||
for child in Global.frame_container.get_children():
|
||||
child.queue_free()
|
||||
for child in Global.canvas_parent.get_children():
|
||||
if child is Canvas:
|
||||
child.queue_free()
|
||||
Global.canvases.clear()
|
||||
|
||||
func _on_SaveSprite_file_selected(path) -> void:
|
||||
current_save_path = path
|
||||
var file := File.new()
|
||||
var err := file.open(path, File.WRITE)
|
||||
if err == 0:
|
||||
file.store_line(ProjectSettings.get_setting("application/config/Version"))
|
||||
for canvas in Global.canvases:
|
||||
file.store_line("--")
|
||||
file.store_16(canvas.size.x)
|
||||
file.store_16(canvas.size.y)
|
||||
for layer in canvas.layers:
|
||||
file.store_line("-")
|
||||
file.store_buffer(layer[0].get_data())
|
||||
file.store_line("END_LAYERS")
|
||||
file.store_line("END_FRAMES")
|
||||
|
||||
#Save tool options
|
||||
var left_color := Global.left_color_picker.color
|
||||
var right_color := Global.right_color_picker.color
|
||||
var left_brush_size := Global.left_brush_size
|
||||
var right_brush_size := Global.right_brush_size
|
||||
var left_palette := Global.left_color_picker.get_picker().get_presets()
|
||||
var right_palette := Global.right_color_picker.get_picker().get_presets()
|
||||
file.store_var(left_color)
|
||||
file.store_var(right_color)
|
||||
file.store_8(left_brush_size)
|
||||
file.store_8(right_brush_size)
|
||||
file.store_var(left_palette)
|
||||
file.store_var(right_palette)
|
||||
file.close()
|
||||
|
||||
func _on_ImportSprites_files_selected(paths) -> void:
|
||||
if !import_as_new_frame.pressed: #If we're not adding a new frame, delete the previous
|
||||
clear_canvases()
|
||||
|
||||
#Find the biggest image and let it handle the camera zoom options
|
||||
var max_size : Vector2
|
||||
var biggest_canvas : Canvas
|
||||
var i := 0
|
||||
var i := Global.canvases.size()
|
||||
for path in paths:
|
||||
var image = Image.new()
|
||||
var err = image.load(path)
|
||||
|
@ -152,7 +245,7 @@ func _on_OpenSprite_files_selected(paths) -> void:
|
|||
Global.canvas_parent.add_child(canvas)
|
||||
Global.canvases.append(canvas)
|
||||
canvas.visible = false
|
||||
if i == 0:
|
||||
if path == paths[0]: #If it's the first file
|
||||
max_size = canvas.size
|
||||
biggest_canvas = canvas
|
||||
else:
|
||||
|
@ -174,8 +267,8 @@ func _on_OpenSprite_files_selected(paths) -> void:
|
|||
else:
|
||||
Global.remove_frame_button.disabled = true
|
||||
Global.remove_frame_button.mouse_default_cursor_shape = Control.CURSOR_FORBIDDEN
|
||||
|
||||
func new_canvas(size : Vector2) -> void:
|
||||
|
||||
func clear_canvases() -> void:
|
||||
for child in Global.vbox_layer_container.get_children():
|
||||
if child is PanelContainer:
|
||||
child.queue_free()
|
||||
|
@ -185,6 +278,9 @@ func new_canvas(size : Vector2) -> void:
|
|||
if child is Canvas:
|
||||
child.queue_free()
|
||||
Global.canvases.clear()
|
||||
|
||||
func new_canvas(size : Vector2) -> void:
|
||||
clear_canvases()
|
||||
Global.canvas = load("res://Canvas.tscn").instance()
|
||||
Global.canvas.size = size
|
||||
|
||||
|
@ -194,8 +290,8 @@ func new_canvas(size : Vector2) -> void:
|
|||
Global.remove_frame_button.disabled = true
|
||||
Global.remove_frame_button.mouse_default_cursor_shape = Control.CURSOR_FORBIDDEN
|
||||
|
||||
func _on_SaveSprite_file_selected(path : String) -> void:
|
||||
current_path = path
|
||||
func _on_ExportSprites_file_selected(path : String) -> void:
|
||||
current_export_path = path
|
||||
export_project()
|
||||
|
||||
func export_project() -> void:
|
||||
|
@ -203,7 +299,7 @@ func export_project() -> void:
|
|||
if !export_as_single_file.pressed:
|
||||
var i := 1
|
||||
for canvas in Global.canvases:
|
||||
var path := "%s_%s" % [current_path, str(i)]
|
||||
var path := "%s_%s" % [current_export_path, str(i)]
|
||||
path = path.replace(".png", "")
|
||||
path = "%s.png" % path
|
||||
save_sprite(canvas, path)
|
||||
|
@ -211,7 +307,7 @@ func export_project() -> void:
|
|||
else:
|
||||
save_spritesheet()
|
||||
else:
|
||||
save_sprite(Global.canvas, current_path)
|
||||
save_sprite(Global.canvas, current_export_path)
|
||||
|
||||
func save_sprite(canvas : Canvas, path : String) -> void:
|
||||
var whole_image := Image.new()
|
||||
|
@ -252,11 +348,11 @@ func save_spritesheet() -> void:
|
|||
else:
|
||||
dst += Vector2(canvas.size.x, 0)
|
||||
|
||||
var err = whole_image.save_png(current_path)
|
||||
var err = whole_image.save_png(current_export_path)
|
||||
if err != OK:
|
||||
OS.alert("Can't save file")
|
||||
|
||||
func _on_OpenSprite_popup_hide() -> void:
|
||||
func _on_ImportSprites_popup_hide() -> void:
|
||||
if !opensprite_file_selected:
|
||||
Global.can_draw = true
|
||||
|
||||
|
@ -446,6 +542,20 @@ func change_frame_order(rate : int) -> void:
|
|||
#Global.canvas.generate_layer_panels()
|
||||
Global.handle_layer_order_buttons()
|
||||
|
||||
func _on_LoopAnim_pressed() -> void:
|
||||
match Global.loop_animation_button.text:
|
||||
"No":
|
||||
#Make it loop
|
||||
animation_loop = 1
|
||||
Global.loop_animation_button.text = "Cycle"
|
||||
"Cycle":
|
||||
#Make it ping-pong
|
||||
animation_loop = 2
|
||||
Global.loop_animation_button.text = "Ping-Pong"
|
||||
"Ping-Pong":
|
||||
#Make it stop
|
||||
animation_loop = 0
|
||||
Global.loop_animation_button.text = "No"
|
||||
|
||||
func _on_PlayForward_toggled(button_pressed) -> void:
|
||||
Global.play_backwards.pressed = false
|
||||
|
@ -478,22 +588,35 @@ func _on_AnimationTimer_timeout() -> void:
|
|||
if Global.current_frame < Global.canvases.size() - 1:
|
||||
Global.current_frame += 1
|
||||
else:
|
||||
if animation_loop:
|
||||
Global.current_frame = 0
|
||||
else:
|
||||
Global.play_forward.pressed = false
|
||||
Global.play_forward.text = "Play Forward"
|
||||
$AnimationTimer.stop()
|
||||
match animation_loop:
|
||||
0: #No loop
|
||||
Global.play_forward.pressed = false
|
||||
Global.play_forward.text = "Play Forward"
|
||||
Global.play_backwards.pressed = false
|
||||
Global.play_backwards.text = "Play Backwards"
|
||||
$AnimationTimer.stop()
|
||||
1: #Cycle loop
|
||||
Global.current_frame = 0
|
||||
2: #Ping pong loop
|
||||
animation_forward = false
|
||||
_on_AnimationTimer_timeout()
|
||||
|
||||
else:
|
||||
if Global.current_frame > 0:
|
||||
Global.current_frame -= 1
|
||||
else:
|
||||
if animation_loop:
|
||||
Global.current_frame = Global.canvases.size() - 1
|
||||
else:
|
||||
Global.play_backwards.pressed = false
|
||||
Global.play_backwards.text = "Play Backwards"
|
||||
$AnimationTimer.stop()
|
||||
match animation_loop:
|
||||
0: #No loop
|
||||
Global.play_backwards.pressed = false
|
||||
Global.play_backwards.text = "Play Backwards"
|
||||
Global.play_forward.pressed = false
|
||||
Global.play_forward.text = "Play Forward"
|
||||
$AnimationTimer.stop()
|
||||
1: #Cycle loop
|
||||
Global.current_frame = Global.canvases.size() - 1
|
||||
2: #Ping pong loop
|
||||
animation_forward = true
|
||||
_on_AnimationTimer_timeout()
|
||||
|
||||
Global.change_frame()
|
||||
|
||||
|
@ -501,5 +624,11 @@ func _on_FPSValue_value_changed(value) -> void:
|
|||
fps = float(value)
|
||||
$AnimationTimer.wait_time = 1 / fps
|
||||
|
||||
func _on_LoopAnim_toggled(button_pressed) -> void:
|
||||
animation_loop = button_pressed
|
||||
func _on_PastOnionSkinning_value_changed(value) -> void:
|
||||
Global.onion_skinning_past_rate = int(value)
|
||||
|
||||
func _on_FutureOnionSkinning_value_changed(value) -> void:
|
||||
Global.onion_skinning_future_rate = int(value)
|
||||
|
||||
func _on_BlueRedMode_toggled(button_pressed) -> void:
|
||||
Global.onion_skinning_blue_red = button_pressed
|
Binary file not shown.
Before Width: | Height: | Size: 558 B After Width: | Height: | Size: 84 B |
|
@ -29,6 +29,7 @@ _global_script_class_icons={
|
|||
config/name="Pixelorama"
|
||||
run/main_scene="res://Main.tscn"
|
||||
config/icon="res://icon.png"
|
||||
config/Version="v0.2"
|
||||
|
||||
[autoload]
|
||||
|
||||
|
|
Loading…
Reference in a new issue