SDL2: custom activity that overrides SDLActivity

This commit is contained in:
Sergii Pylypenko
2022-01-02 00:11:31 +02:00
parent a235249f57
commit 919bf9a378
16 changed files with 179 additions and 100 deletions

View File

@@ -338,54 +338,6 @@ class DataDownloader extends Thread
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.connecting_to, url) );
if( url.equals("assetpack") )
{
Log.i("SDL", "Checking for asset pack");
/*
try
{
AssetPackManager assetPackManager = AssetPackManagerFactory.getInstance(Parent.getApplicationContext());
Log.i("SDL", "Parent.getApplicationContext(): " + Parent.getApplicationContext() + " assetPackManager " + assetPackManager);
if( assetPackManager != null )
{
Log.i("SDL", "assetPackManager.getPackLocation(): " + assetPackManager.getPackLocation("assetpack"));
if( assetPackManager.getPackLocation("assetpack") != null )
{
String assetPackPath = assetPackManager.getPackLocation("assetpack").assetsPath();
Parent.assetPackPath = assetPackPath;
if( assetPackPath != null )
{
Log.i("SDL", "Asset pack is installed at: " + assetPackPath);
return true;
}
}
}
}
catch( Exception e )
{
Log.i("SDL", "Asset pack exception: " + e);
}
*/
try
{
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP )
{
ApplicationInfo info = Parent.getPackageManager().getApplicationInfo(Parent.getPackageName(), 0);
if( info.splitSourceDirs != null )
{
for( String apk: info.splitSourceDirs )
{
Log.i("SDL", "Package apk: " + apk);
if( apk.endsWith("assetpack.apk") )
{
Parent.assetPackPath = apk;
}
}
}
}
}
catch( Exception e )
{
Log.i("SDL", "Asset pack exception: " + e);
}
if( Parent.assetPackPath != null )
{
Log.i("SDL", "Found asset pack: " + Parent.assetPackPath);

View File

@@ -39,8 +39,7 @@ class Globals
{ "expat", "expat-sdl" },
{ "sqlite3", "sqlite3-sdl" },
}; // Because some libraries are named differently to not clash with system libs
public static final boolean Using_SDL_1_3 = false;
public static final boolean Using_SDL_2_0 = false;
public static final boolean UsingSDL2 = false;
public static String[] DataDownloadUrl = { "Data files are 2 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-data.zip/download", "High-quality GFX and music - 40 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-hqp.zip/download" };
public static boolean SwVideoMode = false;
public static boolean NeedDepthBuffer = false;

View File

@@ -188,6 +188,31 @@ public class MainActivity extends Activity
_videoLayout.requestFocus();
DimSystemStatusBar.dim(_videoLayout, getWindow());
Log.i("SDL", "Checking for asset pack");
try
{
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP )
{
ApplicationInfo info = this.getPackageManager().getApplicationInfo(Parent.getPackageName(), 0);
if( info.splitSourceDirs != null )
{
for( String apk: info.splitSourceDirs )
{
Log.i("SDL", "Package apk: " + apk);
if( apk.endsWith("assetpack.apk") )
{
this.assetPackPath = apk;
Log.i("SDL", "Found asset pack: " + this.assetPackPath);
}
}
}
}
}
catch( Exception eee )
{
Log.i("SDL", "Asset pack exception: " + eee);
}
class Callback implements Runnable
{
MainActivity p;

View File

@@ -1001,6 +1001,7 @@ public class Settings
Save(MainActivity.instance);
}
// libsdl-1.2.so, does not exist in SDL2
private static native void nativeSetAccelerometerSettings(int sensitivity, int centerPos);
private static native void nativeSetMouseUsed(int RightClickMethod, int ShowScreenUnderFinger, int LeftClickMethod,
int MoveMouseWithJoystick, int ClickMouseWithDpad, int MaxForce, int MaxRadius,
@@ -1035,6 +1036,7 @@ public class Settings
private static native void nativeSetKeymapKeyMultitouchGesture(int keynum, int key);
private static native void nativeSetMultitouchGestureSensitivity(int sensitivity);
public static native void nativeSetTouchscreenCalibration(int x1, int y1, int x2, int y2);
// libsdl_native_helpers.so, exists in both versions
public static native void nativeSetEnv(final String name, final String value);
public static native int nativeChmod(final String name, int mode);
public static native void nativeChdir(final String dir);