a bunch of things are now working, im not logging it all, its not worth the time
authorEduardo <[email protected]>
Tue, 25 Jun 2024 19:32:41 +0000 (21:32 +0200)
committerEduardo <[email protected]>
Tue, 25 Jun 2024 19:32:41 +0000 (21:32 +0200)
scenes/ImageModel.tscn
scenes/interface.tscn
scripts/globals.gd
scripts/image_model.gd
scripts/interface.gd
scripts/splash_screen.gd

index 53d4c90006a5dc5e3dda26fb225f33195e806556..741ab20ff046cae8cdd6a4c413e272ff608cbd1c 100644 (file)
@@ -3,14 +3,15 @@
 [ext_resource type="Script" path="res://scripts/image_model.gd" id="1_4mtp2"]
 
 [node name="ImageModel" type="Control"]
+clip_contents = true
 layout_mode = 3
-anchor_right = 1.25
-anchor_bottom = 1.0
-grow_horizontal = 2
-grow_vertical = 2
+anchors_preset = 0
+offset_right = 1000.0
+offset_bottom = 1000.0
 script = ExtResource("1_4mtp2")
 
 [node name="ColorRect" type="ColorRect" parent="."]
+visible = false
 layout_mode = 1
 anchors_preset = 15
 anchor_right = 1.0
index 90bd028d6ec93e60c66808ebe0c71d60d477fe3a..418d0bf6241ee13a328625fcbc7feb7e58f538eb 100644 (file)
@@ -3,7 +3,6 @@
 [ext_resource type="Texture2D" uid="uid://bh8r1544r4w0a" path="res://ui/button_square_depth_line.svg" id="1_4tdiw"]
 [ext_resource type="Script" path="res://scripts/interface.gd" id="1_u68dg"]
 [ext_resource type="Texture2D" uid="uid://2ksj38qp50ka" path="res://ui/icon_cross.svg" id="2_wpbrs"]
-[ext_resource type="PackedScene" uid="uid://bl5au3ffuw4pn" path="res://scenes/main_window.tscn" id="3_rbdes"]
 [ext_resource type="Texture2D" uid="uid://d2ynbocejw2m7" path="res://ui/resize_a_cross_diagonal.svg" id="3_xkt53"]
 [ext_resource type="Texture2D" uid="uid://jyvf5d266eyn" path="res://ui/arrow_n.svg" id="4_a6v15"]
 [ext_resource type="Texture2D" uid="uid://dkrtom37um7ci" path="res://ui/arrow_s.svg" id="5_ejge0"]
@@ -19,6 +18,7 @@
 [ext_resource type="Texture2D" uid="uid://b40puvvid5axi" path="res://ui/button_round_line.svg" id="10_1tmay"]
 [ext_resource type="Texture2D" uid="uid://bs230jvbr3gbm" path="res://ui/drawing_picker.svg" id="11_ct4lx"]
 [ext_resource type="Texture2D" uid="uid://dwyr2pa2kvpu6" path="res://ui/save_transparentDark32.png" id="17_e3qu3"]
+[ext_resource type="PackedScene" uid="uid://dlbvag0hb0wny" path="res://scenes/ImageModel.tscn" id="17_nc44u"]
 [ext_resource type="Texture2D" uid="uid://5qonnbx3tie8" path="res://ui/button_rectangle_depth_line.svg" id="20_dm01o"]
 [ext_resource type="Theme" uid="uid://ba300xn4cvkke" path="res://themes/grid_container_theme.tres" id="21_fqc5r"]
 [ext_resource type="Texture2D" uid="uid://tmikywrrcq54" path="res://ui/button_rectangle_line.svg" id="21_tly76"]
@@ -195,7 +195,7 @@ grow_vertical = 2
 mouse_filter = 1
 script = ExtResource("1_u68dg")
 metadata/_edit_vertical_guides_ = [592.0, 559.0, 584.0, 25.0, 575.0, 16.0, 620.0, 623.0, 633.0]
-metadata/_edit_horizontal_guides_ = [500.0, 162.0, 178.0, 230.0, 508.0]
+metadata/_edit_horizontal_guides_ = [500.0, 162.0, 178.0, 230.0, 508.0, 492.0, 24.0]
 metadata/_edit_lock_ = true
 
 [node name="DefaultCursorColorRect" type="ColorRect" parent="."]
