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
@@ -1,8 +1,14 @@
package com.metin2.ava2;
import android.content.Context;
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.SDLSurface;
/**
* 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) {
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;
}
}
}