feat: Implement initial main game scene with gridmap, environment, and touch control UI elements.
This commit is contained in:
@@ -15,6 +15,7 @@ var attack_mode_button: Button # Renamed from special_button
|
||||
var spawn_boost_button: Button
|
||||
var settings_button: Button
|
||||
var tekton_grab_button: Button
|
||||
@onready var SettingsManager = get_node_or_null("/root/SettingsManager")
|
||||
|
||||
# Settings - persisted to config file
|
||||
const CONFIG_PATH = "user://touch_controls_settings.cfg"
|
||||
@@ -39,6 +40,27 @@ func initialize(p_main: Node3D):
|
||||
main_scene = p_main
|
||||
_create_touch_ui()
|
||||
_load_settings()
|
||||
|
||||
# Connect to remapping signals
|
||||
if SettingsManager and not SettingsManager.control_remapped.is_connected(_on_control_remapped):
|
||||
SettingsManager.control_remapped.connect(_on_control_remapped)
|
||||
|
||||
func _on_control_remapped(_action: String, _key: int):
|
||||
print("[TouchControls] Control remapped: %s. Refreshing labels." % _action)
|
||||
|
||||
# Refresh primary assigned buttons
|
||||
if grab_button: _ensure_shortcut_label(grab_button, "Grab")
|
||||
if put_button: _ensure_shortcut_label(put_button, "Put")
|
||||
if attack_mode_button: _ensure_shortcut_label(attack_mode_button, "AttackMode")
|
||||
if spawn_boost_button: _ensure_shortcut_label(spawn_boost_button, "SpawnBoost")
|
||||
if tekton_grab_button: _ensure_shortcut_label(tekton_grab_button, "TektonGrab")
|
||||
|
||||
# Also check all direct children of actions_container just in case
|
||||
if actions_container:
|
||||
for child in actions_container.get_children():
|
||||
if child is Button:
|
||||
var b_name = child.name.replace("Btn", "")
|
||||
_ensure_shortcut_label(child, b_name)
|
||||
|
||||
func set_player(p_player: Node3D):
|
||||
local_player = p_player
|
||||
@@ -275,16 +297,17 @@ func _style_button(btn: Button, opacity: float):
|
||||
|
||||
func _ensure_shortcut_label(btn: Button, button_name: String):
|
||||
if btn.has_node("ShortcutLabel"):
|
||||
# Update Label content if it exists to match potential remapping
|
||||
var existing_lbl = btn.get_node("ShortcutLabel")
|
||||
var is_sng = LobbyManager.is_game_mode(GameMode.Mode.STOP_N_GO)
|
||||
if not SettingsManager: return
|
||||
|
||||
match button_name:
|
||||
"Grab": existing_lbl.text = "Space" if is_sng else ""
|
||||
"Grab": existing_lbl.text = SettingsManager.get_control_text("grab")
|
||||
"Put": existing_lbl.text = ""
|
||||
"AttackMode": existing_lbl.text = "Q" if is_sng else ""
|
||||
"SpawnBoost": existing_lbl.text = "E" if is_sng else ""
|
||||
"TektonGrab": existing_lbl.text = "G"
|
||||
"AttackMode": existing_lbl.text = SettingsManager.get_control_text("attack_mode")
|
||||
"SpawnBoost": existing_lbl.text = SettingsManager.get_control_text("spawn_boost")
|
||||
"TektonGrab": existing_lbl.text = SettingsManager.get_control_text("tekton_grab")
|
||||
|
||||
print("[TouchControls] Updated %s shortcut label to: %s" % [button_name, existing_lbl.text])
|
||||
|
||||
# Ensure correct placement (Top Right)
|
||||
existing_lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||
@@ -310,11 +333,11 @@ func _ensure_shortcut_label(btn: Button, button_name: String):
|
||||
shortcut_lbl.add_theme_constant_override("outline_size", 4)
|
||||
|
||||
match button_name:
|
||||
"Grab": shortcut_lbl.text = "Space"
|
||||
"Grab": shortcut_lbl.text = SettingsManager.get_control_text("grab") if SettingsManager else "Space"
|
||||
"Put": shortcut_lbl.text = "" # Disabled shortcut
|
||||
"AttackMode": shortcut_lbl.text = "Q"
|
||||
"SpawnBoost": shortcut_lbl.text = "E"
|
||||
"TektonGrab": shortcut_lbl.text = "G"
|
||||
"AttackMode": shortcut_lbl.text = SettingsManager.get_control_text("attack_mode") if SettingsManager else "Q"
|
||||
"SpawnBoost": shortcut_lbl.text = SettingsManager.get_control_text("spawn_boost") if SettingsManager else "E"
|
||||
"TektonGrab": shortcut_lbl.text = SettingsManager.get_control_text("tekton_grab") if SettingsManager else "G"
|
||||
|
||||
btn.add_child(shortcut_lbl)
|
||||
|
||||
@@ -387,14 +410,12 @@ func _on_button_released(button_name: String):
|
||||
tween.tween_property(btn, "scale", Vector2(1.0, 1.0), 0.1)
|
||||
|
||||
func _on_settings_pressed():
|
||||
# Open settings panel in main scene
|
||||
if main_scene:
|
||||
var settings_panel = main_scene.get_node_or_null("SettingsPanel")
|
||||
if settings_panel:
|
||||
settings_panel.visible = true
|
||||
print("[TouchControls] Opening settings panel")
|
||||
else:
|
||||
print("[TouchControls] SettingsPanel not found in main scene")
|
||||
# Toggle pause menu on main scene
|
||||
if main_scene and main_scene.has_method("_toggle_pause_menu"):
|
||||
main_scene._toggle_pause_menu()
|
||||
print("[TouchControls] Toggling pause menu")
|
||||
else:
|
||||
print("[TouchControls] Main scene _toggle_pause_menu method not found")
|
||||
|
||||
func _is_touch_device() -> bool:
|
||||
# Check if running on mobile
|
||||
|
||||
Reference in New Issue
Block a user