Lame support for multipart archives in assets, added XRick game
This commit is contained in:
@@ -875,7 +875,10 @@ if [ -d "project/jni/application/src/AndroidData" ] ; then
|
||||
echo Copying asset files
|
||||
for F in project/jni/application/src/AndroidData/*; do
|
||||
if [ `cat $F | wc -c` -gt 1048576 ] ; then
|
||||
echo "Error: the file $F is bigger than 1048576 bytes - some Android devices will fail to extract such file\nPlease split your data into several small files, or use HTTP download method"
|
||||
echo "Error: the file $F is bigger than 1048576 bytes - some Android devices will fail to extract such file"
|
||||
echo "Please use HTTP download method, or split your data into several small files with command:"
|
||||
echo "split -b 1000000 -d data.zip data.zip"
|
||||
echo "It will create files data.zip00, data.zip01 etc, and SDL will try to search for such files in assets when unpacking data.zip"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -185,22 +185,32 @@ class DataDownloader extends Thread
|
||||
public void run()
|
||||
{
|
||||
String [] downloadFiles = Globals.DataDownloadUrl.split("\\^");
|
||||
int total = 0;
|
||||
int count = 0;
|
||||
for( int i = 0; i < downloadFiles.length; i++ )
|
||||
{
|
||||
if( downloadFiles[i].length() > 0 &&
|
||||
( Globals.OptionalDataDownload.length > i && Globals.OptionalDataDownload[i] ) ||
|
||||
( Globals.OptionalDataDownload.length <= i && downloadFiles[i].indexOf("!") == 0 ) )
|
||||
if( ! DownloadDataFile(downloadFiles[i], "libsdl-DownloadFinished-" + String.valueOf(i) + ".flag") )
|
||||
total += 1;
|
||||
}
|
||||
for( int i = 0; i < downloadFiles.length; i++ )
|
||||
{
|
||||
if( downloadFiles[i].length() > 0 &&
|
||||
( Globals.OptionalDataDownload.length > i && Globals.OptionalDataDownload[i] ) ||
|
||||
( Globals.OptionalDataDownload.length <= i && downloadFiles[i].indexOf("!") == 0 ) )
|
||||
if( ! DownloadDataFile(downloadFiles[i], "libsdl-DownloadFinished-" + String.valueOf(i) + ".flag", count, total) )
|
||||
{
|
||||
DownloadFailed = true;
|
||||
return;
|
||||
}
|
||||
count += 1;
|
||||
}
|
||||
DownloadComplete = true;
|
||||
initParent();
|
||||
}
|
||||
|
||||
public boolean DownloadDataFile(final String DataDownloadUrl, final String DownloadFlagFileName)
|
||||
public boolean DownloadDataFile(final String DataDownloadUrl, final String DownloadFlagFileName, int downloadCount, int downloadTotal)
|
||||
{
|
||||
String [] downloadUrls = DataDownloadUrl.split("[|]");
|
||||
if( downloadUrls.length < 2 )
|
||||
@@ -261,7 +271,7 @@ class DataDownloader extends Thread
|
||||
String url = "";
|
||||
|
||||
int downloadUrlIndex = 1;
|
||||
while( downloadUrlIndex < downloadUrls.length )
|
||||
while( downloadUrlIndex < downloadUrls.length )
|
||||
{
|
||||
System.out.println("Processing download " + downloadUrls[downloadUrlIndex]);
|
||||
url = new String(downloadUrls[downloadUrlIndex]);
|
||||
@@ -271,7 +281,7 @@ class DataDownloader extends Thread
|
||||
url = url.substring( url.indexOf(":", 1) + 1 );
|
||||
DoNotUnzip = true;
|
||||
}
|
||||
Status.setText( res.getString(R.string.connecting_to, url) );
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.connecting_to, url) );
|
||||
if( url.indexOf("http://") == -1 && url.indexOf("https://") == -1 ) // File inside assets
|
||||
{
|
||||
System.out.println("Fetching file from assets: " + url);
|
||||
@@ -306,16 +316,43 @@ class DataDownloader extends Thread
|
||||
}
|
||||
if( FileInAssets )
|
||||
{
|
||||
try {
|
||||
stream = new CountingInputStream(Parent.getAssets().open(url), 8192);
|
||||
while( stream.skip(65536) > 0 ) { };
|
||||
totalLen = stream.getBytesRead();
|
||||
stream.close();
|
||||
stream = new CountingInputStream(Parent.getAssets().open(url), 8192);
|
||||
} catch( IOException e ) {
|
||||
System.out.println("Unpacking from assets '" + url + "' - error: " + e.toString());
|
||||
Status.setText( res.getString(R.string.error_dl_from, url) );
|
||||
return false;
|
||||
int multipartCounter = 0;
|
||||
InputStream multipart = null;
|
||||
while( true )
|
||||
{
|
||||
try {
|
||||
// Make string ".zip00", ".zip01" etc for multipart archives
|
||||
String url1 = url + String.format("%02d", multipartCounter);
|
||||
CountingInputStream stream1 = new CountingInputStream(Parent.getAssets().open(url1), 8192);
|
||||
while( stream1.skip(65536) > 0 ) { };
|
||||
totalLen += stream1.getBytesRead();
|
||||
stream1.close();
|
||||
InputStream s = Parent.getAssets().open(url1);
|
||||
if( multipart == null )
|
||||
multipart = s;
|
||||
else
|
||||
multipart = new SequenceInputStream(multipart, s);
|
||||
System.out.println("Multipart archive found: " + url1);
|
||||
} catch( IOException e ) {
|
||||
break;
|
||||
}
|
||||
multipartCounter += 1;
|
||||
}
|
||||
if( multipart != null )
|
||||
stream = new CountingInputStream(multipart, 8192);
|
||||
else
|
||||
{
|
||||
try {
|
||||
stream = new CountingInputStream(Parent.getAssets().open(url), 8192);
|
||||
while( stream.skip(65536) > 0 ) { };
|
||||
totalLen += stream.getBytesRead();
|
||||
stream.close();
|
||||
stream = new CountingInputStream(Parent.getAssets().open(url), 8192);
|
||||
} catch( IOException e ) {
|
||||
System.out.println("Unpacking from assets '" + url + "' - error: " + e.toString());
|
||||
Status.setText( res.getString(R.string.error_dl_from, url) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -327,7 +364,7 @@ class DataDownloader extends Thread
|
||||
return false;
|
||||
}
|
||||
|
||||
Status.setText( res.getString(R.string.dl_from, url) );
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_from, url) );
|
||||
totalLen = response.getEntity().getContentLength();
|
||||
try {
|
||||
stream = new CountingInputStream(response.getEntity().getContent(), 8192);
|
||||
@@ -374,7 +411,7 @@ class DataDownloader extends Thread
|
||||
float percent = 0.0f;
|
||||
if( totalLen > 0 )
|
||||
percent = stream.getBytesRead() * 100.0f / totalLen;
|
||||
Status.setText( res.getString(R.string.dl_progress, percent, path) );
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
|
||||
}
|
||||
out.flush();
|
||||
out.close();
|
||||
@@ -461,7 +498,7 @@ class DataDownloader extends Thread
|
||||
float percent = 0.0f;
|
||||
if( totalLen > 0 )
|
||||
percent = stream.getBytesRead() * 100.0f / totalLen;
|
||||
Status.setText( res.getString(R.string.dl_progress, percent, path) );
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
|
||||
|
||||
try {
|
||||
int len = zip.read(buf);
|
||||
@@ -474,7 +511,7 @@ class DataDownloader extends Thread
|
||||
percent = 0.0f;
|
||||
if( totalLen > 0 )
|
||||
percent = stream.getBytesRead() * 100.0f / totalLen;
|
||||
Status.setText( res.getString(R.string.dl_progress, percent, path) );
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
|
||||
}
|
||||
out.flush();
|
||||
out.close();
|
||||
@@ -518,7 +555,7 @@ class DataDownloader extends Thread
|
||||
Status.setText( res.getString(R.string.error_write, path) );
|
||||
return false;
|
||||
};
|
||||
Status.setText( res.getString(R.string.dl_finished) );
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_finished) );
|
||||
|
||||
try {
|
||||
stream.close();
|
||||
|
||||
@@ -1 +1 @@
|
||||
fheroes2
|
||||
xrick
|
||||
44
project/jni/application/xrick/AndroidAppSettings.cfg
Normal file
44
project/jni/application/xrick/AndroidAppSettings.cfg
Normal file
@@ -0,0 +1,44 @@
|
||||
# The application settings for Android libSDL port
|
||||
AppSettingVersion=17
|
||||
LibSdlVersion=1.2
|
||||
AppName="XRick"
|
||||
AppFullName=net.xrick.sdl
|
||||
ScreenOrientation=h
|
||||
InhibitSuspend=y
|
||||
AppDataDownloadUrl="!Data size is 1 Mb|data1.zip"
|
||||
VideoDepthBpp=16
|
||||
NeedDepthBuffer=n
|
||||
NeedStencilBuffer=n
|
||||
NeedGles2=n
|
||||
SwVideoMode=y
|
||||
SdlVideoResize=y
|
||||
SdlVideoResizeKeepAspect=n
|
||||
CompatibilityHacks=n
|
||||
AppUsesMouse=n
|
||||
AppNeedsTwoButtonMouse=n
|
||||
ShowMouseCursor=n
|
||||
ForceRelativeMouseMode=n
|
||||
AppNeedsArrowKeys=y
|
||||
AppNeedsTextInput=y
|
||||
AppUsesJoystick=n
|
||||
AppHandlesJoystickSensitivity=y
|
||||
AppUsesMultitouch=n
|
||||
NonBlockingSwapBuffers=n
|
||||
RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP E ESCAPE P F7 F8 F9"
|
||||
AppTouchscreenKeyboardKeysAmount=1
|
||||
AppTouchscreenKeyboardKeysAmountAutoFire=0
|
||||
RedefinedKeysScreenKb="SPACE"
|
||||
StartupMenuButtonTimeout=3000
|
||||
HiddenMenuOptions='OptionalDownloadConfig'
|
||||
FirstStartMenuOptions=''
|
||||
MultiABI=n
|
||||
AppVersionCode=100001
|
||||
AppVersionName="021212"
|
||||
ResetSdlConfigForThisVersion=n
|
||||
CompiledLibraries="jpeg png"
|
||||
CustomBuildScript=n
|
||||
AppCflags='-DENABLE_SOUND'
|
||||
AppLdflags=''
|
||||
AppSubdirsBuild='xrick-021212/src/* xrick-021212/include/*'
|
||||
AppCmdline=''
|
||||
ReadmeText='^You may press "Home" now - the data will be downloaded in background'
|
||||
BIN
project/jni/application/xrick/AndroidData/data1.zip00
Normal file
BIN
project/jni/application/xrick/AndroidData/data1.zip00
Normal file
Binary file not shown.
BIN
project/jni/application/xrick/AndroidData/data1.zip01
Normal file
BIN
project/jni/application/xrick/AndroidData/data1.zip01
Normal file
Binary file not shown.
1
project/jni/application/xrick/ReadMe.txt
Normal file
1
project/jni/application/xrick/ReadMe.txt
Normal file
@@ -0,0 +1 @@
|
||||
source code: http://www.bigorno.net/xrick/xrick-021212.tgz
|
||||
BIN
project/jni/application/xrick/icon.png
Normal file
BIN
project/jni/application/xrick/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
106
project/jni/application/xrick/xrick-021212-diff.patch
Normal file
106
project/jni/application/xrick/xrick-021212-diff.patch
Normal file
@@ -0,0 +1,106 @@
|
||||
diff -u -r xrick-021212-orig/include/game.h xrick-021212/include/game.h
|
||||
--- xrick-021212-orig/include/game.h 2002-12-24 15:32:56.000000000 +0200
|
||||
+++ xrick-021212/include/game.h 2011-11-29 13:14:33.454886155 +0200
|
||||
@@ -28,7 +28,7 @@
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
-#define GAME_PERIOD 75
|
||||
+#define GAME_PERIOD 50
|
||||
|
||||
#define GAME_BOMBS_INIT 6
|
||||
#define GAME_BULLETS_INIT 6
|
||||
diff -u -r xrick-021212-orig/include/system.h xrick-021212/include/system.h
|
||||
--- xrick-021212-orig/include/system.h 2002-12-24 15:32:56.000000000 +0200
|
||||
+++ xrick-021212/include/system.h 2011-11-29 13:05:45.970890984 +0200
|
||||
@@ -76,7 +76,7 @@
|
||||
/*
|
||||
* video section
|
||||
*/
|
||||
-#define SYSVID_ZOOM 2
|
||||
+#define SYSVID_ZOOM 1
|
||||
#define SYSVID_MAXZOOM 4
|
||||
#define SYSVID_WIDTH 320
|
||||
#define SYSVID_HEIGHT 200
|
||||
Only in xrick-021212: Makefile.global
|
||||
diff -u -r xrick-021212-orig/src/syssnd.c xrick-021212/src/syssnd.c
|
||||
--- xrick-021212-orig/src/syssnd.c 2002-12-24 15:33:43.000000000 +0200
|
||||
+++ xrick-021212/src/syssnd.c 2011-11-29 13:00:12.022894042 +0200
|
||||
@@ -125,7 +125,7 @@
|
||||
}
|
||||
|
||||
desired.freq = SYSSND_FREQ;
|
||||
- desired.format = AUDIO_U8;
|
||||
+ desired.format = AUDIO_S8;
|
||||
desired.channels = SYSSND_CHANNELS;
|
||||
desired.samples = SYSSND_MIXSAMPLES;
|
||||
desired.callback = syssnd_callback;
|
||||
diff -u -r xrick-021212-orig/src/system.c xrick-021212/src/system.c
|
||||
--- xrick-021212-orig/src/system.c 2002-12-24 15:33:43.000000000 +0200
|
||||
+++ xrick-021212/src/system.c 2011-11-29 13:54:55.738863977 +0200
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "system.h"
|
||||
+#include <android/log.h>
|
||||
|
||||
/*
|
||||
* Panic
|
||||
@@ -42,6 +43,7 @@
|
||||
|
||||
/* print message and die */
|
||||
printf("%s\npanic!\n", s);
|
||||
+ __android_log_print(ANDROID_LOG_FATAL, "XRick", "Error: %s", s);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -65,6 +67,7 @@
|
||||
vsprintf(s, msg, argptr);
|
||||
va_end(argptr);
|
||||
printf(s);
|
||||
+ __android_log_print(ANDROID_LOG_INFO, "XRick", "%s", s);
|
||||
}
|
||||
|
||||
/*
|
||||
diff -u -r xrick-021212-orig/src/sysvid.c xrick-021212/src/sysvid.c
|
||||
--- xrick-021212-orig/src/sysvid.c 2002-12-24 15:33:43.000000000 +0200
|
||||
+++ xrick-021212/src/sysvid.c 2011-11-29 13:10:59.218888117 +0200
|
||||
@@ -29,11 +29,11 @@
|
||||
|
||||
static SDL_Color palette[256];
|
||||
static SDL_Surface *screen;
|
||||
-static U32 videoFlags;
|
||||
+static U32 videoFlags = SDL_SWSURFACE;
|
||||
|
||||
static U8 zoom = SYSVID_ZOOM; /* actual zoom level */
|
||||
-static U8 szoom = 0; /* saved zoom level */
|
||||
-static U8 fszoom = 0; /* fullscreen zoom level */
|
||||
+static U8 szoom = 1; /* saved zoom level */
|
||||
+static U8 fszoom = 1; /* fullscreen zoom level */
|
||||
|
||||
#include "img_icon.e"
|
||||
|
||||
@@ -221,7 +221,7 @@
|
||||
SDL_WM_SetIcon(s, NULL);
|
||||
|
||||
/* video modes and screen */
|
||||
- videoFlags = SDL_HWSURFACE|SDL_HWPALETTE;
|
||||
+ videoFlags = SDL_SWSURFACE;
|
||||
sysvid_chkvm(); /* check video modes */
|
||||
if (sysarg_args_zoom)
|
||||
zoom = sysarg_args_zoom;
|
||||
@@ -315,12 +315,13 @@
|
||||
area.y = rects->y * zoom;
|
||||
area.h = rects->height * zoom;
|
||||
area.w = rects->width * zoom;
|
||||
- SDL_UpdateRects(screen, 1, &area);
|
||||
+ /* SDL_UpdateRects(screen, 1, &area); */
|
||||
|
||||
rects = rects->next;
|
||||
}
|
||||
|
||||
SDL_UnlockSurface(screen);
|
||||
+ SDL_Flip(screen);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user