Now you can put data files inside .apk file, into assets - they will be unpacked automatically via omnipotent DataDownloader.java

This commit is contained in:
pelya
2010-10-14 13:25:16 +03:00
parent d2ce86cd80
commit 512c014691
18 changed files with 89 additions and 65 deletions

View File

@@ -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;

View File

@@ -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.*;

View File

@@ -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;

View File

@@ -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)

View File

@@ -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;

View File

@@ -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"); };
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;