mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
Add colors etc. to prefs dialog; wire player colors to be set from
prefs rather than hard-coded. Remaining new prefs entries still unused.
This commit is contained in:
parent
e6871c0840
commit
4a12409d97
6 changed files with 143 additions and 44 deletions
|
@ -187,6 +187,18 @@
|
|||
<string name="prefs_colors">Colors</string>
|
||||
<string name="player0">First player</string>
|
||||
<string name="player1">Second player</string>
|
||||
<string name="player2">Third player</string>
|
||||
<string name="player3">Fourth player</string>
|
||||
<string name="bonus_l2x">Double letter</string>
|
||||
<string name="bonus_l3x">Triple letter</string>
|
||||
<string name="bonus_w2x">Double word</string>
|
||||
<string name="bonus_w3x">Triple word</string>
|
||||
<string name="tile_back">Tile background</string>
|
||||
<string name="focus">Focus color</string>
|
||||
<string name="advanced">Advanced</string>
|
||||
<string name="relay_host">Relay address</string>
|
||||
<string name="relay_port">Relay port</string>
|
||||
<string name="sms_port">SMS port</string>
|
||||
|
||||
<!-- These do not require localization -->
|
||||
<string name="key_color_tiles">key_color_tiles</string>
|
||||
|
@ -196,5 +208,15 @@
|
|||
<string name="key_hide_values">key_hide_values</string>
|
||||
<string name="key_player0">key_player0</string>
|
||||
<string name="key_player1">key_player1</string>
|
||||
|
||||
<string name="key_player2">key_player2</string>
|
||||
<string name="key_player3">key_player3</string>
|
||||
<string name="key_bonus_l2x">key_bonus_l2x</string>
|
||||
<string name="key_bonus_l3x">key_bonus_l3x</string>
|
||||
<string name="key_bonus_w2x">key_bonus_w2x</string>
|
||||
<string name="key_bonus_w3x">key_bonus_w3x</string>
|
||||
<string name="key_tile_back">key_tile_back</string>
|
||||
<string name="key_focus">key_focus</string>
|
||||
<string name="key_relay_host">key_relay_host</string>
|
||||
<string name="key_relay_port">key_relay_port</string>
|
||||
<string name="key_sms_port">key_sms_port</string>
|
||||
</resources>
|
||||
|
|
|
@ -39,6 +39,60 @@
|
|||
android:title="@string/player1"
|
||||
android:defaultValue="0xFF0000"
|
||||
/>
|
||||
|
||||
<EditTextPreference android:key="@string/key_player2"
|
||||
android:title="@string/player2"
|
||||
android:defaultValue="0x000000"
|
||||
/>
|
||||
<EditTextPreference android:key="@string/key_player3"
|
||||
android:title="@string/player3"
|
||||
android:defaultValue="0xFF0000"
|
||||
/>
|
||||
|
||||
<EditTextPreference android:key="@string/key_bonus_l2x"
|
||||
android:title="@string/bonus_l2x"
|
||||
android:defaultValue="0xAFAF00"
|
||||
/>
|
||||
<EditTextPreference android:key="@string/key_bonus_l3x"
|
||||
android:title="@string/bonus_l3x"
|
||||
android:defaultValue="0x00AFAF"
|
||||
/>
|
||||
<EditTextPreference android:key="@string/key_bonus_w2x"
|
||||
android:title="@string/bonus_w2x"
|
||||
android:defaultValue="0xAF00AF"
|
||||
/>
|
||||
<EditTextPreference android:key="@string/key_bonus_w3x"
|
||||
android:title="@string/bonus_w3x"
|
||||
android:defaultValue="0xAFAFAF"
|
||||
/>
|
||||
|
||||
<EditTextPreference android:key="@string/key_tile_back"
|
||||
android:title="@string/tile_back"
|
||||
android:defaultValue="0xFFFF99"
|
||||
/>
|
||||
<EditTextPreference android:key="@string/key_focus"
|
||||
android:title="@string/focus"
|
||||
android:defaultValue="0x7070FF"
|
||||
/>
|
||||
</PreferenceScreen>
|
||||
|
||||
|
||||
<PreferenceScreen android:title="@string/advanced"
|
||||
>
|
||||
<EditTextPreference android:key="@string/key_relay_host"
|
||||
android:title="@string/relay_host"
|
||||
android:defaultValue="eehouse.org"
|
||||
/>
|
||||
<EditTextPreference android:key="@string/key_relay_port"
|
||||
android:title="@string/relay_port"
|
||||
android:defaultValue="10999"
|
||||
android:numeric="decimal"
|
||||
/>
|
||||
<EditTextPreference android:key="@string/key_sms_port"
|
||||
android:title="@string/sms_port"
|
||||
android:defaultValue="5432"
|
||||
android:numeric="decimal"
|
||||
/>
|
||||
</PreferenceScreen>
|
||||
|
||||
-->
|
||||
|
|
|
@ -112,7 +112,7 @@ public class BoardActivity extends Activity implements UtilCtxt {
|
|||
{
|
||||
super.onCreate( savedInstanceState );
|
||||
|
||||
m_cp = new CommonPrefs( this );
|
||||
m_cp = CommonPrefs.get();
|
||||
|
||||
setContentView( R.layout.board );
|
||||
m_handler = new Handler();
|
||||
|
@ -183,12 +183,12 @@ public class BoardActivity extends Activity implements UtilCtxt {
|
|||
public void onWindowFocusChanged( boolean hasFocus )
|
||||
{
|
||||
super.onWindowFocusChanged( hasFocus );
|
||||
if ( hasFocus )
|
||||
if ( hasFocus ) {
|
||||
if ( null == m_cp ) {
|
||||
m_cp = new CommonPrefs( this );
|
||||
m_jniThread.handle( JNIThread.JNICmd.CMD_PREFS_CHANGE, m_cp );
|
||||
m_jniThread.handle( JNIThread.JNICmd.CMD_PREFS_CHANGE );
|
||||
}
|
||||
onContentChanged();
|
||||
// onContentChanged();
|
||||
}
|
||||
}
|
||||
|
||||
protected void onDestroy()
|
||||
|
|
|
@ -46,14 +46,7 @@ public class BoardView extends View implements DrawCtx,
|
|||
0xFF00AFAF,
|
||||
0xFFAF00AF,
|
||||
0xFFAFAFAF };
|
||||
private static final int[] m_playerColors = {
|
||||
0xFF000000,
|
||||
0xFFFF0000,
|
||||
0xFF0000FF,
|
||||
0xFF008F00,
|
||||
};
|
||||
|
||||
|
||||
private int[] m_playerColors;
|
||||
|
||||
public BoardView( Context context )
|
||||
{
|
||||
|
@ -126,6 +119,8 @@ public class BoardView extends View implements DrawCtx,
|
|||
m_origin = res.getDrawable( R.drawable.origin );
|
||||
|
||||
m_boundsScratch = new Rect();
|
||||
|
||||
m_playerColors = CommonPrefs.get().playerColors;
|
||||
}
|
||||
|
||||
private boolean layoutBoardOnce()
|
||||
|
|
|
@ -10,6 +10,7 @@ import junit.framework.Assert;
|
|||
|
||||
public class CommonPrefs {
|
||||
private static Context s_context = null;
|
||||
private static CommonPrefs s_cp = null;
|
||||
|
||||
public boolean showBoardArrow;
|
||||
public boolean showRobotScores;
|
||||
|
@ -17,49 +18,75 @@ public class CommonPrefs {
|
|||
public boolean skipCommitConfirm;
|
||||
public boolean showColors;
|
||||
|
||||
public CommonPrefs( Context context )
|
||||
{
|
||||
if ( s_context == null ) {
|
||||
s_context = context;
|
||||
}
|
||||
public int[] playerColors;
|
||||
|
||||
private CommonPrefs()
|
||||
{
|
||||
playerColors = new int[4];
|
||||
}
|
||||
|
||||
private CommonPrefs refresh()
|
||||
{
|
||||
SharedPreferences sp =
|
||||
PreferenceManager.getDefaultSharedPreferences( s_context );
|
||||
String str;
|
||||
String key;
|
||||
|
||||
str = s_context.getString( R.string.key_show_arrow );
|
||||
showBoardArrow = sp.getBoolean( str, true );
|
||||
key = s_context.getString( R.string.key_show_arrow );
|
||||
showBoardArrow = sp.getBoolean( key, true );
|
||||
|
||||
str = s_context.getString( R.string.key_explain_robot );
|
||||
showRobotScores = sp.getBoolean( str, false );
|
||||
key = s_context.getString( R.string.key_explain_robot );
|
||||
showRobotScores = sp.getBoolean( key, false );
|
||||
|
||||
str = s_context.getString( R.string.key_hide_values );
|
||||
hideTileValues = sp.getBoolean( str, false );
|
||||
key = s_context.getString( R.string.key_hide_values );
|
||||
hideTileValues = sp.getBoolean( key, false );
|
||||
|
||||
str = s_context.getString( R.string.key_skip_confirm );
|
||||
skipCommitConfirm = sp.getBoolean( str, false );
|
||||
key = s_context.getString( R.string.key_skip_confirm );
|
||||
skipCommitConfirm = sp.getBoolean( key, false );
|
||||
|
||||
str = s_context.getString( R.string.key_color_tiles );
|
||||
showColors = sp.getBoolean( str, true );
|
||||
key = s_context.getString( R.string.key_color_tiles );
|
||||
showColors = sp.getBoolean( key, true );
|
||||
|
||||
int ids[] = { R.string.key_player0,
|
||||
R.string.key_player1,
|
||||
R.string.key_player2,
|
||||
R.string.key_player3,
|
||||
};
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommonPrefs( Context context, CommonPrefs src ) {
|
||||
this( context );
|
||||
copyFrom( src );
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
// public void copyFrom( CommonPrefs src )
|
||||
// {
|
||||
// showBoardArrow = src.showBoardArrow;
|
||||
// showRobotScores = src.showRobotScores;
|
||||
// hideTileValues = src.hideTileValues;
|
||||
// skipCommitConfirm = src.skipCommitConfirm;
|
||||
// showColors = src.showColors;
|
||||
// }
|
||||
|
||||
public static void setContext( Context context )
|
||||
{
|
||||
Assert.assertTrue( s_context == null );
|
||||
s_context = context;
|
||||
}
|
||||
|
||||
public static CommonPrefs get()
|
||||
{
|
||||
Assert.assertNotNull( s_context );
|
||||
if ( null == s_cp ) {
|
||||
s_cp = new CommonPrefs();
|
||||
}
|
||||
return s_cp.refresh();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,8 +198,9 @@ public class JNIThread extends Thread {
|
|||
break;
|
||||
|
||||
case CMD_PREFS_CHANGE:
|
||||
draw = XwJNI.board_prefsChanged( m_jniGamePtr,
|
||||
(CommonPrefs)args[0] );
|
||||
XwJNI.board_invalAll( m_jniGamePtr );
|
||||
XwJNI.board_prefsChanged( m_jniGamePtr, CommonPrefs.get() );
|
||||
draw = true;
|
||||
break;
|
||||
|
||||
case CMD_PEN_DOWN:
|
||||
|
|
Loading…
Add table
Reference in a new issue