#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>
This commit is contained in:
parent
f0291133fd
commit
c47e67891e
10 changed files with 368 additions and 23 deletions
|
|
@ -19,8 +19,10 @@ extends Node
|
|||
## over GD-Sync (GDSyncLink), with voice chat. In co-op the menus don't pause the farm; the
|
||||
## host's leaving ends the partner's game (back to this menu, which says why), the partner's
|
||||
## leaving leaves the host alone. [M] mutes the microphone.
|
||||
## * On a phone (MobilePort): no ToonLook, no co-op, two thumbsticks (TouchSticks), and leaving
|
||||
## the app pauses. The iOS test build adds PerfTest (frame times and test buttons).
|
||||
## * On a phone (MobilePort): no ToonLook (Main adds the ScreenLabels that draws the Label3Ds
|
||||
## flat), no co-op, no Quit buttons, two thumbsticks (TouchSticks), and leaving the app
|
||||
## pauses. Android's back button (go_back) closes what's on top or pauses, and quits from the
|
||||
## main menu. The iOS test build adds PerfTest (frame times and test buttons).
|
||||
## Main processes while paused; the farm doesn't. Tests set save_path and settings_path
|
||||
## before adding it to the tree.
|
||||
|
||||
|
|
@ -63,6 +65,8 @@ func _ready() -> void:
|
|||
var look := ToonLook.new() # toon shading and pixel outlines on the farm
|
||||
look.name = "ToonLook"
|
||||
add_child(look)
|
||||
else:
|
||||
ScreenLabels.ensure(self).watch(get_tree().root) # ToonLook's label drawing, without the look
|
||||
if MobilePort.perf_test():
|
||||
var perf := PerfTest.new()
|
||||
perf.name = "PerfTest"
|
||||
|
|
@ -267,6 +271,49 @@ func _notification(what: int) -> void:
|
|||
quit_game()
|
||||
elif what == NOTIFICATION_APPLICATION_PAUSED: # a phone app sent to the background
|
||||
pause()
|
||||
elif what == NOTIFICATION_WM_GO_BACK_REQUEST and MobilePort.active(): # Android's back button
|
||||
go_back()
|
||||
|
||||
|
||||
## The phone's back button (application/config/quit_on_go_back is off, so it comes here): what's
|
||||
## on top closes. Playing: the workbench's or the shed's panel, the pouch panel, or build mode,
|
||||
## else it pauses (over a conversation, a sign, the intro, or the end panel too, as Escape does).
|
||||
## Paused: the question, then settings, then it resumes. The main menu: the question, then
|
||||
## settings, else it quits (as Quit: quit_requested).
|
||||
func go_back() -> void:
|
||||
if quitting:
|
||||
return
|
||||
match screen:
|
||||
Screen.PLAYING:
|
||||
if sim.upgrade_panel != null and sim.upgrade_panel.is_open:
|
||||
sim.upgrade_panel.close()
|
||||
elif sim.shed_panel != null and sim.shed_panel.is_open:
|
||||
sim.shed_panel.close()
|
||||
elif sim.resource_hud != null and sim.resource_hud.open:
|
||||
sim.resource_hud.toggle()
|
||||
elif sim.build != null and sim.build.active:
|
||||
sim.build.set_active(false)
|
||||
else:
|
||||
pause()
|
||||
Screen.PAUSED:
|
||||
_back_in_pause()
|
||||
Screen.MENU:
|
||||
if confirm.is_open:
|
||||
confirm.close()
|
||||
elif settings_menu.is_open:
|
||||
settings_menu.close()
|
||||
elif main_menu.visible: # (not the co-op menu's screens: no co-op on phones)
|
||||
main_menu.quit_requested.emit()
|
||||
|
||||
|
||||
## Paused, the pause action or back: the question closes first, then settings, then it resumes.
|
||||
func _back_in_pause() -> void:
|
||||
if confirm.is_open:
|
||||
confirm.close()
|
||||
elif settings_menu.is_open:
|
||||
settings_menu.close()
|
||||
else:
|
||||
resume()
|
||||
|
||||
|
||||
func _play() -> void:
|
||||
|
|
@ -407,10 +454,5 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||
pause()
|
||||
get_viewport().set_input_as_handled()
|
||||
Screen.PAUSED:
|
||||
if confirm.is_open:
|
||||
confirm.close()
|
||||
elif settings_menu.is_open:
|
||||
settings_menu.close()
|
||||
else:
|
||||
resume()
|
||||
_back_in_pause()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue