From 92332cc52e506ad320d18c07ff5831108ad2dfd1 Mon Sep 17 00:00:00 2001 From: OverloadedOrama Date: Tue, 18 Aug 2020 16:21:31 +0300 Subject: [PATCH] Move Canvas related files to a "Canvas" folder under "UI" --- project.godot | 6 +-- src/{ => UI/Canvas}/CameraMovement.gd | 0 src/{ => UI/Canvas}/Canvas.gd | 0 src/{ => UI/Canvas}/Canvas.tscn | 4 +- src/UI/{ => Canvas}/CanvasPreview.gd | 0 src/UI/Canvas/CanvasPreview.tscn | 39 +++++++++++++++++++ src/UI/{ => Canvas}/Grid.gd | 0 src/UI/{ => Canvas}/Rulers/Guide.gd | 0 src/UI/{ => Canvas}/Rulers/HorizontalRuler.gd | 0 src/UI/{ => Canvas}/Rulers/SymmetryGuide.gd | 0 src/UI/{ => Canvas}/Rulers/VerticalRuler.gd | 0 src/UI/CanvasPreview.tscn | 9 ----- src/UI/CanvasPreviewContainer.tscn | 25 ++++++++++-- src/UI/UI.tscn | 10 ++--- 14 files changed, 71 insertions(+), 22 deletions(-) rename src/{ => UI/Canvas}/CameraMovement.gd (100%) rename src/{ => UI/Canvas}/Canvas.gd (100%) rename src/{ => UI/Canvas}/Canvas.tscn (54%) rename src/UI/{ => Canvas}/CanvasPreview.gd (100%) create mode 100644 src/UI/Canvas/CanvasPreview.tscn rename src/UI/{ => Canvas}/Grid.gd (100%) rename src/UI/{ => Canvas}/Rulers/Guide.gd (100%) rename src/UI/{ => Canvas}/Rulers/HorizontalRuler.gd (100%) rename src/UI/{ => Canvas}/Rulers/SymmetryGuide.gd (100%) rename src/UI/{ => Canvas}/Rulers/VerticalRuler.gd (100%) delete mode 100644 src/UI/CanvasPreview.tscn diff --git a/project.godot b/project.godot index bcdd497b9..387eecf8f 100644 --- a/project.godot +++ b/project.godot @@ -22,7 +22,7 @@ _global_script_classes=[ { "base": "Node2D", "class": "Canvas", "language": "GDScript", -"path": "res://src/Canvas.gd" +"path": "res://src/UI/Canvas/Canvas.gd" }, { "base": "Reference", "class": "Cel", @@ -42,7 +42,7 @@ _global_script_classes=[ { "base": "Line2D", "class": "Guide", "language": "GDScript", -"path": "res://src/UI/Rulers/Guide.gd" +"path": "res://src/UI/Canvas/Rulers/Guide.gd" }, { "base": "Reference", "class": "Layer", @@ -77,7 +77,7 @@ _global_script_classes=[ { "base": "Guide", "class": "SymmetryGuide", "language": "GDScript", -"path": "res://src/UI/Rulers/SymmetryGuide.gd" +"path": "res://src/UI/Canvas/Rulers/SymmetryGuide.gd" } ] _global_script_class_icons={ "AnimationTag": "", diff --git a/src/CameraMovement.gd b/src/UI/Canvas/CameraMovement.gd similarity index 100% rename from src/CameraMovement.gd rename to src/UI/Canvas/CameraMovement.gd diff --git a/src/Canvas.gd b/src/UI/Canvas/Canvas.gd similarity index 100% rename from src/Canvas.gd rename to src/UI/Canvas/Canvas.gd diff --git a/src/Canvas.tscn b/src/UI/Canvas/Canvas.tscn similarity index 54% rename from src/Canvas.tscn rename to src/UI/Canvas/Canvas.tscn index fb31f3ae4..77825b2be 100644 --- a/src/Canvas.tscn +++ b/src/UI/Canvas/Canvas.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=2] -[ext_resource path="res://src/Canvas.gd" type="Script" id=1] -[ext_resource path="res://src/UI/Grid.gd" type="Script" id=2] +[ext_resource path="res://src/UI/Canvas/Canvas.gd" type="Script" id=1] +[ext_resource path="res://src/UI/Canvas/Grid.gd" type="Script" id=2] [node name="Canvas" type="Node2D"] script = ExtResource( 1 ) diff --git a/src/UI/CanvasPreview.gd b/src/UI/Canvas/CanvasPreview.gd similarity index 100% rename from src/UI/CanvasPreview.gd rename to src/UI/Canvas/CanvasPreview.gd diff --git a/src/UI/Canvas/CanvasPreview.tscn b/src/UI/Canvas/CanvasPreview.tscn new file mode 100644 index 000000000..f9b249b69 --- /dev/null +++ b/src/UI/Canvas/CanvasPreview.tscn @@ -0,0 +1,39 @@ +[gd_scene load_steps=2 format=2] + +[sub_resource type="GDScript" id=1] +script/source = "extends Node2D + + +var frame : int = 0 +onready var animation_timer : Timer = $AnimationTimer + +func _draw() -> void: + var current_project : Project = Global.current_project + $AnimationTimer.wait_time = Global.animation_timer.wait_time + + if animation_timer.is_stopped(): + frame = current_project.current_frame + var current_cels : Array = current_project.frames[frame].cels + + # Draw current frame layers + for i in range(current_cels.size()): + var modulate_color := Color(1, 1, 1, current_cels[i].opacity) + if i < current_project.layers.size() and current_project.layers[i].visible: + draw_texture(current_cels[i].image_texture, Vector2.ZERO, modulate_color) + + +func _on_AnimationTimer_timeout() -> void: + var current_project : Project = Global.current_project + + if frame < current_project.frames.size() - 1: + frame += 1 + else: + frame = 0 + update() +" + +[node name="CanvasPreview" type="Node2D"] +script = SubResource( 1 ) + +[node name="AnimationTimer" type="Timer" parent="."] +[connection signal="timeout" from="AnimationTimer" to="." method="_on_AnimationTimer_timeout"] diff --git a/src/UI/Grid.gd b/src/UI/Canvas/Grid.gd similarity index 100% rename from src/UI/Grid.gd rename to src/UI/Canvas/Grid.gd diff --git a/src/UI/Rulers/Guide.gd b/src/UI/Canvas/Rulers/Guide.gd similarity index 100% rename from src/UI/Rulers/Guide.gd rename to src/UI/Canvas/Rulers/Guide.gd diff --git a/src/UI/Rulers/HorizontalRuler.gd b/src/UI/Canvas/Rulers/HorizontalRuler.gd similarity index 100% rename from src/UI/Rulers/HorizontalRuler.gd rename to src/UI/Canvas/Rulers/HorizontalRuler.gd diff --git a/src/UI/Rulers/SymmetryGuide.gd b/src/UI/Canvas/Rulers/SymmetryGuide.gd similarity index 100% rename from src/UI/Rulers/SymmetryGuide.gd rename to src/UI/Canvas/Rulers/SymmetryGuide.gd diff --git a/src/UI/Rulers/VerticalRuler.gd b/src/UI/Canvas/Rulers/VerticalRuler.gd similarity index 100% rename from src/UI/Rulers/VerticalRuler.gd rename to src/UI/Canvas/Rulers/VerticalRuler.gd diff --git a/src/UI/CanvasPreview.tscn b/src/UI/CanvasPreview.tscn deleted file mode 100644 index cc9cf7923..000000000 --- a/src/UI/CanvasPreview.tscn +++ /dev/null @@ -1,9 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[ext_resource path="res://src/UI/CanvasPreview.gd" type="Script" id=1] - -[node name="CanvasPreview" type="Node2D"] -script = ExtResource( 1 ) - -[node name="AnimationTimer" type="Timer" parent="."] -[connection signal="timeout" from="AnimationTimer" to="." method="_on_AnimationTimer_timeout"] diff --git a/src/UI/CanvasPreviewContainer.tscn b/src/UI/CanvasPreviewContainer.tscn index ebb3db1a3..9cc1d9dc3 100644 --- a/src/UI/CanvasPreviewContainer.tscn +++ b/src/UI/CanvasPreviewContainer.tscn @@ -1,9 +1,9 @@ [gd_scene load_steps=8 format=2] -[ext_resource path="res://src/UI/CanvasPreview.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/UI/Canvas/CanvasPreview.tscn" type="PackedScene" id=1] [ext_resource path="res://src/UI/TransparentChecker.tscn" type="PackedScene" id=2] [ext_resource path="res://src/UI/CanvasPreviewContainer.gd" type="Script" id=3] -[ext_resource path="res://src/CameraMovement.gd" type="Script" id=4] +[ext_resource path="res://src/UI/Canvas/CameraMovement.gd" type="Script" id=4] [ext_resource path="res://src/Shaders/TransparentChecker.shader" type="Shader" id=5] [ext_resource path="res://assets/graphics/dark_themes/timeline/play.png" type="Texture" id=7] @@ -12,6 +12,11 @@ shader = ExtResource( 5 ) shader_param/size = 10.0 shader_param/color1 = Color( 0.7, 0.7, 0.7, 1 ) shader_param/color2 = Color( 1, 1, 1, 1 ) +shader_param/offset = Vector2( 0, 0 ) +shader_param/scale = Vector2( 0, 0 ) +shader_param/rect_size = Vector2( 0, 0 ) +shader_param/follow_movement = false +shader_param/follow_scale = false [node name="CanvasPreviewContainer" type="HBoxContainer"] margin_right = 332.0 @@ -32,13 +37,27 @@ margin_top = 7.0 margin_right = 27.0 margin_bottom = 157.0 +[node name="Label" type="Label" parent="SettingsContainer/VBoxContainer"] +margin_right = 20.0 +margin_bottom = 14.0 +text = "+" +align = 1 + [node name="PreviewZoomSlider" type="VSlider" parent="SettingsContainer/VBoxContainer"] +margin_top = 18.0 margin_right = 16.0 -margin_bottom = 126.0 +margin_bottom = 108.0 mouse_default_cursor_shape = 2 size_flags_vertical = 3 step = 0.01 +[node name="Label2" type="Label" parent="SettingsContainer/VBoxContainer"] +margin_top = 112.0 +margin_right = 20.0 +margin_bottom = 126.0 +text = "-" +align = 1 + [node name="PlayButton" type="Button" parent="SettingsContainer/VBoxContainer" groups=[ "UIButtons", ]] diff --git a/src/UI/UI.tscn b/src/UI/UI.tscn index 962704c4e..78df2bc70 100644 --- a/src/UI/UI.tscn +++ b/src/UI/UI.tscn @@ -1,12 +1,12 @@ [gd_scene load_steps=23 format=2] [ext_resource path="res://src/UI/ToolButtons.gd" type="Script" id=1] -[ext_resource path="res://src/UI/CanvasPreview.tscn" type="PackedScene" id=2] +[ext_resource path="res://src/UI/Canvas/CanvasPreview.tscn" type="PackedScene" id=2] [ext_resource path="res://src/UI/Tabs.gd" type="Script" id=3] -[ext_resource path="res://src/UI/Rulers/VerticalRuler.gd" type="Script" id=4] +[ext_resource path="res://src/UI/Canvas/Rulers/VerticalRuler.gd" type="Script" id=4] [ext_resource path="res://src/UI/TransparentChecker.tscn" type="PackedScene" id=5] -[ext_resource path="res://src/UI/Rulers/HorizontalRuler.gd" type="Script" id=6] -[ext_resource path="res://src/CameraMovement.gd" type="Script" id=7] +[ext_resource path="res://src/UI/Canvas/Rulers/HorizontalRuler.gd" type="Script" id=6] +[ext_resource path="res://src/UI/Canvas/CameraMovement.gd" type="Script" id=7] [ext_resource path="res://src/SelectionRectangle.gd" type="Script" id=8] [ext_resource path="res://assets/graphics/dark_themes/tools/bucket.png" type="Texture" id=10] [ext_resource path="res://assets/graphics/dark_themes/tools/colorpicker.png" type="Texture" id=11] @@ -17,7 +17,7 @@ [ext_resource path="res://src/UI/CanvasPreviewContainer.tscn" type="PackedScene" id=16] [ext_resource path="res://src/UI/ColorAndToolOptions.tscn" type="PackedScene" id=17] [ext_resource path="res://src/UI/Timeline/AnimationTimeline.tscn" type="PackedScene" id=18] -[ext_resource path="res://src/Canvas.tscn" type="PackedScene" id=19] +[ext_resource path="res://src/UI/Canvas/Canvas.tscn" type="PackedScene" id=19] [ext_resource path="res://src/Palette/PalettePanelContainer.tscn" type="PackedScene" id=20] [ext_resource path="res://assets/graphics/dark_themes/tools/zoom.png" type="Texture" id=21] [ext_resource path="res://src/UI/ViewportContainer.gd" type="Script" id=23]