First implementation of picture button theme, still no transparency

This commit is contained in:
pelya
2010-08-26 17:18:03 +03:00
parent 8c5bb493da
commit 2ba663a7b1
37 changed files with 371 additions and 79 deletions

View File

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