finishing color controls and other polishing touches
authorEduardo <[email protected]>
Sat, 12 Oct 2024 10:49:28 +0000 (12:49 +0200)
committerEduardo <[email protected]>
Sat, 12 Oct 2024 10:49:28 +0000 (12:49 +0200)
export_presets.cfg
project.godot
scenes/interface.tscn
scripts/globals.gd
scripts/image_model.gd
scripts/interface.gd
scripts/main_window.gd
scripts/splash_screen.gd

index 009b830b249ed82eacd58d38a70bcf9a7db043e8..c4da094bdbd7fbb6554ffee12e4508f4bbbb1d71 100644 (file)
@@ -32,15 +32,15 @@ codesign/digest_algorithm=1
 codesign/description=""
 codesign/custom_options=PackedStringArray()
 application/modify_resources=true
-application/icon=""
+application/icon="res://icon.png"
 application/console_wrapper_icon=""
 application/icon_interpolation=4
 application/file_version=""
 application/product_version=""
 application/company_name="Back Pain Games"
-application/product_name=""
+application/product_name="Picrowo"
 application/file_description=""
-application/copyright=""
+application/copyright="Back Pain Games"
 application/trademarks=""
 application/export_angle=0
 application/export_d3d12=0
index 1d8a26be160636caf470c166e6a4dd120d1ef719..f9a387fc489fcc257b811a794fd75a8ff0d6b8a8 100644 (file)
@@ -17,7 +17,7 @@ run/low_processor_mode=true
 boot_splash/bg_color=Color(1, 0.894118, 0.796078, 1)
 boot_splash/image="res://back_pain_logo.png"
 boot_splash/fullsize=false
-config/icon="res://icon.svg"
+config/icon="res://icon.png"
 
 [autoload]
 
@@ -33,6 +33,10 @@ window/energy_saving/keep_screen_on=false
 window/stretch/mode="viewport"
 window/per_pixel_transparency/allowed=true
 
+[editor_plugins]
+
+enabled=PackedStringArray("res://addons/script-ide/plugin.cfg")
+
 [physics]
 
 common/physics_ticks_per_second=10
