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:
@@ -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=""
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.enigmagame.enigma"
|
||||
android:versionCode="1"
|
||||
android:versionName="0.1"
|
||||
package="de.schwardtnet.alienblaster"
|
||||
android:versionCode="110011"
|
||||
android:versionName="1.1.0.11 - fixed keys stuck sometimes for on-screen keyboard, fixed restoring app from background"
|
||||
android:installLocation="preferExternal"
|
||||
>
|
||||
<application android:label="@string/app_name"
|
||||
|
||||
0
project/assets/PUT_DATA_FILES_HERE
Normal file
0
project/assets/PUT_DATA_FILES_HERE
Normal file
@@ -1,6 +1,6 @@
|
||||
|
||||
# The namespace in Java file, with dots replaced with underscores
|
||||
SDL_JAVA_PACKAGE_PATH := org_enigmagame_enigma
|
||||
SDL_JAVA_PACKAGE_PATH := de_schwardtnet_alienblaster
|
||||
|
||||
# Path to shared libraries - Android 1.6 cannot load them properly, thus we have to specify absolute path here
|
||||
# SDL_SHARED_LIBRARIES_PATH := /data/data/de.schwardtnet.alienblaster/lib
|
||||
@@ -10,7 +10,7 @@ SDL_JAVA_PACKAGE_PATH := org_enigmagame_enigma
|
||||
# Typically /sdcard/alienblaster
|
||||
# Or /data/data/de.schwardtnet.alienblaster/files if you're planning to unpack data in application private folder
|
||||
# Your application will just set current directory there
|
||||
SDL_CURDIR_PATH := org.enigmagame.enigma
|
||||
SDL_CURDIR_PATH := de.schwardtnet.alienblaster
|
||||
|
||||
# Android Dev Phone G1 has trackball instead of cursor keys, and
|
||||
# sends trackball movement events as rapid KeyDown/KeyUp events,
|
||||
@@ -23,11 +23,11 @@ SDL_TRACKBALL_KEYUP_DELAY := 1
|
||||
# resized in HW-accelerated way, however it eats a tiny bit of CPU
|
||||
SDL_VIDEO_RENDER_RESIZE := 1
|
||||
|
||||
COMPILED_LIBRARIES := sdl_mixer sdl_image sdl_ttf intl lua
|
||||
COMPILED_LIBRARIES := sdl_mixer sdl_image
|
||||
|
||||
APPLICATION_ADDITIONAL_CFLAGS := -finline-functions -O2
|
||||
|
||||
APPLICATION_ADDITIONAL_LDFLAGS := -lpng -lxerces
|
||||
APPLICATION_ADDITIONAL_LDFLAGS :=
|
||||
|
||||
APPLICATION_SUBDIRS_BUILD :=
|
||||
|
||||
@@ -35,7 +35,7 @@ APPLICATION_CUSTOM_BUILD_SCRIPT :=
|
||||
|
||||
SDL_ADDITIONAL_CFLAGS := -DSDL_ANDROID_KEYCODE_MOUSE=UNKNOWN -DSDL_ANDROID_KEYCODE_0=RETURN -DSDL_ANDROID_KEYCODE_1=LCTRL -DSDL_ANDROID_KEYCODE_2=PAGEUP -DSDL_ANDROID_KEYCODE_3=PAGEDOWN -DSDL_ANDROID_KEYCODE_4=LCTRL
|
||||
|
||||
SDL_VERSION := 1.2
|
||||
SDL_VERSION := 1.3
|
||||
|
||||
# If SDL_Mixer should link to libMAD
|
||||
SDL_MIXER_USE_LIBMAD :=
|
||||
|
||||
@@ -6,6 +6,6 @@ APP_PROJECT_PATH := $(call my-dir)/..
|
||||
# sdl_image depends on png and jpeg
|
||||
# sdl_ttf depends on freetype
|
||||
|
||||
APP_MODULES := application sdl-1.2 sdl_main stlport tremor png jpeg freetype xerces sdl_mixer sdl_image sdl_ttf intl lua
|
||||
APP_MODULES := application sdl-1.3 sdl_main stlport tremor png jpeg freetype xerces sdl_mixer sdl_image
|
||||
|
||||
APP_ABI := armeabi
|
||||
|
||||
@@ -4,7 +4,7 @@ LibSdlVersion=1.3
|
||||
AppName="Alien Blaster"
|
||||
AppFullName=de.schwardtnet.alienblaster
|
||||
ScreenOrientation=h
|
||||
AppDataDownloadUrl="Data size is 2 Mb|http://sites.google.com/site/xpelyax/Home/alienblaster110_data.zip?attredirects=0&d=1|http://sitesproxy.goapk.com/site/xpelyax/Home/alienblaster110_data.zip"
|
||||
AppDataDownloadUrl="Data size is 2 Mb|alienblaster110_data.zip|http://sites.google.com/site/xpelyax/Home/alienblaster110_data.zip?attredirects=0&d=1|http://sitesproxy.goapk.com/site/xpelyax/Home/alienblaster110_data.zip"
|
||||
SdlVideoResize=y
|
||||
NeedDepthBuffer=n
|
||||
AppUsesMouse=n
|
||||
|
||||
@@ -1 +1 @@
|
||||
enigma
|
||||
alienblaster
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">enigma</string>
|
||||
<string name="app_name">Alien Blaster</string>
|
||||
|
||||
|
||||
<string name="init">Initializing</string>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.*;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"); };
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
10
readme.txt
10
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
|
||||
|
||||
Reference in New Issue
Block a user