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:
co-authored by
Claude Opus 5.5
parent
15b2397b54
commit
c132891aef
@@ -1,8 +1,14 @@
|
|||||||
package com.metin2.ava2;
|
package com.metin2.ava2;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.graphics.Insets;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.WindowInsets;
|
||||||
|
|
||||||
import org.libsdl.app.SDLActivity;
|
import org.libsdl.app.SDLActivity;
|
||||||
|
import org.libsdl.app.SDLSurface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SDLActivity with command-line arguments for development runs:
|
* SDLActivity with command-line arguments for development runs:
|
||||||
@@ -26,4 +32,37 @@ public class Ava2Activity extends SDLActivity {
|
|||||||
public void setOrientationBis(int w, int h, boolean resizable, String hint) {
|
public void setOrientationBis(int w, int h, boolean resizable, String hint) {
|
||||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SDLSurface createSDLSurface(Context context) {
|
||||||
|
return new Ava2Surface(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SDL folds the system-gesture insets into the safe area. In landscape fullscreen the status bar
|
||||||
|
* is hidden, but its swipe-down gesture zone still reported a 120 px top inset, which pushed the
|
||||||
|
* top HUD row down. Keep SDL's left/right/bottom; take the top only from what really covers the
|
||||||
|
* screen there (display cutout and visible system bars).
|
||||||
|
*/
|
||||||
|
static class Ava2Surface extends SDLSurface {
|
||||||
|
Ava2Surface(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
|
||||||
|
WindowInsets result = super.onApplyWindowInsets(v, insets);
|
||||||
|
if (Build.VERSION.SDK_INT >= 30 /* Android 11 (R) */) {
|
||||||
|
Insets combined = insets.getInsets(WindowInsets.Type.systemBars() |
|
||||||
|
WindowInsets.Type.systemGestures() |
|
||||||
|
WindowInsets.Type.mandatorySystemGestures() |
|
||||||
|
WindowInsets.Type.tappableElement() |
|
||||||
|
WindowInsets.Type.displayCutout());
|
||||||
|
Insets covering = insets.getInsets(WindowInsets.Type.systemBars() |
|
||||||
|
WindowInsets.Type.displayCutout());
|
||||||
|
SDLActivity.onNativeInsetsChanged(combined.left, combined.right, covering.top, combined.bottom);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1568,3 +1568,24 @@ Verified:
|
|||||||
`ava2.speedtree_forest` (without that option the 9 asset tests are skipped).
|
`ava2.speedtree_forest` (without that option the 9 asset tests are skipped).
|
||||||
- Desktop phone layout and the device both render trees with real branches and fronds.
|
- Desktop phone layout and the device both render trees with real branches and fronds.
|
||||||
- Device game phase: 60.3 fps, max frame gap 16.6 ms, 0 frames over 25 ms.
|
- Device game phase: 60.3 fps, max frame gap 16.6 ms, 0 frames over 25 ms.
|
||||||
|
|
||||||
|
### 2026-10-13 Mobile HUD: minimap frame and top inset
|
||||||
|
|
||||||
|
- Minimap outside its frame (preview): with `--preview-data` no map loads, so
|
||||||
|
`miniMap.Render` returns early and the green circle was app_loop's dev radar, drawn at
|
||||||
|
the fixed PC spot `(screen_width - 132, 5)`. `CPythonMiniMap::Render` now records the
|
||||||
|
window position before the map check (`GetScreenPosition`), and the radar draws there.
|
||||||
|
It opens the minimap once via `ShowMiniMap()` (normally `AtlasInfo` does that on map
|
||||||
|
load), so `CanShow()` follows its close/open buttons. A real map was not affected.
|
||||||
|
- Top HUD row too low: SDL folds system-gesture insets into the safe area. In landscape
|
||||||
|
fullscreen the status bar is hidden but its swipe zone still gave a 120 px (67 logical)
|
||||||
|
top inset. `Ava2Activity.Ava2Surface` re-sends the insets with the top taken only from
|
||||||
|
the display cutout and visible system bars (device cutout is left-only).
|
||||||
|
- The preview keyboard-hint header is not drawn in touch mode; it overlapped the HUD.
|
||||||
|
- `--game-script` now also runs with `--preview-data` (desktop probing of the mobile HUD).
|
||||||
|
|
||||||
|
Verified on the device: minimap inside its frame, portrait/status bars and the entry row
|
||||||
|
at the top edge. Desktop ctest 59/59.
|
||||||
|
|
||||||
|
Outstanding: after a tap the cursor stays where the finger lifted, so hover tooltips
|
||||||
|
(e.g. "[F6] Battle pass") remain until the next touch.
|
||||||
|
|||||||
+40
-16
@@ -27,6 +27,7 @@
|
|||||||
#include "python_event_manager.h"
|
#include "python_event_manager.h"
|
||||||
#include "python_system.h"
|
#include "python_system.h"
|
||||||
#include "python_background.h"
|
#include "python_background.h"
|
||||||
|
#include "python_minimap.h"
|
||||||
#include "eter_base/Random.h"
|
#include "eter_base/Random.h"
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <random>
|
#include <random>
|
||||||
@@ -776,6 +777,7 @@ ava2::app::AppLoop::Frame RunClient(ava2::app::AppLoop* loop, int argc, char** a
|
|||||||
|
|
||||||
// Initialize Minimap Radar System
|
// Initialize Minimap Radar System
|
||||||
ava2::MinimapManager minimap_mgr;
|
ava2::MinimapManager minimap_mgr;
|
||||||
|
bool minimap_preview_opened = false;
|
||||||
minimap_mgr.SetWorldBounds(outdoor_terrain.GetWorldMinX(), outdoor_terrain.GetWorldMaxX(),
|
minimap_mgr.SetWorldBounds(outdoor_terrain.GetWorldMinX(), outdoor_terrain.GetWorldMaxX(),
|
||||||
outdoor_terrain.GetWorldMinZ(), outdoor_terrain.GetWorldMaxZ());
|
outdoor_terrain.GetWorldMinZ(), outdoor_terrain.GetWorldMaxZ());
|
||||||
std::string minimap_path = "map/metin2_map_a1/001003/minimap.dds";
|
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
|
#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) {
|
if (last_phase == "game" && !preview_data) {
|
||||||
int rotateInput=0,pitchInput=0,zoomInput=0;
|
int rotateInput=0,pitchInput=0,zoomInput=0;
|
||||||
ava2::GetCameraInput(rotateInput,pitchInput,zoomInput);
|
ava2::GetCameraInput(rotateInput,pitchInput,zoomInput);
|
||||||
orbit_camera.SetYaw(orbit_camera.GetYaw()+rotateInput*60.0f*dt);
|
orbit_camera.SetYaw(orbit_camera.GetYaw()+rotateInput*60.0f*dt);
|
||||||
orbit_camera.SetPitch(orbit_camera.GetPitch()+pitchInput*45.0f*dt);
|
orbit_camera.SetPitch(orbit_camera.GetPitch()+pitchInput*45.0f*dt);
|
||||||
if (zoomInput) orbit_camera.SetDistance(orbit_camera.GetDistance()*std::exp(zoomInput*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.
|
// Network/loading callbacks can replace the map during this frame.
|
||||||
// Resolve owners again after pumping packets instead of retaining freed terrain.
|
// Resolve owners again after pumping packets instead of retaining freed terrain.
|
||||||
active_terrain = ava2::CPythonBackground::Instance().GetTerrain();
|
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);
|
SDL_UpdateTexture(minimap_texture.get(), nullptr, minimap_surface->pixels, minimap_surface->pitch);
|
||||||
minimap_last_radar = radar;minimap_radar_valid = true;
|
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_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) {
|
if (original_phase_mode && preview_data && !touch_mode) {
|
||||||
// Informative header for interactive mode
|
// Informative header for interactive mode (keyboard hints; the mobile HUD owns the top row)
|
||||||
SDL_SetRenderDrawColor(renderer.get(), 200, 220, 240, 200);
|
SDL_SetRenderDrawColor(renderer.get(), 200, 220, 240, 200);
|
||||||
std::string hud;
|
std::string hud;
|
||||||
if (last_phase == "select") {
|
if (last_phase == "select") {
|
||||||
|
|||||||
@@ -293,13 +293,8 @@ void CPythonMiniMap::Update(float fCenterX, float fCenterY)
|
|||||||
|
|
||||||
void CPythonMiniMap::Render(float fScreenX, float fScreenY)
|
void CPythonMiniMap::Render(float fScreenX, float fScreenY)
|
||||||
{
|
{
|
||||||
// CPythonBackground::IsMapReady is implied by GetOutdoorMap (the terrain block loaded).
|
// Record the window position even before a map is ready: the --preview-data radar
|
||||||
if (!GetOutdoorMap())
|
// (app_loop) draws into the minimap frame through GetScreenPosition.
|
||||||
return;
|
|
||||||
|
|
||||||
if (!m_bShow)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (m_fScreenX != fScreenX || m_fScreenY != fScreenY)
|
if (m_fScreenX != fScreenX || m_fScreenY != fScreenY)
|
||||||
{
|
{
|
||||||
m_fScreenX = fScreenX;
|
m_fScreenX = fScreenX;
|
||||||
@@ -307,6 +302,13 @@ void CPythonMiniMap::Render(float fScreenX, float fScreenY)
|
|||||||
__SetPosition();
|
__SetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CPythonBackground::IsMapReady is implied by GetOutdoorMap (the terrain block loaded).
|
||||||
|
if (!GetOutdoorMap())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!m_bShow)
|
||||||
|
return;
|
||||||
|
|
||||||
// Draw the native terrain minimap tiles under the existing player/NPC marks.
|
// Draw the native terrain minimap tiles under the existing player/NPC marks.
|
||||||
auto* device = CGraphicDevice::InstancePtr();
|
auto* device = CGraphicDevice::InstancePtr();
|
||||||
if (auto* renderer = device ? device->GetRenderer() : nullptr) {
|
if (auto* renderer = device ? device->GetRenderer() : nullptr) {
|
||||||
@@ -1037,6 +1039,7 @@ void CPythonMiniMap::ShowAtlas() { m_bShowAtlas = true; }
|
|||||||
void CPythonMiniMap::HideAtlas() { m_bShowAtlas = false; }
|
void CPythonMiniMap::HideAtlas() { m_bShowAtlas = false; }
|
||||||
bool CPythonMiniMap::CanShowAtlas() { return m_bShowAtlas; }
|
bool CPythonMiniMap::CanShowAtlas() { return m_bShowAtlas; }
|
||||||
bool CPythonMiniMap::CanShow() { return m_bShow; }
|
bool CPythonMiniMap::CanShow() { return m_bShow; }
|
||||||
|
void CPythonMiniMap::GetScreenPosition(float* pfx, float* pfy) const { *pfx = m_fScreenX; *pfy = m_fScreenY; }
|
||||||
void CPythonMiniMap::Show() { m_bShow = true; }
|
void CPythonMiniMap::Show() { m_bShow = true; }
|
||||||
void CPythonMiniMap::Hide() { m_bShow = false; }
|
void CPythonMiniMap::Hide() { m_bShow = false; }
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ public:
|
|||||||
|
|
||||||
void Update(float fCenterX, float fCenterY);
|
void Update(float fCenterX, float fCenterY);
|
||||||
void Render(float fScreenX, float fScreenY);
|
void Render(float fScreenX, float fScreenY);
|
||||||
|
// Last position passed to Render (0,0 before the minimap window first rendered).
|
||||||
|
void GetScreenPosition(float* pfx, float* pfy) const;
|
||||||
|
|
||||||
void Show();
|
void Show();
|
||||||
void Hide();
|
void Hide();
|
||||||
|
|||||||
Reference in New Issue
Block a user