index 418d0bf6241ee13a328625fcbc7feb7e58f538eb..9b53bc3db6c689711a783e7e9b799a87f5ef2544 100644 (file)
 [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"]
 
-[sub_resource type="LabelSettings" id="LabelSettings_o5aan"]
-line_spacing = 0.0
-font_size = 12
-
 [sub_resource type="Animation" id="Animation_315ma"]
 resource_name = "OpenLayer"
 length = 0.2
@@ -122,6 +118,10 @@ _data = {
 "openPosition": SubResource("Animation_l6o8m")
 }
 
+[sub_resource type="LabelSettings" id="LabelSettings_o5aan"]
+line_spacing = 0.0
+font_size = 12
+
 [sub_resource type="SystemFont" id="SystemFont_brntw"]
 font_names = PackedStringArray("Monospace")
 font_weight = 500
@@ -194,24 +194,15 @@ grow_horizontal = 2
 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_vertical_guides_ = [592.0, 559.0, 584.0, 25.0, 575.0, 16.0, 620.0, 623.0, 633.0, 700.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="."]
-layout_mode = 0
-offset_left = 623.0
-offset_right = 699.0
-offset_bottom = 422.0
-color = Color(1, 0, 1, 0)
+[node name="Area2D" type="Area2D" parent="."]
+monitorable = false
 
-[node name="DefaultCursorColorRect2" type="ColorRect" parent="."]
-layout_mode = 0
-offset_left = 600.0
-offset_top = 415.0
-offset_right = 700.0
-offset_bottom = 1000.0
-color = Color(1, 0, 1, 0)
+[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Area2D"]
+polygon = PackedVector2Array(700, -4, 700, 1000, 601, 1000, 601, 404, 626, 404, 624, 79, 600, 79, 600, -4)
 
 [node name="LayerControlsNinePatchRect" type="NinePatchRect" parent="."]
 self_modulate = Color(0.5815, 0.888169, 0.625567, 1)
@@ -261,6 +252,11 @@ offset_bottom = 74.0
 mouse_filter = 1
 texture_normal = ExtResource("5_ejge0")
 
+[node name="LayerControlsAnimationPlayer" type="AnimationPlayer" parent="."]
+libraries = {
+"": SubResource("AnimationLibrary_5jdm1")
+}
+
 [node name="MovementControlsNinePatch" type="NinePatchRect" parent="."]
 self_modulate = Color(0.708798, 0.676581, 0.981097, 1)
 layout_mode = 1
@@ -362,6 +358,11 @@ label_settings = SubResource("LabelSettings_o5aan")
 horizontal_alignment = 1
 vertical_alignment = 1
 
+[node name="MovementControlsAnimationPlayer" type="AnimationPlayer" parent="."]
+libraries = {
+"": SubResource("AnimationLibrary_5jdm1")
+}
+
 [node name="ColorsNinePatch" type="NinePatchRect" parent="."]
 self_modulate = Color(0.832958, 0.681458, 0.641437, 1)
 layout_mode = 1
@@ -394,13 +395,12 @@ vertical_alignment = 1
 layout_mode = 0
 offset_left = 7.0
 offset_top = 9.0
-offset_right = 85.0
+offset_right = 87.0
 offset_bottom = 99.0
 horizontal_scroll_mode = 0
 
-[node name="GridContainer" type="GridContainer" parent="ColorsNinePatch/ScrollContainer"]
+[node name="GridContainer" type="HFlowContainer" parent="ColorsNinePatch/ScrollContainer"]
 layout_mode = 2
-columns = 3
 
 [node name="ColorPickerButton" type="ColorPickerButton" parent="ColorsNinePatch/ScrollContainer/GridContainer"]
 custom_minimum_size = Vector2(70, 20)
@@ -416,6 +416,11 @@ texture = ExtResource("11_ct4lx")
 expand_mode = 1
 stretch_mode = 5
 
+[node name="ColorControlsAnimationPlayer" type="AnimationPlayer" parent="."]
+libraries = {
+"": SubResource("AnimationLibrary_5jdm1")
+}
+
 [node name="MainNinePatchRect" type="NinePatchRect" parent="."]
 self_modulate = Color(0.895691, 0.882184, 0.888758, 1)
 layout_mode = 1
@@ -438,10 +443,7 @@ metadata/_edit_lock_ = true
 [node name="DragableRect" type="ColorRect" parent="Buttons"]
 anchors_preset = 10
 anchor_right = 1.0
-offset_left = 7.0
-offset_top = 2.0
-offset_right = 7.0
-offset_bottom = 25.0
+offset_bottom = 34.0
 grow_horizontal = 2
 color = Color(1, 1, 1, 0)
 metadata/_edit_lock_ = true
@@ -530,68 +532,6 @@ rotation = 3.14135
 texture = ExtResource("8_3567f")
 metadata/_edit_lock_ = true
 
-[node name="AnimationPlayers" type="Node" parent="."]
-
-[node name="AnimationPlayer1" type="AnimationPlayer" parent="AnimationPlayers"]
-root_node = NodePath("../..")
-libraries = {
-"": SubResource("AnimationLibrary_5jdm1")
-}
-
-[node name="AnimationPlayer2" type="AnimationPlayer" parent="AnimationPlayers"]
-root_node = NodePath("../..")
-libraries = {
-"": SubResource("AnimationLibrary_5jdm1")
-}
-
-[node name="AnimationPlayer3" type="AnimationPlayer" parent="AnimationPlayers"]
-root_node = NodePath("../..")
-libraries = {
-"": SubResource("AnimationLibrary_5jdm1")
-}
-
-[node name="AnimationPlayer4" type="AnimationPlayer" parent="AnimationPlayers"]
-root_node = NodePath("../..")
-libraries = {
-"": SubResource("AnimationLibrary_5jdm1")
-}
-
-[node name="AnimationPlayer5" type="AnimationPlayer" parent="AnimationPlayers"]
-root_node = NodePath("../..")
-libraries = {
-"": SubResource("AnimationLibrary_5jdm1")
-}
-
-[node name="AnimationPlayer6" type="AnimationPlayer" parent="AnimationPlayers"]
-root_node = NodePath("../..")
-libraries = {
-"": SubResource("AnimationLibrary_5jdm1")
-}
-
-[node name="AnimationPlayer7" type="AnimationPlayer" parent="AnimationPlayers"]
-root_node = NodePath("../..")
-libraries = {
-"": SubResource("AnimationLibrary_5jdm1")
-}
-
-[node name="AnimationPlayer8" type="AnimationPlayer" parent="AnimationPlayers"]
-root_node = NodePath("../..")
-libraries = {
-"": SubResource("AnimationLibrary_5jdm1")
-}
-
-[node name="AnimationPlayer9" type="AnimationPlayer" parent="AnimationPlayers"]
-root_node = NodePath("../..")
-libraries = {
-"": SubResource("AnimationLibrary_5jdm1")
-}
-
-[node name="AnimationPlayer10" type="AnimationPlayer" parent="AnimationPlayers"]
-root_node = NodePath("../..")
-libraries = {
-"": SubResource("AnimationLibrary_5jdm1")
-}
-
 [node name="SectionsTabContainer" type="TabContainer" parent="."]
 layout_mode = 0
 offset_left = 25.0
@@ -614,10 +554,8 @@ layout_mode = 2
 theme = SubResource("Theme_xu50c")
 metadata/_tab_index = 1
 
-[connection signal="mouse_entered" from="DefaultCursorColorRect" to="." method="_on_default_cursor_rect_mouse_entered"]
-[connection signal="mouse_exited" from="DefaultCursorColorRect" to="." method="_on_default_cursor_rect_mouse_exited"]
-[connection signal="mouse_entered" from="DefaultCursorColorRect2" to="." method="_on_default_cursor_rect_mouse_entered"]
-[connection signal="mouse_exited" from="DefaultCursorColorRect2" to="." method="_on_default_cursor_rect_mouse_exited"]
+[connection signal="mouse_entered" from="Area2D" to="." method="_on_default_cursor_rect_mouse_entered"]
+[connection signal="mouse_exited" from="Area2D" to="." method="_on_default_cursor_rect_mouse_exited"]
 [connection signal="mouse_entered" from="LayerControlsNinePatchRect" to="." method="_on_layer_controls_rect_mouse_entered"]
 [connection signal="mouse_exited" from="LayerControlsNinePatchRect" to="." method="_on_layer_controls_rect_mouse_exited"]
 [connection signal="pressed" from="LayerControlsNinePatchRect/LayerUpTextureButton" to="." method="_on_layer_up_button_pressed"]
index 8268f3d06fc9c76fbefb3446158bd58e1f5d0e30..e1531f4895ad21c4a67bdb58483a28069b4e7fd8 100644 (file)
@@ -16,7 +16,7 @@ var _thread := Thread.new()
 var sections: Array[Section]
 var files_to_process: Array[String]
 
-
+@warning_ignore("unused_signal") # used as string
 signal image_loaded
 
 
@@ -65,14 +65,14 @@ 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.resize(100, (100 * new_img.get_height()) / new_img.get_width(), Image.INTERPOLATE_NEAREST)
        new_img.save_png(miniature_file_path)
        
        # remove work from queue
        files_to_process.remove_at(files_to_process.find(image_file_path))
        
        # notify
-       image_loaded.emit()
+       call_deferred("emit_signal", "image_loaded")
        var elapsed_time := Time.get_ticks_usec() - start_time
        print("Texture ready, took %d microseconds" % elapsed_time)
 
index d3e999246cdaf302017ade2c77df76bd0ba36332..e75dca766ad4a680327ee4502ef39d7afdf1d165 100644 (file)
@@ -22,7 +22,7 @@ func _ready():
        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)
+       interface_scene.colorPicked.connect(_on_color_picked)
 
 
 func _on_section_changed(new_section: String):
@@ -30,7 +30,7 @@ func _on_section_changed(new_section: String):
        load_section_z_index(new_section)
        load_default_position(new_section)
        load_colors(new_section)
-       # print_rich("[color=", color_placeholder.to_html(), "]", color_placeholder, "[/color]")
+       #print_rich("[color=", color_placeholder.to_html(), "]", color_placeholder, "[/color]")
 
 
 func _on_option_pressed(file_path: String):
@@ -63,7 +63,8 @@ func _on_option_pressed(file_path: String):
        texture_rect.ignore_texture_size = true
        texture_rect.custom_minimum_size = Vector2(500, 480)
        
-       image_model.add_child(texture_rect)
+       if (!texture_rect.get_parent()):
+               image_model.add_child(texture_rect)
        # print(file_path)
 
 
@@ -78,21 +79,21 @@ func _movement_pressed(direction: Globals.MOVEMENT, multiplier: int):
        if child != null:
                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_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):
