From 314e097733e805af180981a4feb8006e1938ce3a Mon Sep 17 00:00:00 2001 From: jyatch Date: Mon, 24 Nov 2025 17:29:43 -0500 Subject: [PATCH 1/6] created file dialog specific cursor Need to make an update so that when we update the base cursor, we also change the file one. --- .../scripts/player_select_menu.gd | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/CogsPartyLauncher/scripts/player_select_menu.gd b/CogsPartyLauncher/scripts/player_select_menu.gd index 5a241f5..eeb38da 100644 --- a/CogsPartyLauncher/scripts/player_select_menu.gd +++ b/CogsPartyLauncher/scripts/player_select_menu.gd @@ -155,17 +155,7 @@ func _on_player_count_changed(): func _on_add_player_button_pressed(): - var main = get_tree().current_scene - var player_cursor = player_cursor_prefab.instantiate() as CharacterBody2D - var id = _get_next_id() - _add_taken_id(id) - player_cursor.construct( - Vector2(randi_range(476,676), randi_range(224,424)), - id - ) - player_cursors.append(player_cursor) - main.add_child.call_deferred(player_cursor) - + var player_cursor = _create_new_cursor() var inst = player_setting_prefab.instantiate() as PlayerSetting player_setting_container.add_child(inst) @@ -178,6 +168,7 @@ func _on_add_player_button_pressed(): _get_next_available_color_or_self() ) player_settings.append(inst) + _create_file_dialog_cursor(player_cursor) _on_player_count_changed() @@ -203,6 +194,33 @@ func _on_player_setting_removed(player_setting: PlayerSetting): _on_player_count_changed() +func _create_new_cursor() -> CharacterBody2D: + var player_cursor = player_cursor_prefab.instantiate() as CharacterBody2D + var id = _get_next_id() + _add_taken_id(id) + + player_cursor.construct( + Vector2(randi_range(476,676), randi_range(224,424)), + id + ) + player_cursors.append(player_cursor) + get_tree().current_scene.add_child.call_deferred(player_cursor) + return player_cursor + + +func _create_file_dialog_cursor(player_cursor: CharacterBody2D): + var file_dialog_cursor = player_cursor.duplicate() + var controller_id: int = player_cursor.controller_id + var main_menu = get_tree().current_scene.find_child("Menus").find_child("MainMenu") + + file_dialog_cursor.construct( + Vector2(randi_range(476,676), randi_range(224,424)), + controller_id + ) + if main_menu != null: + main_menu.games_folder_select_file_dialog.add_child(file_dialog_cursor) + + func _on_joy_connection_changed(device_id: int, connected: bool): if connected: _add_controls(device_id) From c126e9fa1f099d17f6432c3c5923789ead3d4a4f Mon Sep 17 00:00:00 2001 From: jyatch Date: Mon, 24 Nov 2025 21:29:26 -0500 Subject: [PATCH 2/6] linked regular cursor to file dialog one --- CogsPartyLauncher/scripts/player_cursor.gd | 17 +++++++++++++++++ CogsPartyLauncher/scripts/player_select_menu.gd | 16 ++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/CogsPartyLauncher/scripts/player_cursor.gd b/CogsPartyLauncher/scripts/player_cursor.gd index 2e4fd65..6c843d0 100644 --- a/CogsPartyLauncher/scripts/player_cursor.gd +++ b/CogsPartyLauncher/scripts/player_cursor.gd @@ -6,6 +6,9 @@ extends CharacterBody2D # unlinked cursors have an ID of -1 var controller_id: int = 0 +# reference to a matching cursor used to navigate the file dialog from the edit button on the main menu +var file_dialog_cursor: CharacterBody2D + func construct(cursor_position: Vector2, id: int): position = cursor_position @@ -35,6 +38,10 @@ func _physics_process(delta): _simulate_stop_scroll(MOUSE_BUTTON_WHEEL_DOWN) +func get_id() -> int: + return controller_id + + func _input(event: InputEvent) -> void: if controller_id != -1: if event.is_action_pressed("select%s" % [controller_id]): @@ -77,7 +84,17 @@ func _simulate_stop_scroll(direction: MouseButton): func update_player_label(player_number: int): player_name_label.text = "P%d" % player_number + if file_dialog_cursor != null: + file_dialog_cursor.update_player_label(player_number) func update_color(color: Color): $Sprite2D.modulate = color + if file_dialog_cursor != null: + file_dialog_cursor.update_color(color) + + +func update_id(id: int): + controller_id = id + if file_dialog_cursor != null: + file_dialog_cursor.update_id(id) diff --git a/CogsPartyLauncher/scripts/player_select_menu.gd b/CogsPartyLauncher/scripts/player_select_menu.gd index eeb38da..0292560 100644 --- a/CogsPartyLauncher/scripts/player_select_menu.gd +++ b/CogsPartyLauncher/scripts/player_select_menu.gd @@ -182,10 +182,12 @@ func _on_player_setting_removed(player_setting: PlayerSetting): else: pass # next_focus_control.grab_focus() - # delete cursor - _remove_taken_id(player_setting.player_cursor.controller_id) + # delete cursor and its file dialog duplicate + _remove_taken_id(player_setting.player_cursor.get_id()) player_cursors.erase(player_setting.player_cursor) + player_setting.player_cursor.file_dialog_cursor.queue_free() player_setting.player_cursor.queue_free() + player_setting_container.remove_child(player_setting) player_setting.queue_free() @@ -210,12 +212,14 @@ func _create_new_cursor() -> CharacterBody2D: func _create_file_dialog_cursor(player_cursor: CharacterBody2D): var file_dialog_cursor = player_cursor.duplicate() - var controller_id: int = player_cursor.controller_id var main_menu = get_tree().current_scene.find_child("Menus").find_child("MainMenu") + # gives the original player cursor a reference to the duplicate used in the file dialog + player_cursor.file_dialog_cursor = file_dialog_cursor + file_dialog_cursor.construct( Vector2(randi_range(476,676), randi_range(224,424)), - controller_id + player_cursor.get_id() ) if main_menu != null: main_menu.games_folder_select_file_dialog.add_child(file_dialog_cursor) @@ -240,11 +244,11 @@ func _reset_controller_ids(): taken_ids.clear() for cursor in player_cursors: - cursor.controller_id = -1 + cursor.update_id(-1) for device in devices: if not taken_ids.has(device): taken_ids[device] = null - cursor.controller_id = device + cursor.update_id(device) break From d2e92fe84ffa3ed1de70d04a2853d188a561e833 Mon Sep 17 00:00:00 2001 From: jyatch Date: Tue, 25 Nov 2025 15:34:31 -0500 Subject: [PATCH 3/6] world borders for file dialog --- CogsPartyLauncher/scenes/main.tscn | 39 +++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/CogsPartyLauncher/scenes/main.tscn b/CogsPartyLauncher/scenes/main.tscn index 6c2434a..ae5c5bc 100644 --- a/CogsPartyLauncher/scenes/main.tscn +++ b/CogsPartyLauncher/scenes/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=28 format=3 uid="uid://k31chn02rvs2"] +[gd_scene load_steps=32 format=3 uid="uid://k31chn02rvs2"] [ext_resource type="Theme" uid="uid://036n6qd3ik2g" path="res://assets/theme.tres" id="1_erdau"] [ext_resource type="Script" uid="uid://du6vnjc42pp0f" path="res://scripts/main_menu.gd" id="2_6njpl"] @@ -94,6 +94,14 @@ corner_radius_top_right = 4 corner_radius_bottom_right = 4 corner_radius_bottom_left = 4 +[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_yc10j"] + +[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_jscy8"] + +[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_pm3ni"] + +[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_y6deb"] + [sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_muem4"] [sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_dp3eg"] @@ -435,11 +443,40 @@ layout_mode = 2 text = "E D I T" [node name="GamesFolderSelectFileDialog" type="FileDialog" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer/GamesFolderSelectButton"] +oversampling_override = 1.0 title = "Open a Directory" ok_button_text = "Select Current Folder" file_mode = 2 access = 2 +[node name="BottomBorder" type="StaticBody2D" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer/GamesFolderSelectButton/GamesFolderSelectFileDialog"] +position = Vector2(599, 562) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer/GamesFolderSelectButton/GamesFolderSelectFileDialog/BottomBorder"] +shape = SubResource("WorldBoundaryShape2D_yc10j") + +[node name="TopBorder" type="StaticBody2D" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer/GamesFolderSelectButton/GamesFolderSelectFileDialog"] +position = Vector2(613, 514) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer/GamesFolderSelectButton/GamesFolderSelectFileDialog/TopBorder"] +position = Vector2(1, -533) +rotation = 3.1415927 +shape = SubResource("WorldBoundaryShape2D_jscy8") + +[node name="RightBorder" type="StaticBody2D" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer/GamesFolderSelectButton/GamesFolderSelectFileDialog"] +position = Vector2(966, 288) +rotation = -1.5707964 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer/GamesFolderSelectButton/GamesFolderSelectFileDialog/RightBorder"] +shape = SubResource("WorldBoundaryShape2D_pm3ni") + +[node name="StaticBody2D" type="StaticBody2D" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer/GamesFolderSelectButton/GamesFolderSelectFileDialog"] +position = Vector2(-23, 282) +rotation = 1.5707964 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer/GamesFolderSelectButton/GamesFolderSelectFileDialog/StaticBody2D"] +shape = SubResource("WorldBoundaryShape2D_y6deb") + [node name="GamesFolderLabel" type="Label" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer"] layout_mode = 2 size_flags_horizontal = 3 From 176ac34005d3dda006cc154074af90ade5297244 Mon Sep 17 00:00:00 2001 From: jyatch Date: Tue, 25 Nov 2025 16:34:01 -0500 Subject: [PATCH 4/6] simulate double click --- CogsPartyLauncher/scripts/player_cursor.gd | 32 ++++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/CogsPartyLauncher/scripts/player_cursor.gd b/CogsPartyLauncher/scripts/player_cursor.gd index 6c843d0..875a190 100644 --- a/CogsPartyLauncher/scripts/player_cursor.gd +++ b/CogsPartyLauncher/scripts/player_cursor.gd @@ -3,11 +3,12 @@ extends CharacterBody2D @export var speed: float = 30000.0 @export var player_name_label: Label -# unlinked cursors have an ID of -1 -var controller_id: int = 0 +const DOUBLE_CLICK_THRESHOLD: float = 0.5 -# reference to a matching cursor used to navigate the file dialog from the edit button on the main menu -var file_dialog_cursor: CharacterBody2D +var controller_id: int = 0 # unlinked cursors have an id of -1 +var file_dialog_cursor: CharacterBody2D # reference to matching cursor in main menus file dialog +var last_click: float # last time the player clicked (double click detection) +var elapsed_time: float = 0.0 func construct(cursor_position: Vector2, id: int): @@ -15,7 +16,13 @@ func construct(cursor_position: Vector2, id: int): controller_id = id +func get_id() -> int: + return controller_id + + func _physics_process(delta): + elapsed_time += delta + if controller_id != -1: var direction = Input.get_vector( "left%s" % [controller_id], @@ -23,12 +30,11 @@ func _physics_process(delta): "up%s" % [controller_id], "down%s" % [controller_id] ) - var rs_strength = abs(Input.get_axis("scroll_down", "scroll_up")) velocity = direction * speed * delta move_and_slide() - + if Input.is_action_pressed("scroll_up%s" % [controller_id]): _simulate_scroll(MOUSE_BUTTON_WHEEL_UP, rs_strength) elif Input.is_action_pressed("scroll_down%s" % [controller_id]): @@ -38,27 +44,29 @@ func _physics_process(delta): _simulate_stop_scroll(MOUSE_BUTTON_WHEEL_DOWN) -func get_id() -> int: - return controller_id - - func _input(event: InputEvent) -> void: if controller_id != -1: if event.is_action_pressed("select%s" % [controller_id]): - _simulate_mouse_click() + if elapsed_time - last_click <= DOUBLE_CLICK_THRESHOLD: + _simulate_mouse_click(true) + else: + _simulate_mouse_click(false) + last_click = elapsed_time -func _simulate_mouse_click(): +func _simulate_mouse_click(double_click: bool): var click_pos = get_viewport().get_screen_transform() * position var press = InputEventMouseButton.new() press.button_index = MOUSE_BUTTON_LEFT + press.double_click = double_click press.position = click_pos press.pressed = true Input.parse_input_event(press) var release = InputEventMouseButton.new() release.button_index = MOUSE_BUTTON_LEFT + release.double_click = double_click release.position = click_pos release.pressed = false Input.parse_input_event(release) From 3aadf46e65405a62139c52c889820e6d9e238ed5 Mon Sep 17 00:00:00 2001 From: jyatch Date: Mon, 1 Dec 2025 10:26:21 -0500 Subject: [PATCH 5/6] double click update --- CogsPartyLauncher/scripts/player_cursor.gd | 9 +++++---- CogsPartyLauncher/scripts/player_select_menu.gd | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CogsPartyLauncher/scripts/player_cursor.gd b/CogsPartyLauncher/scripts/player_cursor.gd index 875a190..9a63bb8 100644 --- a/CogsPartyLauncher/scripts/player_cursor.gd +++ b/CogsPartyLauncher/scripts/player_cursor.gd @@ -47,10 +47,11 @@ func _physics_process(delta): func _input(event: InputEvent) -> void: if controller_id != -1: if event.is_action_pressed("select%s" % [controller_id]): - if elapsed_time - last_click <= DOUBLE_CLICK_THRESHOLD: - _simulate_mouse_click(true) - else: - _simulate_mouse_click(false) + if elapsed_time - last_click <= DOUBLE_CLICK_THRESHOLD: + _simulate_mouse_click(true) + last_click = 0 + else: + _simulate_mouse_click(false) last_click = elapsed_time diff --git a/CogsPartyLauncher/scripts/player_select_menu.gd b/CogsPartyLauncher/scripts/player_select_menu.gd index 0292560..f71f38f 100644 --- a/CogsPartyLauncher/scripts/player_select_menu.gd +++ b/CogsPartyLauncher/scripts/player_select_menu.gd @@ -31,6 +31,7 @@ func _ready(): _update_add_player_button() _get_non_ui_controls() + for device in Input.get_connected_joypads(): _add_controls(device) _on_add_player_button_pressed() From d17ab73a269b4f3995ae9b66a53344d13cf1ef2e Mon Sep 17 00:00:00 2001 From: jyatch Date: Wed, 17 Dec 2025 07:20:11 -0500 Subject: [PATCH 6/6] made the file dialog larger --- CogsPartyLauncher/scenes/main.tscn | 8 ++++---- CogsPartyLauncher/scripts/main_menu.gd | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CogsPartyLauncher/scenes/main.tscn b/CogsPartyLauncher/scenes/main.tscn index ae5c5bc..16528f6 100644 --- a/CogsPartyLauncher/scenes/main.tscn +++ b/CogsPartyLauncher/scenes/main.tscn @@ -450,7 +450,7 @@ file_mode = 2 access = 2 [node name="BottomBorder" type="StaticBody2D" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer/GamesFolderSelectButton/GamesFolderSelectFileDialog"] -position = Vector2(599, 562) +position = Vector2(599, 638) [node name="CollisionShape2D" type="CollisionShape2D" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer/GamesFolderSelectButton/GamesFolderSelectFileDialog/BottomBorder"] shape = SubResource("WorldBoundaryShape2D_yc10j") @@ -464,17 +464,17 @@ rotation = 3.1415927 shape = SubResource("WorldBoundaryShape2D_jscy8") [node name="RightBorder" type="StaticBody2D" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer/GamesFolderSelectButton/GamesFolderSelectFileDialog"] -position = Vector2(966, 288) +position = Vector2(1115, 288) rotation = -1.5707964 [node name="CollisionShape2D" type="CollisionShape2D" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer/GamesFolderSelectButton/GamesFolderSelectFileDialog/RightBorder"] shape = SubResource("WorldBoundaryShape2D_pm3ni") -[node name="StaticBody2D" type="StaticBody2D" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer/GamesFolderSelectButton/GamesFolderSelectFileDialog"] +[node name="LeftBorder" type="StaticBody2D" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer/GamesFolderSelectButton/GamesFolderSelectFileDialog"] position = Vector2(-23, 282) rotation = 1.5707964 -[node name="CollisionShape2D" type="CollisionShape2D" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer/GamesFolderSelectButton/GamesFolderSelectFileDialog/StaticBody2D"] +[node name="CollisionShape2D" type="CollisionShape2D" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer/GamesFolderSelectButton/GamesFolderSelectFileDialog/LeftBorder"] shape = SubResource("WorldBoundaryShape2D_y6deb") [node name="GamesFolderLabel" type="Label" parent="Menus/MainMenu/VBoxContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/MarginContainer"] diff --git a/CogsPartyLauncher/scripts/main_menu.gd b/CogsPartyLauncher/scripts/main_menu.gd index 895adec..74282d1 100644 --- a/CogsPartyLauncher/scripts/main_menu.gd +++ b/CogsPartyLauncher/scripts/main_menu.gd @@ -66,7 +66,9 @@ func _on_refresh_games_button_pressed(): func _on_games_folder_select_pressed(): - games_folder_select_file_dialog.popup_centered_ratio() + # NOTE: if you change this, you will also need to adjust the WorldBorders containing the cursors + # under the GamesFolderSelectFileDialog + games_folder_select_file_dialog.popup_centered_ratio(0.93) func _on_games_folder_selected(folder: String):