Add platform layer: lifecycle, data dirs, safe area (mobile step 2)

Move the macOS/Android data and config directory code out of main.cpp
into src/app/platform. Handle background/foreground: save config and
interface status, pause audio, cancel touch input and skip rendering
while keeping the network pumped. Map the window safe area through the
letterboxed presentation into TouchLayout and expose touch.GetSafeArea()
so the mobile HUD stays clear of notches and gesture bars.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-12 20:45:07 +09:00
co-authored by Claude Opus 5.5
parent 260d421bde
commit b79fbce0b0
16 changed files with 475 additions and 73 deletions
+7 -4
View File
@@ -10,6 +10,7 @@ import math
import ui_mobile_joystick
import ui_mobile_combat
import ui_mobile_drawer
import touch
class MobileHUD(ui.Window):
"""
@@ -35,6 +36,7 @@ class MobileHUD(ui.Window):
self.AddFlag("attach")
self.AddFlag("not_pick")
self.safe_area = touch.GetSafeArea()
self.__BuildUI(sw, sh)
def __del__(self):
@@ -46,7 +48,8 @@ class MobileHUD(ui.Window):
# ---------------------------------------------------------------------
self.player_hud = ui.Window()
self.player_hud.SetParent(self)
self.player_hud.SetPosition(25, 20)
safe_l, safe_t, safe_r, safe_b = self.safe_area
self.player_hud.SetPosition(safe_l + 25, safe_t + 20)
self.player_hud.SetSize(320, 100)
self.player_hud.Show()
@@ -108,7 +111,7 @@ class MobileHUD(ui.Window):
# ---------------------------------------------------------------------
self.target_hud = ui.Window()
self.target_hud.SetParent(self)
self.target_hud.SetPosition((w - 420) / 2, 20)
self.target_hud.SetPosition((w - 420) / 2, safe_t + 20)
self.target_hud.SetSize(420, 50)
self.target_bg = ui.Bar()
@@ -155,7 +158,7 @@ class MobileHUD(ui.Window):
# ---------------------------------------------------------------------
# 5. 右下角:核心战斗轮盘 (Mobile Combat Wheel)
# ---------------------------------------------------------------------
self.combat_wheel = ui_mobile_combat.MobileCombatWheel(origin_x=w - 120, origin_y=h - 120)
self.combat_wheel = ui_mobile_combat.MobileCombatWheel(origin_x=w - safe_r - 120, origin_y=h - safe_b - 120)
self.combat_wheel.SetParent(self)
self.combat_wheel.Show()
@@ -164,7 +167,7 @@ class MobileHUD(ui.Window):
# ---------------------------------------------------------------------
self.quick_belt = ui.Window()
self.quick_belt.SetParent(self)
self.quick_belt.SetPosition((w - 360) / 2, h - 70)
self.quick_belt.SetPosition((w - 360) / 2, h - safe_b - 70)
self.quick_belt.SetSize(360, 60)
self.quick_belt.Show()