From 245e09f0cf8d40f1cb828ff060791063ed8fbb7c Mon Sep 17 00:00:00 2001 From: db0 Date: Sat, 25 May 2024 12:02:25 +0200 Subject: [PATCH 1/6] feat: added popup info for each control button --- LucidCreations.tscn | 65 ++++++++++++++++++++++++-------------------- Panel.gd | 2 ++ PopupInfoPanel.gd | 8 ++++++ StableHordeClient.gd | 5 ++-- 4 files changed, 49 insertions(+), 31 deletions(-) diff --git a/LucidCreations.tscn b/LucidCreations.tscn index a79d71c..485bd35 100644 --- a/LucidCreations.tscn +++ b/LucidCreations.tscn @@ -1110,8 +1110,10 @@ script = ExtResource( 25 ) [node name="Advanced" type="VBoxContainer" parent="Margin/Panel/Display/Panels/Controls"] unique_name_in_owner = true visible = false -margin_right = 300.0 -margin_bottom = 346.0 +margin_left = 10.0 +margin_top = 10.0 +margin_right = 330.0 +margin_bottom = 386.0 rect_min_size = Vector2( 320, 0 ) size_flags_horizontal = 3 size_flags_vertical = 3 @@ -1119,74 +1121,79 @@ custom_constants/separation = 8 [node name="Width" parent="Margin/Panel/Display/Panels/Controls/Advanced" instance=ExtResource( 5 )] unique_name_in_owner = true -margin_bottom = 30.0 +margin_right = 320.0 +margin_bottom = 36.0 config_setting = "width" [node name="Height" parent="Margin/Panel/Display/Panels/Controls/Advanced" instance=ExtResource( 5 )] unique_name_in_owner = true -margin_top = 38.0 -margin_bottom = 68.0 +margin_top = 44.0 +margin_right = 320.0 +margin_bottom = 80.0 config_setting = "height" [node name="StepsSlider" parent="Margin/Panel/Display/Panels/Controls/Advanced" instance=ExtResource( 5 )] unique_name_in_owner = true -margin_top = 76.0 -margin_bottom = 106.0 +margin_top = 88.0 +margin_right = 320.0 +margin_bottom = 124.0 config_setting = "steps" [node name="ConfigSlider" parent="Margin/Panel/Display/Panels/Controls/Advanced" instance=ExtResource( 5 )] unique_name_in_owner = true -margin_top = 114.0 -margin_bottom = 144.0 +margin_top = 132.0 +margin_right = 320.0 +margin_bottom = 168.0 config_setting = "cfg_scale" [node name="ClipSkipSlider" parent="Margin/Panel/Display/Panels/Controls/Advanced" instance=ExtResource( 5 )] unique_name_in_owner = true -margin_top = 152.0 -margin_bottom = 182.0 +margin_top = 176.0 +margin_right = 320.0 +margin_bottom = 212.0 config_setting = "clip_skip" [node name="SamplerMethodLabel" type="Label" parent="Margin/Panel/Display/Panels/Controls/Advanced"] -margin_top = 190.0 -margin_right = 300.0 -margin_bottom = 210.0 +margin_top = 220.0 +margin_right = 320.0 +margin_bottom = 240.0 custom_fonts/font = ExtResource( 40 ) text = "Sampling method" autowrap = true [node name="SamplerMethod" type="OptionButton" parent="Margin/Panel/Display/Panels/Controls/Advanced"] unique_name_in_owner = true -margin_top = 218.0 -margin_right = 300.0 -margin_bottom = 246.0 +margin_top = 248.0 +margin_right = 320.0 +margin_bottom = 276.0 text = "k_lms" items = [ "k_lms", null, false, 0, null, "k_heun", null, false, 1, null, "k_euler", null, false, 2, null, "k_euler_a", null, false, 3, null, "k_dpm_2", null, false, 4, null, "k_dpm_2_a", null, false, 5, null, "k_dpm_fast", null, false, 6, null, "k_dpm_adaptive", null, false, 7, null, "k_dpmpp_2s_a", null, false, 8, null, "k_dpmpp_2m", null, false, 9, null, "k_dpmpp_sde", null, false, 10, null, "dpmsolver", null, false, 11, null, "lcm", null, false, 12, null ] selected = 0 [node name="SeedLabel" type="Label" parent="Margin/Panel/Display/Panels/Controls/Advanced"] -margin_top = 254.0 -margin_right = 300.0 -margin_bottom = 274.0 +margin_top = 284.0 +margin_right = 320.0 +margin_bottom = 304.0 custom_fonts/font = ExtResource( 40 ) text = "Seed (blank to randomize)" autowrap = true [node name="Seed" type="LineEdit" parent="Margin/Panel/Display/Panels/Controls/Advanced"] unique_name_in_owner = true -margin_top = 282.0 -margin_right = 300.0 -margin_bottom = 310.0 +margin_top = 312.0 +margin_right = 320.0 +margin_bottom = 340.0 caret_blink = true caret_blink_speed = 0.5 [node name="HBC" type="HBoxContainer" parent="Margin/Panel/Display/Panels/Controls/Advanced"] -margin_top = 318.0 -margin_right = 300.0 -margin_bottom = 346.0 +margin_top = 348.0 +margin_right = 320.0 +margin_bottom = 376.0 [node name="Karras" type="CheckButton" parent="Margin/Panel/Display/Panels/Controls/Advanced/HBC"] unique_name_in_owner = true -margin_right = 148.0 +margin_right = 158.0 margin_bottom = 28.0 size_flags_horizontal = 3 pressed = true @@ -1194,8 +1201,8 @@ text = "Karras" [node name="HiResFix" type="CheckButton" parent="Margin/Panel/Display/Panels/Controls/Advanced/HBC"] unique_name_in_owner = true -margin_left = 152.0 -margin_right = 300.0 +margin_left = 162.0 +margin_right = 320.0 margin_bottom = 28.0 size_flags_horizontal = 3 pressed = true diff --git a/Panel.gd b/Panel.gd index 7df479e..b8d05f7 100644 --- a/Panel.gd +++ b/Panel.gd @@ -43,6 +43,8 @@ func _ready() -> void: # we pass the button name to get panel name :D for button in button_panels.group.get_buttons(): button.connect("toggled", self, "_show_panel", [button.name]) + button.connect("mouse_entered", EventBus, "_on_node_hovered", [button]) + button.connect("mouse_exited", EventBus, "_on_node_unhovered", [button]) if button.pressed: _show_panel(true, button.name) diff --git a/PopupInfoPanel.gd b/PopupInfoPanel.gd index 69038c9..481e64d 100644 --- a/PopupInfoPanel.gd +++ b/PopupInfoPanel.gd @@ -41,6 +41,14 @@ const DESCRIPTIONS = { "WorkerAutoComplete": "Specify workers to use for this generation. Use the toggle below to specify using them as an allowlist or a blocklist. When models are selected, only workers which can generate any of those models will be shown.", "ShowAllWorkers": "Press this button to display and select available workers for your selected model.", "AllowDowngrade": "When enabled and your account doesn't have enough kudos to generate the image, it will be downgraded in resolution and steps, so that it does not need upfront kudos, instead of failing.", + # Control Buttons + "Prompt": "Prompt: This tab allows you to specify the prompt which will generate the image", + "img2img": "Img2Img: This tab allows you to specify image-to-image functionality, such as the source image or controlnets.", + "Basic": "Basic: Controls for image generation.", + "Workers": "Workers: Allows you to control which workers will serve this request.", + "Advanced": "Advanced: Extra controls for image generation.", + "Options": "Options: Customize the Lucid Creations application.", + "Information": "Information: Learn about the Lucid Creations application.", } const META_DESCRIPTIONS = { diff --git a/StableHordeClient.gd b/StableHordeClient.gd index 305a966..ae03391 100644 --- a/StableHordeClient.gd +++ b/StableHordeClient.gd @@ -48,11 +48,12 @@ onready var save_all = $"%SaveAll" onready var load_from_disk = $"%LoadFromDisk" onready var status_text = $"%StatusText" onready var kudos_text = $"%KudosText" -onready var controls_basic := $"%Basic" -onready var control_advanced := $"%Advanced" onready var generations_processing = $"%GenerationsProcessing" onready var generations_done = $"%GenerationsDone" onready var cancel_button = $"%CancelButton" +# Tab Buttons +onready var controls_basic := $"%Basic" +onready var control_advanced := $"%Advanced" # Prompts onready var _tween = $"%Tween" onready var prompt_cc = $"%PromptCC" From 36297f5095bfaa391715391459ff3022a58e4c7e Mon Sep 17 00:00:00 2001 From: db0 Date: Sat, 25 May 2024 12:09:39 +0200 Subject: [PATCH 2/6] feat: allow to expand the prompt again: --- LucidCreations.tscn | 7 ++++--- src/PromptLine.gd | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/LucidCreations.tscn b/LucidCreations.tscn index 485bd35..d4fac48 100644 --- a/LucidCreations.tscn +++ b/LucidCreations.tscn @@ -392,14 +392,14 @@ size_flags_vertical = 3 script = ExtResource( 32 ) [node name="HSeparator" type="HSeparator" parent="Margin/Panel/Display/Panels/Controls/Prompt/NegPromptHBC"] -margin_top = 125.0 margin_right = 320.0 -margin_bottom = 129.0 +margin_bottom = 4.0 [node name="NegativePromptLine" type="TextEdit" parent="Margin/Panel/Display/Panels/Controls/Prompt/NegPromptHBC"] unique_name_in_owner = true +margin_top = 8.0 margin_right = 320.0 -margin_bottom = 121.0 +margin_bottom = 129.0 rect_min_size = Vector2( 0, 41 ) size_flags_horizontal = 3 size_flags_vertical = 3 @@ -1471,6 +1471,7 @@ margin_right = 300.0 margin_bottom = 350.0 [node name="Workers" type="MarginContainer" parent="Margin/Panel/Display/Panels/Controls"] +visible = false margin_left = 10.0 margin_top = 10.0 margin_right = 330.0 diff --git a/src/PromptLine.gd b/src/PromptLine.gd index bde811c..3027eb9 100644 --- a/src/PromptLine.gd +++ b/src/PromptLine.gd @@ -26,10 +26,10 @@ func toggle_expand_collapse() -> void: func expand() -> void: prompt_context_menu.set_item_text(expand_idx, "Collapse") #prompt_line.wrap_enabled = true - rect_min_size.y = 300 + rect_min_size.x = 1024 func collapse() -> void: prompt_context_menu.set_item_text(expand_idx, "Expand") #prompt_line.wrap_enabled = false - rect_min_size.y = 0 + rect_min_size.x = 0 From 333122df671359b7e433f8d423e590a33428bc4f Mon Sep 17 00:00:00 2001 From: db0 Date: Sat, 25 May 2024 12:38:06 +0200 Subject: [PATCH 3/6] feat: Added buttons to generate/cancel on footer --- LucidCreations.tscn | 40 ++++++++++++++++++++++++++------ Panel.gd | 4 +--- PopupInfoPanel.gd | 8 +++++++ StableHordeClient.gd | 17 +++++++++++--- bus.gd | 2 ++ theme/assets/iconpark/play.svg | 1 + theme/assets/iconpark/toxins.svg | 1 + 7 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 theme/assets/iconpark/play.svg create mode 100644 theme/assets/iconpark/toxins.svg diff --git a/LucidCreations.tscn b/LucidCreations.tscn index d4fac48..d15a36f 100644 --- a/LucidCreations.tscn +++ b/LucidCreations.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=59 format=2] +[gd_scene load_steps=61 format=2] [ext_resource path="res://StableHordeClient.gd" type="Script" id=1] [ext_resource path="res://addons/stable_horde_client/stable_horde_client.gd" type="Script" id=2] @@ -47,6 +47,8 @@ [ext_resource path="res://addons/stable_horde_client/stable_horde_workers.gd" type="Script" id=45] [ext_resource path="res://Workers.gd" type="Script" id=46] [ext_resource path="res://theme/assets/iconpark/worker.svg" type="Texture" id=47] +[ext_resource path="res://theme/assets/iconpark/play.svg" type="Texture" id=48] +[ext_resource path="res://theme/assets/iconpark/toxins.svg" type="Texture" id=49] [sub_resource type="StreamTexture" id=9] flags = 4 @@ -366,6 +368,7 @@ unique_name_in_owner = true margin_right = 320.0 margin_bottom = 262.0 size_flags_horizontal = 3 +highlight_all_occurrences = true smooth_scrolling = true wrap_enabled = true caret_blink = true @@ -427,17 +430,19 @@ margin_right = 320.0 margin_bottom = 64.0 rect_min_size = Vector2( 120, 32 ) text = "Generate" +icon = ExtResource( 48 ) [node name="CancelButton" type="Button" parent="Margin/Panel/Display/Panels/Controls/Prompt/Buttons"] unique_name_in_owner = true visible = false -margin_left = 8.0 -margin_right = 128.0 -margin_bottom = 41.251 +margin_top = 68.0 +margin_right = 320.0 +margin_bottom = 100.0 rect_min_size = Vector2( 120, 32 ) custom_colors/font_color_disabled = Color( 1, 1, 1, 1 ) custom_styles/disabled = SubResource( 2 ) text = "Cancel" +icon = ExtResource( 49 ) [node name="img2img" type="VBoxContainer" parent="Margin/Panel/Display/Panels/Controls"] unique_name_in_owner = true @@ -1769,10 +1774,31 @@ margin_bottom = 40.0 size_flags_horizontal = 3 size_flags_vertical = 3 +[node name="GenerateFooterButton" type="Button" parent="Margin/Panel/Footer/Progress/Margin/Labels"] +unique_name_in_owner = true +margin_right = 30.0 +margin_bottom = 38.0 +rect_min_size = Vector2( 30, 30 ) +icon = ExtResource( 48 ) +icon_align = 1 +expand_icon = true + +[node name="CancelFooterButton" type="Button" parent="Margin/Panel/Footer/Progress/Margin/Labels"] +unique_name_in_owner = true +visible = false +margin_left = 34.0 +margin_right = 64.0 +margin_bottom = 38.0 +rect_min_size = Vector2( 30, 30 ) +icon = ExtResource( 49 ) +icon_align = 1 +expand_icon = true + [node name="KudosText" type="RichTextLabel" parent="Margin/Panel/Footer/Progress/Margin/Labels"] unique_name_in_owner = true +margin_left = 34.0 margin_top = 8.0 -margin_right = 96.0 +margin_right = 130.0 margin_bottom = 29.0 rect_min_size = Vector2( 96, 18 ) size_flags_horizontal = 0 @@ -1784,7 +1810,7 @@ fit_content_height = true scroll_active = false [node name="VBC" type="VBoxContainer" parent="Margin/Panel/Footer/Progress/Margin/Labels"] -margin_left = 100.0 +margin_left = 134.0 margin_top = 8.0 margin_right = 1290.0 margin_bottom = 29.0 @@ -1794,7 +1820,7 @@ custom_constants/separation = 0 [node name="StatusText" type="RichTextLabel" parent="Margin/Panel/Footer/Progress/Margin/Labels/VBC"] unique_name_in_owner = true -margin_right = 1190.0 +margin_right = 1156.0 margin_bottom = 21.0 rect_min_size = Vector2( 0, 18 ) size_flags_horizontal = 3 diff --git a/Panel.gd b/Panel.gd index b8d05f7..718bb16 100644 --- a/Panel.gd +++ b/Panel.gd @@ -12,7 +12,6 @@ const ANIM_ANCHOR := ["anchor_left", "anchor_right"] var thread: Thread onready var tween := Tween.new() - # the `panel` container we will control onready var controls: Control = $"%Controls" @@ -24,7 +23,6 @@ onready var button_panels: Button = $Display/Panels # cycle background every generation onready var background: TextureRect = $"../.." -onready var generate_button: Button = $"%GenerateButton" # auto adjustment for the text onready var text_edit_list := [ @@ -49,7 +47,7 @@ func _ready() -> void: _show_panel(true, button.name) # to change background and hide panels - generate_button.connect("button_up", self, "_generating") + EventBus.connect("generation_started", self, "_generating") # adjust text edit height for node in text_edit_list: diff --git a/PopupInfoPanel.gd b/PopupInfoPanel.gd index 481e64d..7aefc19 100644 --- a/PopupInfoPanel.gd +++ b/PopupInfoPanel.gd @@ -1,5 +1,7 @@ extends PopupPanel +const GENERATE_BUTTON_TEXT = "Requests the image generation from the AI Horde servers." +const CANCEL_BUTTON_TEXT = "Cancel the ongoing generation from the AI Horde servers and retrieves all images already generated." const DESCRIPTIONS = { "NegativePrompt": "When enabled, will display the negative prompt line you can edit", "Amount": "The amount of images to generate with this prompt", @@ -49,6 +51,12 @@ const DESCRIPTIONS = { "Advanced": "Advanced: Extra controls for image generation.", "Options": "Options: Customize the Lucid Creations application.", "Information": "Information: Learn about the Lucid Creations application.", + # Generate/Cancel + "GenerateButton": GENERATE_BUTTON_TEXT, + "GenerateFooterButton": GENERATE_BUTTON_TEXT, + "CancelButton": CANCEL_BUTTON_TEXT, + "CancelFooterButton": CANCEL_BUTTON_TEXT, + } const META_DESCRIPTIONS = { diff --git a/StableHordeClient.gd b/StableHordeClient.gd index ae03391..0908783 100644 --- a/StableHordeClient.gd +++ b/StableHordeClient.gd @@ -28,6 +28,7 @@ onready var config_slider := $"%ConfigSlider" onready var clip_skip_slider := $"%ClipSkipSlider" onready var steps_slider := $"%StepsSlider" onready var generate_button := $"%GenerateButton" +onready var generate_footer_button = $"%GenerateFooterButton" onready var sampler_method : OptionButton = $"%SamplerMethod" onready var karras := $"%Karras" onready var hires_fix = $"%HiResFix" @@ -51,9 +52,7 @@ onready var kudos_text = $"%KudosText" onready var generations_processing = $"%GenerationsProcessing" onready var generations_done = $"%GenerationsDone" onready var cancel_button = $"%CancelButton" -# Tab Buttons -onready var controls_basic := $"%Basic" -onready var control_advanced := $"%Advanced" +onready var cancel_footer_button = $"%CancelFooterButton" # Prompts onready var _tween = $"%Tween" onready var prompt_cc = $"%PromptCC" @@ -117,8 +116,10 @@ func _ready(): load_from_disk.connect("gensettings_loaded", self, "_on_load_from_disk_gensettings_loaded") # warning-ignore:return_value_discarded generate_button.connect("pressed",self,"_on_GenerateButton_pressed") + generate_footer_button.connect("pressed",self,"_on_GenerateButton_pressed") # warning-ignore:return_value_discarded cancel_button.connect("pressed",self,"_on_CancelButton_pressed") + cancel_footer_button.connect("pressed",self,"_on_CancelButton_pressed") # warning-ignore:return_value_discarded model.connect("prompt_inject_requested",self,"_on_prompt_inject") # warning-ignore:return_value_discarded @@ -229,7 +230,9 @@ func _on_GenerateButton_pressed(): # return ## END DEBUG generate_button.visible = false + generate_footer_button.visible = false cancel_button.visible = true + cancel_footer_button.visible = true prompt_cover.visible = true progress_text.visible = true prompt_cc.collapse() @@ -237,11 +240,13 @@ func _on_GenerateButton_pressed(): stable_horde_client.generate() globals.set_setting("saved_prompt", prompt_line_edit.text, "Options") globals.set_setting("saved_negative_prompt", negative_prompt_line_edit.text, "Options") + EventBus.emit_signal("generation_started") func _on_CancelButton_pressed(): progress_text.text = "Cancelling request..." stable_horde_client.cancel_request() + EventBus.emit_signal("generation_cancelled") func _on_images_generated(completed_payload: Dictionary): _reset_input() @@ -459,7 +464,9 @@ func _reset_input() -> void: # generations_processing.value = 0 # generations_done.value = 0 generate_button.visible = true + generate_footer_button.visible = true cancel_button.visible = false + cancel_footer_button.visible = false progress_text.visible = false prompt_cover.visible = false progress_text.text = "Request initiating..." @@ -538,6 +545,10 @@ func _connect_hover_signals() -> void: $"%WorkerAutoComplete", $"%ShowAllWorkers", $"%AllowDowngrade", + $"%GenerateButton", + $"%GenerateFooterButton", + $"%CancelButton", + $"%CancelFooterButton", ]: node.connect("mouse_entered", EventBus, "_on_node_hovered", [node]) node.connect("mouse_exited", EventBus, "_on_node_unhovered", [node]) diff --git a/bus.gd b/bus.gd index b8bb40b..eadf29e 100644 --- a/bus.gd +++ b/bus.gd @@ -26,6 +26,8 @@ signal kudos_calculated(kudos) signal generation_completed # warning-ignore:unused_signal signal cache_wipe_requested +signal generation_started +signal generation_cancelled func _on_node_hovered(node: Control): emit_signal("node_hovered", node) diff --git a/theme/assets/iconpark/play.svg b/theme/assets/iconpark/play.svg new file mode 100644 index 0000000..d649cdc --- /dev/null +++ b/theme/assets/iconpark/play.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/theme/assets/iconpark/toxins.svg b/theme/assets/iconpark/toxins.svg new file mode 100644 index 0000000..1a45796 --- /dev/null +++ b/theme/assets/iconpark/toxins.svg @@ -0,0 +1 @@ + \ No newline at end of file From 23eda7ac9c7098663c08c11ed67edebe35cf69dd Mon Sep 17 00:00:00 2001 From: db0 Date: Sat, 25 May 2024 14:47:46 +0200 Subject: [PATCH 4/6] feat: special tab and extra texts --- ConfigSlider.gd | 1 + LucidCreations.tscn | 40 ++++++++++----- PopupInfoPanel.gd | 12 +++-- StableHordeClient.gd | 2 +- bus.gd | 8 +-- src/ExtraTextContainer.gd | 31 ++++++++++++ src/ExtraTextContainer.tscn | 28 +++++++++++ src/Special.gd | 66 +++++++++++++++++++++++++ src/Special.tscn | 50 +++++++++++++++++++ theme/assets/iconpark/circles-seven.svg | 1 + 10 files changed, 219 insertions(+), 20 deletions(-) create mode 100644 src/ExtraTextContainer.gd create mode 100644 src/ExtraTextContainer.tscn create mode 100644 src/Special.gd create mode 100644 src/Special.tscn create mode 100644 theme/assets/iconpark/circles-seven.svg diff --git a/ConfigSlider.gd b/ConfigSlider.gd index ca496e7..415abcb 100644 --- a/ConfigSlider.gd +++ b/ConfigSlider.gd @@ -76,6 +76,7 @@ func _ready(): ParamBus.connect("models_changed",self,"_on_models_changed") # warning-ignore:return_value_discarded EventBus.connect("kudos_calculated", self, "_on_kudos_calculated") +# warning-ignore:return_value_discarded ParamBus.connect("params_changed",self,"_on_params_changed") func set_value(value) -> void: diff --git a/LucidCreations.tscn b/LucidCreations.tscn index d15a36f..bcf98d9 100644 --- a/LucidCreations.tscn +++ b/LucidCreations.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=61 format=2] +[gd_scene load_steps=63 format=2] [ext_resource path="res://StableHordeClient.gd" type="Script" id=1] [ext_resource path="res://addons/stable_horde_client/stable_horde_client.gd" type="Script" id=2] @@ -49,6 +49,8 @@ [ext_resource path="res://theme/assets/iconpark/worker.svg" type="Texture" id=47] [ext_resource path="res://theme/assets/iconpark/play.svg" type="Texture" id=48] [ext_resource path="res://theme/assets/iconpark/toxins.svg" type="Texture" id=49] +[ext_resource path="res://theme/assets/iconpark/circles-seven.svg" type="Texture" id=50] +[ext_resource path="res://src/Special.tscn" type="PackedScene" id=51] [sub_resource type="StreamTexture" id=9] flags = 4 @@ -347,6 +349,7 @@ size_flags_vertical = 3 custom_styles/panel = ExtResource( 39 ) [node name="Prompt" type="VBoxContainer" parent="Margin/Panel/Display/Panels/Controls"] +visible = false margin_left = 10.0 margin_top = 10.0 margin_right = 330.0 @@ -1213,6 +1216,8 @@ size_flags_horizontal = 3 pressed = true text = "HiResFix" +[node name="Special" parent="Margin/Panel/Display/Panels/Controls" instance=ExtResource( 51 )] + [node name="Options" type="MarginContainer" parent="Margin/Panel/Display/Panels/Controls"] unique_name_in_owner = true visible = false @@ -1629,14 +1634,14 @@ margin_right = 1568.0 margin_bottom = 868.0 [node name="Config" type="PanelContainer" parent="Margin/Panel/Footer"] -margin_right = 178.0 +margin_right = 212.0 margin_bottom = 42.0 size_flags_vertical = 8 [node name="Buttons" type="HBoxContainer" parent="Margin/Panel/Footer/Config"] margin_left = 6.0 margin_top = 6.0 -margin_right = 172.0 +margin_right = 206.0 margin_bottom = 36.0 size_flags_vertical = 4 @@ -1695,9 +1700,20 @@ icon = ExtResource( 35 ) icon_align = 1 expand_icon = true +[node name="Special" type="Button" parent="Margin/Panel/Footer/Config/Buttons"] +margin_left = 170.0 +margin_right = 200.0 +margin_bottom = 30.0 +rect_min_size = Vector2( 30, 30 ) +toggle_mode = true +group = SubResource( 10 ) +icon = ExtResource( 50 ) +icon_align = 1 +expand_icon = true + [node name="About" type="PanelContainer" parent="Margin/Panel/Footer"] -margin_left = 182.0 -margin_right = 258.0 +margin_left = 216.0 +margin_right = 292.0 margin_bottom = 42.0 size_flags_vertical = 8 @@ -1730,7 +1746,7 @@ icon_align = 1 expand_icon = true [node name="Progress" type="MarginContainer" parent="Margin/Panel/Footer"] -margin_left = 262.0 +margin_left = 296.0 margin_right = 1568.0 margin_bottom = 42.0 size_flags_horizontal = 3 @@ -1738,7 +1754,7 @@ size_flags_horizontal = 3 [node name="GenerationsProcessing" type="ProgressBar" parent="Margin/Panel/Footer/Progress"] unique_name_in_owner = true modulate = Color( 1, 1, 1, 0.392157 ) -margin_right = 1306.0 +margin_right = 1272.0 margin_bottom = 42.0 mouse_filter = 2 size_flags_horizontal = 3 @@ -1749,7 +1765,7 @@ max_value = 20.0 [node name="GenerationsDone" type="ProgressBar" parent="Margin/Panel/Footer/Progress"] unique_name_in_owner = true -margin_right = 1306.0 +margin_right = 1272.0 margin_bottom = 42.0 mouse_filter = 2 size_flags_horizontal = 3 @@ -1759,7 +1775,7 @@ custom_styles/bg = SubResource( 17 ) max_value = 20.0 [node name="Margin" type="MarginContainer" parent="Margin/Panel/Footer/Progress"] -margin_right = 1306.0 +margin_right = 1272.0 margin_bottom = 42.0 custom_constants/margin_right = 8 custom_constants/margin_top = 2 @@ -1769,7 +1785,7 @@ custom_constants/margin_bottom = 2 [node name="Labels" type="HBoxContainer" parent="Margin/Panel/Footer/Progress/Margin"] margin_left = 8.0 margin_top = 2.0 -margin_right = 1298.0 +margin_right = 1264.0 margin_bottom = 40.0 size_flags_horizontal = 3 size_flags_vertical = 3 @@ -1812,7 +1828,7 @@ scroll_active = false [node name="VBC" type="VBoxContainer" parent="Margin/Panel/Footer/Progress/Margin/Labels"] margin_left = 134.0 margin_top = 8.0 -margin_right = 1290.0 +margin_right = 1256.0 margin_bottom = 29.0 size_flags_horizontal = 3 size_flags_vertical = 4 @@ -1820,7 +1836,7 @@ custom_constants/separation = 0 [node name="StatusText" type="RichTextLabel" parent="Margin/Panel/Footer/Progress/Margin/Labels/VBC"] unique_name_in_owner = true -margin_right = 1156.0 +margin_right = 1122.0 margin_bottom = 21.0 rect_min_size = Vector2( 0, 18 ) size_flags_horizontal = 3 diff --git a/PopupInfoPanel.gd b/PopupInfoPanel.gd index 7aefc19..0cc8344 100644 --- a/PopupInfoPanel.gd +++ b/PopupInfoPanel.gd @@ -49,6 +49,7 @@ const DESCRIPTIONS = { "Basic": "Basic: Controls for image generation.", "Workers": "Workers: Allows you to control which workers will serve this request.", "Advanced": "Advanced: Extra controls for image generation.", + "Special": "Special: Controls for unique generation options.", "Options": "Options: Customize the Lucid Creations application.", "Information": "Information: Learn about the Lucid Creations application.", # Generate/Cancel @@ -89,8 +90,8 @@ func _ready(): # warning-ignore:return_value_discarded EventBus.connect("rtl_meta_unhovered",self, "_on_rtl_meta_unhovered") -func _on_node_hovered(node: Control) -> void: - if not DESCRIPTIONS.has(node.name): +func _on_node_hovered(node: Control, hovertext = null) -> void: + if not DESCRIPTIONS.has(node.name) and not hovertext: return info.rect_size = Vector2(0,0) current_hovered_node = node @@ -98,8 +99,11 @@ func _on_node_hovered(node: Control) -> void: if rect_global_position.x > get_viewport().size.x: rect_global_position.x = get_viewport().size.x - current_hovered_node.rect_size.x if rect_global_position.y + info.rect_size.y > get_viewport().size.y: - rect_global_position.y = get_viewport().size.y - info.rect_size.y - 10 - info.text = DESCRIPTIONS[node.name] + rect_global_position.y = get_viewport().size.y - info.rect_size.y - 10 + if hovertext: + info.text = hovertext + else: + info.text = DESCRIPTIONS[node.name] visible = true rect_size = info.rect_size diff --git a/StableHordeClient.gd b/StableHordeClient.gd index 0908783..c2bb855 100644 --- a/StableHordeClient.gd +++ b/StableHordeClient.gd @@ -699,7 +699,7 @@ func _accept_settings() -> void: stable_horde_client.set("post_processing", globals.config.get_value("Parameters", "post_processing", stable_horde_client.post_processing)) stable_horde_client.set("lora", globals.config.get_value("Parameters", "loras", stable_horde_client.lora)) stable_horde_client.set("tis", globals.config.get_value("Parameters", "tis", stable_horde_client.tis)) - + if prompt_line_edit.text == '': prompt_line_edit.text = _get_random_placeholder_prompt() stable_horde_client.prompt = prompt_line_edit.text diff --git a/bus.gd b/bus.gd index eadf29e..92a298d 100644 --- a/bus.gd +++ b/bus.gd @@ -1,7 +1,7 @@ extends Node # warning-ignore:unused_signal -signal node_hovered(node) +signal node_hovered(node, hovertext) # warning-ignore:unused_signal signal node_unhovered(node) # warning-ignore:unused_signal @@ -26,11 +26,13 @@ signal kudos_calculated(kudos) signal generation_completed # warning-ignore:unused_signal signal cache_wipe_requested +# warning-ignore:unused_signal signal generation_started +# warning-ignore:unused_signal signal generation_cancelled -func _on_node_hovered(node: Control): - emit_signal("node_hovered", node) +func _on_node_hovered(node: Control, hovertext): + emit_signal("node_hovered", node, hovertext) func _on_node_unhovered(node: Control): emit_signal("node_unhovered", node) diff --git a/src/ExtraTextContainer.gd b/src/ExtraTextContainer.gd new file mode 100644 index 0000000..d852b04 --- /dev/null +++ b/src/ExtraTextContainer.gd @@ -0,0 +1,31 @@ +extends HBoxContainer + +var is_optional := false +onready var reference: Label = $"%Reference" +onready var text: LineEdit = $"%Text" + +func _ready(): + pass # Replace with function body. + +func intiate_extra_text(reference_string: String, _is_optional: bool, description = null): + is_optional = _is_optional + reference.text = reference_string + if is_optional: + reference.text += '*' + text.text = globals.config.get_value("ExtraTexts", reference_string, '') + if not description: + return + connect("mouse_entered", EventBus, "_on_node_hovered", + [ + self, + description + ] + ) + connect("mouse_exited", EventBus, "_on_node_unhovered", [self]) + +func get_and_store_extra_text(): + globals.config.set_value("ExtraTexts", reference.text, text.text) + return { + "reference": reference.text.rstrip('*'), + "text": text.text + } diff --git a/src/ExtraTextContainer.tscn b/src/ExtraTextContainer.tscn new file mode 100644 index 0000000..06df014 --- /dev/null +++ b/src/ExtraTextContainer.tscn @@ -0,0 +1,28 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://src/ExtraTextContainer.gd" type="Script" id=1] + +[node name="ExtraTextContainer" type="HBoxContainer" groups=["ExtraTexts"]] +margin_right = 320.0 +margin_bottom = 30.0 +rect_min_size = Vector2( 0, 30 ) +script = ExtResource( 1 ) + +[node name="Reference" type="Label" parent="."] +unique_name_in_owner = true +margin_top = 5.0 +margin_right = 130.0 +margin_bottom = 25.0 +text = "ExtraTextReference" + +[node name="Text" type="LineEdit" parent="."] +unique_name_in_owner = true +margin_left = 134.0 +margin_right = 320.0 +margin_bottom = 30.0 +hint_tooltip = "Extra Text" +size_flags_horizontal = 3 +expand_to_text_length = true +clear_button_enabled = true +caret_blink = true +caret_blink_speed = 0.5 diff --git a/src/Special.gd b/src/Special.gd new file mode 100644 index 0000000..2203dba --- /dev/null +++ b/src/Special.gd @@ -0,0 +1,66 @@ +extends VBoxContainer + +const QR_MODULE_DRAWERS = [ + "square", + "gapped square", + "circle", + "rounded", + "vertical bars", + "horizontal bars"] + +# The boolean in each extra text reference is whether that is optional +# for that workflow +const WORKFLOWS = { + 'auto-detect': [], + 'qr_code': [ + ['qr_code',false, "The text which will be shown when scanning the generated QR code."], + ['x_offstet',true, "The QR code will be placed this many pixels from the left of the image."], + ['y_offstet',true, "The QR code will be placed this many pixels from the top of the image."], + ['protocol',true, "If your URL QR code fails to generate the right text, You can specify 'http' or 'https' here and remove it from the 'qr_code' field."], + ['module_drawer',true, "The QR Code type. Options are: " + str(QR_MODULE_DRAWERS)], + ['function_layer_prompt',true, "An extra prompt which will guide the generation of the QR code anchors."], + ['border',true, "The pixels of border the generated QR code should have. This will make it move obvious in the final image."], + ] +} + +const ETSCENE = preload("res://src/ExtraTextContainer.tscn") + +onready var extra_texts = $"%ExtraTexts" +onready var workflow = $"%Workflow" +onready var extra_texts_label = $"%ExtraTextsLabel" + +func _ready(): + workflow.connect("mouse_entered", EventBus, "_on_node_hovered", + [ + workflow, + "Select a custom workflow to use for this generation. Custom workflows typically require specifying extra parameters." + ] + ) + workflow.connect("mouse_exited", EventBus, "_on_node_unhovered", [workflow]) + + +func prepare_for_workflow(): + var workflow_name = workflow.get_item_text(workflow.get_selected_id()) + if not WORKFLOWS.has(workflow_name): + push_error("workflow requested that doesn't exist: " + workflow_name) + return + if workflow_name == 'auto-detect': + extra_texts_label.hide() + else: + extra_texts_label.show() + for etnode in extra_texts.get_children(): + etnode.queue_free() + for et in WORKFLOWS[workflow_name]: + var new_et_scene = ETSCENE.instance() + extra_texts.add_child(new_et_scene) + new_et_scene.intiate_extra_text(et[0],et[1],et[2]) + +func get_workflow_and_extra_texts(): + var extra_texts_array: = [] + for etnode in extra_texts.get_children(): + extra_texts_array.append(etnode.get_and_store_extra_text()) + var workflow_name = workflow.get_item_text(workflow.get_selected_id()) + return [workflow_name, extra_texts] + +func _on_Workflow_item_selected(_index): + prepare_for_workflow() diff --git a/src/Special.tscn b/src/Special.tscn new file mode 100644 index 0000000..b7c9bc9 --- /dev/null +++ b/src/Special.tscn @@ -0,0 +1,50 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://theme/fonts/noto/type/type_body_strong.tres" type="DynamicFont" id=1] +[ext_resource path="res://src/Special.gd" type="Script" id=3] + +[node name="Special" type="VBoxContainer"] +unique_name_in_owner = true +margin_left = 10.0 +margin_top = 10.0 +margin_right = 330.0 +margin_bottom = 340.0 +rect_min_size = Vector2( 320, 0 ) +size_flags_horizontal = 3 +size_flags_vertical = 3 +custom_constants/separation = 8 +script = ExtResource( 3 ) + +[node name="WorkflowLabel" type="Label" parent="."] +margin_right = 320.0 +margin_bottom = 20.0 +custom_fonts/font = ExtResource( 1 ) +text = "Workflow" +autowrap = true + +[node name="Workflow" type="OptionButton" parent="."] +unique_name_in_owner = true +margin_top = 28.0 +margin_right = 320.0 +margin_bottom = 56.0 +text = "auto-detect" +items = [ "auto-detect", null, false, 0, null, "qr_code", null, false, 1, null ] +selected = 0 + +[node name="ExtraTextsLabel" type="Label" parent="."] +unique_name_in_owner = true +visible = false +margin_top = 64.0 +margin_right = 320.0 +margin_bottom = 84.0 +custom_fonts/font = ExtResource( 1 ) +text = "Extra Texts (* are optional)" +autowrap = true + +[node name="ExtraTexts" type="VBoxContainer" parent="."] +unique_name_in_owner = true +margin_top = 64.0 +margin_right = 320.0 +margin_bottom = 64.0 + +[connection signal="item_selected" from="Workflow" to="." method="_on_Workflow_item_selected"] diff --git a/theme/assets/iconpark/circles-seven.svg b/theme/assets/iconpark/circles-seven.svg new file mode 100644 index 0000000..ddab1d3 --- /dev/null +++ b/theme/assets/iconpark/circles-seven.svg @@ -0,0 +1 @@ + \ No newline at end of file From 5bc1f325295c06dbcc5844a8d7c09b84030359f7 Mon Sep 17 00:00:00 2001 From: db0 Date: Sat, 25 May 2024 23:04:50 +0200 Subject: [PATCH 5/6] feat: QR code creations --- LucidCreations.tscn | 2 +- StableHordeClient.gd | 9 +++++ .../stable_horde_client.gd | 16 ++++++++- bus.gd | 2 +- src/ExtraTextContainer.gd | 2 ++ src/Special.gd | 34 +++++++++++++++---- 6 files changed, 56 insertions(+), 9 deletions(-) diff --git a/LucidCreations.tscn b/LucidCreations.tscn index bcf98d9..8f05279 100644 --- a/LucidCreations.tscn +++ b/LucidCreations.tscn @@ -516,7 +516,6 @@ text = "Image is control" [node name="Basic" type="VBoxContainer" parent="Margin/Panel/Display/Panels/Controls"] unique_name_in_owner = true -visible = false margin_left = 10.0 margin_top = 10.0 margin_right = 330.0 @@ -1217,6 +1216,7 @@ pressed = true text = "HiResFix" [node name="Special" parent="Margin/Panel/Display/Panels/Controls" instance=ExtResource( 51 )] +visible = false [node name="Options" type="MarginContainer" parent="Margin/Panel/Display/Panels/Controls"] unique_name_in_owner = true diff --git a/StableHordeClient.gd b/StableHordeClient.gd index c2bb855..0bbe8e1 100644 --- a/StableHordeClient.gd +++ b/StableHordeClient.gd @@ -85,6 +85,9 @@ onready var aesthetic_rating = $"%AestheticRating" onready var artifacts_rating = $"%ArtifactsRating" onready var best_of = $"%BestOf" onready var submit_ratings = $"%SubmitRatings" +# special +onready var special = $"%Special" + func _ready(): @@ -699,6 +702,8 @@ func _accept_settings() -> void: stable_horde_client.set("post_processing", globals.config.get_value("Parameters", "post_processing", stable_horde_client.post_processing)) stable_horde_client.set("lora", globals.config.get_value("Parameters", "loras", stable_horde_client.lora)) stable_horde_client.set("tis", globals.config.get_value("Parameters", "tis", stable_horde_client.tis)) + stable_horde_client.set("workflow", special.get_workflow_name()) + stable_horde_client.set("extra_texts", special.get_extra_texts()) if prompt_line_edit.text == '': prompt_line_edit.text = _get_random_placeholder_prompt() @@ -754,6 +759,10 @@ func _on_load_from_disk_gensettings_loaded(settings) -> void: img_2_img_enabled.pressed = false stable_horde_client.source_image = null stable_horde_client.control_type = "none" + if settings.has("workflow"): + special.set_workflow_to(settings['workflow']) + if settings.has("extra_texts"): + special.set_special_texts(settings['extra_texts']) func _set_prompt(prompt: String, force = false) -> bool: """Sets prompt and negative prompt diff --git a/addons/stable_horde_client/stable_horde_client.gd b/addons/stable_horde_client/stable_horde_client.gd index 60187d9..f093eda 100644 --- a/addons/stable_horde_client/stable_horde_client.gd +++ b/addons/stable_horde_client/stable_horde_client.gd @@ -34,6 +34,11 @@ enum ControlTypes { hough } +enum Workflows { + auto_detect = 0 + qr_code +} + enum OngoingRequestOperations { CHECK GET @@ -103,6 +108,8 @@ export(bool) var replacement_filter := true export(Array) var workers := [] export(bool) var worker_blacklist := false export(bool) var allow_downgrade := false +export(String, "auto-detect", "qr_code") var workflow := "auto-detect" +export(Array) var extra_texts = [] var all_image_textures := [] var latest_image_textures := [] @@ -144,6 +151,10 @@ func generate(replacement_prompt := '', replacement_params := {}) -> void: imgen_params["loras"] = _get_loras_payload() if tis.size() > 0: imgen_params["tis"] = _get_tis_payload() + if workflow != 'auto-detect': + imgen_params["workflow"] = workflow + if extra_texts != null and extra_texts.size() > 0: + imgen_params["extra_texts"] = extra_texts for param in replacement_params: imgen_params[param] = replacement_params[param] var submit_dict = { @@ -164,7 +175,10 @@ func generate(replacement_prompt := '', replacement_params := {}) -> void: # "dc0704ab-5b42-4c65-8471-561be16ad696", #portal # ], # debug } -# print_debug(submit_dict) + if false: # Debug + print_debug(submit_dict) + push_warning("Aborting due to debug") + return if source_image: submit_dict["source_image"] = get_img2img_b64(source_image) submit_dict["params"]["denoising_strength"] = denoising_strength diff --git a/bus.gd b/bus.gd index 92a298d..b5a19f8 100644 --- a/bus.gd +++ b/bus.gd @@ -31,7 +31,7 @@ signal generation_started # warning-ignore:unused_signal signal generation_cancelled -func _on_node_hovered(node: Control, hovertext): +func _on_node_hovered(node: Control, hovertext = null): emit_signal("node_hovered", node, hovertext) func _on_node_unhovered(node: Control): diff --git a/src/ExtraTextContainer.gd b/src/ExtraTextContainer.gd index d852b04..94999ce 100644 --- a/src/ExtraTextContainer.gd +++ b/src/ExtraTextContainer.gd @@ -24,6 +24,8 @@ func intiate_extra_text(reference_string: String, _is_optional: bool, descriptio connect("mouse_exited", EventBus, "_on_node_unhovered", [self]) func get_and_store_extra_text(): + if text.text == '': + return null globals.config.set_value("ExtraTexts", reference.text, text.text) return { "reference": reference.text.rstrip('*'), diff --git a/src/Special.gd b/src/Special.gd index 2203dba..7ab378e 100644 --- a/src/Special.gd +++ b/src/Special.gd @@ -14,8 +14,8 @@ const WORKFLOWS = { 'auto-detect': [], 'qr_code': [ ['qr_code',false, "The text which will be shown when scanning the generated QR code."], - ['x_offstet',true, "The QR code will be placed this many pixels from the left of the image."], - ['y_offstet',true, "The QR code will be placed this many pixels from the top of the image."], + ['x_offset',true, "The QR code will be placed this many pixels from the left of the image."], + ['y_offset',true, "The QR code will be placed this many pixels from the top of the image."], ['protocol',true, "If your URL QR code fails to generate the right text, You can specify 'http' or 'https' here and remove it from the 'qr_code' field."], ['module_drawer',true, "The QR Code type. Options are: " + str(QR_MODULE_DRAWERS)], ['function_layer_prompt',true, "An extra prompt which will guide the generation of the QR code anchors."], @@ -55,12 +55,34 @@ func prepare_for_workflow(): extra_texts.add_child(new_et_scene) new_et_scene.intiate_extra_text(et[0],et[1],et[2]) -func get_workflow_and_extra_texts(): +func get_extra_texts(): + if workflow.get_item_text(workflow.get_selected_id()) == 'auto-detect': + return null var extra_texts_array: = [] for etnode in extra_texts.get_children(): - extra_texts_array.append(etnode.get_and_store_extra_text()) - var workflow_name = workflow.get_item_text(workflow.get_selected_id()) - return [workflow_name, extra_texts] + var et = etnode.get_and_store_extra_text() + if et != null: + extra_texts_array.append(et) + return extra_texts_array + +func get_workflow_name(): + return workflow.get_item_text(workflow.get_selected_id()) func _on_Workflow_item_selected(_index): prepare_for_workflow() + +func set_workflow_to(workflow_name: String): + for idx in range(workflow.get_item_count()): + if workflow.get_item_text(idx) == workflow_name: + workflow.select(idx) + prepare_for_workflow() + return + +func set_special_texts(et_array: Array): + for et in et_array: + for etnode in extra_texts.get_children(): + if etnode.is_queued_for_deletion(): + continue + if etnode.reference.text.rstrip('*') == et['reference']: + etnode.text.text = str(et['text']) + break From fb64dac10af01839c32f55ecf5aee3adec61e145 Mon Sep 17 00:00:00 2001 From: db0 Date: Sun, 26 May 2024 00:04:19 +0200 Subject: [PATCH 6/6] feat: allow to switch to godot native browse --- LucidCreations.tscn | 32 +++++++++++++++++----------- Options.gd | 6 ++++++ PopupInfoPanel.gd | 1 + project.godot | 2 +- src/Buttons/LoadFromDisk.gd | 14 +++++++++++- src/Buttons/LoadFromDisk.tscn | 11 ++++++++++ src/Lora/Lora.gd | 2 ++ src/Options/SaveDirBrowseButton.gd | 21 +++++++++++++----- src/Options/SaveDirBrowseButton.tscn | 10 +++++++++ 9 files changed, 80 insertions(+), 19 deletions(-) diff --git a/LucidCreations.tscn b/LucidCreations.tscn index 8f05279..71b4719 100644 --- a/LucidCreations.tscn +++ b/LucidCreations.tscn @@ -1217,6 +1217,7 @@ text = "HiResFix" [node name="Special" parent="Margin/Panel/Display/Panels/Controls" instance=ExtResource( 51 )] visible = false +margin_bottom = 400.0 [node name="Options" type="MarginContainer" parent="Margin/Panel/Display/Panels/Controls"] unique_name_in_owner = true @@ -1224,13 +1225,13 @@ visible = false margin_left = 10.0 margin_top = 10.0 margin_right = 330.0 -margin_bottom = 378.0 +margin_bottom = 450.0 rect_min_size = Vector2( 320, 0 ) script = ExtResource( 11 ) [node name="VBC" type="VBoxContainer" parent="Margin/Panel/Display/Panels/Controls/Options"] margin_right = 320.0 -margin_bottom = 404.0 +margin_bottom = 440.0 custom_constants/separation = 8 [node name="VBCRight" type="VBoxContainer" parent="Margin/Panel/Display/Panels/Controls/Options/VBC"] @@ -1286,7 +1287,7 @@ selection_enabled = true [node name="VBCLeft" type="VBoxContainer" parent="Margin/Panel/Display/Panels/Controls/Options/VBC"] margin_top = 103.0 margin_right = 320.0 -margin_bottom = 368.0 +margin_bottom = 440.0 size_flags_horizontal = 3 custom_constants/separation = 8 @@ -1353,33 +1354,40 @@ margin_left = 261.0 margin_right = 320.0 margin_bottom = 28.0 -[node name="RememberPrompt" type="CheckButton" parent="Margin/Panel/Display/Panels/Controls/Options/VBC/VBCLeft"] +[node name="UseGodotBrowse" type="CheckButton" parent="Margin/Panel/Display/Panels/Controls/Options/VBC/VBCLeft"] unique_name_in_owner = true margin_top = 129.0 margin_right = 320.0 margin_bottom = 157.0 -text = "Remember Prompt" +text = "Use Godot Browse" -[node name="LargerValues" type="CheckButton" parent="Margin/Panel/Display/Panels/Controls/Options/VBC/VBCLeft"] +[node name="RememberPrompt" type="CheckButton" parent="Margin/Panel/Display/Panels/Controls/Options/VBC/VBCLeft"] unique_name_in_owner = true margin_top = 165.0 margin_right = 320.0 margin_bottom = 193.0 +text = "Remember Prompt" + +[node name="LargerValues" type="CheckButton" parent="Margin/Panel/Display/Panels/Controls/Options/VBC/VBCLeft"] +unique_name_in_owner = true +margin_top = 201.0 +margin_right = 320.0 +margin_bottom = 229.0 text = "Larger Values" [node name="AllowDowngrade" type="CheckButton" parent="Margin/Panel/Display/Panels/Controls/Options/VBC/VBCLeft"] unique_name_in_owner = true -margin_top = 165.0 +margin_top = 237.0 margin_right = 320.0 -margin_bottom = 193.0 +margin_bottom = 265.0 pressed = true text = "Allow Downgrade" [node name="LoadSeedFromDisk" type="CheckButton" parent="Margin/Panel/Display/Panels/Controls/Options/VBC/VBCLeft"] unique_name_in_owner = true -margin_top = 201.0 +margin_top = 273.0 margin_right = 320.0 -margin_bottom = 229.0 +margin_bottom = 301.0 text = "Recover Saved Seeds" [node name="Shared" type="CheckButton" parent="Margin/Panel/Display/Panels/Controls/Options/VBC/VBCLeft"] @@ -1392,9 +1400,9 @@ text = "Share Images" [node name="WipeCache" type="Button" parent="Margin/Panel/Display/Panels/Controls/Options/VBC/VBCLeft"] unique_name_in_owner = true -margin_top = 237.0 +margin_top = 309.0 margin_right = 320.0 -margin_bottom = 265.0 +margin_bottom = 337.0 text = "Wipe CivitAI Cache" [node name="Information" type="VBoxContainer" parent="Margin/Panel/Display/Panels/Controls"] diff --git a/Options.gd b/Options.gd index f6f2ae8..e3870fe 100644 --- a/Options.gd +++ b/Options.gd @@ -12,6 +12,7 @@ onready var stable_horde_login = $"%StableHordeLogin" onready var load_seed_from_disk = $"%LoadSeedFromDisk" onready var wipe_cache = $"%WipeCache" onready var allow_downgrade = $"%AllowDowngrade" +onready var use_godot_browse = $"%UseGodotBrowse" func _ready(): remember_prompt.pressed = globals.config.get_value("Options", "remember_prompt", false) @@ -22,6 +23,8 @@ func _ready(): allow_downgrade.connect("toggled",self,"_on_allow_downgrade_pressed") load_seed_from_disk.pressed = globals.config.get_value("Options", "load_seed_from_disk", false) load_seed_from_disk.connect("toggled",self,"_on_load_seed_from_disk_pressed") + use_godot_browse.pressed = globals.config.get_value("Options", "use_godot_browse", false) + use_godot_browse.connect("toggled",self,"_on_use_godot_browse_pressed") shared.pressed = globals.config.get_value("Options", "shared", true) shared.connect("toggled",self,"_on_shared_pressed") # warning-ignore:return_value_discarded @@ -63,6 +66,9 @@ func _on_allow_downgrade_pressed(pressed: bool) -> void: func _on_load_seed_from_disk_pressed(pressed: bool) -> void: globals.set_setting("load_seed_from_disk", pressed, "Options") +func _on_use_godot_browse_pressed(pressed: bool) -> void: + globals.set_setting("use_godot_browse", pressed, "Options") + func _on_shared_pressed(pressed: bool) -> void: globals.set_setting("shared", pressed, "Options") EventBus.emit_signal("shared_toggled") diff --git a/PopupInfoPanel.gd b/PopupInfoPanel.gd index 0cc8344..986b718 100644 --- a/PopupInfoPanel.gd +++ b/PopupInfoPanel.gd @@ -43,6 +43,7 @@ const DESCRIPTIONS = { "WorkerAutoComplete": "Specify workers to use for this generation. Use the toggle below to specify using them as an allowlist or a blocklist. When models are selected, only workers which can generate any of those models will be shown.", "ShowAllWorkers": "Press this button to display and select available workers for your selected model.", "AllowDowngrade": "When enabled and your account doesn't have enough kudos to generate the image, it will be downgraded in resolution and steps, so that it does not need upfront kudos, instead of failing.", + "UseGodotBrowse": "When enabled instead of using your OS' native browse dialog, it will use Godot Engine's built-in node.", # Control Buttons "Prompt": "Prompt: This tab allows you to specify the prompt which will generate the image", "img2img": "Img2Img: This tab allows you to specify image-to-image functionality, such as the source image or controlnets.", diff --git a/project.godot b/project.godot index b12951d..9198790 100644 --- a/project.godot +++ b/project.godot @@ -178,7 +178,7 @@ window/stretch/aspect="keep" [editor_plugins] -enabled=PoolStringArray( "res://addons/stable_horde_client/plugin.cfg" ) +enabled=PoolStringArray( "res://addons/native_dialogs/plugin.cfg", "res://addons/stable_horde_client/plugin.cfg" ) [global] diff --git a/src/Buttons/LoadFromDisk.gd b/src/Buttons/LoadFromDisk.gd index 5b3b2b5..1563dcc 100644 --- a/src/Buttons/LoadFromDisk.gd +++ b/src/Buttons/LoadFromDisk.gd @@ -3,14 +3,19 @@ extends Button signal gensettings_loaded(settings) onready var load_from_disk_native_dialog_open_file = $"%LoadFromDiskNativeDialogOpenFile" +onready var file_dialog = $"%FileDialog" func _ready(): load_from_disk_native_dialog_open_file.initial_path = globals.config.get_value("Options", "load_initial_path", "user://") + file_dialog.current_path = globals.config.get_value("Options", "load_initial_path", "user://") func _on_LoadFromDiskNativeDialogOpenFile_files_selected(files: Array): if files.size() == 0: return var filename: String = files[0] + _load_image_data(filename) + +func _load_image_data(filename: String) -> void: var file = File.new() if filename.ends_with(".png"): filename = filename.get_basename() + '.json' @@ -24,4 +29,11 @@ func _on_LoadFromDiskNativeDialogOpenFile_files_selected(files: Array): emit_signal("gensettings_loaded", data.result) func _on_LoadFromDisk_pressed(): - load_from_disk_native_dialog_open_file.show() + if globals.config.get_value("Options", "use_godot_browse", false): + file_dialog.show() + else: + load_from_disk_native_dialog_open_file.show() + + +func _on_FileDialog_file_selected(path): + _load_image_data(path) diff --git a/src/Buttons/LoadFromDisk.tscn b/src/Buttons/LoadFromDisk.tscn index 0128ca4..800b5dd 100644 --- a/src/Buttons/LoadFromDisk.tscn +++ b/src/Buttons/LoadFromDisk.tscn @@ -18,5 +18,16 @@ title = "Load generation json from disk" initial_path = "user://" filters = PoolStringArray( "*.png ; Image Files", "*.json ; json files", "*.png, *.json ; all files" ) +[node name="FileDialog" type="FileDialog" parent="."] +unique_name_in_owner = true +margin_right = 307.0 +margin_bottom = 156.0 +rect_min_size = Vector2( 800, 600 ) +window_title = "Open a File" +mode = 0 +access = 2 +filters = PoolStringArray( "*.png ; Image Files", "*.json ; json files" ) + [connection signal="pressed" from="." to="." method="_on_LoadFromDisk_pressed"] [connection signal="files_selected" from="LoadFromDiskNativeDialogOpenFile" to="." method="_on_LoadFromDiskNativeDialogOpenFile_files_selected"] +[connection signal="file_selected" from="FileDialog" to="." method="_on_FileDialog_file_selected"] diff --git a/src/Lora/Lora.gd b/src/Lora/Lora.gd index f48ad9b..be665b6 100644 --- a/src/Lora/Lora.gd +++ b/src/Lora/Lora.gd @@ -95,6 +95,8 @@ func replace_loras(loras: Array) -> void: ) if not is_version: lora["id"] = lora_reference_node.get_latest_version(lora["name"]) + if lora["id"] == 'N/A': + continue lora["is_version"] = true lora["lora_id"] = lora_reference_node.get_lora_info(lora["id"], true)["id"] update_selected_loras_label() diff --git a/src/Options/SaveDirBrowseButton.gd b/src/Options/SaveDirBrowseButton.gd index 4010597..69d5b64 100644 --- a/src/Options/SaveDirBrowseButton.gd +++ b/src/Options/SaveDirBrowseButton.gd @@ -3,16 +3,27 @@ extends Button signal savedir_path_set(path) onready var save_dir_browse_native_dialog_select_folder = $"%SaveDirBrowseNativeDialogSelectFolder" +onready var file_dialog = $"%FileDialog" func _ready(): save_dir_browse_native_dialog_select_folder.initial_path = globals.config.get_value("Options", "savedir_path", "user://") + file_dialog.current_path = globals.config.get_value("Options", "savedir_path", "user://") -func _on_SaveDirBrowseNativeDialogSelectFolder_folder_selected(folder: String): - globals.set_setting("savedir_path", folder, "Options") - save_dir_browse_native_dialog_select_folder.initial_path = folder + '/' - emit_signal("savedir_path_set", folder) func _on_SaveDirBrowseButton_pressed(): - save_dir_browse_native_dialog_select_folder.show() + if globals.config.get_value("Options", "use_godot_browse", false): + file_dialog.show() + else: + save_dir_browse_native_dialog_select_folder.show() +func _on_SaveDirBrowseNativeDialogSelectFolder_folder_selected(dir: String): + _on_dir_selected(dir) + +func _on_FileDialog_dir_selected(dir: String): + _on_dir_selected(dir) + +func _on_dir_selected(dir: String): + globals.set_setting("savedir_path", dir, "Options") + save_dir_browse_native_dialog_select_folder.initial_path = dir + '/' + emit_signal("savedir_path_set", dir) diff --git a/src/Options/SaveDirBrowseButton.tscn b/src/Options/SaveDirBrowseButton.tscn index 61cb7a9..1c43f75 100644 --- a/src/Options/SaveDirBrowseButton.tscn +++ b/src/Options/SaveDirBrowseButton.tscn @@ -17,5 +17,15 @@ script = ExtResource( 1 ) title = "Image Save Directory" initial_path = "user://" +[node name="FileDialog" type="FileDialog" parent="."] +unique_name_in_owner = true +margin_right = 307.0 +margin_bottom = 156.0 +rect_min_size = Vector2( 800, 640 ) +window_title = "Open a Directory" +mode = 2 +access = 2 + [connection signal="pressed" from="." to="." method="_on_SaveDirBrowseButton_pressed"] [connection signal="folder_selected" from="SaveDirBrowseNativeDialogSelectFolder" to="." method="_on_SaveDirBrowseNativeDialogSelectFolder_folder_selected"] +[connection signal="dir_selected" from="FileDialog" to="." method="_on_FileDialog_dir_selected"]