Adapt Android mobile controls and native client UI

This commit is contained in:
shen
2026-09-28 19:39:13 -07:00
parent a1ae69aa7a
commit 3c52ced02e
180 changed files with 688 additions and 23782 deletions
@@ -1,6 +1,13 @@
package org.metin2port.client;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.WindowInsets;
import android.view.WindowInsetsController;
import org.libsdl.app.SDLActivity;
@@ -11,6 +18,47 @@ import org.libsdl.app.SDLActivity;
* Without arguments the client runs against the in-process fake server once Client/ is in files/.
*/
public class MainActivity extends SDLActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
applyImmersiveMode();
}
@Override
protected void onResume() {
super.onResume();
applyImmersiveMode();
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus)
applyImmersiveMode();
}
private void applyImmersiveMode() {
final View decor = getWindow().getDecorView();
decor.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
getWindow().setDecorFitsSystemWindows(false);
final WindowInsetsController controller = getWindow().getInsetsController();
if (controller != null) {
controller.hide(WindowInsets.Type.systemBars());
controller.setSystemBarsBehavior(
WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
}
}
}
@Override
protected String[] getLibraries() {
return new String[] { "SDL3", "main" };
@@ -20,8 +68,15 @@ public class MainActivity extends SDLActivity {
protected String[] getArguments() {
Intent intent = getIntent();
String args = intent != null ? intent.getStringExtra("args") : null;
Log.i("Metin2Args", "native args: " + args);
if (args == null || args.trim().isEmpty())
return new String[0];
return args.trim().split("\\s+");
}
@Override
public void setOrientationBis(int w, int h, boolean resizable, String hint) {
// Enforce landscape-only on mobile devices (sensorLandscape allows flipping 180 deg but never portrait).
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
}
}