Add settings menu to control audio and return to main menu

This commit is contained in:
Ben Calegari 2026-07-28 22:01:28 -07:00
parent c88d3fc625
commit 0b7bc936ef
13 changed files with 697 additions and 22 deletions

View file

@ -139,10 +139,11 @@ namespace TD.Gameplay
// Escape: clear selection. Allowed during placement mode too — Escape never
// means anything else here, and clearing selection during placement is fine.
// Suppressed while chat (or any HUD text field) has focus, since Escape there
// means "cancel typing" and should not also clear the unit selection.
// Suppressed while chat (or any HUD text field) has focus or the gear menu is
// open, since Escape there means "cancel typing" / "back out of the menu" and
// should not also clear the unit selection.
if (keyboard != null && keyboard.escapeKey.wasPressedThisFrame
&& !HUDController.IsTextInputActive)
&& !HUDController.IsUiCapturingInput)
{
SelectionState.Instance?.Clear();
}
@ -153,7 +154,7 @@ namespace TD.Gameplay
// Tab: select the builder, or (if already selected) recenter the camera on it.
if (keyboard != null && keyboard.tabKey.wasPressedThisFrame
&& !HUDController.IsTextInputActive)
&& !HUDController.IsUiCapturingInput)
{
var selection = SelectionState.Instance;
if (selection != null && selection.IsSelected(builder))

View file

@ -95,7 +95,7 @@ namespace TD.Gameplay
private void Update()
{
if (!HUDController.IsTextInputActive)
if (!HUDController.IsUiCapturingInput)
ScanHotkeys();
if (activeSlot < 0) return; // idle — nothing to aim

View file

@ -229,9 +229,10 @@ namespace TD.Gameplay
// Keyboard: arrow keys only. WASD is reserved for tower-build hotkeys (the command
// grid) — camera panning is arrow keys plus the mouse edge-pan below. Suppressed
// entirely while the player is typing so arrow keys in chat navigate text instead of
// panning. (Edge-pan below stays active since it's mouse-driven.)
var kb = HUDController.IsTextInputActive ? null : Keyboard.current;
// entirely while the player is typing (so arrow keys in chat navigate text instead
// of panning) or while the gear menu is open. Edge-pan below is mouse-driven and
// gated separately by the pointer-over-HUD check, which the menu overlay satisfies.
var kb = HUDController.IsUiCapturingInput ? null : Keyboard.current;
if (kb != null)
{
if (kb.leftArrowKey.isPressed) dir.x -= 1f;

View file

@ -73,10 +73,11 @@ namespace TD.Gameplay
var keyboard = Keyboard.current;
// Right-click or Escape exits paint mode. (Escape is ignored while a HUD text
// field has focus so it means "cancel typing" there, matching other systems.)
// field has focus or the gear menu is open, so it means "cancel typing" /
// "back out of the menu" there, matching other systems.)
bool escape = keyboard != null
&& keyboard.escapeKey.wasPressedThisFrame
&& !HUDController.IsTextInputActive;
&& !HUDController.IsUiCapturingInput;
if (mouse.rightButton.wasPressedThisFrame || escape)
{
CancelPaint();