mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-01 06:19:57 +01:00
lots of little changes toward making prefs (per-game and global) work,
which they more-or-less do. Some still not captured.
This commit is contained in:
parent
c682a7caac
commit
ec085d8944
11 changed files with 149 additions and 7 deletions
11
xwords4/android/XWords4/res/layout/player_view.xml
Normal file
11
xwords4/android/XWords4/res/layout/player_view.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<org.eehouse.android.xw4.PlayerView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/player_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:focusable="true"
|
||||
android:clickable="true"
|
||||
android:longClickable="true"/>
|
|
@ -1,6 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/game_config_done"
|
||||
android:title="@string/game_config_done"
|
||||
/>
|
||||
<item android:id="@+id/game_config_juggle"
|
||||
android:title="@string/game_config_juggle"
|
||||
/>
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
<item android:id="@+id/gamel_menu_delete_all"
|
||||
android:title="@string/gamel_menu_delete_all"
|
||||
/>
|
||||
<item android:id="@+id/gamel_menu_prefs"
|
||||
android:title="@string/gamel_menu_prefs"
|
||||
/>
|
||||
<item android:id="@+id/gamel_menu_view_hidden"
|
||||
android:title="@string/gamel_menu_view_hidden"
|
||||
/>
|
||||
|
|
|
@ -146,14 +146,34 @@
|
|||
<string name="players_label">Players</string>
|
||||
<string name="button_add_player">Add player</string>
|
||||
|
||||
<string name="game_config_juggle">Juggle</string>
|
||||
<string name="game_config_juggle">Juggle players</string>
|
||||
|
||||
<string name="list_item_up">Up one</string>
|
||||
<string name="list_item_down">Down one</string>
|
||||
|
||||
<string name="dict_label">Dictionary</string>
|
||||
<string name="role_label">Role</string>
|
||||
<string name="phonies_label">Phonies</string>
|
||||
|
||||
<string name="download_dicts">Download more...</string>
|
||||
|
||||
<string name="dict_url">http://eehouse.org/and_dicts</string>
|
||||
|
||||
<string name="hints_allowed">Allow hints</string>
|
||||
<string name="use_timer">Enable timer</string>
|
||||
<string name="color_tiles">Color tiles</string>
|
||||
<string name="smart_robot">Smart robot</string>
|
||||
<string name="show_arrow">Show board arrow</string>
|
||||
<string name="explain_robot">Explain robot moves</string>
|
||||
<string name="skip_confirm_turn">Skip confirming turn</string>
|
||||
<string name="hide_values">Hide values</string>
|
||||
|
||||
<string name="role_standalone">Standalone</string>
|
||||
<string name="role_host">Host</string>
|
||||
<string name="role_guest">Guest</string>
|
||||
|
||||
<string name="phonies_ignore">Ignore</string>
|
||||
<string name="phonies_warn">Warn</string>
|
||||
<string name="phonies_disallow">Disallow</string>
|
||||
<string name="gamel_menu_prefs">Preferences</string>
|
||||
</resources>
|
||||
|
|
|
@ -40,7 +40,6 @@ public class BoardActivity extends Activity implements UtilCtxt, Runnable {
|
|||
private BoardView m_view;
|
||||
private int m_jniGamePtr;
|
||||
private CurGameInfo m_gi;
|
||||
private CommonPrefs m_prefs;
|
||||
private Handler m_handler;
|
||||
private TimerRunnable[] m_timers;
|
||||
private String m_path;
|
||||
|
@ -114,7 +113,6 @@ public class BoardActivity extends Activity implements UtilCtxt, Runnable {
|
|||
m_handler = new Handler();
|
||||
m_timers = new TimerRunnable[4]; // needs to be in sync with
|
||||
// XWTimerReason
|
||||
m_prefs = new CommonPrefs();
|
||||
m_gi = new CurGameInfo();
|
||||
|
||||
m_view = (BoardView)findViewById( R.id.board_view );
|
||||
|
@ -140,10 +138,10 @@ public class BoardActivity extends Activity implements UtilCtxt, Runnable {
|
|||
if ( null == stream ||
|
||||
! XwJNI.game_makeFromStream( m_jniGamePtr, stream,
|
||||
m_gi, dictBytes, this,
|
||||
m_view, m_prefs,
|
||||
m_view, Utils.getCP(),
|
||||
null ) ) {
|
||||
XwJNI.game_makeNewGame( m_jniGamePtr, m_gi, this, m_view, 0,
|
||||
m_prefs, null, dictBytes );
|
||||
Utils.getCP(), null, dictBytes );
|
||||
}
|
||||
|
||||
m_jniThread = new
|
||||
|
|
|
@ -275,6 +275,9 @@ public class BoardView extends View implements DrawCtx,
|
|||
backColor = BLACK;
|
||||
} else {
|
||||
backColor = TILE_BACK;
|
||||
if ( owner < 0 ) {
|
||||
owner = 0;
|
||||
}
|
||||
foreColor = m_playerColors[owner];
|
||||
}
|
||||
|
||||
|
|
|
@ -177,10 +177,20 @@ public class GamesList extends ListActivity implements View.OnClickListener {
|
|||
setListAdapter( m_adapter );
|
||||
handled = true;
|
||||
break;
|
||||
|
||||
case R.id.gamel_menu_prefs:
|
||||
Intent intent = new Intent( this, PrefsActivity.class );
|
||||
intent.setAction( Intent.ACTION_EDIT );
|
||||
startActivity( intent );
|
||||
break;
|
||||
|
||||
case R.id.gamel_menu_view_hidden:
|
||||
Utils.notImpl( this );
|
||||
break;
|
||||
default:
|
||||
handled = false;
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
|
@ -208,7 +218,7 @@ public class GamesList extends ListActivity implements View.OnClickListener {
|
|||
Uri uri = Uri.fromFile( new File(path) );
|
||||
|
||||
Intent intent = new Intent( Intent.ACTION_EDIT, uri,
|
||||
GamesList.this, GameConfig.class );
|
||||
this, GameConfig.class );
|
||||
startActivity( intent );
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant reinstall"; -*- */
|
||||
|
||||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.widget.TextView;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class PlayerView extends TextView {
|
||||
private int m_position;
|
||||
|
||||
public PlayerView( Context cx, AttributeSet as ) {
|
||||
super( cx, as );
|
||||
}
|
||||
|
||||
public int getPosition() { return m_position; }
|
||||
public void setPosition( int indx ) { m_position = indx; }
|
||||
}
|
|
@ -14,9 +14,15 @@ import java.util.ArrayList;
|
|||
import android.content.res.AssetManager;
|
||||
import android.os.Environment;
|
||||
import java.io.InputStream;
|
||||
import android.widget.CheckBox;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
|
||||
import org.eehouse.android.xw4.jni.*;
|
||||
|
||||
public class Utils {
|
||||
static final String TAG = "EJAVA";
|
||||
private static CommonPrefs m_cp;
|
||||
|
||||
private Utils() {}
|
||||
|
||||
|
@ -176,4 +182,45 @@ public class Utils {
|
|||
return bytes;
|
||||
}
|
||||
|
||||
public static void setChecked( Activity activity, int id, boolean value )
|
||||
{
|
||||
CheckBox cbx = (CheckBox)activity.findViewById( id );
|
||||
cbx.setChecked( value );
|
||||
}
|
||||
|
||||
public static void setChecked( Dialog dialog, int id, boolean value )
|
||||
{
|
||||
CheckBox cbx = (CheckBox)dialog.findViewById( id );
|
||||
cbx.setChecked( value );
|
||||
}
|
||||
|
||||
public static boolean getChecked( Activity activity, int id )
|
||||
{
|
||||
CheckBox cbx = (CheckBox)activity.findViewById( id );
|
||||
return cbx.isChecked();
|
||||
}
|
||||
|
||||
public static boolean getChecked( Dialog dialog, int id )
|
||||
{
|
||||
CheckBox cbx = (CheckBox)dialog.findViewById( id );
|
||||
return cbx.isChecked();
|
||||
}
|
||||
|
||||
public static CommonPrefs getCP()
|
||||
{
|
||||
if ( null == m_cp ) {
|
||||
m_cp = new CommonPrefs();
|
||||
}
|
||||
return m_cp;
|
||||
}
|
||||
|
||||
public static void setCP( CommonPrefs cp )
|
||||
{
|
||||
if ( null == m_cp ) {
|
||||
m_cp = new CommonPrefs( cp );
|
||||
} else {
|
||||
m_cp.copyFrom( cp );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,11 +5,27 @@ public class CommonPrefs {
|
|||
public boolean showRobotScores;
|
||||
public boolean hideTileValues;
|
||||
public boolean skipCommitConfirm;
|
||||
public boolean showColors;
|
||||
|
||||
public CommonPrefs() {
|
||||
showBoardArrow = true;
|
||||
showRobotScores = true;
|
||||
hideTileValues = false;
|
||||
skipCommitConfirm = false;
|
||||
showColors = true;
|
||||
}
|
||||
|
||||
public CommonPrefs( CommonPrefs src ) {
|
||||
this();
|
||||
copyFrom( src );
|
||||
}
|
||||
|
||||
public void copyFrom( CommonPrefs src )
|
||||
{
|
||||
showBoardArrow = src.showBoardArrow;
|
||||
showRobotScores = src.showRobotScores;
|
||||
hideTileValues = src.hideTileValues;
|
||||
skipCommitConfirm = src.skipCommitConfirm;
|
||||
showColors = src.showColors;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ public class CurGameInfo {
|
|||
public String dictName;
|
||||
public LocalPlayer[] players;
|
||||
public int gameID;
|
||||
public int gameSeconds; /* for timer */
|
||||
public int nPlayers;
|
||||
public int boardSize;
|
||||
public DeviceRole serverRole;
|
||||
|
@ -25,6 +24,7 @@ public class CurGameInfo {
|
|||
public boolean timerEnabled;
|
||||
public boolean allowPickTiles;
|
||||
public boolean allowHintRect;
|
||||
public boolean showColors;
|
||||
public int robotSmartness;
|
||||
public XWPhoniesChoice phoniesAction;
|
||||
public boolean confirmBTConnect; /* only used for BT */
|
||||
|
@ -36,6 +36,12 @@ public class CurGameInfo {
|
|||
serverRole = DeviceRole.SERVER_STANDALONE;
|
||||
dictName = BUILTIN_DICT;
|
||||
hintsNotAllowed = false;
|
||||
phoniesAction = XWPhoniesChoice.PHONIES_IGNORE;
|
||||
timerEnabled = false;
|
||||
allowPickTiles = false;
|
||||
allowHintRect = false;
|
||||
showColors = true;
|
||||
robotSmartness = 1;
|
||||
|
||||
// Always create MAX_NUM_PLAYERS so jni code doesn't ever have
|
||||
// to cons up a LocalPlayer instance.
|
||||
|
@ -52,6 +58,12 @@ public class CurGameInfo {
|
|||
serverRole = src.serverRole;
|
||||
dictName = src.dictName;
|
||||
hintsNotAllowed = src.hintsNotAllowed;
|
||||
phoniesAction = src.phoniesAction;
|
||||
timerEnabled = src.timerEnabled;
|
||||
allowPickTiles = src.allowPickTiles;
|
||||
allowHintRect = src.allowHintRect;
|
||||
showColors = src.showColors;
|
||||
robotSmartness = src.robotSmartness;
|
||||
|
||||
int ii;
|
||||
for ( ii = 0; ii < MAX_NUM_PLAYERS; ++ii ) {
|
||||
|
|
Loading…
Reference in a new issue