@@ -433,14 +433,6 @@ patch_margin_right = 8
 patch_margin_bottom = 12
 metadata/_edit_lock_ = true
 
-[node name="MainWindow" parent="." instance=ExtResource("3_rbdes")]
-visible = false
-layout_mode = 1
-offset_left = 6.0
-offset_top = 15.0
-offset_right = -4.0
-offset_bottom = -4.0
-
 [node name="Buttons" type="Node" parent="."]
 
 [node name="DragableRect" type="ColorRect" parent="Buttons"]
@@ -487,6 +479,24 @@ texture_normal = ExtResource("17_e3qu3")
 ignore_texture_size = true
 stretch_mode = 5
 
+[node name="ViewportImage" type="SubViewportContainer" parent="."]
+clip_contents = true
+layout_mode = 1
+offset_left = 16.0
+offset_top = 24.0
+offset_right = 584.0
+offset_bottom = 492.0
+
+[node name="SubViewport" type="SubViewport" parent="ViewportImage"]
+disable_3d = true
+handle_input_locally = false
+gui_disable_input = true
+size = Vector2i(568, 468)
+size_2d_override = Vector2i(568, 468)
+render_target_update_mode = 4
+
+[node name="ImageModel" parent="ViewportImage/SubViewport" instance=ExtResource("17_nc44u")]
+
 [node name="Divider" type="Node" parent="."]
 
 [node name="Divider" type="TextureRect" parent="Divider"]
@@ -624,3 +634,6 @@ metadata/_tab_index = 1
 [connection signal="gui_input" from="Buttons/DragableRect" to="." method="_on_Titlebar_gui_input"]
 [connection signal="pressed" from="Buttons/CloseButton" to="." method="_on_close_button_pressed"]
 [connection signal="pressed" from="Buttons/MaximizeButton" to="." method="_on_maximize_button_pressed"]
+[connection signal="pressed" from="Buttons/ResetButton" to="." method="_on_reset_button_pressed"]
+[connection signal="pressed" from="Buttons/SaveButton" to="." method="_on_save_button_pressed"]
+[connection signal="tab_changed" from="SectionsTabContainer" to="." method="_on_sections_tab_container_tab_changed"]
index 69098ef8b7b90f6aec76565fd5c1956131401ef6..8268f3d06fc9c76fbefb3446158bd58e1f5d0e30 100644 (file)
@@ -1,6 +1,9 @@
 extends Node
 
 
+enum LAYER_MOVEMENT {MOVE_UP, MOVE_DOWN}
+enum MOVEMENT {MOVE_UP, MOVE_DOWN, MOVE_RIGHT, MOVE_LEFT}
+
 class Section:
        var name: String
        var color_placeholder: Color
@@ -61,6 +64,7 @@ func _load_texture(image_file_path: String):
        
        var new_img = Image.create(last_w - first_w, last_h - first_h, true, image.get_format())
        new_img.blit_rect(image, Rect2(first_w, first_h, last_w - first_w, last_h - first_h), Vector2i(0, 0))
+       @warning_ignore("integer_division")
        new_img.resize(100, (100 * new_img.get_height()) / new_img.get_width(), Image.INTERPOLATE_LANCZOS)
        new_img.save_png(miniature_file_path)
        
index 40ad455b5f37308739c42eb8fd571203b6e63ae8..d3e999246cdaf302017ade2c77df76bd0ba36332 100644 (file)
@@ -3,12 +3,11 @@ extends Control
 
 var section: String
 var section_z_index := 1
-var movement_multiplier := 1
 var default_position := Vector2(0, 0)
 var color_placeholder: Color
 var color_suggestions: Array[Color]
 
-@onready var main_window := $"../../.."
+@onready var interface_scene := $"../../.."
 @onready var image_model := $"."
 
 
@@ -17,14 +16,13 @@ signal colorsLoaded(placeholder: Color, colors: Array[Color])
 
 func _ready():
        get_viewport().transparent_bg = true
