Added A Roll Modifier Picker
Currently the roll modifier is from -5 to + 50. This can be updated via values/mod.xml Change-Id: I32c5d7ed1c67e0d8bc1b1434025d14134f8bc583 Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -13,6 +13,12 @@
|
||||
<NumberPicker
|
||||
android:id="@+id/d_Picker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="20dip" />
|
||||
|
||||
<NumberPicker
|
||||
android:id="@+id/mod_Picker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -15,7 +15,7 @@
|
||||
<RelativeLayout
|
||||
android:layout_width="0px"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" >
|
||||
android:layout_weight="2" >
|
||||
|
||||
<include
|
||||
android:id="@+id/die_selector"
|
||||
|
||||
63
ExaltedDice/res/values/mod.xml
Normal file
63
ExaltedDice/res/values/mod.xml
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string-array name="mods">
|
||||
<item>-5</item>
|
||||
<item>-4</item>
|
||||
<item>-3</item>
|
||||
<item>-2</item>
|
||||
<item>-1</item>
|
||||
<item>0</item>
|
||||
<item>+1</item>
|
||||
<item>+2</item>
|
||||
<item>+3</item>
|
||||
<item>+4</item>
|
||||
<item>+5</item>
|
||||
<item>+6</item>
|
||||
<item>+7</item>
|
||||
<item>+8</item>
|
||||
<item>+9</item>
|
||||
<item>+10</item>
|
||||
<item>+11</item>
|
||||
<item>+12</item>
|
||||
<item>+13</item>
|
||||
<item>+14</item>
|
||||
<item>+15</item>
|
||||
<item>+16</item>
|
||||
<item>+17</item>
|
||||
<item>+18</item>
|
||||
<item>+19</item>
|
||||
<item>+20</item>
|
||||
<item>+21</item>
|
||||
<item>+22</item>
|
||||
<item>+23</item>
|
||||
<item>+24</item>
|
||||
<item>+25</item>
|
||||
<item>+26</item>
|
||||
<item>+27</item>
|
||||
<item>+28</item>
|
||||
<item>+29</item>
|
||||
<item>+30</item>
|
||||
<item>+31</item>
|
||||
<item>+32</item>
|
||||
<item>+33</item>
|
||||
<item>+34</item>
|
||||
<item>+35</item>
|
||||
<item>+36</item>
|
||||
<item>+37</item>
|
||||
<item>+38</item>
|
||||
<item>+39</item>
|
||||
<item>+40</item>
|
||||
<item>+41</item>
|
||||
<item>+42</item>
|
||||
<item>+43</item>
|
||||
<item>+44</item>
|
||||
<item>+45</item>
|
||||
<item>+46</item>
|
||||
<item>+47</item>
|
||||
<item>+48</item>
|
||||
<item>+49</item>
|
||||
<item>+50</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
@@ -26,5 +26,6 @@
|
||||
<string name="roll_again_summary">Rolls the with the same presets as the selected roll from history</string>
|
||||
<string name="calc_successes">Calculate Successes</string>
|
||||
<string name="calc_successes_summary">Calculates the total amount of success for each roll</string>
|
||||
<string name="total_plus_mod">\nTotal + Mod: </string>
|
||||
|
||||
</resources>
|
||||
@@ -67,6 +67,8 @@ public class Database {
|
||||
public final static String KEY_NUMBER = "number";
|
||||
public final static String KEY_LOG = "log";
|
||||
public final static String KEY_ROLL_ID = "roll_id";
|
||||
public final static String KEY_MOD = "mod";
|
||||
|
||||
|
||||
private static final String TAG = "Database";
|
||||
private Context mContext;
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.DatabaseUtils;
|
||||
import android.os.Bundle;
|
||||
import android.os.Vibrator;
|
||||
import android.util.Log;
|
||||
@@ -47,6 +48,8 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
private long mGameId;
|
||||
private RollHistoryDatabaseAdapter mListAdapter;
|
||||
private SharedPreferences mSettings;
|
||||
private String[] mModValues;
|
||||
private NumberPicker mModPicker;
|
||||
|
||||
/**
|
||||
* clears the rollHistory List array and refreshes the listview
|
||||
@@ -118,6 +121,7 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
mSettings = getSharedPreferences(Settings.SETTINGS, Context.MODE_WORLD_WRITEABLE);
|
||||
|
||||
mDiceValues = getResources().getStringArray(R.array.dice_types);
|
||||
mModValues = getResources().getStringArray(R.array.mods);
|
||||
|
||||
mListView = (ListView) findViewById(R.id.list);
|
||||
mListView.setOnItemClickListener(this);
|
||||
@@ -134,6 +138,12 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
mNumberPicker.setMinValue(1);
|
||||
mNumberPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
|
||||
|
||||
mModPicker = (NumberPicker) findViewById(R.id.mod_Picker);
|
||||
mModPicker.setMinValue(0);
|
||||
mModPicker.setMaxValue(mModValues.length -1);
|
||||
mModPicker.setDisplayedValues(mModValues);
|
||||
mModPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
|
||||
|
||||
findViewById(R.id.roll_button).setOnClickListener(this);
|
||||
|
||||
}
|
||||
@@ -169,6 +179,7 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
ContentValues roll = mDb.getGameHistoryInfo(mGameName, (int) (id + 1));
|
||||
mNumberPicker.setValue(roll.getAsInteger(Database.KEY_NUMBER));
|
||||
mDPicker.setValue(parseD(roll.getAsString(Database.KEY_D_TYPE)));
|
||||
mModPicker.setValue(parseMod(roll.getAsString(Database.KEY_MOD).replace("'", "")));
|
||||
|
||||
if(mSettings.getBoolean(Settings.KEY_ROLL_AGAIN, true))
|
||||
rollDice();
|
||||
@@ -218,6 +229,7 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
mDPicker.setValue(savedInstanceState.getInt("d"));
|
||||
mNumberPicker.setValue(savedInstanceState.getInt("number"));
|
||||
mModPicker.setValue(savedInstanceState.getInt("mod"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,6 +262,7 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
public void onSaveInstanceState(Bundle savedInstanceState) {
|
||||
savedInstanceState.putInt("d", mDPicker.getValue());
|
||||
savedInstanceState.putInt("number", mNumberPicker.getValue());
|
||||
savedInstanceState.putInt("mod", mModPicker.getValue());
|
||||
super.onSaveInstanceState(savedInstanceState);
|
||||
}
|
||||
|
||||
@@ -266,6 +279,19 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the string mod to the appropriate value
|
||||
* @param mod
|
||||
* @return value for d picker
|
||||
* @author ricky barrette
|
||||
*/
|
||||
private int parseMod(String mod) {
|
||||
for(int i = 0; i < mModValues.length; i++)
|
||||
if (mModValues[i].equalsIgnoreCase(mod))
|
||||
return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* displays a quit dialog
|
||||
*
|
||||
@@ -320,6 +346,8 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
|
||||
resultsString.append(getString(R.string.total)+ total);
|
||||
|
||||
resultsString.append(getString(R.string.total_plus_mod)+ (total + Integer.parseInt(mModValues[mModPicker.getValue()].replace("+", ""))));
|
||||
|
||||
if(mSettings.getBoolean(Settings.KEY_CALC_SUCCESSES, true))
|
||||
resultsString.append(getString(R.string.sucesses)+ successes(roll));
|
||||
|
||||
@@ -343,6 +371,8 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
roll.put(Database.KEY_NUMBER, mNumberPicker.getValue());
|
||||
roll.put(Database.KEY_LOG, results(mNumberPicker.getValue()));
|
||||
|
||||
roll.put(Database.KEY_MOD, DatabaseUtils.sqlEscapeString(mModValues[mModPicker.getValue()]));
|
||||
|
||||
mDb.updateGame(mGameId, mGameName, roll, rollId);
|
||||
|
||||
refresh();
|
||||
|
||||
@@ -89,7 +89,8 @@ public class RollHistoryDatabaseAdapter extends BaseAdapter {
|
||||
|
||||
StringBuffer s = new StringBuffer();
|
||||
s.append("Rolled: "+roll.getAsInteger(Database.KEY_NUMBER));
|
||||
s.append(" "+(String)roll.getAsString(Database.KEY_D_TYPE));
|
||||
s.append(" "+roll.getAsString(Database.KEY_D_TYPE));
|
||||
s.append(" "+roll.getAsString(Database.KEY_MOD).replace("'", ""));
|
||||
s.append("\n"+roll.getAsString(Database.KEY_LOG));
|
||||
|
||||
holder.text.setText(s.toString());
|
||||
|
||||
Reference in New Issue
Block a user