+func load_section_z_index(for_section: String):
        # reset value
        section_z_index = 1
        
        var config = ConfigFile.new()
-       var err = config.load("./assets/" + section + "/config.txt")
+       var err = config.load("./assets/" + for_section + "/config.txt")
        
        if err != OK:
                return
@@ -108,12 +109,12 @@ func load_section_z_index(section: String):
                section_z_index = config.get_value("", "layer") as int + 1
 
 
-func load_default_position(section: String):
+func load_default_position(for_section: String):
        # reset value
        default_position = Vector2(0, 0)
        
        var config = ConfigFile.new()
-       var err = config.load("./assets/" + section + "/config.txt")
+       var err = config.load("./assets/" + for_section + "/config.txt")
        
        if err != OK:
                return
@@ -122,13 +123,13 @@ func load_default_position(section: String):
                default_position = config.get_value("", "position")
 
 
-func load_colors(section: String):
+func load_colors(for_section: String):
        # reset defaults
        color_placeholder = Color("#ff00ff")
        color_suggestions.clear()
        
        var config = ConfigFile.new()
-       var err = config.load("./assets/" + section + "/config.txt")
+       var err = config.load("./assets/" + for_section + "/config.txt")
        
        if err != OK:
                return
@@ -143,7 +144,8 @@ func load_colors(section: String):
        
        for color in config.get_value("", "colors"):
                color_suggestions.append(Color(color))
