diff --git a/ChangeAppSettings.sh b/ChangeAppSettings.sh index a1bae2aa8..a299e45b2 100755 --- a/ChangeAppSettings.sh +++ b/ChangeAppSettings.sh @@ -43,9 +43,10 @@ if [ -n "$var" ] ; then ScreenOrientation="$var" fi -echo -n "\nSpecify path to download application data in zip archive in the form 'Description|http://URL|http://BackupURL|...'" +echo -n "\nSpecify path to download application data in zip archive in the form 'Description|URL|MirrorURL|...'" echo -n "\nYou may specify additional paths to optional game content delimited by newlines (empty line to finish)" -echo -n "\nIf the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as-is to game dir and not unzipped\n\n" +echo -n "\nIf the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as-is to game dir and not unzipped" +echo -n "\nIf the URL does not contain 'http://' it is treated as file in 'project/assets' dir (it is bundled in .apk file)\n\n" echo -n "`echo $AppDataDownloadUrl | tr '^' '\\n'`" echo AppDataDownloadUrl1="" diff --git a/project/AndroidManifest.xml b/project/AndroidManifest.xml index 34529bd51..bf765cd4e 100644 --- a/project/AndroidManifest.xml +++ b/project/AndroidManifest.xml @@ -1,8 +1,8 @@ - enigma + Alien Blaster Initializing diff --git a/project/src/Accelerometer.java b/project/src/Accelerometer.java index 85bb7f6f5..8218593d2 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 org.enigmagame.enigma; +package de.schwardtnet.alienblaster; import android.app.Activity; import android.content.Context; diff --git a/project/src/AssetExtract.java b/project/src/AssetExtract.java index 91623c035..72f535f7e 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 org.enigmagame.enigma; +package de.schwardtnet.alienblaster; import java.util.zip.*; import java.io.*; diff --git a/project/src/Audio.java b/project/src/Audio.java index ba74bb618..a7a3bf744 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 org.enigmagame.enigma; +package de.schwardtnet.alienblaster; import android.app.Activity; diff --git a/project/src/DataDownloader.java b/project/src/DataDownloader.java index 53e82c1d7..422b07b1d 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 org.enigmagame.enigma; +package de.schwardtnet.alienblaster; import android.app.Activity; import android.content.Context; @@ -222,10 +222,11 @@ class DataDownloader extends Thread HttpResponse response = null; HttpGet request; - long totalLen; + long totalLen = 0; CountingInputStream stream; byte[] buf = new byte[16384]; boolean DoNotUnzip = false; + boolean FileInAssets = false; String url = ""; int downloadUrlIndex = 1; @@ -241,42 +242,62 @@ class DataDownloader extends Thread } System.out.println("Connecting to " + url); Status.setText( res.getString(R.string.connecting_to, url) ); - request = new HttpGet(url); - request.addHeader("Accept", "*/*"); - try { - DefaultHttpClient client = new DefaultHttpClient(); - client.getParams().setBooleanParameter("http.protocol.handle-redirects", true); - response = client.execute(request); - } catch (IOException e) { - System.out.println("Failed to connect to " + downloadUrls[downloadUrlIndex]); - downloadUrlIndex++; - }; - if( response != null ) + if( url.indexOf("http://") == -1 && url.indexOf("https://") == -1 ) // File inside assets { - if( response.getStatusLine().getStatusCode() != 200 ) - { - response = null; - System.out.println("Failed to connect to " + url); + FileInAssets = true; + break; + } + else + { + request = new HttpGet(url); + request.addHeader("Accept", "*/*"); + try { + DefaultHttpClient client = new DefaultHttpClient(); + client.getParams().setBooleanParameter("http.protocol.handle-redirects", true); + response = client.execute(request); + } catch (IOException e) { + System.out.println("Failed to connect to " + downloadUrls[downloadUrlIndex]); downloadUrlIndex++; + }; + if( response != null ) + { + if( response.getStatusLine().getStatusCode() != 200 ) + { + response = null; + System.out.println("Failed to connect to " + url); + downloadUrlIndex++; + } + else + break; } - else - break; } } - if( response == null ) + if( FileInAssets ) { - System.out.println("Error connecting to " + url); - Status.setText( res.getString(R.string.failed_connecting_to, url) ); - return false; + try { + stream = new CountingInputStream(Parent.getAssets().open(url)); + } catch( IOException e ) { + Status.setText( res.getString(R.string.error_dl_from, url) ); + return false; + } } + else + { + if( response == null ) + { + System.out.println("Error connecting to " + url); + Status.setText( res.getString(R.string.failed_connecting_to, url) ); + return false; + } - Status.setText( res.getString(R.string.dl_from, url) ); - totalLen = response.getEntity().getContentLength(); - try { - stream = new CountingInputStream(response.getEntity().getContent()); - } catch( java.io.IOException e ) { - Status.setText( res.getString(R.string.error_dl_from, url) ); - return false; + Status.setText( res.getString(R.string.dl_from, url) ); + totalLen = response.getEntity().getContentLength(); + try { + stream = new CountingInputStream(response.getEntity().getContent()); + } catch( java.io.IOException e ) { + Status.setText( res.getString(R.string.error_dl_from, url) ); + return false; + } } if(DoNotUnzip) diff --git a/project/src/GLSurfaceView_SDL.java b/project/src/GLSurfaceView_SDL.java index 613821999..ecb423fcf 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 org.enigmagame.enigma; +package de.schwardtnet.alienblaster; import java.io.Writer; import java.util.ArrayList; diff --git a/project/src/Globals.java b/project/src/Globals.java index 33739bdad..49a30d819 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 org.enigmagame.enigma; +package de.schwardtnet.alienblaster; import android.app.Activity; import android.content.Context; class Globals { - public static String ApplicationName = "enigma"; + public static String ApplicationName = "AlienBlaster"; // Should be zip file - public static String DataDownloadUrl = "Enigma Game Data (16 MiB)|https://sites.google.com/site/xpelyax/Home/enigma-data.zip?attredirects=0%26d=1"; + public static String DataDownloadUrl = "Data size is 2 Mb|alienblaster110_data.zip|http://sites.google.com/site/xpelyax/Home/alienblaster110_data.zip?attredirects=0%26d=1|http://sitesproxy.goapk.com/site/xpelyax/Home/alienblaster110_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; @@ -17,21 +17,21 @@ class Globals { public static boolean HorizontalOrientation = true; // Readme text to be shown on download page - public static String ReadmeText = "^You can press \"Home\" now - the data will be downloaded in background^Have fun playing enigma!^".replace("^","\n"); + public static String ReadmeText = "^You can press \"Home\" now - the data will be downloaded in background^In game press \"Menu\" for secondary fire, \"Volume Up/Down\" to cycle weapons".replace("^","\n"); - public static boolean AppUsesMouse = true; + public static boolean AppUsesMouse = false; - public static boolean AppNeedsArrowKeys = false; + public static boolean AppNeedsArrowKeys = true; - public static boolean AppUsesJoystick = true; + public static boolean AppUsesJoystick = false; public static boolean AppUsesMultitouch = false; public static boolean NonBlockingSwapBuffers = false; - public static int AppTouchscreenKeyboardKeysAmount = 0; + public static int AppTouchscreenKeyboardKeysAmount = 4; - public static int AppTouchscreenKeyboardKeysAmountAutoFire = 0; + public static int AppTouchscreenKeyboardKeysAmountAutoFire = 1; // Phone-specific config // It will download app data to /sdcard/alienblaster if set to true, @@ -50,5 +50,5 @@ class Globals { } class LoadLibrary { - public LoadLibrary() { System.loadLibrary("sdl-1.2"); System.loadLibrary("sdl_mixer"); System.loadLibrary("sdl_image"); System.loadLibrary("sdl_ttf"); System.loadLibrary("intl"); System.loadLibrary("lua"); }; + public LoadLibrary() { System.loadLibrary("sdl-1.3"); System.loadLibrary("sdl_mixer"); System.loadLibrary("sdl_image"); }; } diff --git a/project/src/MainActivity.java b/project/src/MainActivity.java index 3aab35e7f..be53b5dd9 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 org.enigmagame.enigma; +package de.schwardtnet.alienblaster; import android.app.Activity; import android.content.Context; diff --git a/project/src/Settings.java b/project/src/Settings.java index a29901cbe..2bdf841d8 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 org.enigmagame.enigma; +package de.schwardtnet.alienblaster; import android.app.Activity; import android.content.Context; diff --git a/project/src/Video.java b/project/src/Video.java index 29a2789bb..b70c5f7ea 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 org.enigmagame.enigma; +package de.schwardtnet.alienblaster; import javax.microedition.khronos.opengles.GL10; diff --git a/readme.txt b/readme.txt index 8ad679c34..0f448ac0f 100644 --- a/readme.txt +++ b/readme.txt @@ -81,6 +81,7 @@ SDL_BlitSurface(SDL_GetVideoSurface(), sourceRect, sprite, &targetRect); To compile your own app, put your app sources into project/jni/application dir, and change symlink "src" to point to your app, then launch script ChangeAppSettings.sh - it will ask few questions and modify some Java code. +You may take AndroidAppSettings.cfg file from some other application to get some sane defaults. The C++ files shall have .cpp extension to be compiled, rename them if necessary. Also you can replace icon image at project/res/drawable/icon.png. Then you can launch build.sh. @@ -91,10 +92,11 @@ Unzip it, and put in your PATH instead of original NDK - do not rename the targe check if there's "crystax" string in path to gcc toolchain, and will disable STLPort because CrystaX's NDK already contains STL library. -Application data is not bundled with app itself - it should be downloaded from net on first run. -Create .ZIP file with your application data, and put it somewhere on HTTP server - ChangeAppSettings.sh -will ask you for the URL. -If you'll release new version of data files you should change download URL and update your app as well - +Application data may be bundled with app itself, or downloaded from net on first run. +Create .ZIP file with your application data, and put it on HTTP server, or to "project/assets" dir - +ChangeAppSettings.sh will ask you for the URL, if URL won't contain "http://" it will try to open file from assets. +Note that there is some limit on maximum .APK file size on Market, like 20 Mb or so, so big files should be downloaded by HTTP. +If you'll release new version of data files you should change download URL or asset file name and update your app as well - the app will re-download the data if URL does not match the saved URL from previous download. If you'll add new libs - add them to project/jni/, copy Android.mk from existing lib, and