mirror of
https://github.com/DrBeef/QVR.git
synced 2025-04-20 13:20:46 +00:00
Better folder handling
This commit is contained in:
parent
0a6c268e85
commit
e7e374c48a
9 changed files with 60 additions and 26 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -59,3 +59,6 @@ bin/*
|
|||
gen/*
|
||||
.idea/*
|
||||
.gradle/*
|
||||
app/build/*
|
||||
build/intermediates/*
|
||||
app/libs/libs.jar
|
||||
|
|
|
@ -84,9 +84,11 @@
|
|||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Android API 16 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" exported="" name="cardboard" level="project" />
|
||||
<orderEntry type="library" exported="" name="libs" level="project" />
|
||||
</component>
|
||||
</module>
|
|
@ -0,0 +1 @@
|
|||
quake
|
|
@ -1,6 +1,5 @@
|
|||
bind TAB "+showscores"
|
||||
bind ENTER "+jump"
|
||||
bind ESCAPE "togglemenu"
|
||||
bind SPACE "+jump"
|
||||
bind + "sizeup"
|
||||
bind , "+moveleft"
|
||||
|
|
Binary file not shown.
|
@ -31,11 +31,9 @@ class DownloadTask extends AsyncTask<Void, String, Void> {
|
|||
|
||||
public boolean please_abort = false;
|
||||
|
||||
private String sdcard = Environment.getExternalStorageDirectory().getPath();
|
||||
|
||||
private String url = "https://www.dropbox.com/s/cgd8ynsvp8aen5v/quake106.zip?dl=1";
|
||||
private String demofile = sdcard + "/QVR/quake106.zip";
|
||||
private String pakfile = sdcard + "/QVR/id1/pak0.pak";
|
||||
private String demofile = QVRConfig.GetFullWorkingFolder() + "quake106.zip";
|
||||
private String pakfile = QVRConfig.GetFullWorkingFolder() + "id1/pak0.pak";
|
||||
|
||||
public DownloadTask set_context(Context context){
|
||||
this.context = context;
|
||||
|
@ -102,7 +100,7 @@ class DownloadTask extends AsyncTask<Void, String, Void> {
|
|||
}
|
||||
|
||||
/// setup output directory
|
||||
new File(sdcard + "/QVR/id1").mkdirs();
|
||||
new File(QVRConfig.GetFullWorkingFolder() + "id1").mkdirs();
|
||||
|
||||
InputStream is = null;
|
||||
FileOutputStream fos = null;
|
||||
|
@ -124,8 +122,7 @@ class DownloadTask extends AsyncTask<Void, String, Void> {
|
|||
|
||||
|
||||
int count = is.read (buffer);
|
||||
//Log.i( "DownloadTask.java", "received " + count + " bytes");
|
||||
|
||||
|
||||
if ( count<=0 ) break;
|
||||
fos.write (buffer, 0, count);
|
||||
|
||||
|
@ -287,7 +284,7 @@ class DownloadTask extends AsyncTask<Void, String, Void> {
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(Void unused) {
|
||||
File f = new File(sdcard + "/QVR/id1/pak0.pak");
|
||||
File f = new File(QVRConfig.GetFullWorkingFolder() + "id1/pak0.pak");
|
||||
if (f.exists()) {
|
||||
QVRJNILib.setDownloadStatus(1);
|
||||
} else
|
||||
|
|
|
@ -168,8 +168,6 @@ public class MainActivity
|
|||
//Shader Program
|
||||
public static int sp_Image;
|
||||
|
||||
private String sdcard = Environment.getExternalStorageDirectory().getPath();
|
||||
|
||||
private DownloadTask mDownloadTask = null;
|
||||
|
||||
public static boolean mQVRInitialised = false;
|
||||
|
@ -198,14 +196,11 @@ public class MainActivity
|
|||
}
|
||||
|
||||
public void copy_asset(String name, String folder) {
|
||||
File f = new File(sdcard + folder + name);
|
||||
if (!f.exists() ||
|
||||
//If file was somehow corrupted, copy the back-up
|
||||
f.length() < 500) {
|
||||
|
||||
File f = new File(folder + name);
|
||||
if (!f.exists()) {
|
||||
//Ensure we have an appropriate folder
|
||||
new File(sdcard + folder).mkdirs();
|
||||
_copy_asset(name, sdcard + folder + name);
|
||||
new File(folder).mkdirs();
|
||||
_copy_asset(name, folder + name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,13 +310,13 @@ public class MainActivity
|
|||
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
||||
|
||||
//At the very least ensure we have a directory containing a config file
|
||||
copy_asset("config.cfg", "/QVR/id1/");
|
||||
copy_asset("commandline.txt", "/QVR/");
|
||||
copy_asset("config.cfg", QVRConfig.GetFullWorkingFolder() + "id1/");
|
||||
copy_asset("commandline.txt", QVRConfig.GetFullWorkingFolder());
|
||||
|
||||
//See if user is trying to use command line params
|
||||
BufferedReader br;
|
||||
try {
|
||||
br = new BufferedReader(new FileReader(sdcard + "/QVR/commandline.txt"));
|
||||
br = new BufferedReader(new FileReader(QVRConfig.GetFullWorkingFolder() + "commandline.txt"));
|
||||
String s;
|
||||
StringBuilder sb=new StringBuilder(0);
|
||||
while ((s=br.readLine())!=null)
|
||||
|
@ -343,7 +338,7 @@ public class MainActivity
|
|||
}
|
||||
else
|
||||
{
|
||||
File f = new File(sdcard + "/QVR/id1/pak0.pak");
|
||||
File f = new File(QVRConfig.GetFullWorkingFolder() + "id1/pak0.pak");
|
||||
if (!f.exists()) {
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
|
||||
this);
|
||||
|
@ -569,7 +564,7 @@ public class MainActivity
|
|||
|
||||
if (!mQVRInitialised && !mShowingSpashScreen)
|
||||
{
|
||||
QVRJNILib.initialise(sdcard + "/QVR", commandLineParams);
|
||||
QVRJNILib.initialise(QVRConfig.GetFullWorkingFolder(), commandLineParams);
|
||||
|
||||
//Now calculate the auto lens centre correction
|
||||
CardboardDeviceParams device = cardboardView.getHeadMountedDisplay().getCardboardDeviceParams();
|
||||
|
@ -786,7 +781,9 @@ public class MainActivity
|
|||
|
||||
if (System.currentTimeMillis() - triggerTimeout > 200) {
|
||||
|
||||
QVRJNILib.onKeyEvent(K_ENTER, KeyEvent.ACTION_DOWN, 0);
|
||||
if (mQVRInitialised) {
|
||||
QVRJNILib.onKeyEvent(K_ENTER, KeyEvent.ACTION_DOWN, 0);
|
||||
}
|
||||
|
||||
cardboardView.resetHeadTracker();
|
||||
|
||||
|
@ -873,7 +870,10 @@ public class MainActivity
|
|||
if (keyCode == K_ESCAPE)
|
||||
cardboardView.resetHeadTracker();
|
||||
|
||||
QVRJNILib.onKeyEvent( keyCode, action, character );
|
||||
if (mQVRInitialised) {
|
||||
QVRJNILib.onKeyEvent(keyCode, action, character);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
32
app/src/main/java/com/drbeef/qvr/QVRConfig.java
Normal file
32
app/src/main/java/com/drbeef/qvr/QVRConfig.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package com.drbeef.qvr;
|
||||
|
||||
|
||||
import android.os.Environment;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class QVRConfig {
|
||||
|
||||
static public String GetSDCARD()
|
||||
{
|
||||
return Environment.getExternalStorageDirectory().getPath();
|
||||
}
|
||||
|
||||
static public String GetWorkingFolder()
|
||||
{
|
||||
//Do we use old folder name?
|
||||
if (new File(GetSDCARD() + "/Q4C").exists())
|
||||
{
|
||||
return "Q4C/";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "QVR/";
|
||||
}
|
||||
}
|
||||
|
||||
static public String GetFullWorkingFolder()
|
||||
{
|
||||
return GetSDCARD() + "/" + GetWorkingFolder();
|
||||
}
|
||||
}
|
|
@ -7,5 +7,5 @@
|
|||
# Location of the SDK. This is only used by Gradle.
|
||||
# For customization when using a Version Control System, please read the
|
||||
# header note.
|
||||
#Fri Jan 29 22:26:37 GMT 2016
|
||||
#Sat Jan 30 19:15:49 GMT 2016
|
||||
sdk.dir=C\:\\Users\\Simon\\AppData\\Local\\Android\\sdk
|
||||
|
|
Loading…
Reference in a new issue