#41: menus and settings at phone scale
On phones the main menu, pause menu, question box, and settings fit the scaled canvas inside the safe area, with buttons and rows at least 44 pt tall (19.5:9 at 1.6x, the iPhone SE at the 1.7 cap, 4:3 iPads). The pause menu puts its buttons in a column beside the rest. Phone settings: Audio, Touch (Interface size, Swap sticks, Camera distance, Haptics, and a short touch-controls guide), Display (3D resolution scale), and Gameplay. The list scrolls by dragging, and a slider only moves after a mostly sideways drag. GameSettings saves the touch settings under [touch] and applies them live (&"touch_controls", the follow camera on phones). A hit buzzes the phone with Haptics on. Desktop menus are unchanged. Test: game/tests/mobile/menus_test.gd. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5392ae09af
commit
0c401171f3
10 changed files with 1139 additions and 46 deletions
|
|
@ -7,6 +7,7 @@ extends RefCounted
|
|||
## boxes, and tabs to match. Labels keep the default look; the HUD sets its own sizes.
|
||||
## sketch() is the hand-drawn theme the in-game panels use instead (the pause menu and its
|
||||
## questions, the workbench and shed shops), to match the HUD's pouch panel (Sketch).
|
||||
## touch_height, inset_to_safe_area, and overlay_rect fit the menus on a phone.
|
||||
|
||||
const TEXT := Color(0.95, 0.93, 0.85)
|
||||
const GOLD := Color(0.95, 0.82, 0.45)
|
||||
|
|
@ -67,6 +68,35 @@ static func sketch() -> Theme:
|
|||
return t
|
||||
|
||||
|
||||
## --- Menus on a phone (MobilePort): touch-sized buttons, inside the safe area ---
|
||||
## The menus (MainMenu, PauseMenu, ConfirmBox, SettingsMenu) fit themselves on a phone when they
|
||||
## open and whenever the canvas changes (the window, or the Interface size); desktop keeps the
|
||||
## layout they're built with.
|
||||
|
||||
## A canvas item's height on a phone: at least the minimum touch target (44 pt,
|
||||
## MobilePort.minimum_target). On desktop, h.
|
||||
static func touch_height(ci: CanvasItem, h: float) -> float:
|
||||
return maxf(h, ceilf(MobilePort.minimum_target(ci))) if MobilePort.active() else h
|
||||
|
||||
|
||||
## A full-screen overlay (a CenterContainer menu, a child of a CanvasLayer) inset to the safe area,
|
||||
## so what it centers sits clear of the notch, the rounded corners, and the home indicator. Its
|
||||
## dim and its input still cover the whole screen (overlay_rect).
|
||||
static func inset_to_safe_area(c: Control) -> void:
|
||||
var safe := MobilePort.safe_rect(c)
|
||||
var view := c.get_viewport_rect().size
|
||||
c.offset_left = safe.position.x
|
||||
c.offset_top = safe.position.y
|
||||
c.offset_right = safe.end.x - view.x
|
||||
c.offset_bottom = safe.end.y - view.y
|
||||
|
||||
|
||||
## The whole screen in an overlay's coordinates (its own rect unless inset_to_safe_area moved it):
|
||||
## what it dims, and where it takes the pointer so nothing behind it does.
|
||||
static func overlay_rect(c: Control) -> Rect2:
|
||||
return Rect2(-c.position, c.get_viewport_rect().size)
|
||||
|
||||
|
||||
static func _margins(s: StyleBox, x: float, y: float) -> void:
|
||||
s.content_margin_left = x
|
||||
s.content_margin_right = x
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue