mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
pull bonus colors from prefs too
This commit is contained in:
parent
6522f54989
commit
35352f8b6c
2 changed files with 29 additions and 23 deletions
|
@ -41,11 +41,7 @@ public class BoardView extends View implements DrawCtx,
|
|||
private static final int BLACK = 0xFF000000;
|
||||
private static final int WHITE = 0xFFFFFFFF;
|
||||
private static final int TILE_BACK = 0xFFFFFF99;
|
||||
private int [] m_bonusColors = { WHITE, // BONUS_NONE
|
||||
0xFFAFAF00, /* bonus 1 */
|
||||
0xFF00AFAF,
|
||||
0xFFAF00AF,
|
||||
0xFFAFAFAF };
|
||||
private int [] m_bonusColors;
|
||||
private int[] m_playerColors;
|
||||
|
||||
public BoardView( Context context )
|
||||
|
@ -120,7 +116,9 @@ public class BoardView extends View implements DrawCtx,
|
|||
|
||||
m_boundsScratch = new Rect();
|
||||
|
||||
m_playerColors = CommonPrefs.get().playerColors;
|
||||
CommonPrefs prefs = CommonPrefs.get();
|
||||
m_playerColors = prefs.playerColors;
|
||||
m_bonusColors = prefs.bonusColors;
|
||||
}
|
||||
|
||||
private boolean layoutBoardOnce()
|
||||
|
|
|
@ -19,10 +19,13 @@ public class CommonPrefs {
|
|||
public boolean showColors;
|
||||
|
||||
public int[] playerColors;
|
||||
public int[] bonusColors;
|
||||
|
||||
private CommonPrefs()
|
||||
{
|
||||
playerColors = new int[4];
|
||||
playerColors = new int[4];
|
||||
bonusColors = new int[5];
|
||||
bonusColors[0] = 0xFFFFFFFF; // white
|
||||
}
|
||||
|
||||
private CommonPrefs refresh()
|
||||
|
@ -53,28 +56,33 @@ public class CommonPrefs {
|
|||
};
|
||||
|
||||
for ( int ii = 0; ii < ids.length; ++ii ) {
|
||||
key = s_context.getString( ids[ii] );
|
||||
String val = sp.getString( key, "" );
|
||||
playerColors[ii] = 0xFF000000 | Integer.decode( val );
|
||||
playerColors[ii] = prefToColor( sp, ids[ii] );
|
||||
}
|
||||
|
||||
int ids2[] = { R.string.key_bonus_l2x,
|
||||
R.string.key_bonus_l3x,
|
||||
R.string.key_bonus_w2x,
|
||||
R.string.key_bonus_w3x,
|
||||
};
|
||||
for ( int ii = 0; ii < ids2.length; ++ii ) {
|
||||
bonusColors[ii+1] = prefToColor( sp, ids2[ii] );
|
||||
}
|
||||
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// private CommonPrefs( Context context, CommonPrefs src ) {
|
||||
// this( context );
|
||||
// copyFrom( src );
|
||||
// }
|
||||
|
||||
// public void copyFrom( CommonPrefs src )
|
||||
// {
|
||||
// showBoardArrow = src.showBoardArrow;
|
||||
// showRobotScores = src.showRobotScores;
|
||||
// hideTileValues = src.hideTileValues;
|
||||
// skipCommitConfirm = src.skipCommitConfirm;
|
||||
// showColors = src.showColors;
|
||||
// }
|
||||
private int prefToColor( SharedPreferences sp, int id )
|
||||
{
|
||||
String key = s_context.getString( id );
|
||||
String val = sp.getString( key, "" );
|
||||
return 0xFF000000 | Integer.decode( val );
|
||||
}
|
||||
|
||||
/*
|
||||
* static methods
|
||||
*/
|
||||
public static void setContext( Context context )
|
||||
{
|
||||
Assert.assertTrue( s_context == null );
|
||||
|
|
Loading…
Add table
Reference in a new issue