Added android_support library from NDK for swprinf and wchar support, updated JA2 project

This commit is contained in:
Sergii Pylypenko
2014-10-13 21:22:35 +03:00
parent 1a70e20b52
commit 7019f13274
10 changed files with 59 additions and 28 deletions

1
.gitignore vendored
View File

@@ -16,3 +16,4 @@ project/res/drawable/app_icon.png
project/proguard-project.txt
project/proguard-local.cfg
project/themes/converter
project/jni/android-support

View File

@@ -912,6 +912,9 @@ fi
./copyAssets.sh || exit 1
rm -rf project/jni/android-support
ln -s "`which ndk-build | sed 's@/ndk-build@@'`/sources/android/support" project/jni/android-support
if uname -s | grep -i "darwin" > /dev/null ; then
find project/src -name "*.killme.tmp" -delete
fi

View File

@@ -3,7 +3,7 @@
APP_MODULES := application sdl-1.2 sdl_main sdl_native_helpers jpeg png ogg flac vorbis freetype tremor ogg
# To filter out static libs from all libs in makefile
APP_AVAILABLE_STATIC_LIBS := jpeg png tremor freetype xerces ogg tremor vorbis flac boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread boost_locale glu icudata icutest icui18n icuio icule iculx icutu icuuc sdl_savepng
APP_AVAILABLE_STATIC_LIBS := jpeg png tremor freetype xerces ogg tremor vorbis flac boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread boost_locale glu icudata icutest icui18n icuio icule iculx icutu icuuc sdl_savepng android_support
APP_ABI := armeabi

View File

@@ -221,7 +221,7 @@ AppMinimumRAM=0
# Optional shared libraries to compile - removing some of them will save space
# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
CompiledLibraries="sdl_image"
CompiledLibraries="sdl_image android_support"
# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n)
CustomBuildScript=n

View File

@@ -13,6 +13,7 @@
#include <string.h>
#include <math.h>
#include <android/log.h>
#include <wchar.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
@@ -554,6 +555,19 @@ int main(int argc, char* argv[])
memset(gamepads, 0, sizeof(gamepads));
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "sizeof(int) %d long %d long long %d size_t %d", sizeof(int), sizeof(long), sizeof(long long), sizeof(size_t));
wchar_t ss[256];
const wchar_t *ss2 = L"String 2 ЕНГ ---";
swprintf(ss, 256, L"String ЙЦУК --- %ls", ss2);
char ss3[512] = "";
char ss4[512] = "";
for(i = 0; i < wcslen(ss); i++)
{
char tmp[16];
sprintf(tmp, "%04X ", (int)ss[i]);
strcat(ss3, tmp);
sprintf(ss4, "%ls", ss);
}
__android_log_print(ANDROID_LOG_VERBOSE, "Ballfield", "swprintf: len %d data %s: %s", wcslen(ss), ss3, ss4);
__android_log_print(ANDROID_LOG_VERBOSE, "Ballfield", "On-screen buttons:");
for(i = 0; i < SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM; i++)

View File

