diff --git a/JGE/Dependencies/SDL/src/atomic/SDL_spinlock.c b/JGE/Dependencies/SDL/src/atomic/SDL_spinlock.c index f74de81c7..07c26308a 100644 --- a/JGE/Dependencies/SDL/src/atomic/SDL_spinlock.c +++ b/JGE/Dependencies/SDL/src/atomic/SDL_spinlock.c @@ -77,6 +77,13 @@ SDL_AtomicTryLock(SDL_SpinLock *lock) : "=&r" (result) : "r" (1), "r" (lock) : "cc", "memory"); return (result == 0); +#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) + int result; + __asm__ __volatile__( + "lock ; xchgl %0, (%1)\n" + : "=r" (result) : "r" (lock), "0" (1) : "cc", "memory"); + return (result == 0); + #else /* Need CPU instructions for spinlock here! */ __need_spinlock_implementation__ diff --git a/projects/mtg/Android/.gitignore b/projects/mtg/Android/.gitignore index 5a9b113aa..fb2d02061 100644 --- a/projects/mtg/Android/.gitignore +++ b/projects/mtg/Android/.gitignore @@ -1,3 +1,4 @@ /gen /bin +/libs diff --git a/projects/mtg/Android/AndroidManifest.xml b/projects/mtg/Android/AndroidManifest.xml index 3a4255c1c..543d9f775 100644 --- a/projects/mtg/Android/AndroidManifest.xml +++ b/projects/mtg/Android/AndroidManifest.xml @@ -4,15 +4,13 @@ - - + + - - diff --git a/projects/mtg/Android/jni/Application.mk b/projects/mtg/Android/jni/Application.mk index 01804bb30..53a2e0f9d 100644 --- a/projects/mtg/Android/jni/Application.mk +++ b/projects/mtg/Android/jni/Application.mk @@ -1,6 +1,7 @@ APP_PROJECT_PATH := $(call my-dir)/.. APP_CPPFLAGS += -frtti -fexceptions APP_ABI := armeabi armeabi-v7a +#APP_ABI := x86 # mainly for emulators APP_STL := gnustl_static APP_MODULES := libpng libjpeg main SDL diff --git a/projects/mtg/Android/res/drawable-hdpi/icon.png b/projects/mtg/Android/res/drawable-hdpi/icon.png index 5332e9cf4..f38502e79 100644 Binary files a/projects/mtg/Android/res/drawable-hdpi/icon.png and b/projects/mtg/Android/res/drawable-hdpi/icon.png differ diff --git a/projects/mtg/Android/res/drawable-ldpi/icon.png b/projects/mtg/Android/res/drawable-ldpi/icon.png index 16ebfc68e..0d8fd16ac 100644 Binary files a/projects/mtg/Android/res/drawable-ldpi/icon.png and b/projects/mtg/Android/res/drawable-ldpi/icon.png differ diff --git a/projects/mtg/Android/res/drawable-mdpi/icon.png b/projects/mtg/Android/res/drawable-mdpi/icon.png index a45d22ba5..62b802c6f 100644 Binary files a/projects/mtg/Android/res/drawable-mdpi/icon.png and b/projects/mtg/Android/res/drawable-mdpi/icon.png differ diff --git a/projects/mtg/Android/src/net/wagic/utils/DeckImporter.java b/projects/mtg/Android/src/net/wagic/utils/DeckImporter.java index 55bfe3dd6..74aeaafe0 100644 --- a/projects/mtg/Android/src/net/wagic/utils/DeckImporter.java +++ b/projects/mtg/Android/src/net/wagic/utils/DeckImporter.java @@ -11,14 +11,13 @@ import android.util.Log; public class DeckImporter { - public static String importDeck( File f, String mypath, String activePath ) { String message = ""; String deck = ""; String deckname = ""; - String prefix = "#SB:"; - int cardcount = 0; + String prefix = "#SB:"; + int cardcount = 0; if(f.exists() && !f.isDirectory()) { deckname = f.getName(); @@ -36,91 +35,86 @@ public class DeckImporter while (scanner.hasNext()) { String line = scanner.nextLine(); - line = line.trim(); - if (!line.equals("") && cardcount < 61) // don't write out blank lines - { - String[] slines = line.split("\\s+"); - String arranged = ""; - for(int idx = 1; idx < slines.length; idx++) - { - arranged += slines[idx] + " "; - } - if ((isNumeric(slines[0])) && arranged != null) - { - if (slines[1] != null && slines[1].startsWith("[")) - { - arranged = arranged.substring(5); - slines[1] = slines[1].replaceAll("\\[", "").replaceAll("\\]",""); - deck += arranged + " (" + renameSet(slines[1]) + ") * " + slines[0] + "\n"; - } - else - { - deck += arranged + "(*) * " + slines[0] + "\n"; - } - cardcount += Integer.parseInt(slines[0]); - } - } - } - File profile = new File(activePath+"/Res/settings/options.txt"); - if(profile.exists() && !profile.isDirectory()) - { - String profileName = getActiveProfile(profile); - if(profileName != "Missing!") - { - File rootProfiles = new File(activePath+"/Res/profiles/"+profileName); - if(rootProfiles.exists() && rootProfiles.isDirectory()) - { - //save deck - int countdeck = 1; - File[] files = rootProfiles.listFiles(); - for (int i = 0; i < files.length; i++) - {//check if there is available deck... - if(files[i].getName().startsWith("deck")) - countdeck++; - } - File toSave = new File(rootProfiles+"/deck"+countdeck+".txt"); - try - { - FileOutputStream fop = new FileOutputStream(toSave); - - // if file doesn't exists, then create it - if (!toSave.exists()) { - toSave.createNewFile(); - } - // get the content in bytes - byte[] contentInBytes = deck.getBytes(); - fop.write(contentInBytes); - fop.flush(); - fop.close(); - message = "Import Deck Success!\n"+cardcount+" total cards in this deck\n\n"+deck; - } - catch (IOException e) - { - message = e.getMessage(); - } - } - else - { - message = "Missing Folder!"; - } - } - } - else - { - message = "Invalid Profile!"; - } - } - else - { - message = "No errors, and file EMPTY"; - } - } - catch(IOException e) - { - message = e.getMessage(); - } - } - return message; + line = line.trim(); + if (!line.equals("") && cardcount < 61) // don't write out blank lines + { + String[] slines = line.split("\\s+"); + String arranged = ""; + for (int idx = 1; idx < slines.length; idx++) + { + arranged += slines[idx] + " "; + } + if ((isNumeric(slines[0])) && arranged != null) + { + if (slines[1] != null && slines[1].startsWith("[")) + { + arranged = arranged.substring(5); + slines[1] = slines[1].replaceAll("\\[", "").replaceAll("\\]", ""); + deck += arranged + " (" + renameSet(slines[1]) + ") * " + slines[0] + "\n"; + } else + { + deck += arranged + "(*) * " + slines[0] + "\n"; + } + cardcount += Integer.parseInt(slines[0]); + } + } + } + File profile = new File(activePath + "/Res/settings/options.txt"); + if (profile.exists() && !profile.isDirectory()) + { + String profileName = getActiveProfile(profile); + if (profileName != "Missing!") + { + File rootProfiles = new File(activePath + "/Res/profiles/" + profileName); + if (rootProfiles.exists() && rootProfiles.isDirectory()) + { + //save deck + int countdeck = 1; + File[] files = rootProfiles.listFiles(); + for (int i = 0; i < files.length; i++) + {//check if there is available deck... + if (files[i].getName().startsWith("deck")) + countdeck++; + } + File toSave = new File(rootProfiles + "/deck" + countdeck + ".txt"); + try + { + FileOutputStream fop = new FileOutputStream(toSave); + + // if file doesn't exists, then create it + if (!toSave.exists()) + { + toSave.createNewFile(); + } + // get the content in bytes + byte[] contentInBytes = deck.getBytes(); + fop.write(contentInBytes); + fop.flush(); + fop.close(); + message = "Import Deck Success!\n" + cardcount + " total cards in this deck\n\n" + deck; + } catch (IOException e) + { + message = e.getMessage(); + } + } else + { + message = "Missing Folder!"; + } + } + } else + { + message = "Invalid Profile!"; + } + } else + { + message = "No errors, and file EMPTY"; + } + } catch (IOException e) + { + message = e.getMessage(); + } + } + return message; } private static boolean isNumeric(String input) @@ -135,7 +129,7 @@ public class DeckImporter } return true; } - + private static String getActiveProfile(File mypath) { String name = ""; @@ -158,7 +152,7 @@ public class DeckImporter } return name; } - + private static String renameSet(String set) { if (set == "") @@ -278,5 +272,4 @@ public class DeckImporter else return set; } - } diff --git a/projects/mtg/Android/src/net/wagic/utils/StorageOptions.java b/projects/mtg/Android/src/net/wagic/utils/StorageOptions.java index 622e89bad..8ab6d2090 100644 --- a/projects/mtg/Android/src/net/wagic/utils/StorageOptions.java +++ b/projects/mtg/Android/src/net/wagic/utils/StorageOptions.java @@ -14,6 +14,7 @@ import android.util.Log; public class StorageOptions { + private static final String TAG = StorageOptions.class.getCanonicalName(); private static ArrayList mMounts = new ArrayList(); private static ArrayList mVold = new ArrayList(); @@ -77,11 +78,11 @@ public class StorageOptions } catch (FileNotFoundException fnfex) { // if proc/mount doesn't exist we just use - Log.i(StorageOptions.class.getCanonicalName(), fnfex.getMessage() + ": assuming " + defaultMountPoint + " is the only mount point"); + Log.i(TAG, fnfex.getMessage() + ": assuming " + defaultMountPoint + " is the only mount point"); mMounts.add(defaultMountPoint); } catch (Exception e) { - Log.e(StorageOptions.class.getCanonicalName(), e.getMessage() + ": unknown exception while reading mounts file"); + Log.e(TAG, e.getMessage() + ": unknown exception while reading mounts file"); mMounts.add(defaultMountPoint); } } @@ -111,11 +112,11 @@ public class StorageOptions } catch (FileNotFoundException fnfex) { // if proc/mount doesn't exist we just use - Log.i(StorageOptions.class.getCanonicalName(), fnfex.getMessage() + ": assuming " + defaultMountPoint + " is the only mount point"); + Log.i(TAG, fnfex.getMessage() + ": assuming " + defaultMountPoint + " is the only mount point"); mMounts.add(defaultMountPoint); } catch (Exception e) { - Log.e(StorageOptions.class.getCanonicalName(), e.getMessage() + ": unknown exception while reading mounts file"); + Log.e(TAG, e.getMessage() + ": unknown exception while reading mounts file"); mMounts.add(defaultMountPoint); } } @@ -144,11 +145,11 @@ public class StorageOptions } catch (FileNotFoundException fnfex) { // if vold.fstab doesn't exist we use the value gathered from the Environment - Log.i(StorageOptions.class.getCanonicalName(), fnfex.getMessage() + ": assuming " + defaultMountPoint + " is the only mount point"); + Log.i(TAG, fnfex.getMessage() + ": assuming " + defaultMountPoint + " is the only mount point"); mMounts.add(defaultMountPoint); } catch (Exception e) { - Log.e(StorageOptions.class.getCanonicalName(), e.getMessage() + ": unknown exception while reading mounts file"); + Log.e(TAG, e.getMessage() + ": unknown exception while reading vold.fstab file"); mMounts.add(defaultMountPoint); } } @@ -174,15 +175,18 @@ public class StorageOptions { /* * Sometimes the two lists of mount points will be different. We only want those mount points that are in both list. - * + * * Compare the two lists together and remove items that are not in both lists. */ - for (int i = 0; i < mMounts.size(); i++) + if (mVold.size() > 0) { - String mount = mMounts.get(i); - if (!mVold.contains(mount)) - mMounts.remove(i--); + for (int i = 0; i < mMounts.size(); i++) + { + String mount = mMounts.get(i); + if (!mVold.contains(mount)) + mMounts.remove(i--); + } } // don't need this anymore, clear the vold list to reduce memory @@ -204,9 +208,10 @@ public class StorageOptions if (!root.exists() || !root.isDirectory() || !root.canWrite()) mMounts.remove(i--); } - + if (t == 0 && Build.VERSION.SDK_INT >= 16 && findForcemount()) - {//if none is found lets force it for Jellybean and above... + { + //if none is found lets force it for Jellybean and above... if (System.getenv("EXTERNAL_STORAGE") != null) { File root = new File(System.getenv("EXTERNAL_STORAGE")); @@ -224,7 +229,7 @@ public class StorageOptions } } } - + if (System.getenv("SECONDARY_STORAGE") != null) { File root = new File(System.getenv("SECONDARY_STORAGE")); @@ -247,6 +252,7 @@ public class StorageOptions private static void setProperties() { + Log.d(TAG, "setProperties()"); /* * At this point all the paths in the list should be valid. Build the public properties. */ @@ -268,7 +274,8 @@ public class StorageOptions else { for (String path : mMounts) - { // TODO: /mnt/sdcard is assumed to always mean internal storage. Use this comparison until there is a better way to do this + { + // TODO: /mnt/sdcard is assumed to always mean internal storage. Use this comparison until there is a better way to do this if ("/mnt/sdcard".equalsIgnoreCase(path)) mLabels.add("Built-in Storage"); else @@ -310,84 +317,97 @@ public class StorageOptions * * @return true if the device is rooted, false otherwise. */ - public static boolean isRooted() { - - // get from build info - String buildTags = android.os.Build.TAGS; - if (buildTags != null && buildTags.contains("test-keys")) { - return true; - } - - // check if /system/app/Superuser.apk is present - try { - File file = new File("/system/app/Superuser.apk"); - if (file.exists()) { - return true; - } - } - catch (Exception e1) { - // ignore - } - try { - File file = new File("/system/app/Superuser/Superuser.apk"); - if (file.exists()) { - return true; - } - } - catch (Exception e1) { - // ignore - } - //SuperSU - try { - File file = new File("/system/app/SuperSU.apk"); - if (file.exists()) { - return true; - } - } - catch (Exception e1) { - // ignore - } - try { - File file = new File("/system/app/SuperSU/SuperSU.apk"); - if (file.exists()) { - return true; - } - } - catch (Exception e1) { - // ignore - } - // try executing commands - return canExecuteCommand("/system/xbin/which su") - || canExecuteCommand("/system/bin/which su") || canExecuteCommand("which su"); - } - - // executes a command on the system - private static boolean canExecuteCommand(String command) { - boolean executedSuccesfully; - try { - Runtime.getRuntime().exec(command); - executedSuccesfully = true; - } - catch (Exception e) { - executedSuccesfully = false; - } - - return executedSuccesfully; - } - - private static boolean findForcemount(){ - try + public static boolean isRooted() { - File file = new File(System.getenv("EXTERNAL_STORAGE")+"/forcemount"); - if (file.exists()) + // get from build info + String buildTags = android.os.Build.TAGS; + if (buildTags != null && buildTags.contains("test-keys")) { return true; } - } - catch (Exception e1) + + // check if /system/app/Superuser.apk is present + try + { + File file = new File("/system/app/Superuser.apk"); + if (file.exists()) + { + return true; + } + } catch (Exception e1) + { + // ignore + } + try + { + File file = new File("/system/app/Superuser/Superuser.apk"); + if (file.exists()) + { + return true; + } + } catch (Exception e1) + { + // ignore + } + //SuperSU + try + { + File file = new File("/system/app/SuperSU.apk"); + if (file.exists()) + { + return true; + } + } catch (Exception e1) + { + // ignore + } + try + { + File file = new File("/system/app/SuperSU/SuperSU.apk"); + if (file.exists()) + { + return true; + } + } catch (Exception e1) + { + // ignore + } + // try executing commands + return canExecuteCommand("/system/xbin/which su") + || canExecuteCommand("/system/bin/which su") || canExecuteCommand("which su"); + } + + // executes a command on the system + private static boolean canExecuteCommand(String command) { + boolean executedSuccesfully; + try + { + Runtime.getRuntime().exec(command); + executedSuccesfully = true; + } catch (Exception e) + { + executedSuccesfully = false; + } + + return executedSuccesfully; + } + + private static boolean findForcemount() + { + Log.d(TAG, "findForcemount()"); + try + { + File file = new File(System.getenv("EXTERNAL_STORAGE") + "/forcemount"); + if (file.exists()) + { + return true; + } + } catch (Exception e) + { + Log.w(TAG, e.getMessage()); + return false; + } return false; } - return false; - } } diff --git a/projects/mtg/Android/src/org/libsdl/app/SDLActivity.java b/projects/mtg/Android/src/org/libsdl/app/SDLActivity.java index 4c4d166ba..56b644caa 100644 --- a/projects/mtg/Android/src/org/libsdl/app/SDLActivity.java +++ b/projects/mtg/Android/src/org/libsdl/app/SDLActivity.java @@ -14,8 +14,6 @@ import java.net.URLConnection; import java.util.ArrayList; import java.util.Scanner; - - import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLContext; @@ -68,12 +66,11 @@ import android.widget.FrameLayout.LayoutParams; */ public class SDLActivity extends Activity implements OnKeyListener { + private static final String TAG = SDLActivity.class.getCanonicalName(); + //import deck globals - public ArrayList myresult = new ArrayList(); - public String myclickedItem = ""; - - // TAG used for debugging in DDMS - public static String TAG = Activity.class.getCanonicalName(); + public ArrayList myresult = new ArrayList(); + public String myclickedItem = ""; // Main components private static SDLActivity mSingleton; @@ -352,7 +349,7 @@ public class SDLActivity extends Activity implements OnKeyListener updateStorageLocations(); } catch (Exception ioex) { - Log.e("SDL", "An error occurred in setting up the storage locations."); + Log.e(TAG, "An error occurred in setting up the storage locations."); } } @@ -497,14 +494,12 @@ public class SDLActivity extends Activity implements OnKeyListener @Override protected void onCreate(Bundle savedInstanceState) { - // Log.v("SDL", "onCreate()"); + //Log.d(TAG, "onCreate()"); super.onCreate(savedInstanceState); // So we can call stuff from static callbacks mSingleton = this; mContext = this.getApplicationContext(); - // get the current version of the app to set the core filename - String versionCodeString = getApplicationCode(); RES_FILENAME = getResourceName(); StorageOptions.determineStorageOptions(); @@ -532,7 +527,7 @@ public class SDLActivity extends Activity implements OnKeyListener @Override protected void onPause() { - // Log.v("SDL", "onPause()"); + // Log.d(TAG, "onPause()"); super.onPause(); SDLActivity.nativePause(); } @@ -540,7 +535,7 @@ public class SDLActivity extends Activity implements OnKeyListener @Override protected void onResume() { - // Log.v("SDL", "onResume()"); + // Log.d(TAG, "onResume()"); super.onResume(); SDLActivity.nativeResume(); } @@ -548,8 +543,7 @@ public class SDLActivity extends Activity implements OnKeyListener @Override public void onDestroy() { - // Log.v("SDL", "onDestroy()"); - + // Log.d(TAG, "onDestroy()"); super.onDestroy(); mSurface.onDestroy(); } @@ -660,7 +654,7 @@ public class SDLActivity extends Activity implements OnKeyListener int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT; int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1); - // Log.v("SDL", "SDL audio: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + ((float)sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer"); + // Log.d(TAG, "SDL audio: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + ((float)sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer"); // Let the user pick a larger buffer if they really want -- but ye // gods they probably shouldn't, the minimums are horrifyingly high @@ -671,7 +665,7 @@ public class SDLActivity extends Activity implements OnKeyListener audioStartThread(); - // Log.v("SDL", "SDL audio: got " + ((mAudioTrack.getChannelCount() >= 2) ? "stereo" : "mono") + " " + ((mAudioTrack.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" : "8-bit") + " " + ((float)mAudioTrack.getSampleRate() / 1000f) + + // Log.d(TAG, "SDL audio: got " + ((mAudioTrack.getChannelCount() >= 2) ? "stereo" : "mono") + " " + ((mAudioTrack.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" : "8-bit") + " " + ((float)mAudioTrack.getSampleRate() / 1000f) + // "kHz, " + desiredFrames + " frames buffer"); if (is16Bit) @@ -719,7 +713,7 @@ public class SDLActivity extends Activity implements OnKeyListener } } else { - Log.w("SDL", "SDL audio: error return from write(short)"); + Log.w(TAG, "SDL audio: error return from write(short)"); return; } } @@ -744,7 +738,7 @@ public class SDLActivity extends Activity implements OnKeyListener } } else { - Log.w("SDL", "SDL audio: error return from write(short)"); + Log.w(TAG, "SDL audio: error return from write(short)"); return; } } @@ -759,11 +753,11 @@ public class SDLActivity extends Activity implements OnKeyListener mAudioThread.join(); } catch (Exception e) { - Log.v("SDL", "Problem stopping audio thread: " + e); + Log.e(TAG, "Problem stopping audio thread: " + e); } mAudioThread = null; - // Log.v("SDL", "Finished waiting for audio thread"); + // Log.d(TAG, "Finished waiting for audio thread"); } if (mAudioTrack != null) @@ -775,7 +769,7 @@ public class SDLActivity extends Activity implements OnKeyListener class DownloadFileAsync extends AsyncTask { - final String TAG1 = DownloadFileAsync.class.getCanonicalName(); + private final String TAG = DownloadFileAsync.class.getCanonicalName(); @Override protected void onPreExecute() @@ -794,7 +788,6 @@ public class SDLActivity extends Activity implements OnKeyListener try { - // // Prepare the sdcard folders in order to download the resource file // @@ -815,7 +808,7 @@ public class SDLActivity extends Activity implements OnKeyListener conexion.connect(); int lengthOfFile = conexion.getContentLength(); - // Log.d("Wagic - " + TAG1, " Length of file: " + lengthOfFile); + // Log.d(TAG, " Length of file: " + lengthOfFile); input = new BufferedInputStream(url.openStream()); // create a File object for the output file @@ -838,8 +831,8 @@ public class SDLActivity extends Activity implements OnKeyListener { String errorMessage = "An error happened while downloading the resources. It could be that our server is temporarily down, that your device is not connected to a network, or that we cannot write to " + mSingleton.getSystemStorageLocation() + ". Please check your phone settings and try again. For more help please go to http://wagic.net"; mSingleton.downloadError(errorMessage); - Log.e(TAG1, errorMessage); - Log.e(TAG1, e.getMessage()); + Log.e(TAG, errorMessage); + Log.e(TAG, e.getMessage()); } return Long.valueOf(totalBytes); @@ -849,7 +842,7 @@ public class SDLActivity extends Activity implements OnKeyListener { if (progress[0] != mProgressDialog.getProgress()) { - // Log.d("Wagic - " + TAG1, "current progress : " + progress[0]); + // Log.d(TAG, "current progress : " + progress[0]); mProgressDialog.setProgress(progress[0]); } } @@ -922,6 +915,7 @@ public class SDLActivity extends Activity implements OnKeyListener */ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnKeyListener, View.OnTouchListener, SensorEventListener { + private static final String TAG = SDLSurface.class.getCanonicalName(); // This is what SDL runs in. It invokes SDL_main(), eventually private Thread mSDLThread; @@ -961,7 +955,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK SDLActivity.nativeQuit(); - Log.v("SDL", "SDL thread terminated"); + Log.d(TAG, "SDL thread terminated"); // On exit, tear everything down for a fresh restart next time. System.exit(0); @@ -988,7 +982,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK // Called when we have a valid drawing surface public void surfaceCreated(SurfaceHolder holder) { - Log.v("SDL", "surfaceCreated()"); + //Log.d(TAG, "surfaceCreated()"); enableSensor(Sensor.TYPE_ACCELEROMETER, true); } @@ -1008,18 +1002,18 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK mSDLThread.join(); } catch (Exception e) { - Log.v("SDL", "Problem stopping thread: " + e); + Log.e(TAG, "Problem stopping thread: " + e); } mSDLThread = null; - // Log.v("SDL", "Finished waiting for SDL thread"); + // Log.d(TAG, "Finished waiting for SDL thread"); } } // Called when we lose the surface public void surfaceDestroyed(SurfaceHolder holder) { - Log.v("SDL", "surfaceDestroyed()"); + Log.d(TAG, "surfaceDestroyed()"); synchronized (mSemSurface) { mSurfaceValid = false; @@ -1031,51 +1025,51 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK // Called when the surface is resized public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { - Log.d("SDL", "surfaceChanged()"); + Log.d(TAG, "surfaceChanged()"); int sdlFormat = 0x85151002; // SDL_PIXELFORMAT_RGB565 by default switch (format) { case PixelFormat.A_8: - Log.d("SDL", "pixel format A_8"); + Log.d("TAG", "pixel format A_8"); break; case PixelFormat.LA_88: - Log.d("SDL", "pixel format LA_88"); + Log.d("TAG", "pixel format LA_88"); break; case PixelFormat.L_8: - Log.d("SDL", "pixel format L_8"); + Log.d("TAG", "pixel format L_8"); break; case PixelFormat.RGBA_4444: - Log.d("SDL", "pixel format RGBA_4444"); + Log.d("TAG", "pixel format RGBA_4444"); sdlFormat = 0x85421002; // SDL_PIXELFORMAT_RGBA4444 break; case PixelFormat.RGBA_5551: - Log.d("SDL", "pixel format RGBA_5551"); + Log.d(TAG, "pixel format RGBA_5551"); sdlFormat = 0x85441002; // SDL_PIXELFORMAT_RGBA5551 break; case PixelFormat.RGBA_8888: - Log.d("SDL", "pixel format RGBA_8888"); + Log.d(TAG, "pixel format RGBA_8888"); sdlFormat = 0x86462004; // SDL_PIXELFORMAT_RGBA8888 break; case PixelFormat.RGBX_8888: - Log.d("SDL", "pixel format RGBX_8888"); + Log.d(TAG, "pixel format RGBX_8888"); sdlFormat = 0x86262004; // SDL_PIXELFORMAT_RGBX8888 break; case PixelFormat.RGB_332: - Log.d("SDL", "pixel format RGB_332"); + Log.d(TAG, "pixel format RGB_332"); sdlFormat = 0x84110801; // SDL_PIXELFORMAT_RGB332 break; case PixelFormat.RGB_565: - Log.d("SDL", "pixel format RGB_565"); + Log.d(TAG, "pixel format RGB_565"); sdlFormat = 0x85151002; // SDL_PIXELFORMAT_RGB565 break; case PixelFormat.RGB_888: - Log.d("SDL", "pixel format RGB_888"); + Log.d(TAG, "pixel format RGB_888"); // Not sure this is right, maybe SDL_PIXELFORMAT_RGB24 instead? sdlFormat = 0x86161804; // SDL_PIXELFORMAT_RGB888 break; default: - Log.d("SDL", "pixel format unknown " + format); + Log.d(TAG, "pixel format unknown " + format); break; } SDLActivity.onNativeResize(width, height, sdlFormat); @@ -1092,11 +1086,10 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK // EGL functions public boolean initEGL(int majorVersion, int minorVersion) { - Log.d("SDL", "Starting up OpenGL ES " + majorVersion + "." + minorVersion); + Log.d(TAG, "Starting up OpenGL ES " + majorVersion + "." + minorVersion); try { - EGL10 egl = (EGL10) EGLContext.getEGL(); EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); @@ -1122,7 +1115,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK int[] num_config = new int[1]; if (!egl.eglChooseConfig(dpy, configSpec, configs, 1, num_config) || num_config[0] == 0) { - Log.e("SDL", "No EGL config available"); + Log.e(TAG, "No EGL config available"); return false; } mEGLConfig = configs[0]; @@ -1130,7 +1123,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK EGLContext ctx = egl.eglCreateContext(dpy, mEGLConfig, EGL10.EGL_NO_CONTEXT, null); if (ctx == EGL10.EGL_NO_CONTEXT) { - Log.e("SDL", "Couldn't create context"); + Log.e(TAG, "Couldn't create context"); return false; } @@ -1144,10 +1137,10 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK } catch (Exception e) { - Log.e("SDL", e + ""); + Log.e(TAG, e + ""); for (StackTraceElement s : e.getStackTrace()) { - Log.e("SDL", s.toString()); + Log.e(TAG, s.toString()); } } @@ -1162,7 +1155,6 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK EGL10 egl = (EGL10) EGLContext.getEGL(); if (mEGLSurface != null) { - /* * Unbind and destroy the old EGL surface, if there is one. */ @@ -1176,7 +1168,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK mEGLSurface = egl.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, holder, null); if (mEGLSurface == EGL10.EGL_NO_SURFACE) { - Log.e("SDL", "Couldn't create surface"); + Log.e(TAG, "Couldn't create surface"); return false; } @@ -1185,7 +1177,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK */ if (!egl.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext)) { - Log.e("SDL", "Couldn't make context current"); + Log.e(TAG, "Couldn't make context current"); return false; } @@ -1197,7 +1189,6 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK // EGL buffer flip public void flipEGL() { - if (!mSurfaceValid) { createSurface(this.getHolder()); @@ -1207,7 +1198,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK { EGL10 egl = (EGL10) EGLContext.getEGL(); - egl.eglWaitNative(EGL10.EGL_NATIVE_RENDERABLE, null); + egl.eglWaitNative(EGL10.EGL_CORE_NATIVE_ENGINE, null); // drawing here @@ -1217,13 +1208,12 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK } catch (Exception e) { - Log.e("SDL", "flipEGL(): " + e); + Log.e(TAG, "flipEGL(): " + e); for (StackTraceElement s : e.getStackTrace()) { - Log.e("SDL", s.toString()); + Log.e(TAG, s.toString()); } } - } // Key events @@ -1234,14 +1224,15 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) return false; + if (event.getAction() == KeyEvent.ACTION_DOWN) { - // Log.d("SDL", "key down: " + keyCode); + // Log.d(TAG, "key down: " + keyCode); SDLActivity.onNativeKeyDown(keyCode); return true; } else if (event.getAction() == KeyEvent.ACTION_UP) { - // Log.d("SDL", "key up: " + keyCode); + // Log.d(TAG, "key up: " + keyCode); SDLActivity.onNativeKeyUp(keyCode); return true; } @@ -1252,7 +1243,6 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, View.OnK // Touch events public boolean onTouch(View v, MotionEvent event) { - for (int index = 0; index < event.getPointerCount(); ++index) { int action = event.getActionMasked(); diff --git a/projects/mtg/src/CardGui.cpp b/projects/mtg/src/CardGui.cpp index dd4db8ff7..de3779fae 100644 --- a/projects/mtg/src/CardGui.cpp +++ b/projects/mtg/src/CardGui.cpp @@ -1152,13 +1152,13 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb, bool noborder { MTGCard * fcard = MTGCollection()->getCardByName(kcard->name); quad = WResourceManager::Instance()->RetrieveCard(fcard); - } + }/* if (kcard->hasCopiedToken && !quad.get()) { MTGCard * tcard = MTGCollection()->getCardById(abs(kcard->copiedID)); quad = thumb ? WResourceManager::Instance()->RetrieveCardToken(tcard, RETRIEVE_THUMB, 1, abs(kcard->copiedID)) : WResourceManager::Instance()->RetrieveCardToken(tcard, RETRIEVE_NORMAL, 1, abs(kcard->copiedID)); - } + }*///temporary disabled this so it will not crash, this must be called when ingame -kevlahnota if (quad.get()) { if (quad->mHeight < quad->mWidth)