Created Game Option "Game Mode"

This option allows the user to select their gaming system. This will
allow us to fine tune the UI of exalted dice to better suit the gaming
system of each particular game.

Note This only commit does not handle applying the game mode in
ExaltedDice.java

Change-Id: I035fe4441027e6536f6d89d038818dc939c26e55
Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
2012-02-12 10:09:05 -05:00
parent 5c8540e0e2
commit 29ea55bd28
5 changed files with 98 additions and 13 deletions

View File

@@ -26,11 +26,25 @@
android:singleLine="true" />
</LinearLayout>
<Spinner
android:id="@+id/game_mode_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/linearLayout1"
android:layout_centerVertical="true"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:entries="@array/game_modes"
android:prompt="@string/game_mode" />
<Button
android:id="@+id/new_game_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/linearLayout1"
android:layout_below="@id/game_mode_spinner"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:text="@string/create_new_game" />
</RelativeLayout>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="game_modes">
<item>@string/game_mode_exalted</item>
<item>@string/game_mode_dd</item>
</string-array>
<string name="game_mode_exalted">Exalted</string>
<string name="game_mode_dd">D&amp;D</string>
</resources>

View File

@@ -34,5 +34,6 @@
<string name="roll_mod_msg">Calculate Roll + Modifier</string>
<string name="higlight_color">Highlight Color</string>
<string name="higlight_color_msg">Highlights your last roll in a custom color</string>
<string name="game_mode">Game Mode</string>
</resources>

View File

@@ -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);
@@ -412,6 +418,37 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
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
*

View File

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