From f1d23b2cf1c8612d5943f7d9cf5dc0eb34d8e448 Mon Sep 17 00:00:00 2001 From: pelya Date: Tue, 28 Sep 2010 17:37:24 +0300 Subject: [PATCH] Do not call exit() when app put to background, we'll recreate GL textures from SDL (not done yet!) --- project/AndroidManifest.xml | 6 +- project/jni/Android.mk | 12 ++-- project/jni/Application.mk | 2 +- project/jni/sdl_main/sdl_main.c | 1 + project/res/values/strings.xml | 2 +- project/src/Accelerometer.java | 2 +- project/src/AssetExtract.java | 2 +- project/src/Audio.java | 2 +- project/src/DataDownloader.java | 2 +- project/src/GLSurfaceView_SDL.java | 6 +- project/src/Globals.java | 14 ++--- project/src/MainActivity.java | 5 +- project/src/Settings.java | 2 +- project/src/Video.java | 97 +++++++++++++++--------------- 14 files changed, 80 insertions(+), 75 deletions(-) diff --git a/project/AndroidManifest.xml b/project/AndroidManifest.xml index 465dd79b2..e05fbab3b 100644 --- a/project/AndroidManifest.xml +++ b/project/AndroidManifest.xml @@ -1,8 +1,8 @@ - Ur-Quan Masters + OpenTyrian diff --git a/project/src/Accelerometer.java b/project/src/Accelerometer.java index 8fa80d363..b46b829e0 100644 --- a/project/src/Accelerometer.java +++ b/project/src/Accelerometer.java @@ -1,5 +1,5 @@ // This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount -package com.sourceforge.sc2; +package com.googlecode.opentyrian; import android.app.Activity; import android.content.Context; diff --git a/project/src/AssetExtract.java b/project/src/AssetExtract.java index def4a9179..e664c297d 100644 --- a/project/src/AssetExtract.java +++ b/project/src/AssetExtract.java @@ -1,6 +1,6 @@ // This string is autogenerated by ChangeAppSettings.sh, do not change // spaces amount -package com.sourceforge.sc2; +package com.googlecode.opentyrian; import java.util.zip.*; import java.io.*; diff --git a/project/src/Audio.java b/project/src/Audio.java index 0c25623e1..8e2da1863 100644 --- a/project/src/Audio.java +++ b/project/src/Audio.java @@ -1,5 +1,5 @@ // This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount -package com.sourceforge.sc2; +package com.googlecode.opentyrian; import android.app.Activity; diff --git a/project/src/DataDownloader.java b/project/src/DataDownloader.java index 973ab3d38..5fb78f0d4 100644 --- a/project/src/DataDownloader.java +++ b/project/src/DataDownloader.java @@ -1,5 +1,5 @@ // This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount -package com.sourceforge.sc2; +package com.googlecode.opentyrian; import android.app.Activity; import android.content.Context; diff --git a/project/src/GLSurfaceView_SDL.java b/project/src/GLSurfaceView_SDL.java index 03f4bffcf..a7a90c140 100644 --- a/project/src/GLSurfaceView_SDL.java +++ b/project/src/GLSurfaceView_SDL.java @@ -18,7 +18,7 @@ fixed with a hammer and rasp to work with libSDL port */ // This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount -package com.sourceforge.sc2; +package com.googlecode.opentyrian; import java.io.Writer; import java.util.ArrayList; @@ -543,6 +543,8 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call */ public abstract void onSurfaceCreated(GL10 gl, EGLConfig config); + public abstract void onSurfaceDestroyed(); + /** * Called when the surface changed size. *

@@ -943,6 +945,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call r.run(); } if (mPaused) { + mRenderer.onSurfaceDestroyed(); mEglHelper.finish(); mNeedStart = true; } @@ -984,6 +987,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call if( mEglHelper.swap() ) return true; // We've lost GL context - recreate it + mRenderer.onSurfaceDestroyed(); mEglHelper.finish(); mNeedStart = true; } diff --git a/project/src/Globals.java b/project/src/Globals.java index 4d7ac1797..57eb31bdd 100644 --- a/project/src/Globals.java +++ b/project/src/Globals.java @@ -1,14 +1,14 @@ // This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount anywhere -package com.sourceforge.sc2; +package com.googlecode.opentyrian; import android.app.Activity; import android.content.Context; class Globals { - public static String ApplicationName = "Ur-QuanMasters"; + public static String ApplicationName = "OpenTyrian"; // Should be zip file - public static String DataDownloadUrl = "Game data is 14 Mb|https://sites.google.com/site/xpelyax/Home/sc2-data.zip?attredirects=0%26d=1|https://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/sc2-data.zip/download|http://sitesproxy.goapk.com/site/xpelyax/Home/sc2-data.zip^3DO remixed music (19 Mb) - enable it in Setup->Sound Options->3DO Remixes|:addons/3domusic/3domusic.zip:https://sites.google.com/site/xpelyax/Home/3domusic.zip?attredirects=0%26d=1|:addons/3domusic/3domusic.zip:https://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3domusic.zip/download|:addons/3domusic/3domusic.zip:http://sitesproxy.goapk.com/site/xpelyax/Home/3domusic.zip^UQM music remix pack (150 Mb) - enable it in Setup->Sound Options->UQM Remixes|:addons/remix/remix.zip:https://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/remix.zip/download^3DO voice (115 Mb) - go to Setup->Sound Options and increase Voice volume from zero|:addons/3dovoice/3dovoice.zip:https://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovoice.zip/download^3DO video support - after installing this pack copy all .duk and .aif files from|https://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^your 3DO Star Control II game CD from 'duckart' dir to the SD card to dir|https://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^'app-data/com.sourceforge.sc2/addons/3dovideo', to extract files from 3DO disk use|https://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^'3DO Commander' or 'uncd-rom' apps from http://madroms.free.fr/3do/|https://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^Then from the game change 'Setup->PC/3DO compat->Cutscenes' to Movies, and restart game|https://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download"; + public static String DataDownloadUrl = "Data files size is 11 Mb|http://sites.google.com/site/xpelyax/Home/tyrian21-data.zip?attredirects=0%26d=1|http://sitesproxy.goapk.com/site/xpelyax/Home/tyrian21-data.zip"; // Set this value to true if you're planning to render 3D using OpenGL - it eats some GFX resources, so disabled for 2D public static boolean NeedDepthBuffer = false; @@ -19,7 +19,7 @@ class Globals { // Readme text to be shown on download page public static String ReadmeText = "^You may press \"Home\" now - the data will be downloaded in background".replace("^","\n"); - public static boolean AppUsesMouse = false; + public static boolean AppUsesMouse = true; public static boolean AppNeedsArrowKeys = true; @@ -27,9 +27,9 @@ class Globals { public static boolean AppUsesMultitouch = false; - public static int AppTouchscreenKeyboardKeysAmount = 2; + public static int AppTouchscreenKeyboardKeysAmount = 4; - public static int AppTouchscreenKeyboardKeysAmountAutoFire = 2; + public static int AppTouchscreenKeyboardKeysAmountAutoFire = 1; // Phone-specific config // It will download app data to /sdcard/alienblaster if set to true, @@ -48,5 +48,5 @@ class Globals { } class LoadLibrary { - public LoadLibrary() { System.loadLibrary("sdl"); System.loadLibrary("sdl_image"); }; + public LoadLibrary() { System.loadLibrary("sdl"); System.loadLibrary("sdl_net"); }; } diff --git a/project/src/MainActivity.java b/project/src/MainActivity.java index 089ae237d..6c32f7996 100644 --- a/project/src/MainActivity.java +++ b/project/src/MainActivity.java @@ -1,5 +1,5 @@ // This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount -package com.sourceforge.sc2; +package com.googlecode.opentyrian; import android.app.Activity; import android.content.Context; @@ -59,10 +59,9 @@ public class MainActivity extends Activity { downloader.setParent(null, null); } } - - super.onPause(); if( mGLView != null ) mGLView.onPause(); + super.onPause(); } @Override diff --git a/project/src/Settings.java b/project/src/Settings.java index b0fb79a41..e36544f93 100644 --- a/project/src/Settings.java +++ b/project/src/Settings.java @@ -1,5 +1,5 @@ // This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount -package com.sourceforge.sc2; +package com.googlecode.opentyrian; import android.app.Activity; import android.content.Context; diff --git a/project/src/Video.java b/project/src/Video.java index 773c1ae11..00aa551f4 100644 --- a/project/src/Video.java +++ b/project/src/Video.java @@ -1,5 +1,5 @@ // This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount -package com.sourceforge.sc2; +package com.googlecode.opentyrian; import javax.microedition.khronos.opengles.GL10; @@ -23,23 +23,46 @@ import java.lang.Thread; import java.util.concurrent.locks.ReentrantLock; import android.os.Build; - abstract class DifferentTouchInput +abstract class DifferentTouchInput +{ + public static DifferentTouchInput getInstance() { - public static DifferentTouchInput getInstance() + if (Integer.parseInt(Build.VERSION.SDK) <= 4) + return SingleTouchInput.Holder.sInstance; + else + return MultiTouchInput.Holder.sInstance; + } + public abstract void process(final MotionEvent event); + private static class SingleTouchInput extends DifferentTouchInput + { + private static class Holder { - if (Integer.parseInt(Build.VERSION.SDK) <= 4) - return SingleTouchInput.Holder.sInstance; - else - return MultiTouchInput.Holder.sInstance; + private static final SingleTouchInput sInstance = new SingleTouchInput(); } - public abstract void process(final MotionEvent event); - private static class SingleTouchInput extends DifferentTouchInput + public void process(final MotionEvent event) { - private static class Holder - { - private static final SingleTouchInput sInstance = new SingleTouchInput(); - } - public void process(final MotionEvent event) + int action = -1; + if( event.getAction() == MotionEvent.ACTION_DOWN ) + action = 0; + if( event.getAction() == MotionEvent.ACTION_UP ) + action = 1; + if( event.getAction() == MotionEvent.ACTION_MOVE ) + action = 2; + if ( action >= 0 ) + DemoGLSurfaceView.nativeMouse( (int)event.getX(), (int)event.getY(), action, 0, + (int)(event.getPressure() * 1000.0), + (int)(event.getSize() * 1000.0) ); + } + } + private static class MultiTouchInput extends DifferentTouchInput + { + private static class Holder + { + private static final MultiTouchInput sInstance = new MultiTouchInput(); + } + public void process(final MotionEvent event) + { + for( int i = 0; i < event.getPointerCount(); i++ ) { int action = -1; if( event.getAction() == MotionEvent.ACTION_DOWN ) @@ -49,39 +72,16 @@ import android.os.Build; if( event.getAction() == MotionEvent.ACTION_MOVE ) action = 2; if ( action >= 0 ) - DemoGLSurfaceView.nativeMouse( (int)event.getX(), (int)event.getY(), action, 0, - (int)(event.getPressure() * 1000.0), - (int)(event.getSize() * 1000.0) ); - } - } - private static class MultiTouchInput extends DifferentTouchInput - { - private static class Holder - { - private static final MultiTouchInput sInstance = new MultiTouchInput(); - } - public void process(final MotionEvent event) - { - for( int i = 0; i < event.getPointerCount(); i++ ) - { - int action = -1; - if( event.getAction() == MotionEvent.ACTION_DOWN ) - action = 0; - if( event.getAction() == MotionEvent.ACTION_UP ) - action = 1; - if( event.getAction() == MotionEvent.ACTION_MOVE ) - action = 2; - if ( action >= 0 ) - DemoGLSurfaceView.nativeMouse( (int)event.getX(i), - (int)event.getY(i), - action, - event.getPointerId(i), - (int)(event.getPressure(i) * 1000.0), - (int)(event.getSize(i) * 1000.0)); - } + DemoGLSurfaceView.nativeMouse( (int)event.getX(i), + (int)event.getY(i), + action, + event.getPointerId(i), + (int)(event.getPressure(i) * 1000.0), + (int)(event.getSize(i) * 1000.0)); } } } +} class DemoRenderer extends GLSurfaceView_SDL.Renderer { @@ -92,13 +92,15 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer { } public void onSurfaceCreated(GL10 gl, EGLConfig config) { - // nativeInit(); } public void onSurfaceChanged(GL10 gl, int w, int h) { - //gl.glViewport(0, 0, w, h); nativeResize(w, h); } + + public void onSurfaceDestroyed() { + nativeGlContextLost(); + }; public void onDrawFrame(GL10 gl) { @@ -122,7 +124,6 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer { synchronized (this) { this.notify(); } - //Thread.yield(); return super.SwapBuffers() ? 1 : 0; } @@ -134,6 +135,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer { private native void nativeInit(); private native void nativeResize(int w, int h); private native void nativeDone(); + private native void nativeGlContextLost(); private Activity context = null; @@ -177,7 +179,6 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL { @Override public void onPause() { super.onPause(); - System.exit(0); // Not implemented yet }; @Override