Mobile HUD: minimap radar in its frame, top row at the screen edge

Preview radar drew at the fixed PC spot; it now follows the uiminimap
window (CPythonMiniMap::GetScreenPosition) and its open state. On
Android the top safe inset came from the hidden status bar's gesture
zone; Ava2Surface takes the top only from the cutout and visible bars.
The preview keyboard-hint header is skipped in touch mode, and
--game-script also runs with --preview-data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-13 11:15:37 +09:00
co-authored by Claude Opus 5.5
parent 15b2397b54
commit c132891aef
5 changed files with 112 additions and 23 deletions
+40 -16
View File
@@ -27,6 +27,7 @@
#include "python_event_manager.h"
#include "python_system.h"
#include "python_background.h"
#include "python_minimap.h"
#include "eter_base/Random.h"
#include <ctime>
#include <random>
@@ -776,6 +777,7 @@ ava2::app::AppLoop::Frame RunClient(ava2::app::AppLoop* loop, int argc, char** a
// Initialize Minimap Radar System
ava2::MinimapManager minimap_mgr;
bool minimap_preview_opened = false;
minimap_mgr.SetWorldBounds(outdoor_terrain.GetWorldMinX(), outdoor_terrain.GetWorldMaxX(),
outdoor_terrain.GetWorldMinZ(), outdoor_terrain.GetWorldMaxZ());
std::string minimap_path = "map/metin2_map_a1/001003/minimap.dds";
@@ -2113,25 +2115,25 @@ const auto profileActiveStart = std::chrono::steady_clock::now();
}
#ifdef AVA2_HAS_PYTHON
// One-shot integration verification against the real GameWindow (also with --preview-data).
if (last_phase == "game" && python && !game_script.empty() && !game_script_executed && rendered_game_frames >= 3) {
FILE* script = std::fopen(game_script.c_str(), "rb");
if (!script) throw std::runtime_error("Cannot open --game-script");
std::string code;
char chunk[4096];
while (size_t size = std::fread(chunk, 1, sizeof(chunk), script)) code.append(chunk, size);
const bool failed = std::ferror(script);
std::fclose(script);
if (failed) throw std::runtime_error("Cannot read --game-script");
python->execute(code);
game_script_executed = true;
}
if (last_phase == "game" && !preview_data) {
int rotateInput=0,pitchInput=0,zoomInput=0;
ava2::GetCameraInput(rotateInput,pitchInput,zoomInput);
orbit_camera.SetYaw(orbit_camera.GetYaw()+rotateInput*60.0f*dt);
orbit_camera.SetPitch(orbit_camera.GetPitch()+pitchInput*45.0f*dt);
if (zoomInput) orbit_camera.SetDistance(orbit_camera.GetDistance()*std::exp(zoomInput*dt));
// One-shot integration verification against the real GameWindow.
if (python && !game_script.empty() && !game_script_executed && rendered_game_frames >= 3) {
FILE* script = std::fopen(game_script.c_str(), "rb");
if (!script) throw std::runtime_error("Cannot open --game-script");
std::string code;
char chunk[4096];
while (size_t size = std::fread(chunk, 1, sizeof(chunk), script)) code.append(chunk, size);
const bool failed = std::ferror(script);
std::fclose(script);
if (failed) throw std::runtime_error("Cannot read --game-script");
python->execute(code);
game_script_executed = true;
}
// Network/loading callbacks can replace the map during this frame.
// Resolve owners again after pumping packets instead of retaining freed terrain.
active_terrain = ava2::CPythonBackground::Instance().GetTerrain();
@@ -2499,8 +2501,30 @@ const auto profileActiveStart = std::chrono::steady_clock::now();
SDL_UpdateTexture(minimap_texture.get(), nullptr, minimap_surface->pixels, minimap_surface->pitch);
minimap_last_radar = radar;minimap_radar_valid = true;
}
// Inside the uiminimap.MiniMap frame (the mobile HUD moves it), at the
// offset its OnRender passes to miniMap.Render; hidden with the minimap.
SDL_FRect dst = { static_cast<float>(screen_width - 132), 5.0f, 128.0f, 128.0f };
SDL_RenderTexture(renderer.get(), minimap_texture.get(), nullptr, &dst);
bool radar_shown = true;
#ifdef AVA2_HAS_PYTHON
if (python) {
auto& mini_map = ava2::CPythonMiniMap::Instance();
float sx = 0.0f, sy = 0.0f;
mini_map.GetScreenPosition(&sx, &sy);
if (sx != 0.0f || sy != 0.0f) {
dst.x = sx; dst.y = sy;
// No map loads in preview, so MiniMap.AtlasInfo never opens the minimap;
// open it once so its close/open buttons drive the radar.
if (!minimap_preview_opened) {
python->execute(
"if 'stream' in globals() and stream.curPhaseWindow and hasattr(stream.curPhaseWindow, 'interface'):\n"
" stream.curPhaseWindow.interface.wndMiniMap.ShowMiniMap()\n");
minimap_preview_opened = true;
}
radar_shown = mini_map.CanShow();
}
}
#endif
if (radar_shown) SDL_RenderTexture(renderer.get(), minimap_texture.get(), nullptr, &dst);
}
}
}
@@ -2543,8 +2567,8 @@ const auto profileActiveStart = std::chrono::steady_clock::now();
}
}
if (original_phase_mode && preview_data) {
// Informative header for interactive mode
if (original_phase_mode && preview_data && !touch_mode) {
// Informative header for interactive mode (keyboard hints; the mobile HUD owns the top row)
SDL_SetRenderDrawColor(renderer.get(), 200, 220, 240, 200);
std::string hud;
if (last_phase == "select") {