mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
Fix crash on pre-fiveway palmos where FrmGetFocus always returns -1;
add new preference for whether small value nums are drawn in tiles in tray.
This commit is contained in:
parent
e5e36f0fa4
commit
6b1fc7e5e4
10 changed files with 69 additions and 42 deletions
|
@ -395,14 +395,17 @@ board_getScale( BoardCtxt* board, XP_U16* hScale, XP_U16* vScale )
|
|||
XP_Bool
|
||||
board_prefsChanged( BoardCtxt* board, CommonPrefs* cp )
|
||||
{
|
||||
XP_Bool changed;
|
||||
XP_Bool oldVal = board->disableArrow;
|
||||
XP_Bool showArrowChanged;
|
||||
XP_Bool hideValChanged;
|
||||
|
||||
showArrowChanged = cp->showBoardArrow == board->disableArrow;
|
||||
hideValChanged = cp->hideTileValues != board->hideValsInTray;
|
||||
|
||||
board->disableArrow = !cp->showBoardArrow;
|
||||
changed = oldVal != board->disableArrow;
|
||||
board->hideValsInTray = cp->hideTileValues;
|
||||
|
||||
if ( changed ) {
|
||||
changed = setArrowVisible( board, XP_FALSE );
|
||||
if ( showArrowChanged ) {
|
||||
showArrowChanged = setArrowVisible( board, XP_FALSE );
|
||||
}
|
||||
|
||||
#ifdef XWFEATURE_SEARCHLIMIT
|
||||
|
@ -419,7 +422,7 @@ board_prefsChanged( BoardCtxt* board, CommonPrefs* cp )
|
|||
}
|
||||
#endif
|
||||
|
||||
return changed;
|
||||
return showArrowChanged || hideValChanged;
|
||||
} /* board_prefsChanged */
|
||||
|
||||
XP_Bool
|
||||
|
|
|
@ -109,6 +109,7 @@ struct BoardCtxt {
|
|||
XP_Bool badWordRejected;
|
||||
XP_Bool timerPending;
|
||||
XP_Bool disableArrow;
|
||||
XP_Bool hideValsInTray;
|
||||
|
||||
XP_Bool tradeInProgress[MAX_NUM_PLAYERS];
|
||||
XP_Bool eraseTray;
|
||||
|
|
|
@ -103,8 +103,8 @@ typedef enum {
|
|||
typedef struct CommonPrefs {
|
||||
XP_Bool showBoardArrow; /* applies to all games */
|
||||
XP_Bool showRobotScores; /* applies to all games */
|
||||
XP_Bool reserved1; /* get to 32-bit for ARM... */
|
||||
XP_Bool reserved2;
|
||||
XP_Bool hideTileValues;
|
||||
XP_Bool reserved2; /* get to 32-bit for ARM... */
|
||||
} CommonPrefs;
|
||||
|
||||
#ifdef XWFEATURE_BLUETOOTH
|
||||
|
|
|
@ -154,8 +154,11 @@ drawTray( BoardCtxt* board, XP_Bool focussed )
|
|||
dict_tilesToString( dictionary, &tile, 1,
|
||||
textP, sizeof(buf) );
|
||||
}
|
||||
value = dict_getTileValue( dictionary, tile );
|
||||
|
||||
if ( board->hideValsInTray ) {
|
||||
value = -1;
|
||||
} else {
|
||||
value = dict_getTileValue( dictionary, tile );
|
||||
}
|
||||
draw_drawTile( board->draw, &tileRect, textP,
|
||||
bitmap, value, highlighted );
|
||||
} else {
|
||||
|
|
|
@ -353,12 +353,14 @@ END /* XW_CONNS_FORM */
|
|||
#endif
|
||||
|
||||
#define PREFS_MODE_TOP 15
|
||||
#define PREFS_TOP 30
|
||||
#define PREFS_ROW1 30
|
||||
#define PREFS_SPACING 15
|
||||
|
||||
/* #define DLG_TOP (52-TRAY_EDIT_ADJUST-SEARCHLIMIT_ADJUST) */
|
||||
#define DLG_HEIGHT (112+TRAY_EDIT_ADJUST+SEARCHLIMIT_ADJUST)
|
||||
#define DLG_TOP (160 - DLG_HEIGHT - 2)
|
||||
#define TIMER_TOP (74+SEARCHLIMIT_ADJUST)
|
||||
#define BUTTON_TOP (TIMER_TOP+16+TRAY_EDIT_ADJUST)
|
||||
#define BUTTON_TOP (TIMER_TOP+18+TRAY_EDIT_ADJUST)
|
||||
#define PREFS_LNHT 4
|
||||
|
||||
FORM ID XW_PREFS_FORM AT (2 DLG_TOP 156 DLG_HEIGHT)
|
||||
|
@ -375,36 +377,38 @@ BEGIN
|
|||
|
||||
/* global prefs */
|
||||
CHECKBOX "Color played tiles" ID XW_PREFS_PLAYERCOLORS_CHECKBOX_ID \
|
||||
AT (LEFTCOL PREFS_TOP AUTO AUTO) NONUSABLE
|
||||
AT (LEFTCOL PREFS_ROW1 AUTO AUTO) NONUSABLE
|
||||
CHECKBOX "Show progress bar" ID XW_PREFS_PROGRESSBAR_CHECKBOX_ID \
|
||||
AT (LEFTCOL PREVBOTTOM+PREFS_LNHT AUTO AUTO) NONUSABLE
|
||||
AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE
|
||||
CHECKBOX "Larger board" ID XW_PREFS_SHOWGRID_CHECKBOX_ID \
|
||||
AT (LEFTCOL PREVBOTTOM+PREFS_LNHT AUTO AUTO) NONUSABLE
|
||||
AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE
|
||||
CHECKBOX "Enable arrow cursor" ID XW_PREFS_SHOWARROW_CHECKBOX_ID \
|
||||
AT (LEFTCOL PREVBOTTOM+PREFS_LNHT AUTO AUTO) NONUSABLE
|
||||
AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE
|
||||
CHECKBOX "Explain robot scores" ID XW_PREFS_ROBOTSCORE_CHECKBOX_ID \
|
||||
AT (LEFTCOL PREVBOTTOM+PREFS_LNHT AUTO AUTO) NONUSABLE
|
||||
AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE
|
||||
CHECKBOX "Hide tile values" ID XW_PREFS_HIDETRAYVAL_CHECKBOX_ID \
|
||||
AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE
|
||||
|
||||
/* single-game prefs */
|
||||
CHECKBOX "Smart robot" ID XW_PREFS_ROBOTSMART_CHECKBOX_ID \
|
||||
AT (LEFTCOL PREFS_TOP AUTO AUTO) NONUSABLE
|
||||
AT (LEFTCOL PREFS_ROW1 AUTO AUTO) NONUSABLE
|
||||
#ifdef XWFEATURE_SEARCHLIMIT
|
||||
CHECKBOX "Disallow hints" ID XW_PREFS_NOHINTS_CHECKBOX_ID \
|
||||
AT (LEFTCOL PREVBOTTOM+PREFS_LNHT AUTO AUTO) NONUSABLE
|
||||
AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE
|
||||
CHECKBOX "Local hints" ID XW_PREFS_HINTRECT_CHECKBOX_ID \
|
||||
AT (PREVRIGHT+3 PREVTOP AUTO AUTO) NONUSABLE
|
||||
#else
|
||||
CHECKBOX "Disallow hints" ID XW_PREFS_NOHINTS_CHECKBOX_ID \
|
||||
AT (PREVRIGHT+3 PREVTOP AUTO AUTO) NONUSABLE
|
||||
AT (PREVRIGHT+3 PREFS_ROW1 AUTO AUTO) NONUSABLE
|
||||
#endif
|
||||
|
||||
LABEL "Phonies:" XW_PREFS_PHONIES_LABEL_ID
|
||||
AT (LEFTCOL PREVBOTTOM+PREFS_LNHT)
|
||||
AT (LEFTCOL PREVTOP+PREFS_SPACING)
|
||||
POPUPTRIGGER "" ID XW_PREFS_PHONIES_TRIGGER_ID
|
||||
AT (PREVRIGHT+5 PREVTOP 72 12) LEFTANCHOR
|
||||
|
||||
LABEL "Board size: " XW_PREFS_BDSIZE_LABEL_ID
|
||||
AT (LEFTCOL PREVBOTTOM+2)
|
||||
AT (LEFTCOL PREVTOP+PREFS_SPACING)
|
||||
SELECTORTRIGGER "" XW_PREFS_BDSIZE_SELECTOR_ID \
|
||||
AT (PREVRIGHT PREVTOP AUTO AUTO) USABLE LEFTANCHOR
|
||||
LIST "Ignore" "Warn" "Disallow" ID XW_PREFS_PHONIES_LIST_ID
|
||||
|
@ -416,13 +420,13 @@ BEGIN
|
|||
NONUSABLE VISIBLEITEMS NUM_BOARD_SIZES
|
||||
|
||||
CHECKBOX "Enable timer (minutes:)" ID XW_PREFS_TIMERON_CHECKBOX_ID \
|
||||
AT (LEFTCOL TIMER_TOP AUTO AUTO) NONUSABLE
|
||||
AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE
|
||||
FIELD XW_PREFS_TIMER_FIELD_ID PREVRIGHT+5 PREVTOP 15 AUTO UNDERLINED \
|
||||
EDITABLE SINGLELINE NUMERIC MAXCHARS 3
|
||||
|
||||
#ifdef FEATURE_TRAY_EDIT
|
||||
CHECKBOX "Pick tiles face-up" ID XW_PREFS_PICKTILES_CHECKBOX_ID \
|
||||
AT (LEFTCOL PREVBOTTOM AUTO AUTO) NONUSABLE
|
||||
AT (LEFTCOL PREVTOP+PREFS_SPACING AUTO AUTO) NONUSABLE
|
||||
#endif
|
||||
|
||||
/* buttons at the bottom */
|
||||
|
@ -443,6 +447,7 @@ NAVIGATIONMAP
|
|||
ROW XW_PREFS_SHOWGRID_CHECKBOX_ID
|
||||
ROW XW_PREFS_SHOWARROW_CHECKBOX_ID
|
||||
ROW XW_PREFS_ROBOTSCORE_CHECKBOX_ID
|
||||
ROW XW_PREFS_HIDETRAYVAL_CHECKBOX_ID
|
||||
|
||||
/* Per-game prefs */
|
||||
ROW XW_PREFS_ROBOTSMART_CHECKBOX_ID
|
||||
|
|
|
@ -89,7 +89,7 @@ newGameHandleEvent( EventPtr event )
|
|||
CurGameInfo* gi;
|
||||
PalmNewGameState* state;
|
||||
Int16 chosen;
|
||||
XP_U16 itemId;
|
||||
XP_S16 itemId;
|
||||
Boolean on;
|
||||
|
||||
CALLBACK_PROLOGUE();
|
||||
|
@ -153,10 +153,12 @@ newGameHandleEvent( EventPtr event )
|
|||
#ifdef XWFEATURE_FIVEWAY
|
||||
case keyDownEvent:
|
||||
itemId = getFocusOwner();
|
||||
result = tryRockerKey( event->data.keyDown.chr, itemId,
|
||||
XW_SOLO_GADGET_ID, XW_CLIENT_GADGET_ID );
|
||||
if ( result ) {
|
||||
changeGadgetHilite( globals, itemId );
|
||||
if ( itemId >= 0 ) {
|
||||
result = tryRockerKey( event->data.keyDown.chr, itemId,
|
||||
XW_SOLO_GADGET_ID, XW_CLIENT_GADGET_ID );
|
||||
if ( result ) {
|
||||
changeGadgetHilite( globals, itemId );
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
|
|
@ -392,11 +392,15 @@ drawOneGadget( UInt16 id, const char* text, Boolean hilite )
|
|||
} /* drawOneGadget */
|
||||
|
||||
#ifdef XWFEATURE_FIVEWAY
|
||||
XP_U16
|
||||
XP_S16
|
||||
getFocusOwner( void )
|
||||
{
|
||||
FormPtr form = FrmGetActiveForm();
|
||||
XP_U16 ownerID = FrmGetObjectId( form, FrmGetFocus( form ) );
|
||||
XP_S16 ownerID = -1;
|
||||
XP_S16 focus = FrmGetFocus( form );
|
||||
if ( focus >= 0 ) {
|
||||
ownerID = FrmGetObjectId( form, focus );
|
||||
}
|
||||
return ownerID;
|
||||
} /* getFocusOwner */
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ void drawGadgetsFromList( ListPtr list, XP_U16 idLow, XP_U16 idHigh,
|
|||
XP_Bool penInGadget( const EventType* event, UInt16* whichGadget );
|
||||
void drawOneGadget( UInt16 id, const char* text, Boolean hilite );
|
||||
# ifdef XWFEATURE_FIVEWAY
|
||||
XP_U16 getFocusOwner( void );
|
||||
XP_S16 getFocusOwner( void );
|
||||
void drawFocusRingOnGadget( XP_U16 idLow, XP_U16 idHigh );
|
||||
XP_Bool considerGadgetFocus( const EventType* event, XP_U16 idLow,
|
||||
XP_U16 idHigh );
|
||||
|
|
|
@ -44,7 +44,7 @@ PrefsFormHandleEvent( EventPtr event )
|
|||
FormPtr form;
|
||||
EventType eventToPost;
|
||||
Int16 chosen;
|
||||
XP_U16 selGadget;
|
||||
XP_S16 selGadget;
|
||||
|
||||
CALLBACK_PROLOGUE();
|
||||
globals = getFormRefcon();
|
||||
|
@ -86,14 +86,16 @@ PrefsFormHandleEvent( EventPtr event )
|
|||
#ifdef XWFEATURE_FIVEWAY
|
||||
case keyDownEvent:
|
||||
selGadget = getFocusOwner();
|
||||
if ( tryRockerKey( event->data.keyDown.chr, selGadget,
|
||||
XW_PREFS_ALLGAMES_GADGET_ID,
|
||||
XW_PREFS_ONEGAME_GADGET_ID ) ) {
|
||||
checkPrefsHiliteGadget( globals, selGadget );
|
||||
result = XP_TRUE;
|
||||
} else if ( !globals->isNewGame
|
||||
&& vchrRockerCenter == event->data.keyDown.chr ) {
|
||||
result = ignoredUnlessNewgame( selGadget );
|
||||
if ( selGadget >= 0 ) {
|
||||
if ( tryRockerKey( event->data.keyDown.chr, selGadget,
|
||||
XW_PREFS_ALLGAMES_GADGET_ID,
|
||||
XW_PREFS_ONEGAME_GADGET_ID ) ) {
|
||||
checkPrefsHiliteGadget( globals, selGadget );
|
||||
result = XP_TRUE;
|
||||
} else if ( !globals->isNewGame
|
||||
&& vchrRockerCenter == event->data.keyDown.chr ) {
|
||||
result = ignoredUnlessNewgame( selGadget );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -281,6 +283,9 @@ localPrefsToControls( PrefsDlgState* state )
|
|||
setBooleanCtrl( XW_PREFS_SHOWARROW_CHECKBOX_ID, state->cp.showBoardArrow );
|
||||
setBooleanCtrl( XW_PREFS_ROBOTSCORE_CHECKBOX_ID,
|
||||
state->cp.showRobotScores );
|
||||
setBooleanCtrl( XW_PREFS_HIDETRAYVAL_CHECKBOX_ID,
|
||||
state->cp.hideTileValues );
|
||||
|
||||
setBooleanCtrl( XW_PREFS_TIMERON_CHECKBOX_ID, state->timerEnabled );
|
||||
|
||||
#ifdef FEATURE_TRAY_EDIT
|
||||
|
@ -311,6 +316,9 @@ controlsToLocalPrefs( PrefsDlgState* state )
|
|||
getBooleanCtrl( XW_PREFS_SHOWARROW_CHECKBOX_ID );
|
||||
state->cp.showRobotScores =
|
||||
getBooleanCtrl( XW_PREFS_ROBOTSCORE_CHECKBOX_ID );
|
||||
state->cp.hideTileValues =
|
||||
getBooleanCtrl( XW_PREFS_HIDETRAYVAL_CHECKBOX_ID );
|
||||
|
||||
state->showProgress = getBooleanCtrl( XW_PREFS_PROGRESSBAR_CHECKBOX_ID );
|
||||
|
||||
/* trapping ctlEnterEvent should mean it can't have changed, so no need
|
||||
|
|
|
@ -266,6 +266,7 @@
|
|||
#define XW_PREFS_SHOWGRID_CHECKBOX_ID 2710
|
||||
#define XW_PREFS_SHOWARROW_CHECKBOX_ID 2711
|
||||
#define XW_PREFS_ROBOTSCORE_CHECKBOX_ID 2712
|
||||
#define XW_PREFS_HIDETRAYVAL_CHECKBOX_ID 2713
|
||||
|
||||
/* per-game */
|
||||
#define XW_PREFS_ROBOTSMART_CHECKBOX_ID 2715
|
||||
|
@ -295,7 +296,7 @@
|
|||
|
||||
/* These are used to set/clear the "pages" of the prefs dialog. */
|
||||
#define XW_PREFS_FIRST_GLOBAL_ID XW_PREFS_PLAYERCOLORS_CHECKBOX_ID
|
||||
#define XW_PREFS_LAST_GLOBAL_ID XW_PREFS_ROBOTSCORE_CHECKBOX_ID
|
||||
#define XW_PREFS_LAST_GLOBAL_ID XW_PREFS_HIDETRAYVAL_CHECKBOX_ID
|
||||
#define XW_PREFS_FIRST_PERGAME_ID XW_PREFS_ROBOTSMART_CHECKBOX_ID
|
||||
|
||||
#if defined XWFEATURE_SEARCHLIMIT
|
||||
|
|
Loading…
Reference in a new issue