-       main_window.sectionChanged.connect(_on_section_changed)
-       main_window.optionPressed.connect(_on_option_pressed)
-       main_window.resetOptions.connect(_on_reset_pressed)
-       main_window.moveLayer.connect(_movement_pressed)
-       main_window.movementMultiplier.connect(_movement_multiplier)
-       main_window.colorPicked.connect(_on_color_picked)
-       main_window.moveLayerUp.connect(_on_layer_moved_up)
-       main_window.moveLayerDown.connect(_on_layer_moved_down)
+       interface_scene.move_layer.connect(_on_layer_moved)
+       interface_scene.move_drawing.connect(_movement_pressed)
+       interface_scene.asset_selected.connect(_on_option_pressed)
+       interface_scene.reset_image.connect(_on_reset_pressed)
+       interface_scene.save_image.connect(_on_save_request)
+       interface_scene.section_changed.connect(_on_section_changed)
+       #interface_scene.colorPicked.connect(_on_color_picked)
 
 
 func _on_section_changed(new_section: String):
@@ -63,7 +61,7 @@ func _on_option_pressed(file_path: String):
        texture_rect.texture = image_texture
        texture_rect.stretch_mode = TextureRect.StretchMode.STRETCH_KEEP_ASPECT
        texture_rect.ignore_texture_size = true
-       texture_rect.custom_minimum_size = Vector2(500, 500)
+       texture_rect.custom_minimum_size = Vector2(500, 480)
        
        image_model.add_child(texture_rect)
        # print(file_path)
@@ -75,17 +73,18 @@ func _on_reset_pressed():
                        child.queue_free()
 
 
-func _movement_pressed(direction: Vector2):
+func _movement_pressed(direction: Globals.MOVEMENT, multiplier: int):
        var child := image_model.get_node(section) as TextureRect
        if child != null:
-               child.position += direction * movement_multiplier
-
-
-func _movement_multiplier():
-       if movement_multiplier == 1:
-               movement_multiplier = 10
-       else:
-               movement_multiplier = 1
+               match direction:
+                       Globals.MOVEMENT.MOVE_UP:
+                               child.position += Vector2(0, 1) * multiplier
+                       Globals.MOVEMENT.MOVE_DOWN:
+                               child.position += Vector2(0, -1) * multiplier
+                       Globals.MOVEMENT.MOVE_RIGHT:
+                               child.position += Vector2(1, 0) * multiplier
+                       Globals.MOVEMENT.MOVE_LEFT:
+                               child.position += Vector2(-1, 0) * multiplier
 
 
 func load_section_z_index(section: String):
@@ -125,7 +124,7 @@ func load_default_position(section: String):
 
 func load_colors(section: String):
        # reset defaults
-       color_placeholder = Color("#000000")
+       color_placeholder = Color("#ff00ff")
        color_suggestions.clear()
        
        var config = ConfigFile.new()
@@ -163,21 +162,19 @@ func _on_color_picked(color: Color):
        texture_rect.material.set("shader_parameter/target_color", color)
 
 
-func _on_layer_moved_up():
-       on_layer_moved("UP")
-
-
-func _on_layer_moved_down():
-       on_layer_moved("DOWN")
-
-
-func on_layer_moved(direction: String):
+func _on_layer_moved(direction: Globals.LAYER_MOVEMENT):
        var child := image_model.get_node(section) as TextureRect
        if child == null:
                return
        
        match direction:
-               "UP":
+               Globals.LAYER_MOVEMENT.MOVE_UP:
                        child.z_index += 1
-               "DOWN":
+               Globals.LAYER_MOVEMENT.MOVE_DOWN:
                        child.z_index -= 1
+
+
+func _on_save_request():
+       var parent := image_model.get_parent()
+       var img = parent.get_texture().get_image()
+       img.save_png("./picrowo.png")
index f3f4874fa7459e9c77777a4cc6d809fe2360270d..c1d99817f414548999a41a121a2499e4a76eb4af 100644 (file)
@@ -1,10 +1,6 @@
 extends Control
 
 