-               
+       
+       
        colorsLoaded.emit(color_placeholder, color_suggestions)
 
 
@@ -159,7 +161,8 @@ func _on_color_picked(color: Color):
                        break
                        
        # set color to shaders
-       texture_rect.material.set("shader_parameter/target_color", color)
+       if (texture_rect):
+               texture_rect.material.set("shader_parameter/target_color", color)
 
 
 func _on_layer_moved(direction: Globals.LAYER_MOVEMENT):
@@ -176,5 +179,40 @@ func _on_layer_moved(direction: Globals.LAYER_MOVEMENT):
 
 func _on_save_request():
        var parent := image_model.get_parent()
-       var img = parent.get_texture().get_image()
-       img.save_png("./picrowo.png")
+       var img: Image = parent.get_texture().get_image()
+       
+       # remove empty pixels from borders
+       var first_h := img.get_height()
+       var first_w := img.get_width()
+       var last_h  := 0
+       var last_w  := 0
+       
+       for h in img.get_height():
+               for w in img.get_width():
+                       if img.get_pixel(w, h).a != 0:
+                               if h < first_h: first_h = h
+                               if h > last_h:  last_h  = h
+                               if w < first_w: first_w = w
+                               if w > last_w:  last_w  = w
+       
+       var new_img := Image.create(last_w - first_w, last_h - first_h, true, img.get_format())
+       new_img.blit_rect(img, Rect2(first_w, first_h, last_w - first_w, last_h - first_h), Vector2i(0, 0))
+
+       
+       var fname := get_valid_name("./picrowo.png")
+       new_img.save_png(fname)
+
+
+## returns a name not used by other file
+func get_valid_name(file_name: String, iteration: int = 0) -> String:
+       var fname := file_name
+       
+       if (FileAccess.file_exists(fname)):
+               iteration += 1
+               var extension := fname.get_extension()
+               var basename := fname.get_basename()
+               basename = basename.split("_")[0]
+               fname = basename + "_" + String.num(iteration) + "." + extension
+               return get_valid_name(fname, iteration)
+       else:
+               return fname
index c1d99817f414548999a41a121a2499e4a76eb4af..0ec676997acb97d61f28236b04cf3e42cc0f8e7c 100644 (file)
@@ -1,11 +1,10 @@
 extends Control
 
 
