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:
@@ -26,11 +26,25 @@
|
|||||||
android:singleLine="true" />
|
android:singleLine="true" />
|
||||||
</LinearLayout>
|
</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
|
<Button
|
||||||
android:id="@+id/new_game_button"
|
android:id="@+id/new_game_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
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" />
|
android:text="@string/create_new_game" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
12
ExaltedDice/res/values/game_modes.xml
Normal file
12
ExaltedDice/res/values/game_modes.xml
Normal 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&D</string>
|
||||||
|
|
||||||
|
</resources>
|
||||||
@@ -34,5 +34,6 @@
|
|||||||
<string name="roll_mod_msg">Calculate Roll + Modifier</string>
|
<string name="roll_mod_msg">Calculate Roll + Modifier</string>
|
||||||
<string name="higlight_color">Highlight Color</string>
|
<string name="higlight_color">Highlight Color</string>
|
||||||
<string name="higlight_color_msg">Highlights your last roll in a custom color</string>
|
<string name="higlight_color_msg">Highlights your last roll in a custom color</string>
|
||||||
|
<string name="game_mode">Game Mode</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -32,11 +32,13 @@ import com.TwentyCodes.android.exception.ExceptionHandler;
|
|||||||
|
|
||||||
public class ExaltedDice extends Activity implements OnClickListener, OnItemClickListener, DatabaseListener {
|
public class ExaltedDice extends Activity implements OnClickListener, OnItemClickListener, DatabaseListener {
|
||||||
|
|
||||||
private static final int MENU_QUIT = Menu.FIRST;
|
public static final String KEY_GAME_MODE = "game_mode";
|
||||||
private static final int MENU_CLEAR = Menu.FIRST + 1;
|
|
||||||
private static final String TAG = "ExaltedDice";
|
|
||||||
public static final String KEY_GAME_NAME = "game_name";
|
public static final String KEY_GAME_NAME = "game_name";
|
||||||
public static final String KEY_GAME_ID = "game_id";
|
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 DELETE = 0;
|
||||||
private static final int SETTINGS = Menu.FIRST + 2;
|
private static final int SETTINGS = Menu.FIRST + 2;
|
||||||
|
|
||||||
@@ -186,12 +188,16 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
|||||||
initCompatPickers();
|
initCompatPickers();
|
||||||
|
|
||||||
Intent i = this.getIntent();
|
Intent i = this.getIntent();
|
||||||
if(i != null)
|
if(i != null){
|
||||||
if(i.hasExtra(KEY_GAME_NAME)){
|
if(i.hasExtra(KEY_GAME_NAME)){
|
||||||
mGameName = i.getStringExtra(KEY_GAME_NAME);
|
mGameName = i.getStringExtra(KEY_GAME_NAME);
|
||||||
mGameId = i.getLongExtra(KEY_GAME_ID, -1);
|
mGameId = i.getLongExtra(KEY_GAME_ID, -1);
|
||||||
this.setTitle(mGameName);
|
this.setTitle(mGameName);
|
||||||
}
|
}
|
||||||
|
if(i.hasExtra(KEY_GAME_MODE)){
|
||||||
|
setGameMode(i.getStringExtra(KEY_GAME_MODE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mListView = (ListView) findViewById(R.id.list);
|
mListView = (ListView) findViewById(R.id.list);
|
||||||
mListView.setOnItemClickListener(this);
|
mListView.setOnItemClickListener(this);
|
||||||
@@ -412,6 +418,37 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
|||||||
return 0;
|
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
|
* displays a quit dialog
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -7,10 +7,12 @@
|
|||||||
package com.TwentyCode.android.ExaltedDice;
|
package com.TwentyCode.android.ExaltedDice;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This dialog will be used to allow a user to enter a name for their game
|
* 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 {
|
public class NewGameDialog extends Dialog implements android.view.View.OnClickListener {
|
||||||
|
|
||||||
private Context mContext;
|
private final Context mContext;
|
||||||
private Database mDb;
|
private final Database mDb;
|
||||||
private EditText mGameName;
|
private final EditText mGameName;
|
||||||
|
private final Spinner mGameModeSpinner;
|
||||||
|
|
||||||
public NewGameDialog(Context context, Database db) {
|
public NewGameDialog(Context context, Database db) {
|
||||||
super(context);
|
super(context);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mDb = db;
|
mDb = db;
|
||||||
this.setTitle(R.string.new_game);
|
setTitle(R.string.new_game);
|
||||||
this.setContentView(R.layout.new_game_dialog);
|
setContentView(R.layout.new_game_dialog);
|
||||||
findViewById(R.id.new_game_button).setOnClickListener(this);
|
findViewById(R.id.new_game_button).setOnClickListener(this);
|
||||||
mGameName = (EditText) findViewById(R.id.editText);
|
mGameName = (EditText) findViewById(R.id.editText);
|
||||||
|
mGameModeSpinner = (Spinner) findViewById(R.id.game_mode_spinner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -38,12 +42,29 @@ public class NewGameDialog extends Dialog implements android.view.View.OnClickLi
|
|||||||
findViewById(R.id.new_game_button).setEnabled(false);
|
findViewById(R.id.new_game_button).setEnabled(false);
|
||||||
|
|
||||||
String name = mGameName.getText().toString();
|
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)
|
Intent i = new Intent(mContext, ExaltedDice.class)
|
||||||
.putExtra(ExaltedDice.KEY_GAME_NAME, name)
|
.putExtra(ExaltedDice.KEY_GAME_NAME, name)
|
||||||
.putExtra(ExaltedDice.KEY_GAME_ID, mDb.insertGame(name));
|
.putExtra(ExaltedDice.KEY_GAME_ID, gameId)
|
||||||
|
.putExtra(ExaltedDice.KEY_GAME_MODE, gameMode);
|
||||||
mContext.startActivity(i);
|
mContext.startActivity(i);
|
||||||
|
|
||||||
this.dismiss();
|
this.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user