Mobile UI scaling and live safe-area relayout (mobile step 5)
Phones and tablets pick the logical UI size from the screen (height 600..768 from the dp height, width from the aspect ratio) instead of letterboxing 1024x768; metin2.cfg is left untouched via a display-size override. --phone/--safe-insets/--ui-height simulate on desktop. The mobile HUD rebuilds and re-adopts the original windows when the safe area changes. Keeps HUD gauge backgrounds alive and fixes the step-4 disc pixel check threshold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
11bd94d1ce
commit
ed2c185135
@@ -7,13 +7,14 @@
|
||||
- `android/build.sh` 可以编出 arm64 调试 APK(SDL3 + FreeType 自动编译,16 KB 页对齐),连接手机时自动安装启动;真机运行尚未验证。
|
||||
- `android/push_assets.py` 把资源(`assets/loose` + python-root + `python27.zip`)推送到应用外部存储目录,客户端启动时切换到该目录。
|
||||
- 游戏资源为 2.8 GB、约 5 万个散文件(`assets/loose`),17 个源文件中 120 多处通过 `std::filesystem` / `ifstream` 直接读文件,无法读取 APK 内置资源。
|
||||
- 平台层已实现(`src/app/platform/`):资源根目录与配置目录;前后台切换(进后台时保存配置、暂停声音、取消输入、停止渲染,网络照常收发;Android 设 `SDL_ANDROID_BLOCK_ON_PAUSE=0`);安全区域按逻辑分辨率换算后放进触摸布局,HUD 用 `touch.GetSafeArea()` 内缩。低内存事件目前只记日志;HUD 只在创建时读安全区;均未真机验证。
|
||||
- 平台层已实现(`src/app/platform/`):资源根目录与配置目录;前后台切换(进后台时保存配置、暂停声音、取消输入、停止渲染,网络照常收发;Android 设 `SDL_ANDROID_BLOCK_ON_PAUSE=0`);安全区域按逻辑分辨率换算后放进触摸布局,HUD 用 `touch.GetSafeArea()` 内缩。低内存事件目前只记日志;均未真机验证。
|
||||
- 触摸分流已实现(`src/app/input/touch_router.*`,见下文 `input/`):移动端或 `--touch` / `AVA2_TOUCH=1` 时关闭 SDL 触摸转鼠标,每个手指分到界面、攻击键、左下浮动摇杆或镜头(单指拖动转向、双指缩放、轻点=点地移动)。Python 模块 `touch` 供 HUD 设置攻击键位置并读取摇杆状态;`ui_mobile_joystick` / `ui_mobile_combat` 改为只做显示(`not_pick`)。多指同时操作尚未在真机验证。
|
||||
- 出招已接通(PORT-PLAN「Mobile step 3b」):触摸攻击键和键盘共用 `ProcessPlayerAttack`,按原版连招时序出招,发送 FUNC_COMBO 移动包,命中检测后发 `CG_ATTACK`;尚未在真服验证,弓箭飞行、技能、PvP 规则等仍缺。
|
||||
- 手机 HUD 布局已实现(PORT-PLAN「Mobile step 4」):左上头像圆框 + 等级名字 + HP/SP/体力条,buff 图标在其下;顶部居中沿用原版目标栏;右上一排圆形入口(好友、角色、背包、菜单)+ 原版小地图 + 活动图标;左侧竖排按钮(任务、技能、表情、聊天)和原版提示按钮;右下攻击键 + 两圈 8 个快捷格(当前快捷页,可切第 1-3 页)+ 换页、上下马、拾取;底部药水栏(第 4 快捷页,全局格 24-31)和经验细条。移动模式下 PC 任务栏隐藏。圆框由原生 `CDisc`(`wndMgr.RegisterDisc`)几何绘制,图标只用 AVA2 自己的贴图,不用其他服的美术。小地图仍是原版圆形、按钮文字为英文、未真机验证。
|
||||
- 软键盘已改为仅在输入框获得焦点(`ime.EnableCaptureInput`)或聊天打开时弹出。
|
||||
- `src/app/main.cpp` 共 2418 行,启动、主循环、登录和调试参数都在其中。
|
||||
- Android 默认渲染缩放 0.75。
|
||||
- 界面缩放已实现(PORT-PLAN「Mobile step 5」):手机/平板按屏幕宽高比和像素密度自动选逻辑分辨率(高 600–768,宽随比例,至少 1024),不再给 1024×768 加黑边,也不改写 metin2.cfg;`--ui-height` / `AVA2_UI_HEIGHT` 可改高度;桌面可用 `--phone 2400x1080@2.75 --safe-insets 50,0,0,24` 模拟。安全区变化(如旋转 180 度刘海换边)时 HUD 实时重建并重新摆放原版窗口。运行中窗口尺寸变化(分屏、折叠屏)仍沿用启动时的逻辑分辨率;尚无游戏内界面大小选项;未真机验证。
|
||||
|
||||
## 分层结构
|
||||
|
||||
|
||||
@@ -1301,3 +1301,39 @@ Outstanding: no device run; minimap is still the original round one; labels
|
||||
are English; chat input line can overlap the wheel's page button while typing;
|
||||
no auto-hunt / target-lock buttons; Android keeps the 1024x768 letterboxed
|
||||
logical size (step 5 scaling); the HUD reads the safe area only when built.
|
||||
|
||||
### 2026-10-12 Mobile step 5 — UI scaling and live safe area
|
||||
|
||||
- Logical UI size on phones / tablets (`platform::ChooseMobileLogicalSize`):
|
||||
instead of letterboxing metin2.cfg's 1024x768, height =
|
||||
clamp(round(height in dp x 1.5), 600, 768) and width = height x screen
|
||||
aspect (landscape, even, at least 1024). A 2400x1080 phone at density 2.75
|
||||
gets 1332x600, a 2400x1080 at 2.25 gets 1600x720, a 4:3 tablet 1024x768.
|
||||
`--ui-height N` / `AVA2_UI_HEIGHT` override the height (600..1080).
|
||||
`CPythonSystem::SetDisplaySizeOverride` makes `systemSetting.GetWidth/Height`
|
||||
and the window manager report it without rewriting metin2.cfg.
|
||||
Android / iOS read the primary display (`QueryDisplay`); desktop simulates
|
||||
with `--phone WxH[@density]` (implies `--touch`) and `--safe-insets L,T,R,B`.
|
||||
- Live safe area: on `SDL_EVENT_WINDOW_SAFE_AREA_CHANGED` / resize the host
|
||||
resets the touch layout for the new insets; `MobileHUD.OnUpdate` sees
|
||||
`touch.GetSafeArea()` change and rebuilds itself under a fresh root window
|
||||
(old root hidden), re-registers the attack button and re-runs
|
||||
`AdoptDefaultWindows` / `AdoptGameWindows` (minimap, chat, hint buttons,
|
||||
buffs, event icon). Covers rotating 180 degrees with a side notch.
|
||||
- HUD gauge backgrounds and frames are now kept referenced (they were
|
||||
destroyed right after creation).
|
||||
- Fixed the step-4 `touch_game` disc pixel check (threshold too high; the
|
||||
earlier run used a stale test binary because the build stopped at the known
|
||||
speedtree_forest_test errors without `-k`).
|
||||
|
||||
Verified: `ava2.platform` (size choice for phones, portrait-reported
|
||||
displays, tablets, override clamp, near-square foldable, `--phone` parsing),
|
||||
`ava2.touch_game` (running HUD relayouts on new insets and back, minimap and
|
||||
buffs follow, attack button re-registered), 53/53 desktop tests,
|
||||
`ava2_client --phone 2400x1080@2.75 --safe-insets 50,0,0,24 --phase game
|
||||
--preview-data` renders 1332x600 full-bleed with the HUD inset.
|
||||
Outstanding: not run on a device (display mode vs. immersive window size,
|
||||
real cutout insets); a window size change at runtime (split screen,
|
||||
foldable) keeps the logical size chosen at start; no in-game UI size option
|
||||
yet (only `--ui-height` / env); original PC windows (inventory etc.) are
|
||||
not rearranged for 600 px height.
|
||||
|
||||
Reference in New Issue
Block a user