feat: Implement cycle timer toggle, refactor continuous input, and improve movement synchronization.
This commit is contained in:
+27
-11
@@ -32,6 +32,8 @@ extends Control
|
||||
@onready var duration_text_label = $LobbyPanel/TopBar/SettingsSection/DurationTextLabel
|
||||
@onready var random_spawn_check = $LobbyPanel/TopBar/SettingsSection/RandomSpawnCheck
|
||||
@onready var random_spawn_label = $LobbyPanel/TopBar/SettingsSection/RandomSpawnLabel
|
||||
@onready var enable_timer_check = $LobbyPanel/TopBar/SettingsSection/EnableTimerCheck
|
||||
@onready var enable_timer_label = $LobbyPanel/TopBar/SettingsSection/EnableTimerLabel
|
||||
|
||||
# UI References - Player Slots
|
||||
@onready var players_container = $LobbyPanel/PlayersContainer
|
||||
@@ -112,6 +114,7 @@ func _ready():
|
||||
copy_id_btn.pressed.connect(_on_copy_id_pressed)
|
||||
duration_option.item_selected.connect(_on_duration_selected)
|
||||
random_spawn_check.toggled.connect(_on_random_spawn_toggled)
|
||||
enable_timer_check.toggled.connect(_on_enable_timer_toggled)
|
||||
area_left_btn.pressed.connect(func(): LobbyManager.cycle_area(-1))
|
||||
area_right_btn.pressed.connect(func(): LobbyManager.cycle_area(1))
|
||||
leave_btn.pressed.connect(_on_leave_pressed)
|
||||
@@ -129,6 +132,7 @@ func _ready():
|
||||
LobbyManager.game_starting.connect(_on_game_starting)
|
||||
LobbyManager.match_duration_changed.connect(_on_match_duration_changed)
|
||||
LobbyManager.randomize_spawn_changed.connect(_on_randomize_spawn_changed)
|
||||
LobbyManager.enable_cycle_timer_changed.connect(_on_enable_cycle_timer_changed)
|
||||
LobbyManager.character_changed.connect(_on_character_changed)
|
||||
LobbyManager.area_changed.connect(_on_area_changed)
|
||||
LobbyManager.player_list_changed.connect(_update_player_slots)
|
||||
@@ -269,10 +273,11 @@ func _on_duration_selected(index: int) -> void:
|
||||
if index >= 0 and index < durations.size():
|
||||
LobbyManager.set_match_duration(durations[index])
|
||||
|
||||
func _on_random_spawn_toggled(enabled: bool) -> void:
|
||||
if not LobbyManager.is_host:
|
||||
return
|
||||
LobbyManager.set_randomize_spawn(enabled)
|
||||
func _on_random_spawn_toggled(toggled_on):
|
||||
LobbyManager.set_randomize_spawn(toggled_on)
|
||||
|
||||
func _on_enable_timer_toggled(toggled_on):
|
||||
LobbyManager.set_enable_cycle_timer(toggled_on)
|
||||
|
||||
func _update_random_spawn_label(enabled: bool) -> void:
|
||||
if random_spawn_label:
|
||||
@@ -328,14 +333,17 @@ func _on_room_joined(room_data: Dictionary) -> void:
|
||||
# Duration: host sees dropdown, clients see text
|
||||
duration_option.visible = is_host
|
||||
duration_text_label.visible = not is_host
|
||||
if not is_host:
|
||||
_update_duration_text_label(LobbyManager.get_match_duration())
|
||||
|
||||
# Random spawn: host sees checkbox, clients see label
|
||||
random_spawn_check.visible = is_host
|
||||
random_spawn_label.visible = not is_host
|
||||
random_spawn_check.button_pressed = LobbyManager.get_randomize_spawn()
|
||||
_update_random_spawn_label(LobbyManager.get_randomize_spawn())
|
||||
|
||||
enable_timer_check.visible = is_host
|
||||
enable_timer_label.visible = not is_host
|
||||
|
||||
# Update values from LobbyManager
|
||||
_on_match_duration_changed(LobbyManager.match_duration)
|
||||
_on_randomize_spawn_changed(LobbyManager.randomize_spawn)
|
||||
_on_enable_cycle_timer_changed(LobbyManager.enable_cycle_timer)
|
||||
|
||||
# Area selector: only host can interact
|
||||
area_left_btn.disabled = not is_host
|
||||
@@ -378,8 +386,16 @@ func _on_match_duration_changed(duration_seconds: int) -> void:
|
||||
_update_duration_text_label(duration_seconds)
|
||||
|
||||
func _on_randomize_spawn_changed(enabled: bool) -> void:
|
||||
if not LobbyManager.is_host:
|
||||
_update_random_spawn_label(enabled)
|
||||
if random_spawn_check:
|
||||
random_spawn_check.set_pressed_no_signal(enabled)
|
||||
if random_spawn_label:
|
||||
random_spawn_label.text = "Random \u2713" if enabled else "Random \u2717"
|
||||
|
||||
func _on_enable_cycle_timer_changed(enabled: bool) -> void:
|
||||
if enable_timer_check:
|
||||
enable_timer_check.set_pressed_no_signal(enabled)
|
||||
if enable_timer_label:
|
||||
enable_timer_label.text = "Timer \u2713" if enabled else "Timer \u2717"
|
||||
|
||||
func _on_character_changed(_player_id: int, _character_name: String) -> void:
|
||||
_update_player_slots()
|
||||
|
||||
@@ -296,6 +296,23 @@ theme_override_colors/font_color = Color(0.647, 0.996, 0.224, 1)
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "Random ✓"
|
||||
|
||||
[node name="TimerSpacer" type="Control" parent="LobbyPanel/TopBar/SettingsSection"]
|
||||
custom_minimum_size = Vector2(15, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="EnableTimerCheck" type="CheckButton" parent="LobbyPanel/TopBar/SettingsSection"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 11
|
||||
button_pressed = true
|
||||
text = "Enable Timer"
|
||||
|
||||
[node name="EnableTimerLabel" type="Label" parent="LobbyPanel/TopBar/SettingsSection"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.647, 0.996, 0.224, 1)
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "Timer ✓"
|
||||
|
||||
[node name="HostBanner" type="PanelContainer" parent="LobbyPanel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
|
||||
+12
-5
@@ -771,7 +771,7 @@ func start_movement_along_path(path: Array, clear_visual: bool = true):
|
||||
target_position = Vector2i(path[-1].x, path[-1].y)
|
||||
|
||||
var tween = create_tween()
|
||||
tween.set_trans(Tween.TRANS_CUBIC)
|
||||
tween.set_trans(Tween.TRANS_LINEAR)
|
||||
tween.set_ease(Tween.EASE_IN_OUT)
|
||||
|
||||
for point in path:
|
||||
@@ -793,6 +793,10 @@ func start_movement_along_path(path: Array, clear_visual: bool = true):
|
||||
if clear_visual:
|
||||
enhanced_gridmap.clear_path_visualization()
|
||||
|
||||
# Check for buffered input
|
||||
if movement_manager and movement_manager.has_method("_on_movement_finished"):
|
||||
movement_manager._on_movement_finished()
|
||||
|
||||
# Only restore UI state if this is a human player
|
||||
if not (is_bot or is_in_group("Bots")):
|
||||
# Restore movement range highlights if it was the player's turn
|
||||
@@ -1075,8 +1079,9 @@ func force_action_state_none():
|
||||
var main = get_tree().get_root().get_node_or_null("Main")
|
||||
if main and main.ui_manager:
|
||||
main.ui_manager.current_action_state = main.ui_manager.ActionState.NONE
|
||||
action_manager.clear_highlights()
|
||||
action_manager.clear_playerboard_highlights()
|
||||
if action_manager:
|
||||
action_manager.clear_highlights()
|
||||
action_manager.clear_playerboard_highlights()
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
@@ -1214,10 +1219,12 @@ func highlight_occupied_playerboard_slots():
|
||||
action_manager.highlight_occupied_playerboard_slots()
|
||||
|
||||
func clear_highlights():
|
||||
action_manager.clear_highlights()
|
||||
if action_manager:
|
||||
action_manager.clear_highlights()
|
||||
|
||||
func clear_playerboard_highlights():
|
||||
action_manager.clear_playerboard_highlights()
|
||||
if action_manager:
|
||||
action_manager.clear_playerboard_highlights()
|
||||
|
||||
func rotate_towards_target(target_pos: Vector2i):
|
||||
movement_manager.rotate_towards_target(target_pos)
|
||||
|
||||
Reference in New Issue
Block a user