Exit if no wads or launcher installed

This commit is contained in:
Simon 2020-04-25 15:27:58 +01:00
parent 2a7c5f0b1d
commit 755762da33
9 changed files with 43 additions and 15 deletions

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.questzdoom" package="com.drbeef.questzdoom"
android:versionCode="8" android:versionCode="9"
android:versionName="0.5.1" android:installLocation="auto" > android:versionName="0.5.2" android:installLocation="auto" >
<!-- Tell the system this app requires OpenGL ES 3.1. --> <!-- Tell the system this app requires OpenGL ES 3.1. -->
<uses-feature android:glEsVersion="0x00030001" android:required="true"/> <uses-feature android:glEsVersion="0x00030001" android:required="true"/>

View file

@ -158,7 +158,8 @@ LAMBDA1VR Stuff
//This is now controlled by the engine //This is now controlled by the engine
static bool useVirtualScreen = true; static bool useVirtualScreen = true;
extern bool automapactive;
static bool hasIWADsAndLauncher = false;
void QzDoom_setUseScreenLayer(bool use) void QzDoom_setUseScreenLayer(bool use)
{ {
@ -167,7 +168,7 @@ void QzDoom_setUseScreenLayer(bool use)
bool QzDoom_useScreenLayer() bool QzDoom_useScreenLayer()
{ {
return useVirtualScreen;// || automapactive; return useVirtualScreen;
} }
static void UnEscapeQuotes( char *arg ) static void UnEscapeQuotes( char *arg )
@ -1474,8 +1475,12 @@ void * AppThreadFunction(void * parm ) {
showLoadingIcon(); showLoadingIcon();
} }
//Should now be all set up and ready - start the Doom main loop if (hasIWADsAndLauncher) {
VR_DoomMain(argc, argv); //Should now be all set up and ready - start the Doom main loop
VR_DoomMain(argc, argv);
} else {
vrapi_ShowFatalError(&gAppState.Java, "Missing Launcher", "Please install Baggyg's Launcher to start QuestZDoom correctly", "", 666);
}
//We are done, shutdown cleanly //We are done, shutdown cleanly
shutdownVR(); shutdownVR();
@ -1745,7 +1750,7 @@ int JNI_OnLoad(JavaVM* vm, void* reserved)
} }
JNIEXPORT jlong JNICALL Java_com_drbeef_questzdoom_GLES3JNILib_onCreate( JNIEnv * env, jclass activityClass, jobject activity, JNIEXPORT jlong JNICALL Java_com_drbeef_questzdoom_GLES3JNILib_onCreate( JNIEnv * env, jclass activityClass, jobject activity,
jstring commandLineParams) jstring commandLineParams, jboolean jHasIWADs)
{ {
ALOGV( " GLES3JNILib::onCreate()" ); ALOGV( " GLES3JNILib::onCreate()" );
@ -1762,6 +1767,8 @@ JNIEXPORT jlong JNICALL Java_com_drbeef_questzdoom_GLES3JNILib_onCreate( JNIEnv
jboolean iscopy; jboolean iscopy;
const char *arg = (*env)->GetStringUTFChars(env, commandLineParams, &iscopy); const char *arg = (*env)->GetStringUTFChars(env, commandLineParams, &iscopy);
hasIWADsAndLauncher = jHasIWADs != 0;
char *cmdLine = NULL; char *cmdLine = NULL;
if (arg && strlen(arg)) if (arg && strlen(arg))
{ {

View file

@ -867,6 +867,14 @@ void DFrameBuffer::CopyWithGammaBgra(void *output, int pitch, const uint8_t *gam
void DFrameBuffer::DrawVersionString () void DFrameBuffer::DrawVersionString ()
{ {
static uint64_t first = screen->FrameTime;
//Only show version string for 5 seconds
if ((screen->FrameTime - first) > 5000)
{
return;
}
if (gamestate == GS_STARTUP || if (gamestate == GS_STARTUP ||
gamestate == GS_DEMOSCREEN) { gamestate == GS_DEMOSCREEN) {
char buff[60]; char buff[60];

View file

@ -41,7 +41,7 @@ const char *GetVersionString();
/** Lots of different version numbers **/ /** Lots of different version numbers **/
#define VERSIONSTR "QuestZDoom-0.5.1 (LZDoom 3.83a)" #define VERSIONSTR "DrBeef's QuestZDoom-0.5.2 (LZDoom 3.83a)"
// The version as seen in the Windows resource // The version as seen in the Windows resource
#define RC_FILEVERSION 3,83,1 #define RC_FILEVERSION 3,83,1

View file

@ -1 +1 @@
qzdoom -iwad wads/DOOM1.WAD qzdoom

Binary file not shown.

Binary file not shown.

View file

@ -42,7 +42,7 @@ import android.support.v4.content.ContextCompat;
private static final int READ_EXTERNAL_STORAGE_PERMISSION_ID = 1; private static final int READ_EXTERNAL_STORAGE_PERMISSION_ID = 1;
private static final int WRITE_EXTERNAL_STORAGE_PERMISSION_ID = 2; private static final int WRITE_EXTERNAL_STORAGE_PERMISSION_ID = 2;
String commandLineParams; private String commandLineParams;
private SurfaceView mView; private SurfaceView mView;
private SurfaceHolder mSurfaceHolder; private SurfaceHolder mSurfaceHolder;
@ -138,12 +138,23 @@ import android.support.v4.content.ContextCompat;
checkPermissionsAndInitialize(); checkPermissionsAndInitialize();
} }
private boolean isPackageInstalled(String packageName, PackageManager packageManager) {
try {
packageManager.getPackageGids(packageName);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
public void create() { public void create() {
copy_asset("/sdcard/QuestZDoom", "commandline.txt", false); copy_asset("/sdcard/QuestZDoom", "commandline.txt", false);
//Create all required folders //Create all required folders
new File("/sdcard/QuestZDoom/res").mkdirs(); new File("/sdcard/QuestZDoom/res").mkdirs();
new File("/sdcard/QuestZDoom/mods").mkdirs(); new File("/sdcard/QuestZDoom/mods").mkdirs();
new File("/sdcard/QuestZDoom/wads").mkdirs();
new File("/sdcard/QuestZDoom/audiopack/snd_fluidsynth").mkdirs(); new File("/sdcard/QuestZDoom/audiopack/snd_fluidsynth").mkdirs();
copy_asset("/sdcard/QuestZDoom", "res/lzdoom.pk3", true); copy_asset("/sdcard/QuestZDoom", "res/lzdoom.pk3", true);
@ -156,9 +167,6 @@ import android.support.v4.content.ContextCompat;
copy_asset("/sdcard/QuestZDoom/audiopack", "snd_fluidsynth/fluidsynth.sf2", false); copy_asset("/sdcard/QuestZDoom/audiopack", "snd_fluidsynth/fluidsynth.sf2", false);
//Doom Sharware WAD
copy_asset("/sdcard/QuestZDoom", "wads/DOOM1.WAD", false);
//Read these from a file and pass through //Read these from a file and pass through
commandLineParams = new String("qzdoom"); commandLineParams = new String("qzdoom");
@ -184,7 +192,12 @@ import android.support.v4.content.ContextCompat;
} }
} }
mNativeHandle = GLES3JNILib.onCreate( this, commandLineParams ); //If there are no IWADS, then should exit after creating the folders
//to allow the launcher app to do its thing, otherwise it would crash anyway
//Check that launcher is installed too
boolean hasIWADsAndLauncher = ((new File("/sdcard/QuestZDoom/wads").listFiles().length) > 0) &&
isPackageInstalled("com.Baggyg.QuestZDoom_Launcher", this.getPackageManager());
mNativeHandle = GLES3JNILib.onCreate( this, commandLineParams, hasIWADsAndLauncher);
} }
public void copy_asset(String path, String name, boolean force) { public void copy_asset(String path, String name, boolean force) {

View file

@ -9,7 +9,7 @@ import android.view.Surface;
public class GLES3JNILib public class GLES3JNILib
{ {
// Activity lifecycle // Activity lifecycle
public static native long onCreate( Activity obj, String commandLineParams ); public static native long onCreate( Activity obj, String commandLineParams, boolean hasIWADs );
public static native void onStart( long handle, Object obj ); public static native void onStart( long handle, Object obj );
public static native void onResume( long handle ); public static native void onResume( long handle );
public static native void onPause( long handle ); public static native void onPause( long handle );