diff --git a/ExaltedDice/res/layout/new_game_dialog.xml b/ExaltedDice/res/layout/new_game_dialog.xml
index a0e71c0..7871016 100644
--- a/ExaltedDice/res/layout/new_game_dialog.xml
+++ b/ExaltedDice/res/layout/new_game_dialog.xml
@@ -26,11 +26,25 @@
android:singleLine="true" />
+
+
\ No newline at end of file
diff --git a/ExaltedDice/res/values/game_modes.xml b/ExaltedDice/res/values/game_modes.xml
new file mode 100644
index 0000000..222c8b1
--- /dev/null
+++ b/ExaltedDice/res/values/game_modes.xml
@@ -0,0 +1,12 @@
+
+
+
+
+ - @string/game_mode_exalted
+ - @string/game_mode_dd
+
+
+ Exalted
+ D&D
+
+
\ No newline at end of file
diff --git a/ExaltedDice/res/values/strings.xml b/ExaltedDice/res/values/strings.xml
index fdea831..4885ef3 100755
--- a/ExaltedDice/res/values/strings.xml
+++ b/ExaltedDice/res/values/strings.xml
@@ -34,5 +34,6 @@
Calculate Roll + Modifier
Highlight Color
Highlights your last roll in a custom color
+ Game Mode
\ No newline at end of file
diff --git a/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/ExaltedDice.java b/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/ExaltedDice.java
index 24724a2..fa455e1 100755
--- a/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/ExaltedDice.java
+++ b/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/ExaltedDice.java
@@ -32,11 +32,13 @@ import com.TwentyCodes.android.exception.ExceptionHandler;
public class ExaltedDice extends Activity implements OnClickListener, OnItemClickListener, DatabaseListener {
- private static final int MENU_QUIT = Menu.FIRST;
- private static final int MENU_CLEAR = Menu.FIRST + 1;
- private static final String TAG = "ExaltedDice";
+ public static final String KEY_GAME_MODE = "game_mode";
public static final String KEY_GAME_NAME = "game_name";
public static final String KEY_GAME_ID = "game_id";
+
+ private static final String TAG = "ExaltedDice";
+ private static final int MENU_QUIT = Menu.FIRST;
+ private static final int MENU_CLEAR = Menu.FIRST + 1;
private static final int DELETE = 0;
private static final int SETTINGS = Menu.FIRST + 2;
@@ -186,12 +188,16 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
initCompatPickers();
Intent i = this.getIntent();
- if(i != null)
+ if(i != null){
if(i.hasExtra(KEY_GAME_NAME)){
mGameName = i.getStringExtra(KEY_GAME_NAME);
mGameId = i.getLongExtra(KEY_GAME_ID, -1);
this.setTitle(mGameName);
}
+ if(i.hasExtra(KEY_GAME_MODE)){
+ setGameMode(i.getStringExtra(KEY_GAME_MODE));
+ }
+ }
mListView = (ListView) findViewById(R.id.list);
mListView.setOnItemClickListener(this);
@@ -411,6 +417,37 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
return i;
return 0;
}
+
+ /**
+ * Sets the game mode for this activity
+ * @param stringExtra
+ * @author ricky barrette
+ */
+ private void setGameMode(String mode) {
+
+ /*
+ * EXALTED
+ */
+ if(mode.equals(getString(R.string.game_mode_exalted))){
+ /*
+ * TODO
+ * + set die to d10
+ * + enable successes
+ * + remove roll modifier
+ */
+ }
+
+ /*
+ * D&D
+ */
+ else if(mode.equals(getString(R.string.game_mode_dd))){
+ /*
+ * TODO
+ * + disable successes
+ */
+ }
+
+ }
/**
* displays a quit dialog
diff --git a/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/NewGameDialog.java b/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/NewGameDialog.java
index 735d475..77571ef 100644
--- a/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/NewGameDialog.java
+++ b/ExaltedDice/src/com/TwentyCode/android/ExaltedDice/NewGameDialog.java
@@ -7,10 +7,12 @@
package com.TwentyCode.android.ExaltedDice;
import android.app.Dialog;
+import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.EditText;
+import android.widget.Spinner;
/**
* This dialog will be used to allow a user to enter a name for their game
@@ -18,18 +20,20 @@ import android.widget.EditText;
*/
public class NewGameDialog extends Dialog implements android.view.View.OnClickListener {
- private Context mContext;
- private Database mDb;
- private EditText mGameName;
+ private final Context mContext;
+ private final Database mDb;
+ private final EditText mGameName;
+ private final Spinner mGameModeSpinner;
public NewGameDialog(Context context, Database db) {
super(context);
mContext = context;
mDb = db;
- this.setTitle(R.string.new_game);
- this.setContentView(R.layout.new_game_dialog);
+ setTitle(R.string.new_game);
+ setContentView(R.layout.new_game_dialog);
findViewById(R.id.new_game_button).setOnClickListener(this);
mGameName = (EditText) findViewById(R.id.editText);
+ mGameModeSpinner = (Spinner) findViewById(R.id.game_mode_spinner);
}
@Override
@@ -38,12 +42,29 @@ public class NewGameDialog extends Dialog implements android.view.View.OnClickLi
findViewById(R.id.new_game_button).setEnabled(false);
String name = mGameName.getText().toString();
+ String gameMode = (String) mGameModeSpinner.getSelectedItem();
+ /*
+ * create a new game in the database
+ */
+ long gameId = mDb.insertGame(name);
+
+ /*
+ * Store the game mode
+ */
+ ContentValues options = new ContentValues();
+ options.put(Database.KEY_MODE, gameMode);
+ mDb.updateOptions(gameId, options );
+
+ /*
+ * Start the dice roller activity
+ */
Intent i = new Intent(mContext, ExaltedDice.class)
- .putExtra(ExaltedDice.KEY_GAME_NAME, name)
- .putExtra(ExaltedDice.KEY_GAME_ID, mDb.insertGame(name));
-
+ .putExtra(ExaltedDice.KEY_GAME_NAME, name)
+ .putExtra(ExaltedDice.KEY_GAME_ID, gameId)
+ .putExtra(ExaltedDice.KEY_GAME_MODE, gameMode);
mContext.startActivity(i);
+
this.dismiss();
}