First implementation of picture button theme, still no transparency
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.sourceforge.sc2"
|
||||
android:versionCode="1002"
|
||||
android:versionName="1.0.02"
|
||||
package="com.googlecode.opentyrian"
|
||||
android:versionCode="2106"
|
||||
android:versionName="2.1.06"
|
||||
android:installLocation="preferExternal"
|
||||
>
|
||||
<application android:label="@string/app_name"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
# The namespace in Java file, with dots replaced with underscores
|
||||
SDL_JAVA_PACKAGE_PATH := com_sourceforge_sc2
|
||||
SDL_JAVA_PACKAGE_PATH := com_googlecode_opentyrian
|
||||
|
||||
# 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 := com_sourceforge_sc2
|
||||
# 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 := com.sourceforge.sc2
|
||||
SDL_CURDIR_PATH := com.googlecode.opentyrian
|
||||
|
||||
# Android Dev Phone G1 has trackball instead of cursor keys, and
|
||||
# sends trackball movement events as rapid KeyDown/KeyUp events,
|
||||
@@ -23,13 +23,13 @@ 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_image
|
||||
COMPILED_LIBRARIES := sdl_net
|
||||
|
||||
APPLICATION_ADDITIONAL_CFLAGS := -O0 -DTHREADLIB_SDL=1 -DTIMELIB=SDL -DOVCODEC_TREMOR=1 -DNETPLAY=1 -DHAVE_REGEX=1 -DHAVE_GETOPT_LONG=1 -DHAVE_ZIP=1
|
||||
APPLICATION_ADDITIONAL_CFLAGS := -finline-functions -O2
|
||||
|
||||
APPLICATION_ADDITIONAL_LDFLAGS := -Lbin/ndk/local/armeabi -ltremor
|
||||
APPLICATION_ADDITIONAL_LDFLAGS :=
|
||||
|
||||
SDL_ADDITIONAL_CFLAGS := -DSDL_ANDROID_KEYCODE_MOUSE=UNKNOWN -DSDL_ANDROID_KEYCODE_0=RETURN -DSDL_ANDROID_KEYCODE_1=RSHIFT -DSDL_ANDROID_KEYCODE_2=KP_PLUS -DSDL_ANDROID_KEYCODE_3=KP_MINUS -DSDL_ANDROID_KEYCODE_4=ESCAPE -DSDL_ANDROID_KEYCODE_5=F10
|
||||
SDL_ADDITIONAL_CFLAGS := -DSDL_ANDROID_KEYCODE_MOUSE=UNKNOWN -DSDL_ANDROID_KEYCODE_0=SPACE -DSDL_ANDROID_KEYCODE_1=RETURN -DSDL_ANDROID_KEYCODE_2=LCTRL -DSDL_ANDROID_KEYCODE_3=LALT -DSDL_ANDROID_KEYCODE_4=RETURN
|
||||
|
||||
# If SDL_Mixer should link to libMAD
|
||||
SDL_MIXER_USE_LIBMAD :=
|
||||
|
||||
@@ -5,6 +5,6 @@ APP_PROJECT_PATH := $(call my-dir)/..
|
||||
# sdl_image depends on png and jpeg
|
||||
# sdl_ttf depends on freetype
|
||||
|
||||
APP_MODULES := application sdl sdl_main stlport tremor png jpeg freetype sdl_image
|
||||
APP_MODULES := application sdl sdl_main stlport tremor png jpeg freetype sdl_net
|
||||
|
||||
APP_ABI := armeabi
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
AppSettingVersion=4
|
||||
AppSettingVersion=6
|
||||
LibSdlVersion=1.2
|
||||
AppName="OpenTyrian"
|
||||
AppFullName=com.googlecode.opentyrian
|
||||
ScreenOrientation=h
|
||||
AppDataDownloadUrl="^Data files size is 11 Mb|http://sites.google.com/site/xpelyax/Home/tyrian21-data.zip?attredirects=0&d=1|http://sitesproxy.goapk.com/site/xpelyax/Home/tyrian21-data.zip"
|
||||
AppDataDownloadUrl="Data files size is 11 Mb|http://sites.google.com/site/xpelyax/Home/tyrian21-data.zip?attredirects=0&d=1|http://sitesproxy.goapk.com/site/xpelyax/Home/tyrian21-data.zip"
|
||||
SdlVideoResize=y
|
||||
NeedDepthBuffer=n
|
||||
AppUsesMouse=n
|
||||
@@ -12,9 +12,10 @@ AppUsesJoystick=n
|
||||
AppUsesMultitouch=n
|
||||
RedefinedKeys="SPACE RETURN LCTRL LALT RETURN"
|
||||
AppTouchscreenKeyboardKeysAmount=4
|
||||
AppTouchscreenKeyboardKeysAmountAutoFire=1
|
||||
MultiABI=n
|
||||
AppVersionCode=2105
|
||||
AppVersionName="2.1.05"
|
||||
AppVersionCode=2106
|
||||
AppVersionName="2.1.06"
|
||||
CompiledLibraries="sdl_net"
|
||||
AppCflags='-finline-functions -O2'
|
||||
AppLdflags=''
|
||||
|
||||
@@ -1 +1 @@
|
||||
sc2
|
||||
opentyrian
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Ur-Quan Masters</string>
|
||||
<string name="app_name">OpenTyrian</string>
|
||||
</resources>
|
||||
|
||||
@@ -27,11 +27,14 @@
|
||||
#include <math.h>
|
||||
#include <string.h> // for memset()
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_version.h"
|
||||
|
||||
//#include "SDL_opengles.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "SDL_androidvideo.h"
|
||||
#include "SDL_androidinput.h"
|
||||
@@ -77,6 +80,24 @@ static int ButtonAutoFireRot[MAX_BUTTONS_AUTOFIRE] = {0, 0};
|
||||
|
||||
static SDL_Rect * OldCoords[MAX_MULTITOUCH_POINTERS] = { NULL };
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GLuint id;
|
||||
GLfloat w;
|
||||
GLfloat h;
|
||||
} GLTexture_t;
|
||||
|
||||
static GLTexture_t arrowImages[5] = { {0, 0, 0}, };
|
||||
static GLTexture_t buttonAutoFireImages[MAX_BUTTONS_AUTOFIRE] = { {0, 0, 0}, };
|
||||
static GLTexture_t buttonImages[MAX_BUTTONS*2] = { {0, 0, 0}, };
|
||||
|
||||
|
||||
static inline int InsideRect(const SDL_Rect * r, int x, int y)
|
||||
{
|
||||
return ( x >= r->x && x <= r->x + r->w ) && ( y >= r->y && y <= r->y + r->h );
|
||||
}
|
||||
|
||||
|
||||
// Should be called on each char of font before drawing
|
||||
static void prepareFontCharWireframe(int idx, int w, int h)
|
||||
{
|
||||
@@ -122,8 +143,7 @@ static inline void endDrawingWireframe()
|
||||
// TODO: use SDL 1.3 renderer routines? It will not be pixel-aligned then, if the screen is resized
|
||||
static inline void drawCharWireframe(int idx, Uint16 x, Uint16 y, int rotation, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
//glColor4f((GLfloat) r * inv255f, (GLfloat) g * inv255f, (GLfloat) b * inv255f, (GLfloat) a * inv255f);
|
||||
glColor4x(r * 0x10000, g * 0x10000, b * 0x10000, a * 0x10000);
|
||||
glColor4x(r * 0x100, g * 0x100, b * 0x100, a * 0x100);
|
||||
|
||||
glVertexPointer(2, GL_SHORT, 0, fontGL[idx]);
|
||||
glPopMatrix();
|
||||
@@ -134,9 +154,59 @@ static inline void drawCharWireframe(int idx, Uint16 x, Uint16 y, int rotation,
|
||||
glDrawArrays(GL_LINES, 0, fontGL[idx][FONT_CHAR_LINES_COUNT]);
|
||||
}
|
||||
|
||||
static inline int InsideRect(const SDL_Rect * r, int x, int y)
|
||||
static inline void beginDrawingTex()
|
||||
{
|
||||
return ( x >= r->x && x <= r->x + r->w ) && ( y >= r->y && y <= r->y + r->h );
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
static inline void endDrawingTex()
|
||||
{
|
||||
/*
|
||||
GLfloat texColor[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, texColor);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glDisable(GL_BLEND);
|
||||
*/
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
|
||||
static inline void drawCharTex(GLTexture_t * tex, SDL_Rect * pos, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
GLint cropRect[4];
|
||||
/*
|
||||
GLfloat texColor[4];
|
||||
static const float onediv255 = 1.0f / 255.0f;
|
||||
*/
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, tex->id);
|
||||
|
||||
glColor4x(r * 0x100, g * 0x100, b * 0x100, a * 0x100 );
|
||||
|
||||
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
/*
|
||||
texColor[0] = r * onediv255;
|
||||
texColor[1] = g * onediv255;
|
||||
texColor[2] = b * onediv255;
|
||||
texColor[3] = a * onediv255;
|
||||
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, texColor);
|
||||
*/
|
||||
|
||||
cropRect[0] = 0;
|
||||
cropRect[1] = tex->h;
|
||||
cropRect[2] = tex->w;
|
||||
cropRect[3] = -tex->h;
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, cropRect);
|
||||
glDrawTexiOES(pos->x, SDL_ANDROID_sWindowHeight - pos->y - pos->h, 0, pos->w, pos->h);
|
||||
}
|
||||
|
||||
int SDL_ANDROID_drawTouchscreenKeyboard()
|
||||
@@ -165,6 +235,35 @@ int SDL_ANDROID_drawTouchscreenKeyboard()
|
||||
}
|
||||
endDrawingWireframe();
|
||||
}
|
||||
else
|
||||
{
|
||||
int blendFactor = ( SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] ? 1 : 0 ) +
|
||||
( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] ? 1 : 0 ) +
|
||||
( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] ? 1 : 0 ) +
|
||||
( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] ? 1 : 0 );
|
||||
beginDrawingTex();
|
||||
if( blendFactor == 0 )
|
||||
drawCharTex( &arrowImages[0], &arrows, 255, 255, 255, 128 );
|
||||
else
|
||||
{
|
||||
if( SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] )
|
||||
drawCharTex( &arrowImages[1], &arrows, 255, 255, 255, 128 / blendFactor );
|
||||
if( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] )
|
||||
drawCharTex( &arrowImages[2], &arrows, 255, 255, 255, 128 / blendFactor );
|
||||
if( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] )
|
||||
drawCharTex( &arrowImages[3], &arrows, 255, 255, 255, 128 / blendFactor );
|
||||
if( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] )
|
||||
drawCharTex( &arrowImages[4], &arrows, 255, 255, 255, 128 / blendFactor );
|
||||
}
|
||||
|
||||
for( i = 0; i < nbuttons; i++ )
|
||||
{
|
||||
drawCharTex( ( i < AutoFireButtonsNum && ButtonAutoFire[i] ) ? &buttonAutoFireImages[i] :
|
||||
&buttonImages[ SDL_GetKeyboardState(NULL)[buttonKeysyms[i]] ? i * 2 + 1 : i *2 ],
|
||||
&buttons[i], 255, 255, 255, i % 2 ? 64 : 192);
|
||||
}
|
||||
endDrawingTex();
|
||||
}
|
||||
return 1;
|
||||
};
|
||||
|
||||
@@ -322,60 +421,95 @@ int SDL_android_processTouchscreenKeyboard(int x, int y, int action, int pointer
|
||||
};
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thiz, jint size, jint _nbuttons, jint nbuttonsAutoFire )
|
||||
JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thiz, jint size, jint theme, jint _nbuttons, jint nbuttonsAutoFire )
|
||||
{
|
||||
int i;
|
||||
int i, ii;
|
||||
int nbuttons1row, nbuttons2row;
|
||||
nbuttons = _nbuttons;
|
||||
touchscreenKeyboardTheme = theme;
|
||||
if( nbuttons > MAX_BUTTONS )
|
||||
nbuttons = MAX_BUTTONS;
|
||||
AutoFireButtonsNum = nbuttonsAutoFire;
|
||||
if( AutoFireButtonsNum > MAX_BUTTONS_AUTOFIRE )
|
||||
AutoFireButtonsNum = MAX_BUTTONS_AUTOFIRE;
|
||||
// TODO: works for horizontal screen orientation only!
|
||||
// TODO: configurable keyboard size
|
||||
|
||||
// Arrows to the lower-left part of screen
|
||||
arrows.w = SDL_ANDROID_sWindowWidth / (size + 2);
|
||||
arrows.h = arrows.w;
|
||||
arrows.x = 0;
|
||||
arrows.y = SDL_ANDROID_sWindowHeight - arrows.h;
|
||||
|
||||
// Main button to the lower-right
|
||||
buttons[0].w = SDL_ANDROID_sWindowWidth / (size + 2);
|
||||
buttons[0].h = SDL_ANDROID_sWindowHeight / (size + 2);
|
||||
buttons[0].x = SDL_ANDROID_sWindowWidth - buttons[0].w;
|
||||
buttons[0].y = SDL_ANDROID_sWindowHeight - buttons[0].h;
|
||||
|
||||
// Row of secondary buttons to the upper-right
|
||||
nbuttons1row = MIN(nbuttons, 4);
|
||||
for( i = 1; i < nbuttons1row; i++ )
|
||||
if(touchscreenKeyboardTheme == 0)
|
||||
{
|
||||
buttons[i].w = SDL_ANDROID_sWindowWidth / (nbuttons1row - 1) / (size + 2);
|
||||
buttons[i].h = SDL_ANDROID_sWindowHeight / (size + 2);
|
||||
buttons[i].x = SDL_ANDROID_sWindowWidth - buttons[i].w * (nbuttons1row - i);
|
||||
buttons[i].y = 0;
|
||||
}
|
||||
// Arrows to the lower-left part of screen
|
||||
arrows.w = SDL_ANDROID_sWindowWidth / (size + 2);
|
||||
arrows.h = arrows.w;
|
||||
arrows.x = 0;
|
||||
arrows.y = SDL_ANDROID_sWindowHeight - arrows.h;
|
||||
|
||||
// Main button to the lower-right
|
||||
buttons[0].w = SDL_ANDROID_sWindowWidth / (size + 2);
|
||||
buttons[0].h = SDL_ANDROID_sWindowHeight / (size + 2);
|
||||
buttons[0].x = SDL_ANDROID_sWindowWidth - buttons[0].w;
|
||||
buttons[0].y = SDL_ANDROID_sWindowHeight - buttons[0].h;
|
||||
|
||||
// Row of secondary buttons to the upper-left above arrows
|
||||
nbuttons2row = MIN(nbuttons, 7);
|
||||
for( i = 4; i < nbuttons2row; i++ )
|
||||
{
|
||||
buttons[i].w = SDL_ANDROID_sWindowWidth / (nbuttons2row - 4) / (size + 2);
|
||||
buttons[i].h = (SDL_ANDROID_sWindowHeight - SDL_ANDROID_sWindowWidth / 2) * 2 / (size + 2);
|
||||
buttons[i].x = buttons[i].w * (nbuttons2row - i - 1);
|
||||
buttons[i].y = 0;
|
||||
}
|
||||
// Row of secondary buttons to the upper-right
|
||||
nbuttons1row = MIN(nbuttons, 4);
|
||||
for( i = 1; i < nbuttons1row; i++ )
|
||||
{
|
||||
buttons[i].w = SDL_ANDROID_sWindowWidth / (nbuttons1row - 1) / (size + 2);
|
||||
buttons[i].h = SDL_ANDROID_sWindowHeight / (size + 2);
|
||||
buttons[i].x = SDL_ANDROID_sWindowWidth - buttons[i].w * (nbuttons1row - i);
|
||||
buttons[i].y = 0;
|
||||
}
|
||||
|
||||
// Row of secondary buttons to the upper-left above arrows
|
||||
nbuttons2row = MIN(nbuttons, 7);
|
||||
for( i = 4; i < nbuttons2row; i++ )
|
||||
{
|
||||
buttons[i].w = SDL_ANDROID_sWindowWidth / (nbuttons2row - 4) / (size + 2);
|
||||
buttons[i].h = (SDL_ANDROID_sWindowHeight - SDL_ANDROID_sWindowWidth / 2) * 2 / (size + 2);
|
||||
buttons[i].x = buttons[i].w * (nbuttons2row - i - 1);
|
||||
buttons[i].y = 0;
|
||||
}
|
||||
|
||||
// Resize char images
|
||||
prepareFontCharWireframe(FONT_LEFT, arrows.w / 2, arrows.h / 2);
|
||||
prepareFontCharWireframe(FONT_RIGHT, arrows.w / 2, arrows.h / 2);
|
||||
prepareFontCharWireframe(FONT_UP, arrows.w / 2, arrows.h / 2);
|
||||
prepareFontCharWireframe(FONT_DOWN, arrows.w / 2, arrows.h / 2);
|
||||
|
||||
// Resize char images
|
||||
prepareFontCharWireframe(FONT_LEFT, arrows.w / 2, arrows.h / 2);
|
||||
prepareFontCharWireframe(FONT_RIGHT, arrows.w / 2, arrows.h / 2);
|
||||
prepareFontCharWireframe(FONT_UP, arrows.w / 2, arrows.h / 2);
|
||||
prepareFontCharWireframe(FONT_DOWN, arrows.w / 2, arrows.h / 2);
|
||||
|
||||
for( i = 0; i < nbuttons; i++ )
|
||||
for( i = 0; i < nbuttons; i++ )
|
||||
{
|
||||
prepareFontCharWireframe(FONT_BTN1 + i, MIN(buttons[i].h, buttons[i].w), MIN(buttons[i].h, buttons[i].w));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
prepareFontCharWireframe(FONT_BTN1 + i, MIN(buttons[i].h, buttons[i].w), MIN(buttons[i].h, buttons[i].w));
|
||||
if(touchscreenKeyboardTheme == 1)
|
||||
AutoFireButtonsNum = 0; // Theme does not support auto-fire
|
||||
// Arrows to the lower-left part of screen
|
||||
arrows.x = SDL_ANDROID_sWindowWidth / 4;
|
||||
arrows.y = SDL_ANDROID_sWindowHeight - SDL_ANDROID_sWindowWidth / 4;
|
||||
arrows.w = SDL_ANDROID_sWindowWidth / (size + 2);
|
||||
arrows.h = arrows.w;
|
||||
arrows.x -= arrows.w/2;
|
||||
arrows.y -= arrows.h/2;
|
||||
|
||||
// Buttons to the lower-right in 2 rows
|
||||
for(i = 0; i < 2; i++)
|
||||
for(ii = 0; ii < 3; ii++)
|
||||
{
|
||||
// Custom button ordering
|
||||
int iii = ii + i*2;
|
||||
if( ii == 2 )
|
||||
iii = 5 + i;
|
||||
buttons[iii].x = SDL_ANDROID_sWindowWidth - SDL_ANDROID_sWindowWidth / 12 - (SDL_ANDROID_sWindowWidth * ii / 6);
|
||||
buttons[iii].y = SDL_ANDROID_sWindowHeight - SDL_ANDROID_sWindowHeight / 8 - (SDL_ANDROID_sWindowHeight * i / 4);
|
||||
buttons[iii].w = SDL_ANDROID_sWindowWidth / (size + 2) / 3;
|
||||
buttons[iii].h = buttons[iii].w;
|
||||
buttons[iii].x -= buttons[iii].w/2;
|
||||
buttons[iii].y -= buttons[iii].h/2;
|
||||
}
|
||||
buttons[6].x = 0;
|
||||
buttons[6].y = 0;
|
||||
buttons[6].w = 30;
|
||||
buttons[6].h = 30;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -386,3 +520,62 @@ JAVA_EXPORT_NAME(Settings_nativeSetTouchscreenKeyboardUsed) ( JNIEnv* env, jobj
|
||||
isTouchscreenKeyboardUsed = 1;
|
||||
}
|
||||
|
||||
static int
|
||||
power_of_2(int input)
|
||||
{
|
||||
int value = 1;
|
||||
|
||||
while (value < input) {
|
||||
value <<= 1;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboardButton) ( JNIEnv* env, jobject thiz, jint buttonID, jbyteArray charBufJava )
|
||||
{
|
||||
// TODO: softstretch with antialiasing
|
||||
jboolean isCopy = JNI_TRUE;
|
||||
Uint8 * charBuf = NULL;
|
||||
int w, h, len, format;
|
||||
GLTexture_t * data = NULL;
|
||||
int texture_w, texture_h;
|
||||
len = (*env)->GetArrayLength(env, charBufJava);
|
||||
charBuf = (Uint8 *) (*env)->GetByteArrayElements(env, charBufJava, &isCopy);
|
||||
|
||||
w = ntohl(((Uint32 *) charBuf)[0]);
|
||||
h = ntohl(((Uint32 *) charBuf)[1]);
|
||||
format = ntohl(((Uint32 *) charBuf)[2]);
|
||||
if( buttonID < 5 )
|
||||
data = &(arrowImages[buttonID]);
|
||||
else
|
||||
if( buttonID < 7 )
|
||||
data = &(buttonAutoFireImages[buttonID-5]);
|
||||
else
|
||||
data = &(buttonImages[buttonID-7]);
|
||||
|
||||
texture_w = power_of_2(w);
|
||||
texture_h = power_of_2(h);
|
||||
data->w = w;
|
||||
data->h = h;
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glGenTextures(1, &data->id);
|
||||
glBindTexture(GL_TEXTURE_2D, data->id);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture_w, texture_h, 0, GL_RGBA,
|
||||
format ? GL_UNSIGNED_SHORT_4_4_4_4 : GL_UNSIGNED_SHORT_5_5_5_1, NULL);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA,
|
||||
format ? GL_UNSIGNED_SHORT_4_4_4_4 : GL_UNSIGNED_SHORT_5_5_5_1,
|
||||
charBuf + 12 );
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
(*env)->ReleaseByteArrayElements(env, charBufJava, (jbyte *)charBuf, 0);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
|
||||
package com.sourceforge.sc2;
|
||||
package com.googlecode.opentyrian;
|
||||
|
||||
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 com.sourceforge.sc2;
|
||||
package com.googlecode.opentyrian;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
|
||||
package com.sourceforge.sc2;
|
||||
package com.googlecode.opentyrian;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
@@ -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 com.sourceforge.sc2;
|
||||
package com.googlecode.opentyrian;
|
||||
|
||||
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 com.sourceforge.sc2;
|
||||
package com.googlecode.opentyrian;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
class Globals {
|
||||
public static String ApplicationName = "Ur-QuanMasters";
|
||||
public static String ApplicationName = "OpenTyrian";
|
||||
|
||||
// Should be zip file
|
||||
public static String DataDownloadUrl = "Game data is 14 Mb|https://sites.google.com/site/xpelyax/Home/sc2-data.zip?attredirects=0%26d=1|http://sitesproxy.goapk.com/site/xpelyax/Home/sc2-data.zip^3DO remixed music (19 Mb)|:addons/3domusic/3domusic.zip:https://sites.google.com/site/xpelyax/Home/3domusic.zip?attredirects=0%26d=1|:addons/3domusic/3domusic.zip:http://sitesproxy.goapk.com/site/xpelyax/Home/3domusic.zip^UQM music remix pack 1 (50 Mb)|:addons/remix/uqm-remix-pack1.zip:http://sourceforge.net/projects/sc2/files/UQM%20Remix%20Packs/UQM%20Remix%20Pack%201/uqm-remix-pack1.zip/download^UQM music remix pack 2 (60 Mb)|:addons/remix/uqm-remix-pack2.zip:http://sourceforge.net/projects/sc2/files/UQM%20Remix%20Packs/UQM%20Remix%20Pack%202/uqm-remix-pack2.zip/download^UQM music remix pack 3 (40 Mb)|:addons/remix/uqm-remix-pack3.zip:http://sourceforge.net/projects/sc2/files/UQM%20Remix%20Packs/UQM%20Remix%20Pack%203/uqm-remix-pack3.zip/download";
|
||||
public static String DataDownloadUrl = "Data files size is 11 Mb|http://sites.google.com/site/xpelyax/Home/tyrian21-data.zip?attredirects=0%26d=1|http://sitesproxy.goapk.com/site/xpelyax/Home/tyrian21-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;
|
||||
@@ -27,9 +27,9 @@ class Globals {
|
||||
|
||||
public static boolean AppUsesMultitouch = false;
|
||||
|
||||
public static int AppTouchscreenKeyboardKeysAmount = 2;
|
||||
public static int AppTouchscreenKeyboardKeysAmount = 4;
|
||||
|
||||
public static int AppTouchscreenKeyboardKeysAmountAutoFire = 2;
|
||||
public static int AppTouchscreenKeyboardKeysAmountAutoFire = 1;
|
||||
|
||||
// Phone-specific config
|
||||
// It will download app data to /sdcard/alienblaster if set to true,
|
||||
@@ -40,6 +40,7 @@ class Globals {
|
||||
public static boolean UseAccelerometerAsArrowKeys = false;
|
||||
public static boolean UseTouchscreenKeyboard = false;
|
||||
public static int TouchscreenKeyboardSize = 0;
|
||||
public static int TouchscreenKeyboardTheme = 0;
|
||||
public static int AccelerometerSensitivity = 0;
|
||||
public static int TrackballDampening = 0;
|
||||
public static int AudioBufferConfig = 0;
|
||||
@@ -47,5 +48,5 @@ class Globals {
|
||||
}
|
||||
|
||||
class LoadLibrary {
|
||||
public LoadLibrary() { System.loadLibrary("sdl"); System.loadLibrary("sdl_image"); };
|
||||
public LoadLibrary() { System.loadLibrary("sdl"); System.loadLibrary("sdl_net"); };
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
|
||||
package com.sourceforge.sc2;
|
||||
package com.googlecode.opentyrian;
|
||||
|
||||
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 com.sourceforge.sc2;
|
||||
package com.googlecode.opentyrian;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
@@ -17,6 +17,7 @@ import android.content.res.Configuration;
|
||||
import android.os.Environment;
|
||||
import android.os.StatFs;
|
||||
import java.util.Locale;
|
||||
import java.util.ArrayList;
|
||||
|
||||
class Settings
|
||||
{
|
||||
@@ -41,6 +42,7 @@ class Settings
|
||||
out.writeInt(Globals.OptionalDataDownload.length);
|
||||
for(int i = 0; i < Globals.OptionalDataDownload.length; i++)
|
||||
out.writeBoolean(Globals.OptionalDataDownload[i]);
|
||||
out.writeInt(Globals.TouchscreenKeyboardTheme);
|
||||
out.close();
|
||||
} catch( FileNotFoundException e ) {
|
||||
} catch( SecurityException e ) {
|
||||
@@ -63,6 +65,7 @@ class Settings
|
||||
Globals.OptionalDataDownload = new boolean[settingsFile.readInt()];
|
||||
for(int i = 0; i < Globals.OptionalDataDownload.length; i++)
|
||||
Globals.OptionalDataDownload[i] = settingsFile.readBoolean();
|
||||
Globals.TouchscreenKeyboardTheme = settingsFile.readInt();
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle("Phone configuration");
|
||||
@@ -174,6 +177,9 @@ class Settings
|
||||
static void showOptionalDownloadConfig(final MainActivity p) {
|
||||
|
||||
String [] downloadFiles = Globals.DataDownloadUrl.split("\\^");
|
||||
System.out.println("downloadFiles.length " + String.valueOf(downloadFiles.length));
|
||||
for(int i = 0; i < downloadFiles.length; i++)
|
||||
System.out.println("downloadFiles[" + String.valueOf(i) + "] = '" + downloadFiles[i] + "'");
|
||||
if(downloadFiles.length <= 1)
|
||||
{
|
||||
Globals.OptionalDataDownload = new boolean[1];
|
||||
@@ -335,11 +341,11 @@ class Settings
|
||||
Globals.TouchscreenKeyboardSize = 0;
|
||||
if( ! Globals.UseTouchscreenKeyboard )
|
||||
{
|
||||
showAudioConfig(p);
|
||||
showScreenKeyboardThemeConfig(p);
|
||||
return;
|
||||
}
|
||||
|
||||
final CharSequence[] items = {"Big", "Medium", "Small"};
|
||||
final CharSequence[] items = {"Big", "Medium", "Small", "Tiny"};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle("On-screen keyboard size (toggle auto-fire by sliding across Fire button)");
|
||||
@@ -349,6 +355,37 @@ class Settings
|
||||
{
|
||||
Globals.TouchscreenKeyboardSize = item;
|
||||
|
||||
dialog.dismiss();
|
||||
showScreenKeyboardThemeConfig(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showScreenKeyboardThemeConfig(final MainActivity p)
|
||||
{
|
||||
Globals.TouchscreenKeyboardTheme = 0;
|
||||
if( ! Globals.UseTouchscreenKeyboard )
|
||||
{
|
||||
showAudioConfig(p);
|
||||
return;
|
||||
}
|
||||
|
||||
final CharSequence[] items = {"Ultimate Droid by Sean Stieber", "Ugly Arrows by pelya"};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle("On-screen keyboard theme");
|
||||
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
if( item == 0 )
|
||||
Globals.TouchscreenKeyboardTheme = 1;
|
||||
if( item == 1 )
|
||||
Globals.TouchscreenKeyboardTheme = 0;
|
||||
|
||||
dialog.dismiss();
|
||||
showAudioConfig(p);
|
||||
}
|
||||
@@ -378,8 +415,28 @@ class Settings
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static byte [] loadRaw(Activity p,int res)
|
||||
{
|
||||
byte [] buf = new byte[128];
|
||||
byte [] a = new byte[0];
|
||||
try{
|
||||
InputStream is = p.getResources().openRawResource(res);
|
||||
int readed = 0;
|
||||
while( (readed = is.read(buf)) >= 0 )
|
||||
{
|
||||
byte [] b = new byte[a.length + readed];
|
||||
for(int i = 0; i < a.length; i++)
|
||||
b[i] = a[i];
|
||||
for(int i = 0; i < readed; i++)
|
||||
b[i+a.length] = buf[i];
|
||||
a = b;
|
||||
}
|
||||
} catch(Exception e) {};
|
||||
return a;
|
||||
}
|
||||
|
||||
static void Apply()
|
||||
static void Apply(Activity p)
|
||||
{
|
||||
nativeIsSdcardUsed( Globals.DownloadToSdcard ? 1 : 0 );
|
||||
|
||||
@@ -394,7 +451,37 @@ class Settings
|
||||
if( Globals.UseTouchscreenKeyboard )
|
||||
{
|
||||
nativeSetTouchscreenKeyboardUsed();
|
||||
nativeSetupScreenKeyboard(Globals.TouchscreenKeyboardSize, Globals.AppTouchscreenKeyboardKeysAmount, Globals.AppTouchscreenKeyboardKeysAmountAutoFire);
|
||||
nativeSetupScreenKeyboard( Globals.TouchscreenKeyboardSize,
|
||||
Globals.TouchscreenKeyboardTheme,
|
||||
Globals.AppTouchscreenKeyboardKeysAmount,
|
||||
Globals.AppTouchscreenKeyboardKeysAmountAutoFire);
|
||||
if( Globals.TouchscreenKeyboardTheme == 1 )
|
||||
{
|
||||
// DPAD
|
||||
nativeSetupScreenKeyboardButton(0, loadRaw(p, R.raw.ultimatedroiddpadbutton));
|
||||
nativeSetupScreenKeyboardButton(1, loadRaw(p, R.raw.ultimatedroidleftbuttonpressed));
|
||||
nativeSetupScreenKeyboardButton(2, loadRaw(p, R.raw.ultimatedroidrightbuttonpressed));
|
||||
nativeSetupScreenKeyboardButton(3, loadRaw(p, R.raw.ultimatedroidupbuttonpressed));
|
||||
nativeSetupScreenKeyboardButton(4, loadRaw(p, R.raw.ultimatedroiddownbuttonpressed));
|
||||
// Auto-fire
|
||||
nativeSetupScreenKeyboardButton(5, loadRaw(p, R.raw.ultimatedroidbutton1pressed));
|
||||
nativeSetupScreenKeyboardButton(6, loadRaw(p, R.raw.ultimatedroidbutton2pressed));
|
||||
// Other buttons
|
||||
nativeSetupScreenKeyboardButton(7, loadRaw(p, R.raw.ultimatedroidbutton1));
|
||||
nativeSetupScreenKeyboardButton(8, loadRaw(p, R.raw.ultimatedroidbutton1pressed));
|
||||
nativeSetupScreenKeyboardButton(9, loadRaw(p, R.raw.ultimatedroidbutton2));
|
||||
nativeSetupScreenKeyboardButton(10, loadRaw(p, R.raw.ultimatedroidbutton2pressed));
|
||||
nativeSetupScreenKeyboardButton(11, loadRaw(p, R.raw.ultimatedroidbutton3));
|
||||
nativeSetupScreenKeyboardButton(12, loadRaw(p, R.raw.ultimatedroidbutton3pressed));
|
||||
nativeSetupScreenKeyboardButton(13, loadRaw(p, R.raw.ultimatedroidbutton4));
|
||||
nativeSetupScreenKeyboardButton(14, loadRaw(p, R.raw.ultimatedroidbutton4pressed));
|
||||
nativeSetupScreenKeyboardButton(15, loadRaw(p, R.raw.ultimatedroidbutton5));
|
||||
nativeSetupScreenKeyboardButton(16, loadRaw(p, R.raw.ultimatedroidbutton5pressed));
|
||||
nativeSetupScreenKeyboardButton(17, loadRaw(p, R.raw.ultimatedroidbutton6));
|
||||
nativeSetupScreenKeyboardButton(18, loadRaw(p, R.raw.ultimatedroidbutton6pressed));
|
||||
nativeSetupScreenKeyboardButton(19, loadRaw(p, R.raw.ultimatedroidbutton7));
|
||||
nativeSetupScreenKeyboardButton(20, loadRaw(p, R.raw.ultimatedroidbutton7));
|
||||
}
|
||||
}
|
||||
nativeSetAccelerometerSensitivity(Globals.AccelerometerSensitivity);
|
||||
nativeSetTrackballDampening(Globals.TrackballDampening);
|
||||
@@ -430,7 +517,8 @@ class Settings
|
||||
private static native void nativeSetJoystickUsed();
|
||||
private static native void nativeSetMultitouchUsed();
|
||||
private static native void nativeSetTouchscreenKeyboardUsed();
|
||||
private static native void nativeSetupScreenKeyboard(int size, int nbuttons, int nbuttonsAutoFire);
|
||||
private static native void nativeSetupScreenKeyboard(int size, int theme, int nbuttons, int nbuttonsAutoFire);
|
||||
private static native void nativeSetupScreenKeyboardButton(int buttonId, byte[] img);
|
||||
public static native void nativeSetEnv(final String name, final String value);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
|
||||
package com.sourceforge.sc2;
|
||||
package com.googlecode.opentyrian;
|
||||
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
@@ -109,7 +109,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer {
|
||||
|
||||
System.loadLibrary("application");
|
||||
System.loadLibrary("sdl_main");
|
||||
Settings.Apply();
|
||||
Settings.Apply(context);
|
||||
// Tweak video thread priority, if user selected big audio buffer
|
||||
if(Globals.AudioBufferConfig >= 2)
|
||||
Thread.currentThread().setPriority( (Thread.NORM_PRIORITY + Thread.MIN_PRIORITY) / 2 ); // Lower than normal
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.7 KiB |
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
for f in ../UltimateDroid/*.png; do
|
||||
newname=`echo $f | sed 's@.*/@@' | tr '[A-Z]' '[a-z]'`.raw
|
||||
./converter $f ../../res/raw/$newname
|
||||
done
|
||||
|
||||
Binary file not shown.
@@ -33,6 +33,8 @@ main(int argc, char *argv[])
|
||||
fwrite( &w, 1, 4, ff );
|
||||
int h = htonl(dst->h);
|
||||
fwrite( &h, 1, 4, ff );
|
||||
int format = htonl(argc <= 3 ? 0 : 1);
|
||||
fwrite( &format, 1, 4, ff );
|
||||
for( int i = 0; i < dst->h; i++ )
|
||||
{
|
||||
for( int ii = 0; ii < dst->w; ii++ )
|
||||
|
||||
Reference in New Issue
Block a user