@@ -7,10 +7,10 @@ AppName="JaggedAlliance2"
AppFullName=com.opensourced.ja2
# Application version code (integer)
AppVersionCode=2347
AppVersionCode=01235202
# Application user-visible version name (string)
AppVersionName="0.12.10"
AppVersionName="0.12.352.02"
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu
@@ -21,7 +21,7 @@ AppVersionName="0.12.10"
AppDataDownloadUrl="!!JaggedAllianceData|ja2.zip"
# Reset SDL config when updating application to the new version (y) / (n)
ResetSdlConfigForThisVersion=y
ResetSdlConfigForThisVersion=n
# Delete application data files when upgrading (specify file/dir paths separated by spaces)
DeleteFilesOnUpgrade=""
@@ -75,30 +75,30 @@ CompatibilityHacksForceScreenUpdate=n
CompatibilityHacksForceScreenUpdateMouseClick=y
# Application initializes SDL audio/video inside static constructors (which is bad, you won't be able to run ndk-gdb) (y)/(n)
CompatibilityHacksStaticInit=
CompatibilityHacksStaticInit=n
# On-screen Android soft text input emulates hardware keyboard, this will only work with Hackers Keyboard app (y)/(n)
CompatibilityHacksTextInputEmulatesHwKeyboard=
CompatibilityHacksTextInputEmulatesHwKeyboard=n
# Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n)
CompatibilityHacksPreventAudioChopping=
CompatibilityHacksPreventAudioChopping=n
# Hack for broken apps: application ignores audio buffer size returned by SDL (y)/(n)
CompatibilityHacksAppIgnoresAudioBufferSize=
CompatibilityHacksAppIgnoresAudioBufferSize=n
# Hack for VCMI: preload additional shared libraries before aplication start
CompatibilityHacksAdditionalPreloadedSharedLibraries=""
# Hack for Free Heroes 2, which redraws the screen inside SDL_PumpEvents(): slow and compatible SDL event queue -
# do not use it with accelerometer/gyroscope, or your app may freeze at random (y)/(n)
CompatibilityHacksSlowCompatibleEventQueue=
CompatibilityHacksSlowCompatibleEventQueue=n
# Save and restore OpenGL state when drawing on-screen keyboard for apps that use SDL_OPENGL
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=n
# Application uses SDL_UpdateRects() properly, and does not draw in any region outside those rects.
# This improves drawing speed, but I know only one application that does that, and it's written by me (y)/(n)
CompatibilityHacksProperUsageOfSDL_UpdateRects=
CompatibilityHacksProperUsageOfSDL_UpdateRects=n
# Application uses mouse (y) or (n), this will show mouse emulation dialog to the user
AppUsesMouse=y
@@ -108,19 +108,19 @@ AppNeedsTwoButtonMouse=y
# Right mouse button can do long-press/drag&drop action, necessary for some games (y) or (n)
# If you disable it, swiping with two fingers will send mouse wheel events
RightMouseButtonLongPress=
RightMouseButtonLongPress=y
# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n)
ShowMouseCursor=
ShowMouseCursor=n
# Generate more touch events, by default SDL generates one event per one video frame, this is useful for drawing apps (y) or (n)
GenerateSubframeTouchEvents=
GenerateSubframeTouchEvents=n
# Force relative (laptop) mouse movement mode, useful when both on-screen keyboard and mouse are needed (y) or (n)
ForceRelativeMouseMode=n
# Show on-screen dpad/joystick, that will act as arrow keys (y) or (n)
AppNeedsArrowKeys=y
AppNeedsArrowKeys=n
# On-screen dpad/joystick will appear under finger when it touches the screen (y) or (n)
# Joystick always follows finger, so moving mouse requires touching the screen with other finger
@@ -154,16 +154,16 @@ AppUsesMultitouch=n
# Application records audio (it will use any available source, such a s microphone)
# API is defined in file SDL_android.h: int SDL_ANDROID_OpenAudioRecording(SDL_AudioSpec *spec); void SDL_ANDROID_CloseAudioRecording(void);
# This option will add additional permission to Android manifest (y)/(n)
AppRecordsAudio=
AppRecordsAudio=n
# Application needs to access SD card. If your data files are bigger than 5 Mb, enable it. (y) / (n)
AccessSdCard=
AccessSdCard=y
# Application needs Internet access. If you disable it, you'll have to bundle all your data files inside .apk (y) / (n)
AccessInternet=
AccessInternet=n
# Immersive mode - Android will hide on-screen Home/Back keys. Looks bad if you invoke Android keyboard. (y) / (n)
ImmersiveMode=
ImmersiveMode=y
# Application implements Android-specific routines to put to background, and will not draw anything to screen
# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them
@@ -176,10 +176,10 @@ NonBlockingSwapBuffers=n
# SEARCH and CALL by default return same keycode as DPAD_CENTER - one of those keys is available on most devices
# Use word NO_REMAP if you want to preserve native functionality for certain key (volume keys are 3-rd and 4-th)
# Keys: TOUCHSCREEN (works only when AppUsesMouse=n), DPAD_CENTER/SEARCH, VOLUMEUP, VOLUMEDOWN, MENU, BACK, CAMERA
RedefinedKeys="LCTRL RETURN KP_PLUS KP_MINUS LCTRL"
RedefinedKeys="MOUSE_RIGHT"
# Number of virtual keyboard keys (currently 6 is maximum)
AppTouchscreenKeyboardKeysAmount=5
AppTouchscreenKeyboardKeysAmount=1
# Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right)
RedefinedKeysScreenKb="LCTRL RETURN KP_PLUS KP_MINUS LCTRL"

View File

@@ -240,8 +240,21 @@ index 263f9b1..57d377c 100644
#define PATH_SEPARATOR '/'
#define PATH_SEPARATOR_STR "/"
#endif
diff --git a/sgp/PlatformSDL.h b/sgp/PlatformSDL.h
index 7d69ce0..246d80c 100644
--- a/sgp/PlatformSDL.h
+++ b/sgp/PlatformSDL.h
@@ -15,7 +15,7 @@
* http://developer.apple.com/library/mac/#technotes/tn2133/_index.html
*
*/
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__ANDROID__)
#define EXPENSIVE_SDL_UPDATE_RECT (1)
#else
#define EXPENSIVE_SDL_UPDATE_RECT (0)
diff --git a/sgp/SGP.cc b/sgp/SGP.cc
index d156d73..66d7cf0 100644
index d156d73..95c4097 100644
--- a/sgp/SGP.cc
+++ b/sgp/SGP.cc
@@ -13,6 +13,9 @@
@@ -273,7 +286,7 @@ index d156d73..66d7cf0 100644
#if defined BROKEN_SWPRINTF
if (setlocale(LC_CTYPE, "UTF-8") == NULL)
@@ -398,7 +401,7 @@ try
@@ -398,7 +398,7 @@ try
if(extraDataDir.empty())
{
// use location of the exe file
@@ -282,7 +295,7 @@ index d156d73..66d7cf0 100644
}
std::string externalizedDataPath = FileMan::joinPaths(extraDataDir, "externalized");
@@ -775,7 +779,7 @@ static void WriteDefaultConfigFile(const char* ConfigFile)
@@ -775,7 +775,7 @@ static void WriteDefaultConfigFile(const char* ConfigFile)
#ifdef _WIN32
fprintf(IniFile, "data_dir = C:\\Program Files\\Jagged Alliance 2");
#else