diff --git a/scenes/main.tscn b/scenes/main.tscn index 82eb004..28f378e 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -9518,14 +9518,10 @@ text = "seconds" horizontal_alignment = 1 [node name="GlobalMatchTimer" type="PanelContainer" parent="." unique_id=1714357974] -anchors_preset = 5 -anchor_left = 0.5 -anchor_right = 0.5 -offset_left = -80.0 -offset_top = 24.0 -offset_right = 80.0 -offset_bottom = 74.0 -grow_horizontal = 2 +offset_left = 48.0 +offset_top = 64.0 +offset_right = 208.0 +offset_bottom = 114.0 [node name="VBox" type="VBoxContainer" parent="GlobalMatchTimer" unique_id=24429117] layout_mode = 2 @@ -9712,7 +9708,6 @@ layout_mode = 2 text = "Back" [node name="TouchControls" type="CanvasLayer" parent="." unique_id=1390485948] -layer = 10 script = ExtResource("touch_manager") [node name="TouchControls" type="Control" parent="TouchControls" unique_id=1539594058] @@ -9726,6 +9721,7 @@ grow_vertical = 2 mouse_filter = 2 [node name="VirtualJoystick" type="Control" parent="TouchControls/TouchControls" unique_id=1983608919] +visible = false layout_mode = 1 anchors_preset = 2 anchor_top = 1.0 @@ -9737,79 +9733,50 @@ offset_bottom = -120.0 grow_vertical = 0 script = ExtResource("virtual_joystick") -[node name="GrabBtn" type="Button" parent="TouchControls/TouchControls" unique_id=914810452] -layout_mode = 1 -anchors_preset = 3 -anchor_left = 1.0 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = -303.0 -offset_top = -249.0 -offset_right = -233.0 -offset_bottom = -179.0 -grow_horizontal = 0 -grow_vertical = 0 -focus_mode = 0 -icon = ExtResource("25_qkpxi") -flat = true -expand_icon = true +[node name="ActionsBtn" type="HBoxContainer" parent="TouchControls/TouchControls" unique_id=1921269452] +layout_mode = 0 +offset_left = 24.0 +offset_top = 58.0 +offset_right = 231.0 +offset_bottom = 123.25 +theme_override_constants/separation = 15 -[node name="PutBtn" type="Button" parent="TouchControls/TouchControls" unique_id=1027790362] +[node name="PutBtn" type="Button" parent="TouchControls/TouchControls/ActionsBtn" unique_id=1027790362] visible = false -layout_mode = 1 -anchors_preset = 3 -anchor_left = 1.0 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = -223.0 -offset_top = -169.0 -offset_right = -153.0 -offset_bottom = -99.0 -grow_horizontal = 0 -grow_vertical = 0 +layout_mode = 2 +size_flags_horizontal = 3 focus_mode = 0 icon = ExtResource("26_5q0nq") flat = true +icon_alignment = 1 expand_icon = true -[node name="SpecialBtn" type="Button" parent="TouchControls/TouchControls" unique_id=1380511463] -layout_mode = 1 -anchors_preset = 3 -anchor_left = 1.0 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = -223.0 -offset_top = -323.0 -offset_right = -153.0 -offset_bottom = -253.0 -grow_horizontal = 0 -grow_vertical = 0 +[node name="AttackModeBtn" type="Button" parent="TouchControls/TouchControls/ActionsBtn" unique_id=1380511463] +layout_mode = 2 +size_flags_horizontal = 3 focus_mode = 0 icon = ExtResource("27_dgi5k") flat = true +icon_alignment = 1 expand_icon = true -[node name="SpawnBoostBtn" type="Button" parent="TouchControls/TouchControls" unique_id=1566173505] -layout_mode = 1 -anchors_preset = 3 -anchor_left = 1.0 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = -143.0 -offset_top = -241.0 -offset_right = -73.0 -offset_bottom = -171.0 -grow_horizontal = 0 -grow_vertical = 0 +[node name="SpawnBoostBtn" type="Button" parent="TouchControls/TouchControls/ActionsBtn" unique_id=1566173505] +layout_mode = 2 +size_flags_horizontal = 3 icon = ExtResource("28_j8jky") flat = true icon_alignment = 1 expand_icon = true +[node name="GrabBtn" type="Button" parent="TouchControls/TouchControls/ActionsBtn" unique_id=914810452] +layout_mode = 2 +size_flags_horizontal = 3 +focus_mode = 0 +icon = ExtResource("25_qkpxi") +flat = true +icon_alignment = 1 +expand_icon = true + [node name="SettingsBtn" type="Button" parent="TouchControls/TouchControls" unique_id=1964422444] layout_mode = 1 anchors_preset = 3 @@ -9817,10 +9784,10 @@ anchor_left = 1.0 anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 -offset_left = -1337.0 -offset_top = -83.0 -offset_right = -1287.0 -offset_bottom = -33.0 +offset_left = -70.0 +offset_top = -80.0 +offset_right = -22.0 +offset_bottom = -32.0 grow_horizontal = 0 grow_vertical = 0 text = "⚙" diff --git a/scripts/managers/player_input_manager.gd b/scripts/managers/player_input_manager.gd index 01cd0e3..a431220 100644 --- a/scripts/managers/player_input_manager.gd +++ b/scripts/managers/player_input_manager.gd @@ -102,12 +102,15 @@ func handle_unhandled_input(event): # player.auto_put_item() KEY_Q: if player.powerup_manager: + # Attack Mode (formerly Special) player.powerup_manager.use_special_effect() - KEY_E: # Swapped to E per request + KEY_E: if player.powerup_manager: + # Spawn Boost if player.powerup_manager.has_method("spawn_boost_reward"): player.powerup_manager.spawn_boost_reward() else: + # Fallback if method missing player.powerup_manager.use_special_effect() # Handle spawn point selection if not yet selected diff --git a/scripts/managers/touch_controls.gd b/scripts/managers/touch_controls.gd index 1e2e618..bfe96e6 100644 --- a/scripts/managers/touch_controls.gd +++ b/scripts/managers/touch_controls.gd @@ -4,13 +4,14 @@ extends CanvasLayer signal grab_pressed signal put_pressed -signal special_pressed +signal attack_mode_pressed # Touch control nodes var virtual_joystick: Control +var actions_container: Control # New container var grab_button: Button var put_button: Button -var special_button: Button +var attack_mode_button: Button # Renamed from special_button var spawn_boost_button: Button var settings_button: Button @@ -19,12 +20,12 @@ const CONFIG_PATH = "user://touch_controls_settings.cfg" var button_size: float = 70.0 var button_opacity: float = 0.7 var joystick_enabled: bool = true -var touch_buttons_enabled: bool = true # Master toggle for action buttons (grab, put, special) +var touch_buttons_enabled: bool = true # Master toggle for action buttons var joystick_position: Vector2 = Vector2(120, -120) # Relative to bottom-left var button_positions: Dictionary = { "grab": Vector2(-200, -240), # Relative to bottom-right "put": Vector2(-120, -160), - "special": Vector2(-200, -80), + "attack_mode": Vector2(-200, -80), # Renamed "spawn_boost": Vector2(-120, -80) } var button_scale: float = 1.0 @@ -111,13 +112,33 @@ func _create_touch_ui(): if not virtual_joystick.direction_changed.is_connected(_on_joystick_direction): virtual_joystick.direction_changed.connect(_on_joystick_direction) - # Helper to find or create button logic moved to function _find_or_create_action_button + # --- Actions Container --- + actions_container = container.get_node_or_null("ActionsBtn") + if not actions_container: + actions_container = Control.new() + actions_container.name = "ActionsBtn" + actions_container.set_anchors_preset(Control.PRESET_FULL_RECT) # Or appropriate preset + actions_container.mouse_filter = Control.MOUSE_FILTER_PASS + container.add_child(actions_container) + else: + print("[TouchControls] Found existing ActionsBtn container") + + # Create action buttons (parented to actions_container if possible, or use logic) + # User Request: "move those button to ActionsBtn children" - # Create action buttons (bottom-right) - grab_button = _find_or_create_action_button(container, "Grab", "👋", button_positions.grab) - put_button = _find_or_create_action_button(container, "Put", "📦", button_positions.put) - special_button = _find_or_create_action_button(container, "Special", "⚡", button_positions.special) - spawn_boost_button = _find_or_create_action_button(container, "SpawnBoost", "🚀", button_positions.spawn_boost) + attack_mode_button = _find_or_create_action_button(actions_container, "AttackMode", "⚡", button_positions.attack_mode) # Renamed + spawn_boost_button = _find_or_create_action_button(actions_container, "SpawnBoost", "🚀", button_positions.spawn_boost) + grab_button = _find_or_create_action_button(actions_container, "Grab", "👋", button_positions.grab) + put_button = _find_or_create_action_button(actions_container, "Put", "📦", button_positions.put) + + # Order: AttackMode, SpawnBoost, Grab + if attack_mode_button: actions_container.move_child(attack_mode_button, 0) + if spawn_boost_button: actions_container.move_child(spawn_boost_button, 1) + if grab_button: actions_container.move_child(grab_button, 2) + + # Hide Put Button + if put_button: + put_button.visible = false # Create settings button (top-right corner) settings_button = container.get_node_or_null("SettingsBtn") @@ -222,6 +243,13 @@ 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") + match button_name: + "Grab": existing_lbl.text = "Space" + "Put": existing_lbl.text = "" + "AttackMode": existing_lbl.text = "Q" + "SpawnBoost": existing_lbl.text = "E" return # Add Keyboard Shortcut Label @@ -238,7 +266,7 @@ func _ensure_shortcut_label(btn: Button, button_name: String): match button_name: "Grab": shortcut_lbl.text = "Space" "Put": shortcut_lbl.text = "" # Disabled shortcut - "Special": shortcut_lbl.text = "Q" + "AttackMode": shortcut_lbl.text = "Q" "SpawnBoost": shortcut_lbl.text = "E" btn.add_child(shortcut_lbl) @@ -257,7 +285,7 @@ func _on_button_pressed(button_name: String): match button_name: "Grab": btn = grab_button "Put": btn = put_button - "Special": btn = special_button + "AttackMode": btn = attack_mode_button "SpawnBoost": btn = spawn_boost_button if btn: @@ -274,17 +302,18 @@ func _on_button_pressed(button_name: String): emit_signal("put_pressed") if local_player.has_method("auto_put_item"): local_player.auto_put_item() - "Special": - emit_signal("special_pressed") + "AttackMode": + emit_signal("attack_mode_pressed") # Also special? + # emit_signal("special_pressed") # Keep legacy signal? var powerup_mgr = local_player.get_node_or_null("PowerUpManager") if powerup_mgr: # Require Full Boost to Activate (User Request: "Connect to boost bar") var can_use = powerup_mgr.can_use_special() var boost_val = powerup_mgr.current_boost - print("[TouchControls] Special Pressed. Boost: %s, CanUse: %s" % [boost_val, can_use]) + print("[TouchControls] AttackMode Pressed. Boost: %s, CanUse: %s" % [boost_val, can_use]) if can_use: - powerup_mgr.use_special_effect() # Sets is_attack_mode=true, Does NOT consume boost yet + powerup_mgr.use_special_effect() # Sets is_attack_mode=true else: # Optional feedback for not ready? pass @@ -298,9 +327,10 @@ func _on_button_pressed(button_name: String): print("[TouchControls] SpawnBoost Pressed. Boost: %s, CanUse: %s" % [boost_val, can_use]) if can_use: # Check if boost is full + # Same usage logic, but specific action if local_player.special_tiles_manager and local_player.special_tiles_manager.has_method("spawn_powerups_around"): local_player.special_tiles_manager.spawn_powerups_around(local_player.current_position) - powerup_mgr.reset_boost() # Consume the boost manually since we bypassed use_special_effect + powerup_mgr.reset_boost() # Consume the boost manually else: print("[TouchControls] PowerUpManager missing on player") @@ -309,7 +339,7 @@ func _on_button_released(button_name: String): match button_name: "Grab": btn = grab_button "Put": btn = put_button - "Special": btn = special_button + "AttackMode": btn = attack_mode_button "SpawnBoost": btn = spawn_boost_button if btn: @@ -348,9 +378,12 @@ func _load_settings(): # Load button positions var grab_pos = config.get_value("touch_controls", "grab_position", Vector2(-200, -240)) var put_pos = config.get_value("touch_controls", "put_position", Vector2(-120, -160)) - var special_pos = config.get_value("touch_controls", "special_position", Vector2(-200, -80)) + var attack_mode_pos = config.get_value("touch_controls", "attack_mode_position", Vector2(-200, -80)) # Changed key from special + if config.has_section_key("touch_controls", "special_position"): # Migrate legacy + attack_mode_pos = config.get_value("touch_controls", "special_position", Vector2(-200, -80)) + var spawn_boost_pos = config.get_value("touch_controls", "spawn_boost_position", Vector2(-120, -80)) - button_positions = {"grab": grab_pos, "put": put_pos, "special": special_pos, "spawn_boost": spawn_boost_pos} + button_positions = {"grab": grab_pos, "put": put_pos, "attack_mode": attack_mode_pos, "spawn_boost": spawn_boost_pos} # Apply loaded settings _apply_settings() @@ -367,7 +400,7 @@ func _save_settings(): config.set_value("touch_controls", "touch_buttons_enabled", touch_buttons_enabled) config.set_value("touch_controls", "grab_position", button_positions.grab) config.set_value("touch_controls", "put_position", button_positions.put) - config.set_value("touch_controls", "special_position", button_positions.special) + config.set_value("touch_controls", "attack_mode_position", button_positions.attack_mode) # Renamed config.set_value("touch_controls", "spawn_boost_position", button_positions.spawn_boost) var err = config.save(CONFIG_PATH) @@ -393,34 +426,34 @@ func _apply_settings(): grab_button.visible = buttons_visible grab_button.scale = Vector2(button_scale, button_scale) # Use offsets for anchored controls, not position - grab_button.offset_left = button_positions.grab.x - grab_button.offset_top = button_positions.grab.y - grab_button.offset_right = button_positions.grab.x + button_size - grab_button.offset_bottom = button_positions.grab.y + button_size + # grab_button.offset_left = button_positions.grab.x + # grab_button.offset_top = button_positions.grab.y + # grab_button.offset_right = button_positions.grab.x + button_size + # grab_button.offset_bottom = button_positions.grab.y + button_size if put_button: - put_button.visible = buttons_visible - put_button.scale = Vector2(button_scale, button_scale) - put_button.offset_left = button_positions.put.x - put_button.offset_top = button_positions.put.y - put_button.offset_right = button_positions.put.x + button_size - put_button.offset_bottom = button_positions.put.y + button_size + put_button.visible = false # Always INTENTIONALLY HIDDEN per request + # put_button.scale = Vector2(button_scale, button_scale) + # put_button.offset_left = button_positions.put.x + # put_button.offset_top = button_positions.put.y + # put_button.offset_right = button_positions.put.x + button_size + # put_button.offset_bottom = button_positions.put.y + button_size - if special_button: - special_button.visible = buttons_visible - special_button.scale = Vector2(button_scale, button_scale) - special_button.offset_left = button_positions.special.x - special_button.offset_top = button_positions.special.y - special_button.offset_right = button_positions.special.x + button_size - special_button.offset_bottom = button_positions.special.y + button_size + if attack_mode_button: + attack_mode_button.visible = buttons_visible + attack_mode_button.scale = Vector2(button_scale, button_scale) + # attack_mode_button.offset_left = button_positions.attack_mode.x + # attack_mode_button.offset_top = button_positions.attack_mode.y + # attack_mode_button.offset_right = button_positions.attack_mode.x + button_size + # attack_mode_button.offset_bottom = button_positions.attack_mode.y + button_size if spawn_boost_button: spawn_boost_button.visible = buttons_visible spawn_boost_button.scale = Vector2(button_scale, button_scale) - spawn_boost_button.offset_left = button_positions.spawn_boost.x - spawn_boost_button.offset_top = button_positions.spawn_boost.y - spawn_boost_button.offset_right = button_positions.spawn_boost.x + button_size - spawn_boost_button.offset_bottom = button_positions.spawn_boost.y + button_size + # spawn_boost_button.offset_left = button_positions.spawn_boost.x + # spawn_boost_button.offset_top = button_positions.spawn_boost.y + # spawn_boost_button.offset_right = button_positions.spawn_boost.x + button_size + # spawn_boost_button.offset_bottom = button_positions.spawn_boost.y + button_size # Force layer update visible = true @@ -430,7 +463,7 @@ func _apply_settings(): # ============================================================================= func set_touch_buttons_enabled(enabled: bool): - """Enable or disable all action buttons (grab, put, special).""" + """Enable or disable all action buttons (grab, put, attack_mode).""" touch_buttons_enabled = enabled _apply_settings() @@ -447,31 +480,8 @@ func set_button_scale(p_scale: float): func set_button_position(button_name: String, new_position: Vector2): """Update position of a specific button.""" button_positions[button_name] = new_position - match button_name: - "grab": - if grab_button: - grab_button.offset_left = new_position.x - grab_button.offset_top = new_position.y - grab_button.offset_right = new_position.x + button_size - grab_button.offset_bottom = new_position.y + button_size - "put": - if put_button: - put_button.offset_left = new_position.x - put_button.offset_top = new_position.y - put_button.offset_right = new_position.x + button_size - put_button.offset_bottom = new_position.y + button_size - "special": - if special_button: - special_button.offset_left = new_position.x - special_button.offset_top = new_position.y - special_button.offset_right = new_position.x + button_size - special_button.offset_bottom = new_position.y + button_size - "spawn_boost": - if spawn_boost_button: - spawn_boost_button.offset_left = new_position.x - spawn_boost_button.offset_top = new_position.y - spawn_boost_button.offset_right = new_position.x + button_size - spawn_boost_button.offset_bottom = new_position.y + button_size + # Logic to update offsets removed per request (Scene Controlled) + # Only saving the data for persistence if user eventually wants it back func get_button_positions() -> Dictionary: """Get current button positions for settings UI.""" @@ -498,7 +508,7 @@ func _on_boost_points_changed(current_points: int, max_points: int): # User Request: Disable Special & SpawnBoost if < 100% var is_full = current_points >= (max_points - 1) # Tolerance - _update_boost_button_state(special_button, is_full) + _update_boost_button_state(attack_mode_button, is_full) _update_boost_button_state(spawn_boost_button, is_full) func _update_boost_button_state(btn: Button, is_enabled: bool):