mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-08 05:11:51 +08:00
Initial beloko drop-out, add extras envs
This commit is contained in:
@@ -57,10 +57,6 @@ import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.beloko.games.hl.NativeLib;
|
||||
import com.beloko.touchcontrols.ControlInterpreter;
|
||||
import com.beloko.touchcontrols.Settings;
|
||||
import com.beloko.touchcontrols.TouchControlsSettings;
|
||||
import android.content.*;
|
||||
|
||||
/**
|
||||
@@ -68,9 +64,10 @@ import android.content.*;
|
||||
*/
|
||||
public class SDLActivity extends Activity {
|
||||
private static final String TAG = "SDL";
|
||||
private static final int PAK_VERSION = 1;
|
||||
|
||||
// Keep track of the paused state
|
||||
public static boolean mIsPaused, mIsSurfaceReady, mHasFocus, mUseControls, mUseVolume;
|
||||
public static boolean mIsPaused, mIsSurfaceReady, mHasFocus, mUseVolume;
|
||||
public static boolean mExitCalledFromJava;
|
||||
|
||||
/** If shared libraries (e.g. SDL or the native application) could not be loaded. */
|
||||
@@ -93,14 +90,8 @@ public class SDLActivity extends Activity {
|
||||
// Audio
|
||||
protected static AudioTrack mAudioTrack;
|
||||
|
||||
// Touch control interp
|
||||
public static ControlInterpreter controlInterp;
|
||||
|
||||
// Preferences
|
||||
public static SharedPreferences mPref;
|
||||
|
||||
// Controls dir
|
||||
public static String mControlsDir;
|
||||
|
||||
// Arguments
|
||||
public static String[] mArgv;
|
||||
@@ -115,7 +106,6 @@ public class SDLActivity extends Activity {
|
||||
protected String[] getLibraries() {
|
||||
return new String[] {
|
||||
"SDL2",
|
||||
"touchcontrols",
|
||||
"xash"
|
||||
};
|
||||
}
|
||||
@@ -149,7 +139,6 @@ public class SDLActivity extends Activity {
|
||||
mIsPaused = false;
|
||||
mIsSurfaceReady = false;
|
||||
mHasFocus = true;
|
||||
mControlsDir = null;
|
||||
mUseVolume = false;
|
||||
}
|
||||
|
||||
@@ -176,7 +165,6 @@ public class SDLActivity extends Activity {
|
||||
// So we can call stuff from static callbacks
|
||||
mSingleton = this;
|
||||
mPref = this.getSharedPreferences("engine", 0);
|
||||
mUseControls = mPref.getBoolean("controls", false);
|
||||
mUseVolume = mPref.getBoolean("usevolume", false);
|
||||
// Load shared libraries
|
||||
String errorMsgBrokenLib = "";
|
||||
@@ -228,16 +216,17 @@ public class SDLActivity extends Activity {
|
||||
String basedir = intent.getStringExtra("basedir");
|
||||
if(basedir == null)
|
||||
basedir = mPref.getString("basedir","/sdcard/xash/");
|
||||
mControlsDir = basedir + "/" + gamedir + "/controls/";
|
||||
File d = new File(mControlsDir);
|
||||
if(!d.exists())
|
||||
mControlsDir = getFilesDir() + "/";
|
||||
|
||||
setenv("XASH3D_BASEDIR", basedir, true);
|
||||
setenv("XASH3D_ENGLIBDIR", getFilesDir().getParentFile().getPath() + "/lib", true);
|
||||
setenv("XASH3D_GAMELIBDIR", gamelibdir, true);
|
||||
setenv("XASH3D_GAMEDIR", gamedir, true);
|
||||
|
||||
extractPAK();
|
||||
|
||||
setenv("XASH3D_EXTRAS_PAK1", getFilesDir().getPath() + "/extras.pak", true);
|
||||
String pakfile = intent.getStringExtra("pakfile");
|
||||
if( pakfile != null && pakfile != "" )
|
||||
setenv("XASH3D_EXTRAS_PAK2", pakfile, true);
|
||||
// Set up the surface
|
||||
mSurface = new SDLSurface(getApplication());
|
||||
|
||||
@@ -348,8 +337,8 @@ public class SDLActivity extends Activity {
|
||||
|
||||
int keyCode = event.getKeyCode();
|
||||
// Ignore certain special keys so they're handled by Android
|
||||
if ( mUseVolume && (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
|
||||
keyCode == KeyEvent.KEYCODE_VOLUME_UP)
|
||||
if ( mUseVolume && ( keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
|
||||
keyCode == KeyEvent.KEYCODE_VOLUME_UP )
|
||||
) return false;
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
@@ -987,9 +976,11 @@ public class SDLActivity extends Activity {
|
||||
private void extractPAK() {
|
||||
InputStream is = null;
|
||||
FileOutputStream os = null;
|
||||
if( mPref.getInt( "pakversion", 0 ) == PAK_VERSION )
|
||||
return;
|
||||
try {
|
||||
is = getAssets().open("pak.pak");
|
||||
os = new FileOutputStream(getFilesDir().getPath()+"/pak.pak");
|
||||
is = getAssets().open("extras.pak");
|
||||
os = new FileOutputStream(getFilesDir().getPath()+"/extras.pak");
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = is.read(buffer)) > 0) {
|
||||
@@ -1011,24 +1002,6 @@ class SDLMain implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
// Runs SDL_main()
|
||||
if(SDLActivity.mUseControls)
|
||||
{
|
||||
NativeLib engine = new NativeLib();
|
||||
|
||||
engine.initTouchControls_if(SDLActivity.mControlsDir,
|
||||
(int)SDLSurface.mWidth, (int)SDLSurface.mHeight);
|
||||
|
||||
SDLActivity.controlInterp = new ControlInterpreter(engine,Settings.IDGame.Doom,Settings.gamePadControlsFile,Settings.gamePadEnabled);
|
||||
|
||||
SDLActivity.controlInterp.setScreenSize((int)SDLSurface.mWidth, (int)SDLSurface.mHeight);
|
||||
|
||||
TouchControlsSettings.setup(SDLActivity.mSingleton, engine);
|
||||
TouchControlsSettings.loadSettings(SDLActivity.mSingleton);
|
||||
TouchControlsSettings.sendToQuake();
|
||||
|
||||
Settings.copyPNGAssets(SDLActivity.mSingleton, SDLActivity.mControlsDir, null);
|
||||
|
||||
}
|
||||
SDLActivity.nativeInit(SDLActivity.mArgv);
|
||||
//Log.v("SDL", "SDL thread terminated");
|
||||
}
|
||||
@@ -1238,12 +1211,6 @@ View.OnKeyListener, View.OnTouchListener, SensorEventListener {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
|
||||
if(SDLActivity.mUseControls)
|
||||
{
|
||||
SDLActivity.controlInterp.onTouchEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Ref: http://developer.android.com/training/gestures/multi.html */
|
||||
|
||||
final int touchDevId = event.getDeviceId();
|
||||
|
||||
Reference in New Issue
Block a user