<item>2</item>
<item>3</item>
</string-array>
-</resources>
+ <string-array name="tilesets">
+ <item>classic</item>
+ <item>jade</item>
+ <item>traditional</item>
+ <item>pixel</item>
+ </string-array>
+</resources>
\ No newline at end of file
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt\n
Get the source code: https://code.google.com/p/freeshisen/</string>
<string name="size">Size</string>
+ <string name="tileset">Tileset</string>
+ <string name="tileset_default">classic</string>
<string name="difficulty">Difficulty</string>
<string name="size_default">2</string>
<string name="difficulty_default">1</string>
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
- <ListPreference
- android:title="@string/size"
- android:entryValues="@array/size_values"
- android:key="pref_size"
- android:dialogTitle="@string/size"
- android:entries="@array/sizes" android:defaultValue="@string/size_default"/>
- <ListPreference
- android:title="@string/difficulty"
- android:entryValues="@array/difficulty_values"
- android:key="pref_diff"
- android:dialogTitle="@string/difficulty"
- android:entries="@array/difficulties" android:defaultValue="@string/difficulty_default"/>
- <CheckBoxPreference
- android:defaultValue="true"
- android:title="@string/gravity"
- android:key="pref_grav" android:summaryOn="@string/gravity_pref_on" android:summaryOff="@string/gravity_pref_off"/>
- <CheckBoxPreference
- android:defaultValue="true"
- android:title="@string/time_counter"
- android:key="pref_time" android:summaryOn="@string/time_pref_on" android:summaryOff="@string/time_pref_off"/>
+ <ListPreference
+ android:defaultValue="@string/size_default"
+ android:dialogTitle="@string/size"
+ android:entries="@array/sizes"
+ android:entryValues="@array/size_values"
+ android:key="pref_size"
+ android:title="@string/size" />
+ <ListPreference
+ android:defaultValue="@string/difficulty_default"
+ android:dialogTitle="@string/difficulty"
+ android:entries="@array/difficulties"
+ android:entryValues="@array/difficulty_values"
+ android:key="pref_diff"
+ android:title="@string/difficulty" />
+ <CheckBoxPreference
+ android:defaultValue="false"
+ android:key="pref_grav"
+ android:summaryOff="@string/gravity_pref_off"
+ android:summaryOn="@string/gravity_pref_on"
+ android:title="@string/gravity" />
+ <CheckBoxPreference
+ android:defaultValue="true"
+ android:key="pref_time"
+ android:summaryOff="@string/time_pref_off"
+ android:summaryOn="@string/time_pref_on"
+ android:title="@string/time_counter" />
+ <ListPreference
+ android:defaultValue="@string/tileset_default"
+ android:dialogTitle="@string/tileset"
+ android:entries="@array/tilesets"
+ android:entryValues="@array/tilesets"
+ android:key="pref_tile"
+ android:title="@string/tileset" />
</PreferenceScreen>
\ No newline at end of file
private static final String KEY_PREF_DIFF = "pref_diff";
private static final String KEY_PREF_SIZE = "pref_size";
+ private static final String KEY_PREF_TILE = "pref_tile";
//private static final String KEY_PREF_GRAV = "pref_grav";
//private static final String KEY_PREF_TIME = "pref_time";
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
updateSummary(sharedPreferences, KEY_PREF_DIFF, KEY_PREF_DIFF, R.array.difficulties);
updateSummary(sharedPreferences, KEY_PREF_SIZE, KEY_PREF_SIZE, R.array.sizes);
+ updateTileSummary(sharedPreferences, KEY_PREF_TILE);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
updateSummary(sharedPreferences, key, KEY_PREF_DIFF, R.array.difficulties);
updateSummary(sharedPreferences, key, KEY_PREF_SIZE, R.array.sizes);
+ updateTileSummary(sharedPreferences, key);
}
private void updateSummary(SharedPreferences sharedPreferences, String changedkey, String mykey, int myresource) {
Preference myPref = findPreference(changedkey);
myPref.setSummary("Currently: " + name);
}
- }
+ }
+
+ private void updateTileSummary(SharedPreferences sharedPreferences, String changedkey) {
+ if (changedkey.equals(KEY_PREF_TILE)) {
+ String name = sharedPreferences.getString(KEY_PREF_TILE, "classic");
+
+ @SuppressWarnings("deprecation")
+ Preference myPref = findPreference(KEY_PREF_TILE);
+ myPref.setSummary("Current Tileset: " + name);
+ }
+ }
+
}
public int[] boardSize=new int[2];
public int difficulty=1; // 1=Easy, 2=Hard
public int size=3; // 1=Small, 2=Medium, 3=Big
+ public int tilesetid = R.drawable.classic;
public boolean gravity=true;
public boolean timeCounter=true;
int difficulty = Integer.parseInt(sharedPref.getString("pref_diff", "1"));
boolean gravity = sharedPref.getBoolean("pref_grav", true);
boolean timeCounter = sharedPref.getBoolean("pref_time", true);
+ int tilesetid = tilesetStringToRes(sharedPref.getString("pref_tile", ""));
boolean needsReset = false;
view.onTimeCounterActivate();
}
+ if ((tilesetid != this.tilesetid) && (view != null)) {
+ this.tilesetid = tilesetid;
+ view.loadTileset();
+ }
+
if (needsReset && (view != null)) {
view.reset();
}
+
}
+ private int tilesetStringToRes(String s)
+ {
+ if (s.equals("classic")) {
+ return R.drawable.classic;
+ } else if (s.equals("jade")) {
+ return R.drawable.jade;
+ } else if (s.equals("traditional")) {
+ return R.drawable.traditional;
+ } else if (s.equals("pixel")) {
+ return R.drawable.pixel;
+ } else {
+ return R.drawable.classic;
+ }
+ }
}
this.cstate=cstate;
}
- private void loadTileset() {
+ public void loadTileset() {
BitmapFactory.Options ops = new BitmapFactory.Options();
ops.inScaled = false;
- Bitmap tileset = BitmapFactory.decodeResource(getResources(), R.drawable.traditional, ops);
+ Bitmap tileset = BitmapFactory.decodeResource(getResources(), app.tilesetid, ops);
tileset.setDensity(Bitmap.DENSITY_NONE);
// The tile set has 4 rows x 9 columns