diff --git a/ExaltedDice/res/layout/dice_selector.xml b/ExaltedDice/res/layout/dice_selector.xml index df1c946..8fe85d2 100644 --- a/ExaltedDice/res/layout/dice_selector.xml +++ b/ExaltedDice/res/layout/dice_selector.xml @@ -13,6 +13,12 @@ + + \ No newline at end of file diff --git a/ExaltedDice/res/layout/main.xml b/ExaltedDice/res/layout/main.xml index aab8fcd..92c088a 100755 --- a/ExaltedDice/res/layout/main.xml +++ b/ExaltedDice/res/layout/main.xml @@ -15,7 +15,7 @@ + android:layout_weight="2" > + + + + -5 + -4 + -3 + -2 + -1 + 0 + +1 + +2 + +3 + +4 + +5 + +6 + +7 + +8 + +9 + +10 + +11 + +12 + +13 + +14 + +15 + +16 + +17 + +18 + +19 + +20 + +21 + +22 + +23 + +24 + +25 + +26 + +27 + +28 + +29 + +30 + +31 + +32 + +33 + +34 + +35 + +36 + +37 + +38 + +39 + +40 + +41 + +42 + +43 + +44 + +45 + +46 + +47 + +48 + +49 + +50 + + + \ No newline at end of file diff --git a/ExaltedDice/res/values/strings.xml b/ExaltedDice/res/values/strings.xml index 6e72d5e..8014595 100755 --- a/ExaltedDice/res/values/strings.xml +++ b/ExaltedDice/res/values/strings.xml @@ -26,5 +26,6 @@ Rolls the with the same presets as the selected roll from history Calculate Successes Calculates the total amount of success for each roll + \nTotal + Mod: \ No newline at end of file diff --git a/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/Database.java b/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/Database.java index 5cfd9ca..737e294 100644 --- a/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/Database.java +++ b/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/Database.java @@ -67,7 +67,9 @@ 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; private SQLiteDatabase mDb; diff --git a/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/ExaltedDice.java b/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/ExaltedDice.java index be6f9fc..d9b0d8b 100755 --- a/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/ExaltedDice.java +++ b/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/ExaltedDice.java @@ -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); } @@ -265,6 +278,19 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic return i; 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(); diff --git a/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/RollHistoryDatabaseAdapter.java b/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/RollHistoryDatabaseAdapter.java index 13f5e45..b8c47c2 100644 --- a/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/RollHistoryDatabaseAdapter.java +++ b/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/RollHistoryDatabaseAdapter.java @@ -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());