feat: Add core player input, movement, and special ability management systems with new UI components.

This commit is contained in:
Yogi Wiguna
2026-03-11 17:40:45 +08:00
parent 18c3dbecd6
commit 650d241a72
6 changed files with 104 additions and 90 deletions
+25 -38
View File
@@ -50,16 +50,13 @@ func _ready():
_setup_btn(2, wall_btn)
_setup_btn(3, ghost_btn)
# All skills available with new logic, but restricted in Stop n Go
if is_restricted:
if wall_btn: wall_btn.visible = false
if freeze_btn: freeze_btn.visible = false
# Re-setup shortcut labels for restricted mode
_update_shortcuts_for_mode(true)
else:
if wall_btn: wall_btn.visible = true
if freeze_btn: freeze_btn.visible = true
_update_shortcuts_for_mode(false)
# Remove mode-based restrictions on visibility for now, as ownership controls visibility
if wall_btn: wall_btn.visible = false
if freeze_btn: freeze_btn.visible = false
if speed_btn: speed_btn.visible = false
if ghost_btn: ghost_btn.visible = false
_update_shortcuts_for_mode(is_restricted)
print("[PowerUpUI] UI Initialization Complete. Mapped %d buttons." % icon_containers.size())
@@ -140,33 +137,16 @@ func _update_shortcuts_for_mode(is_restricted: bool):
var btn = icon_containers[effect_id]
_update_btn_shortcut(effect_id, btn)
func _update_btn_shortcut(effect_id: int, btn: Button):
func _update_btn_shortcut(_effect_id: int, btn: Button):
var sc_lbl = btn.get_node_or_null("ShortcutLabel")
if not sc_lbl: return
var mode = LobbyManager.get_game_mode()
var is_sng = mode == GameMode.Mode.STOP_N_GO
var key_text = ""
# Safety check for SettingsManager (Autoload)
if not SettingsManager:
sc_lbl.text = ""
return
if is_sng:
match effect_id:
0: key_text = SettingsManager.get_control_text("powerup_1")
3: key_text = SettingsManager.get_control_text("powerup_2") # Map P2 to Slot 3 (Ghost) in SNG
_: key_text = ""
else:
match effect_id:
0: key_text = SettingsManager.get_control_text("powerup_1")
2: key_text = SettingsManager.get_control_text("powerup_2")
1: key_text = SettingsManager.get_control_text("powerup_3")
3: key_text = SettingsManager.get_control_text("powerup_4")
sc_lbl.text = key_text
# Show only Shortcut 1 as per single-slot request
sc_lbl.text = "[%s]" % SettingsManager.get_control_text("powerup_1")
func _on_btn_pressed(effect_id: int):
print("[PowerUpUI] Clicked Button %d" % effect_id)
@@ -241,6 +221,10 @@ func _on_powerup_unlocked(effect: int, level: int):
var lvl_lbl = btn.get_node_or_null("LevelLabel")
if lvl_lbl:
lvl_lbl.text = "Lvl %d" % level
# Enforce 1-slot rule by hiding others
if special_manager_ref:
_on_inventory_updated(special_manager_ref.inventory)
else:
print("[PowerUpUI] ERROR: Unlocked Effect %d but no UI button found! Keys: %s" % [effect, icon_containers.keys()])
@@ -261,12 +245,15 @@ func _on_cooldown_updated(effect: int, time_left: float, max_time: float):
btn.modulate = Color.WHITE
func _on_inventory_updated(inventory: Dictionary):
# Update UI icons (Dimmed vs Lit) and Enablement
print("[PowerUpUI] Inventory Updated: ", inventory)
# Update UI icons (Only show ONE active slot as per user request)
print("[PowerUpUI] Inventory Updated Signal Received! Data: ", inventory)
for effect in icon_containers:
if inventory.has(effect):
var has_item = inventory[effect]
var btn = icon_containers[effect]
btn.modulate = Color.WHITE if has_item else Color(0.5, 0.5, 0.5, 0.5)
btn.disabled = !has_item
var has_item = inventory.get(effect, false)
var btn = icon_containers[effect]
# Single slot logic: Only the owned one is visible
btn.visible = has_item
if has_item:
btn.disabled = false # Individual cooldown logic might disable it later
btn.modulate = Color.WHITE
_update_btn_shortcut(effect, btn)