-enum LAYER_MOVEMENT {MOVE_UP, MOVE_DOWN}
-enum MOVEMENT {MOVE_UP, MOVE_DOWN, MOVE_RIGHT, MOVE_LEFT}
-
-
 @onready var animation_players: Array[AnimationPlayer] = [
        $AnimationPlayers/AnimationPlayer1, $AnimationPlayers/AnimationPlayer2, $AnimationPlayers/AnimationPlayer3, 
        $AnimationPlayers/AnimationPlayer4, $AnimationPlayers/AnimationPlayer5, $AnimationPlayers/AnimationPlayer6, 
@@ -31,6 +27,9 @@ var colors_menu_open: bool = false
 signal move_layer(LAYER_MOVEMENT)
 signal move_drawing(MOVEMENT, multiplier: int)
 signal asset_selected(asset_path: String)
+signal section_changed(section: String)
+signal save_image
+signal reset_image
 
 
 #region build in funcs
@@ -153,28 +152,35 @@ func _on_colors_mouse_exited():
 #region buttons
 
 
+func _on_save_button_pressed():
+       save_image.emit()
+
+
+func _on_reset_button_pressed():
+       reset_image.emit()
+
 func _on_layer_up_button_pressed():
-       move_layer.emit(LAYER_MOVEMENT.MOVE_UP)
+       move_layer.emit(Globals.LAYER_MOVEMENT.MOVE_UP)
 
 
 func _on_layer_down_button_pressed():
-       move_layer.emit(LAYER_MOVEMENT.MOVE_DOWN)
+       move_layer.emit(Globals.LAYER_MOVEMENT.MOVE_DOWN)
 
 
 func _on_movement_up_button_pressed():
-       move_drawing.emit(MOVEMENT.MOVE_UP, movement_multiplier)
+       move_drawing.emit(Globals.MOVEMENT.MOVE_UP, movement_multiplier)
 
 
 func _on_movement_down_button_pressed():
-       move_drawing.emit(MOVEMENT.MOVE_DOWN, movement_multiplier)
+       move_drawing.emit(Globals.MOVEMENT.MOVE_DOWN, movement_multiplier)
 
 
 func _on_movement_left_button_pressed():
-       move_drawing.emit(MOVEMENT.MOVE_LEFT, movement_multiplier)
+       move_drawing.emit(Globals.MOVEMENT.MOVE_LEFT, movement_multiplier)
 
 
 func _on_movement_right_button_pressed():
-       move_drawing.emit(MOVEMENT.MOVE_RIGHT, movement_multiplier)
+       move_drawing.emit(Globals.MOVEMENT.MOVE_RIGHT, movement_multiplier)
 
 
 func _on_multiplier_button_pressed():
@@ -190,6 +196,10 @@ func _on_asset_selected(file_path: String):
        asset_selected.emit(file_path)
 
 
+func _on_sections_tab_container_tab_changed(tab):
+       section_changed.emit(Globals.sections[tab].name)
+
+
 #endregion
 
 #region utils
@@ -261,8 +271,19 @@ func _on_section_content(sections: Array[Globals.Section]):
                        texture_button.ignore_texture_size = true
                        texture_button.custom_minimum_size = ASSET_MIN_SIZE
                        
+                       # shader
+                       texture_button.material = ShaderMaterial.new()
+                       texture_button.material.shader = load("res://shaders/color_changer.gdshader")
+                       
+                       if section.color_placeholder != null:
+                               texture_button.material.set("shader_parameter/placeholder_color", section.color_placeholder)
+                       
+                       if not section.colors.is_empty():
+                               texture_button.material.set("shader_parameter/target_color", section.colors[0])
+                       # end shader
+                       
                        texture_button.pressed.connect(_on_asset_selected.bind(file_path))
-
+                       
                        var image = Image.load_from_file(miniature_file_path)
                        var texture = ImageTexture.create_from_image(image)
                        texture_button.texture_normal = texture
index 3bf20f09dc69d9a65dd4436736e530bddeaa3412..02d6b3b88ff3cc97557a040d07daadf471abb9e7 100644 (file)
@@ -144,5 +144,8 @@ func load_colors(section: String):
                Globals.sections[s_index].color_placeholder = color_placeholder
        
        if config.get_value("", "colors") is Array:
-               var colors = config.get_value("", "colors") as Array[Color]
+               var colors: Array[Color]
+               for color in config.get_value("", "colors") as Array[String]:
+                       colors.append(Color(color))
+               
                Globals.sections[s_index].colors.append_array(colors)