From 711dc02adaeda8ee8e32aeb4ceedba6612de6764 Mon Sep 17 00:00:00 2001 From: fredboy Date: Fri, 24 May 2024 16:53:05 +0700 Subject: [PATCH] AndroidLauncher in kotlin --- .../cavedroid/AndroidLauncher.java | 29 ---------------- .../deadsoftware/cavedroid/AndroidLauncher.kt | 34 +++++++++++++++++++ 2 files changed, 34 insertions(+), 29 deletions(-) delete mode 100644 android/src/ru/deadsoftware/cavedroid/AndroidLauncher.java create mode 100644 android/src/ru/deadsoftware/cavedroid/AndroidLauncher.kt diff --git a/android/src/ru/deadsoftware/cavedroid/AndroidLauncher.java b/android/src/ru/deadsoftware/cavedroid/AndroidLauncher.java deleted file mode 100644 index 714c8df..0000000 --- a/android/src/ru/deadsoftware/cavedroid/AndroidLauncher.java +++ /dev/null @@ -1,29 +0,0 @@ -package ru.deadsoftware.cavedroid; - -import android.content.pm.PackageManager; -import android.os.Bundle; -import com.badlogic.gdx.backends.android.AndroidApplication; -import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; - -public class AndroidLauncher extends AndroidApplication { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); - config.useImmersiveMode = true; - String gameFolder = ""; - try { - gameFolder = getPackageManager().getPackageInfo(getPackageName(), 0).applicationInfo.dataDir; - } catch (PackageManager.NameNotFoundException e) { - e.printStackTrace(); - exit(); - } - CaveGame caveGame = new CaveGame(gameFolder, true, BuildConfig.DEBUG, - new AndroidPreferencesStore(getApplicationContext())); - initialize(caveGame, config); - } - - @Override - public void onBackPressed() { - } -} diff --git a/android/src/ru/deadsoftware/cavedroid/AndroidLauncher.kt b/android/src/ru/deadsoftware/cavedroid/AndroidLauncher.kt new file mode 100644 index 0000000..b6fff78 --- /dev/null +++ b/android/src/ru/deadsoftware/cavedroid/AndroidLauncher.kt @@ -0,0 +1,34 @@ +package ru.deadsoftware.cavedroid + +import android.os.Bundle +import com.badlogic.gdx.backends.android.AndroidApplication +import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration + +class AndroidLauncher : AndroidApplication() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + val gameDataDirectoryPath = packageManager.getPackageInfo(packageName, 0) + .applicationInfo.dataDir; + + val config = AndroidApplicationConfiguration() + config.useImmersiveMode = true + + initialize( + /* listener = */ CaveGame( + gameDataDirectoryPath = gameDataDirectoryPath, + isTouchScreen = true, + isDebug = BuildConfig.DEBUG, + preferencesStore = AndroidPreferencesStore(applicationContext) + ), + /* config = */ config + ) + } + + @Suppress("OVERRIDE_DEPRECATION") + override fun onBackPressed() { + // ignore + } + +} \ No newline at end of file -- 2.29.2