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
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]
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
[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
"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
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)
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
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
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)
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
[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
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
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"]
var sections: Array[Section]
var files_to_process: Array[String]
-
+@warning_ignore("unused_signal") # used as string
signal image_loaded
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)
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):
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):
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)
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
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
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
for color in config.get_value("", "colors"):
color_suggestions.append(Color(color))
-
+
+
colorsLoaded.emit(color_placeholder, color_suggestions)
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):
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
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
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
signal section_changed(section: String)
signal save_image
signal reset_image
+signal colorPicked(color: Color)
#region build in funcs
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
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
func _on_reset_button_pressed():
reset_image.emit()
+
func _on_layer_up_button_pressed():
move_layer.emit(Globals.LAYER_MOVEMENT.MOVE_UP)
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
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
#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
+## WARNING: THIS IS THE OLD CODE
+
extends Control
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
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)
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)