-@onready var animation_players: Array[AnimationPlayer] = [
-       $AnimationPlayers/AnimationPlayer1, $AnimationPlayers/AnimationPlayer2, $AnimationPlayers/AnimationPlayer3, 
-       $AnimationPlayers/AnimationPlayer4, $AnimationPlayers/AnimationPlayer5, $AnimationPlayers/AnimationPlayer6, 
-       $AnimationPlayers/AnimationPlayer7, $AnimationPlayers/AnimationPlayer8, $AnimationPlayers/AnimationPlayer9, 
-       $AnimationPlayers/AnimationPlayer10]
+@onready var layer_controls_animation_player: AnimationPlayer = $LayerControlsAnimationPlayer
+@onready var movement_controls_animation_player: AnimationPlayer = $MovementControlsAnimationPlayer
+@onready var color_controls_animation_player: AnimationPlayer = $ColorControlsAnimationPlayer
+
 var finger_mouse = load("res://ui/hand_point.svg")
 
 @onready var sections_tabs := $SectionsTabContainer
@@ -14,6 +13,10 @@ var sections_columns: int = 5
 var movement_multiplier: int = 1
 @onready var movement_multiplier_label: Label = $MovementControlsNinePatch/MultiplierLabel
 
+@onready var colors_grid: HFlowContainer = $ColorsNinePatch/ScrollContainer/GridContainer
+@onready var color_picker: ColorPickerButton = $ColorsNinePatch/ScrollContainer/GridContainer/ColorPickerButton
+
+
 # move window helpers
 var _mouse_start_position: Vector2
 var _dragging: bool = false
@@ -30,6 +33,7 @@ signal asset_selected(asset_path: String)
 signal section_changed(section: String)
 signal save_image
 signal reset_image
+signal colorPicked(color: Color)
 
 
 #region build in funcs
@@ -42,7 +46,10 @@ func _init():
 func _ready():
        _on_section_list(Globals.sections)
        _on_section_content(Globals.sections)
-
+       update_colors(Globals.sections[0].name)
+       
+       section_changed.connect(update_colors.bind())
+       color_picker.color_changed.connect(_on_color_changed)
 
 #endregion
 
@@ -99,52 +106,40 @@ func _on_Titlebar_gui_input(event: InputEvent):
 func _on_layer_controls_rect_mouse_entered():
        if layer_controls_open:
                return
-               
-       var animation_player = get_animation_player()
-       if animation_player != null:
-               animation_player.play("OpenLayer")
-               layer_controls_open = true
+
+       layer_controls_animation_player.play("OpenLayer")
+       layer_controls_open = true
 
 
 func _on_layer_controls_rect_mouse_exited():
-       var animation_player = get_animation_player()
-       if animation_player != null:
-               add_timer_with_timeout(animation_player.play_backwards.bind("OpenLayer"))
-               layer_controls_open = false
+       layer_controls_animation_player.play_backwards("OpenLayer")
+       layer_controls_open = false
 
 
 func _on_movement_controls_rect_mouse_entered():
        if movement_controls_open:
                return
-       
-       var animation_player = get_animation_player()
-       if animation_player != null:
-               animation_player.play("openPosition")
-               movement_controls_open = true
+
+       movement_controls_animation_player.play("openPosition")
+       movement_controls_open = true
 
 
 func _on_movement_controls_mouse_exited():
-       var animation_player = get_animation_player()
-       if animation_player != null:
-               add_timer_with_timeout(animation_player.play_backwards.bind("openPosition"))
-               movement_controls_open = false
+       movement_controls_animation_player.play_backwards("openPosition")
+       movement_controls_open = false
 
 
 func _on_colors_mouse_entered():
        if colors_menu_open:
                return
        
-       var animation_player = get_animation_player()
-       if animation_player != null:
-               animation_player.play("openColor")
-               colors_menu_open = true
+       color_controls_animation_player.play("openColor")
+       colors_menu_open = true
 
 
 func _on_colors_mouse_exited():
-       var animation_player = get_animation_player()
-       if animation_player != null:
-               add_timer_with_timeout(animation_player.play_backwards.bind("openColor"))
-               colors_menu_open = false
+       color_controls_animation_player.play_backwards("openColor")
+       colors_menu_open = false
 
 
 #endregion
@@ -159,6 +154,7 @@ func _on_save_button_pressed():
 func _on_reset_button_pressed():
        reset_image.emit()
 
+
 func _on_layer_up_button_pressed():
        move_layer.emit(Globals.LAYER_MOVEMENT.MOVE_UP)
 
@@ -200,32 +196,8 @@ func _on_sections_tab_container_tab_changed(tab):
        section_changed.emit(Globals.sections[tab].name)
 
 
