Skip to content

Commit 8ed69e4

Browse files
author
nilsnilsnils
committed
Feature: new option for marking suspended players & some bug fixes
1 parent d746bca commit 8ed69e4

18 files changed

+363
-189
lines changed

gen/nldoko/game/R.java

+167-160
Large diffs are not rendered by default.
603 Bytes
Loading
445 Bytes
Loading
758 Bytes
Loading
1.03 KB
Loading

res/layout/activity_newgame.xml

+5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@
8383
android:layout_height="wrap_content"
8484
layout="@layout/set_game_cnt_variant_icon" />
8585

86+
<include
87+
android:layout_width="fill_parent"
88+
android:layout_height="wrap_content"
89+
layout="@layout/set_y_n_suspend_mark_with_icon" />
90+
8691
<include
8792
android:layout_width="wrap_content"
8893
android:layout_height="wrap_content"

res/layout/fragment_game_round_2_player_row.xml

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
android:layout_width="fill_parent"
44
android:layout_height="wrap_content"
55
android:orientation="vertical"
6+
android:layout_marginTop="1dp"
67
android:id="@+id/fragement_game_round_2_player_row">
78

89
<LinearLayout
@@ -12,6 +13,7 @@
1213
android:weightSum="1">
1314

1415
<LinearLayout
16+
android:id="@+id/fragment_game_round_2_player_row_player_row_left_player"
1517
android:layout_width="0dip"
1618
android:orientation="horizontal"
1719
android:layout_height="wrap_content"
@@ -51,6 +53,7 @@
5153
android:background="@color/gray" />
5254

5355
<LinearLayout
56+
android:id="@+id/fragment_game_round_2_player_row_player_row_right_player"
5457
android:layout_width="0dip"
5558
android:layout_height="wrap_content"
5659
android:layout_weight="0.5" >
@@ -86,6 +89,7 @@
8689

8790
<include
8891
android:layout_marginTop="1dp"
92+
android:layout_marginBottom="1dp"
8993
android:layout_width="fill_parent"
9094
android:layout_height="wrap_content"
9195
layout="@layout/spacer_gray" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="fill_parent"
4+
android:layout_height="48dp"
5+
android:orientation="horizontal"
6+
android:id="@+id/fragment_game_set_mark_suspend_entry" >
7+
8+
<LinearLayout
9+
android:layout_width="48dp"
10+
android:layout_height="48dp"
11+
android:orientation="vertical"
12+
android:background="@color/white" >
13+
14+
<ImageView
15+
android:id="@+id/icon"
16+
android:layout_width="match_parent"
17+
android:layout_height="fill_parent"
18+
android:contentDescription="@string/str_image"
19+
android:scaleType="center"
20+
android:src="@drawable/ic_action_labels" />
21+
22+
</LinearLayout>
23+
24+
<View
25+
android:layout_width="1dp"
26+
android:layout_height="match_parent"
27+
android:background="@color/white" />
28+
29+
<LinearLayout
30+
android:layout_width="match_parent"
31+
android:layout_height="match_parent"
32+
android:background="@color/white"
33+
android:weightSum="1"
34+
android:orientation="horizontal" >
35+
36+
37+
<TextView
38+
android:id="@+id/fragment_game_round_str_prim"
39+
android:layout_width="0dip"
40+
android:layout_height="match_parent"
41+
android:paddingLeft="5dp"
42+
android:layout_weight="0.85"
43+
android:gravity="center|left"
44+
android:text="@string/str_mark_suspend"
45+
android:textAppearance="?android:attr/textAppearanceMedium"
46+
android:textColor="@color/black"
47+
android:textStyle="bold" />
48+
49+
<CheckBox
50+
android:id="@+id/cb_suspend"
51+
android:layout_width="0dp"
52+
android:layout_height="wrap_content"
53+
android:layout_weight="0.15"
54+
android:text="" />
55+
56+
</LinearLayout>
57+
58+
</LinearLayout>

res/values-de/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<string name="str_bockrounds">Bockrunden</string>
4141
<string name="str_bock_preview_on_off">Bockvorschau an/aus</string>
4242
<string name="str_bock_preview_not_posible">Bockvorschau nicht vorhanden da das Bocklimit \"0\" ist</string>
43+
<string name="str_mark_suspend">Markiere ausgesetzte</string>
4344
<string name="str_solo">Solo</string>
4445
<string name="str_solo_special">*Solo*</string>
4546
<string name="str_start_game">Spiel starten</string>

