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"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.questzdoom"
android:versionCode="8"
android:versionName="0.5.1" android:installLocation="auto" >
android:versionCode="9"
android:versionName="0.5.2" android:installLocation="auto" >
<!-- Tell the system this app requires OpenGL ES 3.1. -->
<uses-feature android:glEsVersion="0x00030001" android:required="true"/>

View file

@ -158,7 +158,8 @@ LAMBDA1VR Stuff
//This is now controlled by the engine
static bool useVirtualScreen = true;
extern bool automapactive;
static bool hasIWADsAndLauncher = false;
void QzDoom_setUseScreenLayer(bool use)
{
@ -167,7 +168,7 @@ void QzDoom_setUseScreenLayer(bool use)
bool QzDoom_useScreenLayer()
{
return useVirtualScreen;// || automapactive;
return useVirtualScreen;
}
static void UnEscapeQuotes( char *arg )
@ -1474,8 +1475,12 @@ void * AppThreadFunction(void * parm ) {
showLoadingIcon();
}
//Should now be all set up and ready - start the Doom main loop
VR_DoomMain(argc, argv);
if (hasIWADsAndLauncher) {
//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
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,
jstring commandLineParams)
jstring commandLineParams, jboolean jHasIWADs)
{
ALOGV( " GLES3JNILib::onCreate()" );
@ -1762,6 +1767,8 @@ JNIEXPORT jlong JNICALL Java_com_drbeef_questzdoom_GLES3JNILib_onCreate( JNIEnv
jboolean iscopy;
const char *arg = (*env)->GetStringUTFChars(env, commandLineParams, &iscopy);
hasIWADsAndLauncher = jHasIWADs != 0;
char *cmdLine = NULL;
if (arg && strlen(arg))
{

View file

@ -867,6 +867,14 @@ void DFrameBuffer::CopyWithGammaBgra(void *output, int pitch, const uint8_t *gam
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 ||
gamestate == GS_DEMOSCREEN) {
char buff[60];

View file

@ -41,7 +41,7 @@ const char *GetVersionString();
/** 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
#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 WRITE_EXTERNAL_STORAGE_PERMISSION_ID = 2;
String commandLineParams;
private String commandLineParams;
private SurfaceView mView;
private SurfaceHolder mSurfaceHolder;
@ -138,12 +138,23 @@ import android.support.v4.content.ContextCompat;
checkPermissionsAndInitialize();
}
private boolean isPackageInstalled(String packageName, PackageManager packageManager) {
try {
packageManager.getPackageGids(packageName);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
public void create() {
copy_asset("/sdcard/QuestZDoom", "commandline.txt", false);
//Create all required folders
new File("/sdcard/QuestZDoom/res").mkdirs();
new File("/sdcard/QuestZDoom/mods").mkdirs();
new File("/sdcard/QuestZDoom/wads").mkdirs();
new File("/sdcard/QuestZDoom/audiopack/snd_fluidsynth").mkdirs();
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);
//Doom Sharware WAD
copy_asset("/sdcard/QuestZDoom", "wads/DOOM1.WAD", false);
//Read these from a file and pass through
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) {

View file

@ -9,7 +9,7 @@ import android.view.Surface;
public class GLES3JNILib
{
// 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 onResume( long handle );
public static native void onPause( long handle );