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:
shenlei
2026-10-12 21:39:58 +09:00
co-authored by Claude Opus 5.5
parent 11bd94d1ce
commit ed2c185135
10 changed files with 232 additions and 23 deletions
+14 -2
View File
@@ -133,8 +133,20 @@ int main(int argc, char** argv) {
"(ax, ay, ar), joy = touch.GetLayout()\n"
"assert (ax, ay, ar) == (1024 - 30 - 120, 768 - 20 - 120, 60), (ax, ay, ar)\n"
"assert safe_hud.player_hud.GetGlobalPosition()[0] == 40 + 12\n"
"safe_hud.Hide()\nsafe_hud = None\n");
"safe_hud.Hide()\nsafe_hud = None\n"
// Live: the running HUD notices the new insets, rebuilds and moves the original windows.
"hud.OnUpdate()\n"
"assert hud.safe_area == (40, 0, 30, 20)\n"
"assert hud.player_hud.GetGlobalPosition()[0] == 40 + 12\n"
"assert touch.GetLayout()[0] == (1024 - 30 - 120, 768 - 20 - 120, 60)\n"
"assert mm.GetGlobalPosition()[0] + mm.GetWidth() == 1024 - 30\n"
"assert game.affectShower.GetGlobalPosition()[0] == 40 + 12 + 64 + 8\n"
"assert not game.interface.wndTaskBar.IsShow()\n");
router.SetLayout(layout);
runtime.execute("hud.OnUpdate()\n"
"assert hud.safe_area == (0, 0, 0, 0) and hud.player_hud.GetGlobalPosition()[0] == 12\n"
"assert mm.GetGlobalPosition()[0] + mm.GetWidth() == 1024\n"
"game.OnUpdate()\n");
SDL_FillSurfaceRect(surface, nullptr, 0xff10141e);
wm->Render(); SDL_RenderPresent(renderer);
@@ -145,7 +157,7 @@ int main(int argc, char** argv) {
return std::array<int, 3>{r, g, b};
};
const auto disc = pixel(int(layout.attack_x), int(layout.attack_y) + 45);
assert(disc[0] > 80 && disc[0] > disc[2] * 2);
assert(disc[0] > 40 && disc[0] > disc[1] * 3 && disc[0] > disc[2] * 3);
const auto empty = pixel(int(W * 0.6f), int(H * 0.4f));
assert(empty[0] < 40);
if (argc > 3) SDL_SaveBMP(surface, argv[3]);