res/values/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<string name="str_bockrounds">Bockrounds</string>
4141
<string name="str_bock_preview_on_off">Bock preview on/off</string>
4242
<string name="str_bock_preview_not_posible">Bock preview not available if Bocklimit is \"0\"</string>
43+
<string name="str_mark_suspend">Mark suspended players</string>
4344
<string name="str_solo">Solo</string>
4445
<string name="str_solo_special">*Solo*</string>
4546
<string name="str_start_game">Start game</string>

src/nldoko/game/XML/DokoXMLClass.java

+9
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ public static boolean saveGameStateToXML(Context c, GameClass game){
7575
serializer.text(game.getGameCntVariant().toString());
7676
serializer.endTag("", "GameCntVariant");
7777

78+
serializer.text("\n\t");
79+
serializer.startTag("", "MarkSuspendedPlayers");
80+
Log.d(TAG,"boolstr:"+Boolean.valueOf(game.isMarkSuspendedPlayersEnable()).toString()+" bool:"+game.isMarkSuspendedPlayersEnable());
81+
serializer.text(Boolean.valueOf(game.isMarkSuspendedPlayersEnable()).toString());
82+
serializer.endTag("", "MarkSuspendedPlayers");
83+
7884

7985
serializer.text("\n\t");
8086
serializer.startTag("", "Players");
@@ -152,6 +158,7 @@ public static GameClass restoreGameStateFromXML(Context c,String filePath) {
152158
int mPreID = 1; // 0 = show state
153159
int mPlayerCnt = 0, mPreRoundCnt = 0, mBockCount = -1, mActivePlayers = 0, mBockRoundLimit = 0;
154160
GAME_CNT_VARIANT mGameCntVariant = GAME_CNT_VARIANT.CNT_VARIANT_NORMAL;
161+
boolean mMarkSuspendedPlayers = false; // default
155162
Float mPoints = (float) 0.0;
156163
String mName = "";
157164

@@ -194,6 +201,7 @@ public static GameClass restoreGameStateFromXML(Context c,String filePath) {
194201
else if(mNode.getNodeName().equalsIgnoreCase("ActivePlayers")) mActivePlayers = Integer.valueOf(mNode.getTextContent());
195202
else if(mNode.getNodeName().equalsIgnoreCase("BockRoundLimit")) mBockRoundLimit = Integer.valueOf(mNode.getTextContent());
196203
else if(mNode.getNodeName().equalsIgnoreCase("GameCntVariant")) mGameCntVariant = GAME_CNT_VARIANT.valueOf(mNode.getTextContent());
204+
else if(mNode.getNodeName().equalsIgnoreCase("MarkSuspendedPlayers")) mMarkSuspendedPlayers = Boolean.valueOf(mNode.getTextContent());
197205
else if(mNode.getNodeName().equalsIgnoreCase("Players")){
198206
mNodesTmp = mNode.getChildNodes();
199207
for(int t=0; t<mNodesTmp.getLength();t++) {
@@ -261,6 +269,7 @@ else if(mNode.getNodeName().equalsIgnoreCase("PreRounds")){
261269
mPlayers.get(i).updatePoints(0,(float)0);
262270
}
263271

272+
mGame.setMarkSuspendedPlayers(mMarkSuspendedPlayers);
264273
mGame.setActivePlayerCount(mActivePlayers);
265274
mGame.setPlayerCount(mPlayerCnt);
266275
mGame.setBockRoundLimit(mBockRoundLimit);

src/nldoko/game/classes/GameClass.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ public class GameClass implements Serializable{
2121
private int mPlayerCount;
2222
private int mActivePlayerCount;
2323
private int mBockRoundLimit;
24+
private boolean mMarkSuspendedPlayers;
2425
private String mCurrentFilename;
25-
26+
2627
public GameClass(){
2728
setDefaults();
2829
}
@@ -32,13 +33,14 @@ public GameClass(String fromFile){
3233
this.mCurrentFilename = fromFile;
3334
}
3435

35-
public GameClass(int playerCount, int activePlayer, int bockLimit, GAME_CNT_VARIANT cntVariant){
36+
public GameClass(int playerCount, int activePlayer, int bockLimit, GAME_CNT_VARIANT cntVariant, boolean markSuspendedPlayers){
3637
this.mPlayers = new ArrayList<PlayerClass>();
3738
this.mRoundList = new ArrayList<RoundClass>();
3839
this.mPreRoundList = new ArrayList<RoundClass>();
3940
this.mPlayerCount = playerCount;
4041
this.mActivePlayerCount = activePlayer;
4142
this.mBockRoundLimit = bockLimit;
43+
this.setMarkSuspendedPlayers(markSuspendedPlayers);
4244

4345
this.cntVariant = cntVariant;
4446

@@ -56,6 +58,7 @@ private void setDefaults(){
5658
this.mActivePlayerCount = 0;
5759
this.mBockRoundLimit = 0;
5860
this.cntVariant = GAME_CNT_VARIANT.CNT_VARIANT_NORMAL;
61+
this.setMarkSuspendedPlayers(false);
5962
}
6063

6164
public void setGameDataFromRestore(ArrayList<PlayerClass> playerList, ArrayList<RoundClass> preRoundList){
@@ -76,6 +79,13 @@ public ArrayList<PlayerClass> getPlayers(){
7679
return this.mPlayers;
7780
}
7881

82+
public boolean isMarkSuspendedPlayersEnable() {
83+
return mMarkSuspendedPlayers;
84+
}
85+
86+
public void setMarkSuspendedPlayers(boolean mMarkSuspendedPlayers) {
87+
this.mMarkSuspendedPlayers = mMarkSuspendedPlayers;
88+
}
7989

8090
public void addRound(RoundClass round){
8191
this.mRoundList.add(round);
@@ -340,5 +350,6 @@ public String generateNewFilename(){
340350
mCurrentFilename = formattedDate+DokoData.SAVED_GAME_FILE_POSTFIX;
341351
return currentFilename();
342352
}
353+
343354

344355
}

src/nldoko/game/data/DokoData.java

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public static enum GAME_VIEW_TYPE {
7575
public static final String CHANGE_GAME_SETTINGS_KEY = "CHANGE_GAME_SETTINGS";
7676
public static final String CHANGE_ROUND_KEY = "CHANGE_ROUND";
7777
public static final String PLAYER_CNT_KEY = "PLAYER_CNT";
78+
public static final String MARK_SUSPEND_OPTION_KEY = "MARK_SUSPEND_OPTION";
7879
public static final String BOCKLIMIT_KEY = "BOCKLIMIT";
7980
public static final String BOCKROUND_KEY = "BOCKROUND";
8081
public static final String ACTIVE_PLAYER_KEY = "ACTIVE_PLAYER";

src/nldoko/game/game/ChangeGameSettingActivity.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,15 @@ private GameClass loadGameState() {
103103
mPlayerCnt = extras.getInt(DokoData.PLAYER_CNT_KEY,0);
104104
mActivePlayers = extras.getInt(DokoData.ACTIVE_PLAYER_KEY,0);
105105
mBockLimit = extras.getInt(DokoData.BOCKLIMIT_KEY,0);
106+
boolean mMarkSuspendedPlayers = extras.getBoolean(DokoData.MARK_SUSPEND_OPTION_KEY,false);
106107
mGameCntVaraint = (GAME_CNT_VARIANT)intent.getSerializableExtra(DokoData.GAME_CNT_VARIANT_KEY);
107108

108109
if(mPlayerCnt < DokoData.MIN_PLAYER || mPlayerCnt > DokoData.MAX_PLAYER
109110
|| mActivePlayers > mPlayerCnt || mActivePlayers < DokoData.MIN_PLAYER ||
110111
(mPlayerCnt == 0 || mActivePlayers == 0))
111112
return null;
112113

113-
mGame = new GameClass(mPlayerCnt, mActivePlayers, mBockLimit,mGameCntVaraint);
114+
mGame = new GameClass(mPlayerCnt, mActivePlayers, mBockLimit,mGameCntVaraint,mMarkSuspendedPlayers);
114115
for(int k=0;k<mPlayerCnt;k++){
115116
Log.d(TAG,mTmp+"k:"+k);
116117
mTmp = extras.getString(DokoData.PLAYERS_KEY[k],"");

src/nldoko/game/game/GameActivity.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public class GameActivity extends FragmentActivity {
8181
private int mPlayerCnt;
8282
private Spinner mSpActivePlayer;
8383
private Spinner mSpBockLimit;
84+
private Boolean mMarkSuspendedPlayers;
8485

8586
private static RadioGroup mNewRoundBockRadioGroup;
8687
private static Button mBtnAddRound;
@@ -202,14 +203,15 @@ else if(extras != null){
202203
mPlayerCnt = extras.getInt(DokoData.PLAYER_CNT_KEY,0);
203204
mActivePlayers = extras.getInt(DokoData.ACTIVE_PLAYER_KEY,0);
204205
mBockLimit = extras.getInt(DokoData.BOCKLIMIT_KEY,0);
206+
mMarkSuspendedPlayers = extras.getBoolean(DokoData.MARK_SUSPEND_OPTION_KEY,false);
205207
mGameCntVaraint = (GAME_CNT_VARIANT)intent.getSerializableExtra(DokoData.GAME_CNT_VARIANT_KEY);
206208

207209
if(mPlayerCnt < DokoData.MIN_PLAYER || mPlayerCnt > DokoData.MAX_PLAYER
208210
|| mActivePlayers > mPlayerCnt || mActivePlayers < DokoData.MIN_PLAYER
209211
|| (mPlayerCnt == 0 || mActivePlayers == 0))
210212
return null;
211-
212-
mGame = new GameClass(mPlayerCnt, mActivePlayers, mBockLimit,mGameCntVaraint);
213+
Log.d(TAG,"ng:"+mMarkSuspendedPlayers);
214+
mGame = new GameClass(mPlayerCnt, mActivePlayers, mBockLimit, mGameCntVaraint,mMarkSuspendedPlayers);
213215
Log.d(TAG,"bl:"+mBockLimit+" - prercnt"+mGame.getPreRoundList().size());
214216
for(int k=0;k<mPlayerCnt;k++){
215217
//Log.d(TAG,mTmp+"k:"+k);
@@ -220,7 +222,7 @@ else if(extras != null){
220222
}
221223
}
222224
else{
223-
mGame = new GameClass(5, 4, 1, GAME_CNT_VARIANT.CNT_VARIANT_NORMAL);
225+
mGame = new GameClass(5, 4, 1, GAME_CNT_VARIANT.CNT_VARIANT_NORMAL,false);
224226

225227
mGame.getPlayer(0).setName("Johannes");
226228
mGame.getPlayer(1).setName("Christoph");

src/nldoko/game/game/GameMainListAdapter.java

+43-9
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,20 @@ else if(mRound.getID() % 2 == 1)
139139
else mBockCountInfo.setVisibility(View.GONE);
140140

141141
for(int i=0;i<mGame.getPlayerCount();i++){
142+
mPoints = mGame.getPlayer(i).getPointHistory(mRound.getID());
142143
mPlayerPoints = (TextView)v.findViewById(DokoData.mTvTablePlayerName[i]);
143-
mPoints = mGame.getPlayer(i).getPointHistory(mRound.getID());
144+
144145
mPlayerPoints.setText(Functions.getFloatAsString(mPoints));
145146
if(mPoints < 0) mPlayerPoints.setTextColor(parent.getResources().getColor(R.color.red));
146147
else mPlayerPoints.setTextColor(parent.getResources().getColor(R.color.green_dark));
148+
149+
// if points don't change player was suspended
150+
if (mGame.isMarkSuspendedPlayersEnable() &&
151+
mRound.getID() > 0 &&
152+
mPoints == mGame.getPlayer(i).getPointHistory(mRound.getID() - 1)) {
153+
mPlayerPoints.setTextColor(parent.getResources().getColor(R.color.blue_dark));
154+
}
155+
147156

148157
}
149158
v.setOnLongClickListener(mRoundNrLongListerner);
@@ -215,17 +224,19 @@ else if(mGame.getPlayerCount() != 4 && v.getId() != R.id.fragment_game_round_vie
215224
else mBockCnt.setText(null);
216225
//Set player (name,points,state,colors)
217226
mTmp = (int) ((double)mGame.getPlayerCount()/2 + 0.5d);
227+
//Log.d("tag","pc:"+mGame.getPlayerCount());
218228

219-
for(int i=0; i< (mGame.getMAXPlayerCount()/mPlayerPerRow) && i<mTmp; i++){
229+
for(int i=0; i<(mGame.getMAXPlayerCount()/mPlayerPerRow); i++){
220230
switch(i){
221231
case 0: mPlayerRow = (LinearLayout)v.findViewById(R.id.fragment_game_round_2_player_row0); break;
222232
case 1: mPlayerRow = (LinearLayout)v.findViewById(R.id.fragment_game_round_2_player_row1); break;
223233
case 2: mPlayerRow = (LinearLayout)v.findViewById(R.id.fragment_game_round_2_player_row2); break;
224234
case 3: mPlayerRow = (LinearLayout)v.findViewById(R.id.fragment_game_round_2_player_row3); break;
225235
}
226236

227-
if(mPlayerRow == null) return v;
228237

238+
if(mPlayerRow == null) return v;
239+
if (i>=mTmp) mPlayerRow.setVisibility(View.GONE);
229240
//Left
230241
mPlayerLeftName = (TextView)mPlayerRow.findViewById(R.id.fragment_game_round_2_player_row_player_left_name);
231242
mPlayerLeftPoints = (TextView)mPlayerRow.findViewById(R.id.fragment_game_round_2_player_row_player_left_points);
@@ -240,9 +251,21 @@ else if(mGame.getPlayerCount() != 4 && v.getId() != R.id.fragment_game_round_vie
240251
if(mRound.getID()>0) mPointsDiff = mPoints - mGame.getPlayer(i*mPlayerPerRow).getPointHistory(mRound.getID()-1);
241252
else mPointsDiff = mPoints;
242253

243-
if(mPointsDiff == 0 || mRound.getPoints() == 0) mPlayerLeftRoundState.setImageDrawable(parent.getResources().getDrawable(R.drawable.navigation_cancel));
244-
else if(mPointsDiff > 0)mPlayerLeftRoundState.setImageDrawable(parent.getResources().getDrawable(R.drawable.ic_arrow_up_green));
245-
else mPlayerLeftRoundState.setImageDrawable(parent.getResources().getDrawable(R.drawable.ic_arrow_up_red));
254+
255+
if(mPointsDiff == 0 || mRound.getPoints() == 0) {
256+
if (mGame.isMarkSuspendedPlayersEnable()) {
257+
mPlayerRow.findViewById(R.id.fragment_game_round_2_player_row_player_row_left_player).setBackgroundDrawable(v.getResources().getDrawable(R.drawable.select_gray));
258+
}
259+
mPlayerLeftRoundState.setImageDrawable(parent.getResources().getDrawable(R.drawable.navigation_cancel));
260+
}
261+
else if(mPointsDiff > 0) {
262+
mPlayerRow.findViewById(R.id.fragment_game_round_2_player_row_player_row_left_player).setBackgroundDrawable(null);
263+
mPlayerLeftRoundState.setImageDrawable(parent.getResources().getDrawable(R.drawable.ic_arrow_up_green));
264+
}
265+
else {
266+
mPlayerRow.findViewById(R.id.fragment_game_round_2_player_row_player_row_left_player).setBackgroundDrawable(null);
267+
mPlayerLeftRoundState.setImageDrawable(parent.getResources().getDrawable(R.drawable.ic_arrow_up_red));
268+
}
246269

247270
//Right
248271
mPlayerRightName = (TextView)mPlayerRow.findViewById(R.id.fragment_game_round_2_player_row_player_right_name);
@@ -268,9 +291,20 @@ else if(mGame.getPlayerCount() != 4 && v.getId() != R.id.fragment_game_round_vie
268291
if(mRound.getID()>0) mPointsDiff = mPoints - mGame.getPlayer(i*mPlayerPerRow+1).getPointHistory(mRound.getID()-1);
269292
else mPointsDiff = mPoints;
270293

271-
if(mPointsDiff == 0 || mRound.getPoints() == 0) mPlayerRightRoundState.setImageDrawable(parent.getResources().getDrawable(R.drawable.navigation_cancel));
272-
else if(mPointsDiff > 0)mPlayerRightRoundState.setImageDrawable(parent.getResources().getDrawable(R.drawable.ic_arrow_up_green));
273-
else mPlayerRightRoundState.setImageDrawable(parent.getResources().getDrawable(R.drawable.ic_arrow_up_red));
294+
if(mPointsDiff == 0 || mRound.getPoints() == 0) {
295+
if (mGame.isMarkSuspendedPlayersEnable()) {
296+
mPlayerRow.findViewById(R.id.fragment_game_round_2_player_row_player_row_right_player).setBackgroundDrawable(v.getResources().getDrawable(R.drawable.select_gray));
297+
}
298+
mPlayerRightRoundState.setImageDrawable(parent.getResources().getDrawable(R.drawable.navigation_cancel));
299+
}
300+
else if(mPointsDiff > 0) {
301+
mPlayerRow.findViewById(R.id.fragment_game_round_2_player_row_player_row_right_player).setBackgroundDrawable(null);;
302+
mPlayerRightRoundState.setImageDrawable(parent.getResources().getDrawable(R.drawable.ic_arrow_up_green));
303+
}
304+
else {
305+
mPlayerRow.findViewById(R.id.fragment_game_round_2_player_row_player_row_right_player).setBackgroundDrawable(null);
306+
mPlayerRightRoundState.setImageDrawable(parent.getResources().getDrawable(R.drawable.ic_arrow_up_red));
307+
}
274308
}
275309

276310
}

0 commit comments

Comments
 (0)