From bf56a9862f929da15bdbcc5b99a2154beb72ee54 Mon Sep 17 00:00:00 2001 From: BlankManifold Date: Sun, 23 Oct 2022 12:00:37 +0200 Subject: [PATCH] Impletented: size selection (still not working correctly), text editor, load text from file, text incipit selection, closing text selection, font size, background color selection, font color selection, zoom buttons, preview rect Connected: all tools with preview ui --- assets/ToolsUIBasic.tres | 7 + assets/temp.tres | 2 +- project.godot | 2 + scenes/BackgroundColorSelection.tscn | 28 ++++ scenes/ColorIcon.tscn | 24 ++++ scenes/MainControl.tscn | 18 ++- scenes/PreviewUI.tscn | 25 +++- scenes/TextEditor.tscn | 52 ++++++++ scenes/ToolsUI.tscn | 160 ++++++++++++++++++++-- scenes/ZoomButtons.tscn | 29 ++++ scripts/BackgroundColorSelection.cs | 55 ++++++++ scripts/ColorIcon.cs | 23 ++++ scripts/Globals.cs | 16 +++ scripts/MainControl.cs | 44 ++++++ scripts/PreviewUI.cs | 44 ++++++ scripts/TextEditor.cs | 37 ++++++ scripts/ToolsUI.cs | 191 +++++++++++++++++++++++++++ scripts/ZoomButtons.cs | 16 +++ 18 files changed, 752 insertions(+), 21 deletions(-) create mode 100644 assets/ToolsUIBasic.tres create mode 100644 scenes/BackgroundColorSelection.tscn create mode 100644 scenes/ColorIcon.tscn create mode 100644 scenes/TextEditor.tscn create mode 100644 scenes/ZoomButtons.tscn create mode 100644 scripts/BackgroundColorSelection.cs create mode 100644 scripts/ColorIcon.cs create mode 100644 scripts/Globals.cs create mode 100644 scripts/MainControl.cs create mode 100644 scripts/TextEditor.cs create mode 100644 scripts/ToolsUI.cs create mode 100644 scripts/ZoomButtons.cs diff --git a/assets/ToolsUIBasic.tres b/assets/ToolsUIBasic.tres new file mode 100644 index 0000000..1d9a6c9 --- /dev/null +++ b/assets/ToolsUIBasic.tres @@ -0,0 +1,7 @@ +[gd_resource type="Theme" load_steps=2 format=2] + +[ext_resource path="res://assets/temp.tres" type="DynamicFont" id=1] + +[resource] +default_font = ExtResource( 1 ) +OptionButton/fonts/font = ExtResource( 1 ) diff --git a/assets/temp.tres b/assets/temp.tres index 5f7f1e8..d9d41a8 100644 --- a/assets/temp.tres +++ b/assets/temp.tres @@ -4,5 +4,5 @@ font_path = "res://assets/Louis George Cafe Bold.ttf" [resource] -size = 50 +size = 35 font_data = SubResource( 1 ) diff --git a/project.godot b/project.godot index d4e1ba6..becd168 100644 --- a/project.godot +++ b/project.godot @@ -11,12 +11,14 @@ config_version=4 [application] config/name="ComunqueIG_Tools" +run/main_scene="res://scenes/MainControl.tscn" config/icon="res://icon.png" [display] window/size/width=1080 window/size/height=1920 +window/dpi/allow_hidpi=true window/handheld/orientation="portrait" window/stretch/mode="2d" window/stretch/aspect="expand" diff --git a/scenes/BackgroundColorSelection.tscn b/scenes/BackgroundColorSelection.tscn new file mode 100644 index 0000000..8afbc7a --- /dev/null +++ b/scenes/BackgroundColorSelection.tscn @@ -0,0 +1,28 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://scripts/BackgroundColorSelection.cs" type="Script" id=1] + +[node name="BackgroundColorSelection" type="VBoxContainer"] +anchor_left = 1.0 +anchor_right = 1.0 +margin_left = -447.0 +margin_top = 30.0 +margin_right = -54.0 +margin_bottom = 74.0 +custom_constants/separation = 5 +script = ExtResource( 1 ) + +[node name="Button" type="Button" parent="."] +margin_right = 393.0 +margin_bottom = 20.0 +text = "Background Color" + +[node name="ColorGrid" type="GridContainer" parent="."] +margin_top = 25.0 +margin_right = 393.0 +margin_bottom = 25.0 +custom_constants/vseparation = 5 +custom_constants/hseparation = 5 +columns = 5 + +[connection signal="button_down" from="Button" to="." method="_on_BackgroundColorSelection_button_down"] diff --git a/scenes/ColorIcon.tscn b/scenes/ColorIcon.tscn new file mode 100644 index 0000000..61b89c6 --- /dev/null +++ b/scenes/ColorIcon.tscn @@ -0,0 +1,24 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://scripts/ColorIcon.cs" type="Script" id=1] + +[node name="ColorIcon" type="Button"] +self_modulate = Color( 0, 0, 0, 0 ) +margin_right = 40.0 +margin_bottom = 40.0 +rect_min_size = Vector2( 80, 80 ) +toggle_mode = true +flat = true +script = ExtResource( 1 ) + +[node name="ColorRect" type="ColorRect" parent="."] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -40.0 +margin_top = -40.0 +margin_right = 40.0 +margin_bottom = 40.0 +rect_min_size = Vector2( 80, 80 ) +mouse_filter = 2 diff --git a/scenes/MainControl.tscn b/scenes/MainControl.tscn index 8b67938..d73504d 100644 --- a/scenes/MainControl.tscn +++ b/scenes/MainControl.tscn @@ -1,34 +1,38 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://scenes/ToolsUI.tscn" type="PackedScene" id=1] [ext_resource path="res://scenes/PreviewUI.tscn" type="PackedScene" id=2] [ext_resource path="res://scripts/PreviewUI.cs" type="Script" id=3] +[ext_resource path="res://scripts/MainControl.cs" type="Script" id=4] [node name="MainControl" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 +script = ExtResource( 4 ) [node name="ToolsUI" parent="." instance=ExtResource( 1 )] +unique_name_in_owner = true -[node name="CenterContainer" type="CenterContainer" parent="."] +[node name="PreviewContainer" type="CenterContainer" parent="."] anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 margin_left = -469.0 -margin_top = -585.0 +margin_top = -552.5 margin_right = 469.0 -margin_bottom = 585.0 +margin_bottom = 552.5 grow_horizontal = 2 grow_vertical = 2 size_flags_horizontal = 3 size_flags_vertical = 3 -[node name="PreviewUI" parent="CenterContainer" instance=ExtResource( 2 )] +[node name="PreviewUI" parent="PreviewContainer" instance=ExtResource( 2 )] +unique_name_in_owner = true anchor_right = 0.0 anchor_bottom = 0.0 margin_left = 469.0 -margin_top = 585.0 +margin_top = 552.0 margin_right = 469.0 -margin_bottom = 585.0 +margin_bottom = 552.0 script = ExtResource( 3 ) diff --git a/scenes/PreviewUI.tscn b/scenes/PreviewUI.tscn index 5387a69..ff4ef48 100644 --- a/scenes/PreviewUI.tscn +++ b/scenes/PreviewUI.tscn @@ -1,4 +1,14 @@ -[gd_scene format=2] +[gd_scene load_steps=3 format=2] + +[sub_resource type="DynamicFontData" id=1] +font_path = "res://assets/Louis George Cafe Bold.ttf" + +[sub_resource type="DynamicFont" id=2] +resource_name = "TextFont" +size = 30 +use_mipmaps = true +use_filter = true +font_data = SubResource( 1 ) [node name="PreviewUI" type="Control"] anchor_right = 1.0 @@ -15,3 +25,16 @@ margin_left = -200.0 margin_top = -200.0 margin_right = 200.0 margin_bottom = 200.0 +rect_pivot_offset = Vector2( 200, 200 ) + +[node name="Text" type="Label" parent="BackgroundRect"] +unique_name_in_owner = true +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 5.0 +margin_top = 5.0 +margin_right = -5.0 +margin_bottom = -5.0 +custom_colors/font_color = Color( 0, 0, 0, 1 ) +custom_fonts/font = SubResource( 2 ) +autowrap = true diff --git a/scenes/TextEditor.tscn b/scenes/TextEditor.tscn new file mode 100644 index 0000000..cb2a62f --- /dev/null +++ b/scenes/TextEditor.tscn @@ -0,0 +1,52 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://scripts/TextEditor.cs" type="Script" id=1] + +[sub_resource type="DynamicFontData" id=1] +font_path = "res://assets/Louis George Cafe Bold.ttf" + +[sub_resource type="DynamicFont" id=2] +size = 30 +font_data = SubResource( 1 ) + +[node name="TextEditor" type="VBoxContainer"] +margin_top = 98.0 +margin_right = 391.0 +margin_bottom = 322.0 +rect_min_size = Vector2( 450, 0 ) +custom_constants/separation = 10 +script = ExtResource( 1 ) + +[node name="TextEdit" type="TextEdit" parent="."] +margin_right = 450.0 +margin_bottom = 200.0 +rect_min_size = Vector2( 100, 200 ) +custom_fonts/font = SubResource( 2 ) +text = " +" +draw_tabs = true +draw_spaces = true +wrap_enabled = true + +[node name="Buttons" type="HBoxContainer" parent="."] +margin_top = 210.0 +margin_right = 450.0 +margin_bottom = 230.0 +custom_constants/separation = 20 + +[node name="LoadFile" type="Button" parent="Buttons"] +margin_right = 230.0 +margin_bottom = 20.0 +size_flags_horizontal = 3 +text = "Load" + +[node name="Update" type="Button" parent="Buttons"] +margin_left = 250.0 +margin_right = 450.0 +margin_bottom = 20.0 +rect_min_size = Vector2( 200, 0 ) +size_flags_vertical = 3 +text = "Update Text" + +[connection signal="button_down" from="Buttons/LoadFile" to="." method="_on_LoadFile_button_down"] +[connection signal="button_down" from="Buttons/Update" to="." method="_on_Update_button_down"] diff --git a/scenes/ToolsUI.tscn b/scenes/ToolsUI.tscn index fdf852e..cf82f2b 100644 --- a/scenes/ToolsUI.tscn +++ b/scenes/ToolsUI.tscn @@ -1,23 +1,159 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=9 format=2] -[ext_resource path="res://assets/temp.tres" type="DynamicFont" id=1] +[ext_resource path="res://scenes/BackgroundColorSelection.tscn" type="PackedScene" id=1] +[ext_resource path="res://scripts/ToolsUI.cs" type="Script" id=2] +[ext_resource path="res://assets/ToolsUIBasic.tres" type="Theme" id=3] +[ext_resource path="res://scenes/TextEditor.tscn" type="PackedScene" id=4] +[ext_resource path="res://scenes/ZoomButtons.tscn" type="PackedScene" id=5] -[sub_resource type="Theme" id=1] -default_font = ExtResource( 1 ) -OptionButton/fonts/font = ExtResource( 1 ) +[sub_resource type="DynamicFontData" id=1] +font_path = "res://assets/Louis George Cafe Bold.ttf" + +[sub_resource type="DynamicFont" id=2] +size = 35 +font_data = SubResource( 1 ) + +[sub_resource type="Theme" id=3] +default_font = SubResource( 2 ) +/fonts/font = SubResource( 2 ) [node name="ToolsUI" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 mouse_filter = 1 +theme = ExtResource( 3 ) +script = ExtResource( 2 ) + +[node name="ToolContainer" type="HBoxContainer" parent="."] +anchor_left = 0.5 +anchor_right = 0.5 +margin_left = -518.0 +margin_top = 48.0 +margin_right = 518.0 +margin_bottom = 402.0 +custom_constants/separation = 15 -[node name="FrameSizeSelection" type="OptionButton" parent="."] -margin_left = 32.0 -margin_top = 24.0 -margin_right = 534.0 -margin_bottom = 96.0 -theme = SubResource( 1 ) -custom_fonts/font = ExtResource( 1 ) +[node name="VBoxContainer" type="VBoxContainer" parent="ToolContainer"] +margin_right = 450.0 +margin_bottom = 354.0 +custom_constants/separation = 30 + +[node name="FrameSizeSelection" type="OptionButton" parent="ToolContainer/VBoxContainer" groups=["framesize"]] +unique_name_in_owner = true +margin_right = 450.0 +margin_bottom = 46.0 +rect_min_size = Vector2( 450, 0 ) text = "1:1 (1080x1080)" items = [ "1:1 (1080x1080)", null, false, 0, null, "9:16 (1080x1920)", null, false, 1, null ] selected = 0 + +[node name="TextEditor" parent="ToolContainer/VBoxContainer" instance=ExtResource( 4 )] +unique_name_in_owner = true +margin_top = 76.0 +margin_right = 450.0 +margin_bottom = 332.0 + +[node name="VBoxContainer2" type="VBoxContainer" parent="ToolContainer"] +margin_left = 465.0 +margin_right = 715.0 +margin_bottom = 354.0 +custom_constants/separation = 30 + +[node name="IncipitSelection" type="OptionButton" parent="ToolContainer/VBoxContainer2"] +unique_name_in_owner = true +margin_right = 250.0 +margin_bottom = 46.0 +rect_min_size = Vector2( 250, 0 ) +align = 1 +icon_align = 1 +items = [ "", null, false, 0, null, "comunque...", null, false, 1, null, "e comunque...", null, false, 2, null, "o comunque...", null, false, 3, null ] +selected = 0 + +[node name="ClosingSelection" type="OptionButton" parent="ToolContainer/VBoxContainer2"] +unique_name_in_owner = true +margin_top = 76.0 +margin_right = 250.0 +margin_bottom = 122.0 +rect_min_size = Vector2( 250, 0 ) +align = 1 +icon_align = 1 +items = [ "", null, false, 0, null, "-- INSERT --", null, false, 1, null, ":wq", null, false, 2, null ] +selected = 0 + +[node name="FontSelection" type="OptionButton" parent="ToolContainer/VBoxContainer2"] +unique_name_in_owner = true +margin_top = 152.0 +margin_right = 250.0 +margin_bottom = 198.0 +rect_min_size = Vector2( 250, 0 ) +align = 1 +icon_align = 1 +items = [ "", null, false, 0, null, "-- INSERT --", null, false, 1, null, ":wq", null, false, 2, null ] +selected = 0 + +[node name="FontSizeSpinBox" type="SpinBox" parent="ToolContainer/VBoxContainer2"] +unique_name_in_owner = true +margin_top = 228.0 +margin_right = 250.0 +margin_bottom = 278.0 +min_value = 18.0 +max_value = 50.0 +value = 18.0 +rounded = true +align = 1 + +[node name="VBoxContainer3" type="VBoxContainer" parent="ToolContainer"] +margin_left = 730.0 +margin_right = 1036.0 +margin_bottom = 354.0 +custom_constants/separation = 25 + +[node name="BackgroundColorSelection" parent="ToolContainer/VBoxContainer3" instance=ExtResource( 1 )] +anchor_left = 0.0 +anchor_right = 0.0 +margin_left = 0.0 +margin_top = 0.0 +margin_right = 306.0 +margin_bottom = 51.0 +_title = "Background Color" + +[node name="FontColorSelection" parent="ToolContainer/VBoxContainer3" instance=ExtResource( 1 )] +anchor_left = 0.0 +anchor_right = 0.0 +margin_left = 0.0 +margin_top = 76.0 +margin_right = 306.0 +margin_bottom = 127.0 +_title = "Font Color" + +[node name="ZoomButtons" parent="ToolContainer/VBoxContainer3" instance=ExtResource( 5 )] + +[node name="FileDialog" type="FileDialog" parent="."] +unique_name_in_owner = true +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -467.0 +margin_top = -460.0 +margin_right = 467.0 +margin_bottom = 460.0 +rect_min_size = Vector2( 400, 140 ) +theme = SubResource( 3 ) +window_title = "Open a File" +mode = 0 +access = 2 +filters = PoolStringArray( "*.cmqtxt" ) +show_hidden_files = true + +[connection signal="item_selected" from="ToolContainer/VBoxContainer/FrameSizeSelection" to="." method="_on_FrameSizeSelection_item_selected"] +[connection signal="LoadPressed" from="ToolContainer/VBoxContainer/TextEditor" to="." method="_on_TextEditor_LoadPressed"] +[connection signal="UpdateText" from="ToolContainer/VBoxContainer/TextEditor" to="." method="_on_TextEditor_UpdateText"] +[connection signal="item_selected" from="ToolContainer/VBoxContainer2/IncipitSelection" to="." method="_on_IncipitSelection_item_selected"] +[connection signal="item_selected" from="ToolContainer/VBoxContainer2/ClosingSelection" to="." method="_on_ClosingSelection_item_selected"] +[connection signal="item_selected" from="ToolContainer/VBoxContainer2/FontSelection" to="." method="_on_ClosingSelection_item_selected"] +[connection signal="value_changed" from="ToolContainer/VBoxContainer2/FontSizeSpinBox" to="." method="_on_FontSize_value_changed"] +[connection signal="Selected" from="ToolContainer/VBoxContainer3/BackgroundColorSelection" to="." method="_on_BackgroundColorSelection_Selected"] +[connection signal="Selected" from="ToolContainer/VBoxContainer3/FontColorSelection" to="." method="_on_FontColorSelection_Selected"] +[connection signal="Changed" from="ToolContainer/VBoxContainer3/ZoomButtons" to="." method="_on_ZoomButtons_Changed"] +[connection signal="file_selected" from="FileDialog" to="." method="_on_FileDialog_file_selected"] diff --git a/scenes/ZoomButtons.tscn b/scenes/ZoomButtons.tscn new file mode 100644 index 0000000..dcab5c3 --- /dev/null +++ b/scenes/ZoomButtons.tscn @@ -0,0 +1,29 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://scripts/ZoomButtons.cs" type="Script" id=1] + +[node name="ZoomContainer" type="HBoxContainer"] +margin_top = 152.0 +margin_right = 306.0 +margin_bottom = 198.0 +rect_min_size = Vector2( 200, 0 ) +custom_constants/separation = 20 +alignment = 1 +script = ExtResource( 1 ) + +[node name="PlusButton" type="Button" parent="."] +margin_left = 68.0 +margin_right = 143.0 +margin_bottom = 46.0 +rect_min_size = Vector2( 75, 0 ) +text = "+" + +[node name="MinusButton" type="Button" parent="."] +margin_left = 163.0 +margin_right = 238.0 +margin_bottom = 46.0 +rect_min_size = Vector2( 75, 0 ) +text = "-" + +[connection signal="button_down" from="PlusButton" to="." method="_on_PlusButton_button_down"] +[connection signal="button_down" from="MinusButton" to="." method="_on_MinusButton_button_down"] diff --git a/scripts/BackgroundColorSelection.cs b/scripts/BackgroundColorSelection.cs new file mode 100644 index 0000000..37ae009 --- /dev/null +++ b/scripts/BackgroundColorSelection.cs @@ -0,0 +1,55 @@ +using Godot; +using System; + +public class BackgroundColorSelection : VBoxContainer +{ + [Export] + private string _title; + + private GridContainer _grid; + private Button _button; + private PackedScene _colorIconScene; + private Godot.Collections.Array _colors = new Godot.Collections.Array() + { + "3e4084ff", + "882b5aff", + "7c9052ff", + "000000" + }; + + + [Signal] + delegate void Selected(Color color); + public override void _Ready() + { + + _colorIconScene = ResourceLoader.Load(Globals.PATHS.COLORICON); + + _button = GetNode