SDL 1.3 WILL NOT COMPILE! OpenTyrian can be successfully put to background and restored, yay! However music keeps playing while on background, little annoying.
Also I'm not sure how my code will behave on Android 1.6
This commit is contained in:
@@ -938,12 +938,14 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
||||
while(true) { // Loop until we're re-created GL context and successfully called swap()
|
||||
|
||||
int w, h;
|
||||
boolean changed;
|
||||
boolean changed = false;
|
||||
synchronized (this) {
|
||||
/*
|
||||
Runnable r;
|
||||
while ((r = getEvent()) != null) {
|
||||
r.run();
|
||||
}
|
||||
*/
|
||||
if (mPaused) {
|
||||
mRenderer.onSurfaceDestroyed();
|
||||
mEglHelper.finish();
|
||||
@@ -956,7 +958,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
||||
if (mDone) {
|
||||
return false;
|
||||
}
|
||||
changed = mSizeChanged;
|
||||
// changed = mSizeChanged;
|
||||
w = mWidth;
|
||||
h = mHeight;
|
||||
mSizeChanged = false;
|
||||
|
||||
@@ -80,7 +80,7 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
protected void onDestroy()
|
||||
{
|
||||
if( downloader != null ) {
|
||||
synchronized( downloader ) {
|
||||
@@ -89,8 +89,8 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
if( mGLView != null )
|
||||
mGLView.exitApp();
|
||||
super.onStop();
|
||||
finish();
|
||||
super.onDestroy();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -432,6 +432,37 @@ class Settings
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void Apply(Activity p)
|
||||
{
|
||||
nativeIsSdcardUsed( Globals.DownloadToSdcard ? 1 : 0 );
|
||||
|
||||
if( Globals.PhoneHasTrackball )
|
||||
nativeSetTrackballUsed();
|
||||
if( Globals.AppUsesMouse )
|
||||
nativeSetMouseUsed();
|
||||
if( Globals.AppUsesJoystick && !Globals.UseAccelerometerAsArrowKeys )
|
||||
nativeSetJoystickUsed();
|
||||
if( Globals.AppUsesMultitouch )
|
||||
nativeSetMultitouchUsed();
|
||||
nativeSetAccelerometerSensitivity(Globals.AccelerometerSensitivity);
|
||||
nativeSetTrackballDampening(Globals.TrackballDampening);
|
||||
if( Globals.UseTouchscreenKeyboard )
|
||||
{
|
||||
nativeSetTouchscreenKeyboardUsed();
|
||||
nativeSetupScreenKeyboard( Globals.TouchscreenKeyboardSize,
|
||||
Globals.TouchscreenKeyboardTheme,
|
||||
Globals.AppTouchscreenKeyboardKeysAmount,
|
||||
Globals.AppTouchscreenKeyboardKeysAmountAutoFire);
|
||||
}
|
||||
SetupTouchscreenKeyboardGraphics(p);
|
||||
String lang = new String(Locale.getDefault().getLanguage());
|
||||
if( Locale.getDefault().getCountry().length() > 0 )
|
||||
lang = lang + "_" + Locale.getDefault().getCountry();
|
||||
System.out.println( "libSDL: setting envvar LANG to '" + lang + "'");
|
||||
nativeSetEnv( "LANG", lang );
|
||||
// TODO: get current user name and set envvar USER, the API is not availalbe on Android 1.6 so I don't bother with this
|
||||
}
|
||||
|
||||
static byte [] loadRaw(Activity p,int res)
|
||||
{
|
||||
byte [] buf = new byte[128];
|
||||
@@ -452,25 +483,10 @@ class Settings
|
||||
return a;
|
||||
}
|
||||
|
||||
static void Apply(Activity p)
|
||||
static void SetupTouchscreenKeyboardGraphics(Activity p)
|
||||
{
|
||||
nativeIsSdcardUsed( Globals.DownloadToSdcard ? 1 : 0 );
|
||||
|
||||
if( Globals.PhoneHasTrackball )
|
||||
nativeSetTrackballUsed();
|
||||
if( Globals.AppUsesMouse )
|
||||
nativeSetMouseUsed();
|
||||
if( Globals.AppUsesJoystick && !Globals.UseAccelerometerAsArrowKeys )
|
||||
nativeSetJoystickUsed();
|
||||
if( Globals.AppUsesMultitouch )
|
||||
nativeSetMultitouchUsed();
|
||||
if( Globals.UseTouchscreenKeyboard )
|
||||
{
|
||||
nativeSetTouchscreenKeyboardUsed();
|
||||
nativeSetupScreenKeyboard( Globals.TouchscreenKeyboardSize,
|
||||
Globals.TouchscreenKeyboardTheme,
|
||||
Globals.AppTouchscreenKeyboardKeysAmount,
|
||||
Globals.AppTouchscreenKeyboardKeysAmountAutoFire);
|
||||
if( Globals.TouchscreenKeyboardTheme == 1 )
|
||||
{
|
||||
// DPAD
|
||||
@@ -486,8 +502,8 @@ class Settings
|
||||
nativeSetupScreenKeyboardButton(8, loadRaw(p, R.raw.ultimatedroidbutton2autoanim));
|
||||
// Other buttons
|
||||
nativeSetupScreenKeyboardButton(9, loadRaw(p, R.raw.ultimatedroidbutton1));
|
||||
nativeSetupScreenKeyboardButton(10, loadRaw(p, R.raw.ultimatedroidbutton1pressed));
|
||||
nativeSetupScreenKeyboardButton(11, loadRaw(p, R.raw.ultimatedroidbutton2));
|
||||
nativeSetupScreenKeyboardButton(10, loadRaw(p, R.raw.ultimatedroidbutton1pressed));
|
||||
nativeSetupScreenKeyboardButton(11, loadRaw(p, R.raw.ultimatedroidbutton2));
|
||||
nativeSetupScreenKeyboardButton(12, loadRaw(p, R.raw.ultimatedroidbutton2pressed));
|
||||
nativeSetupScreenKeyboardButton(13, loadRaw(p, R.raw.ultimatedroidbutton3));
|
||||
nativeSetupScreenKeyboardButton(14, loadRaw(p, R.raw.ultimatedroidbutton3pressed));
|
||||
@@ -501,14 +517,6 @@ class Settings
|
||||
nativeSetupScreenKeyboardButton(22, loadRaw(p, R.raw.ultimatedroidbutton7));
|
||||
}
|
||||
}
|
||||
nativeSetAccelerometerSensitivity(Globals.AccelerometerSensitivity);
|
||||
nativeSetTrackballDampening(Globals.TrackballDampening);
|
||||
String lang = new String(Locale.getDefault().getLanguage());
|
||||
if( Locale.getDefault().getCountry().length() > 0 )
|
||||
lang = lang + "_" + Locale.getDefault().getCountry();
|
||||
System.out.println( "libSDL: setting envvar LANG to '" + lang + "'");
|
||||
nativeSetEnv( "LANG", lang );
|
||||
// TODO: get current user name and set envvar USER, the API is not availalbe on Android 1.6 so I don't bother with this
|
||||
}
|
||||
|
||||
static void startDownloader(MainActivity p)
|
||||
|
||||
@@ -89,6 +89,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer {
|
||||
public DemoRenderer(Activity _context)
|
||||
{
|
||||
context = _context;
|
||||
mGlContextLost = false;
|
||||
}
|
||||
|
||||
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
|
||||
@@ -99,6 +100,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer {
|
||||
}
|
||||
|
||||
public void onSurfaceDestroyed() {
|
||||
mGlContextLost = true;
|
||||
nativeGlContextLost();
|
||||
};
|
||||
|
||||
@@ -119,12 +121,18 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer {
|
||||
System.exit(0); // The main() returns here - I don't bother with deinit stuff, just terminate process
|
||||
}
|
||||
|
||||
public int swapBuffers() // Called from native code, returns 1 on success, 0 when GL context lost (user put app to background)
|
||||
public int swapBuffers() // Called from native code
|
||||
{
|
||||
synchronized (this) {
|
||||
this.notify();
|
||||
}
|
||||
return super.SwapBuffers() ? 1 : 0;
|
||||
mGlContextLost = false;
|
||||
super.SwapBuffers();
|
||||
if(mGlContextLost) {
|
||||
mGlContextLost = false;
|
||||
Settings.SetupTouchscreenKeyboardGraphics(context); // Reload on-screen buttons graphics
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void exitApp() {
|
||||
@@ -143,6 +151,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer {
|
||||
private EGLDisplay mEglDisplay = null;
|
||||
private EGLSurface mEglSurface = null;
|
||||
private EGLContext mEglContext = null;
|
||||
private boolean mGlContextLost = false;
|
||||
}
|
||||
|
||||
class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
@@ -156,7 +165,6 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
setRenderer(mRenderer);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(final MotionEvent event)
|
||||
{
|
||||
@@ -172,8 +180,6 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
|
||||
public void exitApp() {
|
||||
mRenderer.exitApp();
|
||||
accelerometer.stop();
|
||||
accelerometer = null;
|
||||
};
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user