This commit is contained in:
2026-01-28 02:29:43 +08:00
parent d71f5d67e3
commit 6949e20a1f
13 changed files with 285 additions and 100 deletions
+57
View File
@@ -64,6 +64,10 @@ var admin_panel_instance: Control
# Store current match ID for copy function
var current_match_id: String = ""
# Scarcity Controls (Injected via code since we can't edit scene)
var scarcity_option: OptionButton
var scarcity_label: Label
func _ready():
# Check if user is authenticated
if not AuthManager.is_logged_in():
@@ -73,6 +77,9 @@ func _ready():
# Load character textures
_load_character_textures()
# Inject Scarcity UI
call_deferred("_setup_scarcity_ui")
# Get player slot references
_setup_player_slots()
@@ -135,6 +142,7 @@ func _ready():
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.scarcity_mode_changed.connect(_on_scarcity_mode_changed)
LobbyManager.player_list_changed.connect(_update_player_slots)
# Connect NakamaManager signals
@@ -158,6 +166,35 @@ func _load_character_textures() -> void:
else:
print("[Lobby] Character texture not found: ", tex_path)
func _setup_scarcity_ui() -> void:
"""Inject scarcity controls into SettingsSection."""
if not duration_option: return
var settings_section = duration_option.get_parent()
if not settings_section: return
# Create OptionButton for Host
scarcity_option = OptionButton.new()
scarcity_option.add_item("Normal") # ID 0
scarcity_option.add_item("Aggressive") # ID 1
scarcity_option.add_item("Chaos") # ID 2
scarcity_option.selected = 0
scarcity_option.tooltip_text = "Select Scarcity Mode"
scarcity_option.name = "ScarcityOption"
scarcity_option.item_selected.connect(_on_scarcity_selected)
# Create Label for Clients
scarcity_label = Label.new()
scarcity_label.text = "Normal"
scarcity_label.name = "ScarcityLabel"
# Copy style from duration_text_label if possible, usually fine default
# Add to scene
settings_section.add_child(scarcity_option)
settings_section.add_child(scarcity_label)
# Initial visibility update will handle showing correct one
func _setup_player_slots() -> void:
"""Get references to all player slot nodes."""
player_slots.clear()
@@ -279,6 +316,21 @@ func _on_random_spawn_toggled(toggled_on):
func _on_enable_timer_toggled(toggled_on):
LobbyManager.set_enable_cycle_timer(toggled_on)
func _on_scarcity_selected(index: int) -> void:
if not LobbyManager.is_host: return
var mode = scarcity_option.get_item_text(index)
LobbyManager.set_scarcity_mode(mode)
func _on_scarcity_mode_changed(mode: String) -> void:
if scarcity_option:
for i in range(scarcity_option.item_count):
if scarcity_option.get_item_text(i) == mode:
scarcity_option.selected = i
break
if scarcity_label:
scarcity_label.text = mode
func _update_random_spawn_label(enabled: bool) -> void:
if random_spawn_label:
random_spawn_label.text = "Random ✓" if enabled else "Random ✗"
@@ -345,6 +397,11 @@ func _on_room_joined(room_data: Dictionary) -> void:
_on_randomize_spawn_changed(LobbyManager.randomize_spawn)
_on_enable_cycle_timer_changed(LobbyManager.enable_cycle_timer)
# Scarcity Update
if scarcity_option: scarcity_option.visible = is_host
if scarcity_label: scarcity_label.visible = not is_host
_on_scarcity_mode_changed(LobbyManager.scarcity_mode)
# Area selector: only host can interact
area_left_btn.disabled = not is_host
area_right_btn.disabled = not is_host