-#endregion
-
-#region utils
-
-
-func get_animation_player() -> AnimationPlayer:
-       for ap in animation_players:
-               if not ap.is_playing():
-                       return ap
-       
-       return null
-
-
-func add_timer_with_timeout(function: Callable, seconds: float = 2):
-       var timer = Timer.new()
-       timer.autostart = true
-       timer.one_shot = true
-       timer.wait_time = seconds
-       timer.timeout.connect(function)
-       timer.timeout.connect(timer.queue_free)
-       add_child(timer)
-
-
-#endregion
-
-#region signal callbacks
+func _on_color_changed(color: Color):
+       colorPicked.emit(color)
 
 
 #endregion
@@ -284,6 +256,11 @@ func _on_section_content(sections: Array[Globals.Section]):
                        
                        texture_button.pressed.connect(_on_asset_selected.bind(file_path))
                        
+                       # await for the texture to be ready
+                       while (!FileAccess.file_exists(miniature_file_path)):
+                               await get_tree().create_timer(0.25).timeout
+                       
+                       # and load the texture
                        var image = Image.load_from_file(miniature_file_path)
                        var texture = ImageTexture.create_from_image(image)
                        texture_button.texture_normal = texture
@@ -296,3 +273,44 @@ func _on_section_content(sections: Array[Globals.Section]):
 
 
 #endregion
+
+#region signals
+
+
+func update_colors(section_name: String):
+       var section := Globals.sections[Globals.get_section_index(section_name)]
+       
+       # first remove colors in the grid
+       for node in colors_grid.get_children():
+               if node == color_picker:
+                       continue
+               node.queue_free()
+
+       # set default colors as picked
+       if len(section.colors) == 0:
+               color_picker.color = Color.BLACK
+               return
+       
+       color_picker.color = section.colors[0]
+       
+       # add colors to the grid
+       for color in section.colors:
+               # create new texture button
+               var texture_rect := TextureRect.new()
+
+               texture_rect.texture = PlaceholderTexture2D.new()
+               texture_rect.material = ShaderMaterial.new()
+               texture_rect.material.shader = load("res://shaders/color_changer.gdshader")
+               texture_rect.material.set("shader_parameter/target_color", color)
+               texture_rect.custom_minimum_size = Vector2(20, 20)
+               
+               # TODO: add this to a button to setup an easy click
+               var btn := TextureButton.new()
+               btn.custom_minimum_size = Vector2(20, 20)
+               btn.mouse_filter = Control.MOUSE_FILTER_PASS
+               btn.pressed.connect(_on_color_changed.bind(color))
+               btn.add_child(texture_rect)
+       
+               colors_grid.add_child(btn)
+
+#endregion
index 660d5e2c5700810a3950798f92516cb1fa4b6236..86287eae6da8df21417d412aa2d1544f10d16d0f 100644 (file)
@@ -1,3 +1,5 @@
+## WARNING: THIS IS THE OLD CODE
+
 extends Control
 
 
@@ -135,6 +137,7 @@ func _color_picker_button_pressed():
 
 func add_suggested_colors(placeholder: Color, colors: Array[Color]):
        var colorPicker: ColorPicker = $ColorPickerNode/ColorPickerScrollContainer/CenterContainer/ColorPicker
+       print("add_suggested_colors")
 
        if not colors.is_empty():
                suggested_colors = colors
@@ -142,6 +145,7 @@ func add_suggested_colors(placeholder: Color, colors: Array[Color]):
                selected_color = colors[0]
        
        for color in colors:
+               print_rich("[color=", color.to_html(), "]", color, "[/color]")
                colorPicker.add_preset(color)
        
        # open Swatches (FIX: totally a hack)
index 02d6b3b88ff3cc97557a040d07daadf471abb9e7..f2a25c2b277e5435d33cdac7489b8d2afc353012 100644 (file)
@@ -120,7 +120,10 @@ func load_options(section: String):
                if dir.dir_exists("/.thumb"):
                        dir.make_dir("/.thumb")
                
-               var thumbs := DirAccess.get_files_at("./assets/" + section + "/.thumb")
+               var thumbs_folder := "./assets/" + section + "/.thumb"
+               var thumbs: PackedStringArray
+               if (FileAccess.file_exists(thumbs_folder)):
+                       thumbs = DirAccess.get_files_at("./assets/" + section + "/.thumb")
                if not thumbs.has(file):
                        Globals.files_to_process.append(file_path)