harvest/game/scripts/mobile_port.gd
Forrest c47e67891e #37: platform back button, no Quit on phones, flat labels, camera
- Android back: application/config/quit_on_go_back=false; Main.go_back()
  (from NOTIFICATION_WM_GO_BACK_REQUEST, phones only) closes the shop or
  pouch panel or leaves build mode, else pauses; paused it closes the
  question, then settings, then resumes (shared with the pause action);
  at the main menu it closes the question or settings, else quits.
- Phones hide the main menu's Quit and the pause menu's Quit the game.
- ScreenLabels.ensure() makes the one ScreenLabels (ToonLook's on
  desktop; Main's on phones, which watch()es the tree for Label3Ds).
  Label sizes grow with the window's content_scale_factor (1 on desktop).
- FollowCamera starts at PHONE_DISTANCE (12 m) on phones.
- MobilePort.forced for tests; game/tests/mobile/platform_test.gd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 14:36:26 -04:00

27 lines
1.4 KiB
GDScript

class_name MobilePort
extends RefCounted
## The phone build's switches (the iOS preset in export_presets.cfg; docs/ios-test-port.md):
## * active(): a phone (the "mobile" feature). The farm keeps its standard materials (Main
## doesn't add ToonLook: the outline needs Forward+, phones run the Mobile renderer), the 3D
## view renders at GameSettings.resolution_scale instead of pixelated, co-op is hidden (the
## main menu's button and the settings' Co-op section), two thumbsticks move and attack
## (TouchSticks), and leaving the app pauses the game.
## The microphone is never opened (audio/driver/enable_input.mobile in project.godot).
## * perf_test(): the iOS preset's "perf_test" feature. Main adds PerfTest (the frame-time
## readout and test buttons), and CampaignDebug's jumps work in that release build.
## On desktop, `-- --mobile` and `-- --perf-test` after the usual arguments turn the same switches
## on, to see the phone build without a phone (add --rendering-method mobile for its renderer).
## Tests: -1 detects the platform, 0 forces desktop, 1 forces a phone.
static var forced := -1
static func active() -> bool:
if forced >= 0:
return forced == 1
return OS.has_feature("mobile") or "--mobile" in OS.get_cmdline_user_args()
static func perf_test() -> bool:
return OS.has_feature("perf_test") or "--perf-test" in OS.get_cmdline_user_args()