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:
ehouse 2006-10-29 17:41:14 +00:00
parent e5e36f0fa4
commit 6b1fc7e5e4
10 changed files with 69 additions and 42 deletions

View file

@ -395,14 +395,17 @@ board_getScale( BoardCtxt* board, XP_U16* hScale, XP_U16* vScale )
XP_Bool XP_Bool
board_prefsChanged( BoardCtxt* board, CommonPrefs* cp ) board_prefsChanged( BoardCtxt* board, CommonPrefs* cp )
{ {
XP_Bool changed; XP_Bool showArrowChanged;
XP_Bool oldVal = board->disableArrow; XP_Bool hideValChanged;
showArrowChanged = cp->showBoardArrow == board->disableArrow;
hideValChanged = cp->hideTileValues != board->hideValsInTray;
board->disableArrow = !cp->showBoardArrow; board->disableArrow = !cp->showBoardArrow;
changed = oldVal != board->disableArrow; board->hideValsInTray = cp->hideTileValues;
if ( changed ) { if ( showArrowChanged ) {
changed = setArrowVisible( board, XP_FALSE ); showArrowChanged = setArrowVisible( board, XP_FALSE );
} }
#ifdef XWFEATURE_SEARCHLIMIT #ifdef XWFEATURE_SEARCHLIMIT
@ -419,7 +422,7 @@ board_prefsChanged( BoardCtxt* board, CommonPrefs* cp )
} }
#endif #endif
return changed; return showArrowChanged || hideValChanged;
} /* board_prefsChanged */ } /* board_prefsChanged */
XP_Bool XP_Bool

View file

@ -109,6 +109,7 @@ struct BoardCtxt {
XP_Bool badWordRejected; XP_Bool badWordRejected;
XP_Bool timerPending; XP_Bool timerPending;
XP_Bool disableArrow; XP_Bool disableArrow;
XP_Bool hideValsInTray;
XP_Bool tradeInProgress[MAX_NUM_PLAYERS]; XP_Bool tradeInProgress[MAX_NUM_PLAYERS];
XP_Bool eraseTray; XP_Bool eraseTray;

View file

@ -103,8 +103,8 @@ typedef enum {
typedef struct CommonPrefs { typedef struct CommonPrefs {
XP_Bool showBoardArrow; /* applies to all games */ XP_Bool showBoardArrow; /* applies to all games */
XP_Bool showRobotScores; /* applies to all games */ XP_Bool showRobotScores; /* applies to all games */
XP_Bool reserved1; /* get to 32-bit for ARM... */ XP_Bool hideTileValues;
XP_Bool reserved2; XP_Bool reserved2; /* get to 32-bit for ARM... */
} CommonPrefs; } CommonPrefs;
#ifdef XWFEATURE_BLUETOOTH #ifdef XWFEATURE_BLUETOOTH

View file

@ -154,8 +154,11 @@ drawTray( BoardCtxt* board, XP_Bool focussed )
dict_tilesToString( dictionary, &tile, 1, dict_tilesToString( dictionary, &tile, 1,
textP, sizeof(buf) ); 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, draw_drawTile( board->draw, &tileRect, textP,
bitmap, value, highlighted ); bitmap, value, highlighted );
} else { } else {

View file

@ -353,12 +353,14 @@ END /* XW_CONNS_FORM */
#endif #endif
#define PREFS_MODE_TOP 15 #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_TOP (52-TRAY_EDIT_ADJUST-SEARCHLIMIT_ADJUST) */
#define DLG_HEIGHT (112+TRAY_EDIT_ADJUST+SEARCHLIMIT_ADJUST) #define DLG_HEIGHT (112+TRAY_EDIT_ADJUST+SEARCHLIMIT_ADJUST)
#define DLG_TOP (160 - DLG_HEIGHT - 2) #define DLG_TOP (160 - DLG_HEIGHT - 2)
#define TIMER_TOP (74+SEARCHLIMIT_ADJUST) #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 #define PREFS_LNHT 4
FORM ID XW_PREFS_FORM AT (2 DLG_TOP 156 DLG_HEIGHT) FORM ID XW_PREFS_FORM AT (2 DLG_TOP 156 DLG_HEIGHT)
@ -375,36 +377,38 @@ BEGIN
/* global prefs */ /* global prefs */
CHECKBOX "Color played tiles" ID XW_PREFS_PLAYERCOLORS_CHECKBOX_ID \ 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 \ 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 \ 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 \ 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 \ 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 */ /* single-game prefs */
CHECKBOX "Smart robot" ID XW_PREFS_ROBOTSMART_CHECKBOX_ID \ 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 #ifdef XWFEATURE_SEARCHLIMIT
CHECKBOX "Disallow hints" ID XW_PREFS_NOHINTS_CHECKBOX_ID \ 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 \ CHECKBOX "Local hints" ID XW_PREFS_HINTRECT_CHECKBOX_ID \
AT (PREVRIGHT+3 PREVTOP AUTO AUTO) NONUSABLE AT (PREVRIGHT+3 PREVTOP AUTO AUTO) NONUSABLE
#else #else
CHECKBOX "Disallow hints" ID XW_PREFS_NOHINTS_CHECKBOX_ID \ 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 #endif
LABEL "Phonies:" XW_PREFS_PHONIES_LABEL_ID LABEL "Phonies:" XW_PREFS_PHONIES_LABEL_ID
AT (LEFTCOL PREVBOTTOM+PREFS_LNHT) AT (LEFTCOL PREVTOP+PREFS_SPACING)
POPUPTRIGGER "" ID XW_PREFS_PHONIES_TRIGGER_ID POPUPTRIGGER "" ID XW_PREFS_PHONIES_TRIGGER_ID
AT (PREVRIGHT+5 PREVTOP 72 12) LEFTANCHOR AT (PREVRIGHT+5 PREVTOP 72 12) LEFTANCHOR
LABEL "Board size: " XW_PREFS_BDSIZE_LABEL_ID LABEL "Board size: " XW_PREFS_BDSIZE_LABEL_ID
AT (LEFTCOL PREVBOTTOM+2) AT (LEFTCOL PREVTOP+PREFS_SPACING)
SELECTORTRIGGER "" XW_PREFS_BDSIZE_SELECTOR_ID \ SELECTORTRIGGER "" XW_PREFS_BDSIZE_SELECTOR_ID \
AT (PREVRIGHT PREVTOP AUTO AUTO) USABLE LEFTANCHOR AT (PREVRIGHT PREVTOP AUTO AUTO) USABLE LEFTANCHOR
LIST "Ignore" "Warn" "Disallow" ID XW_PREFS_PHONIES_LIST_ID LIST "Ignore" "Warn" "Disallow" ID XW_PREFS_PHONIES_LIST_ID
@ -416,13 +420,13 @@ BEGIN
NONUSABLE VISIBLEITEMS NUM_BOARD_SIZES NONUSABLE VISIBLEITEMS NUM_BOARD_SIZES
CHECKBOX "Enable timer (minutes:)" ID XW_PREFS_TIMERON_CHECKBOX_ID \ 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 \ FIELD XW_PREFS_TIMER_FIELD_ID PREVRIGHT+5 PREVTOP 15 AUTO UNDERLINED \
EDITABLE SINGLELINE NUMERIC MAXCHARS 3 EDITABLE SINGLELINE NUMERIC MAXCHARS 3
#ifdef FEATURE_TRAY_EDIT #ifdef FEATURE_TRAY_EDIT
CHECKBOX "Pick tiles face-up" ID XW_PREFS_PICKTILES_CHECKBOX_ID \ 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 #endif
/* buttons at the bottom */ /* buttons at the bottom */
@ -443,6 +447,7 @@ NAVIGATIONMAP
ROW XW_PREFS_SHOWGRID_CHECKBOX_ID ROW XW_PREFS_SHOWGRID_CHECKBOX_ID
ROW XW_PREFS_SHOWARROW_CHECKBOX_ID ROW XW_PREFS_SHOWARROW_CHECKBOX_ID
ROW XW_PREFS_ROBOTSCORE_CHECKBOX_ID ROW XW_PREFS_ROBOTSCORE_CHECKBOX_ID
ROW XW_PREFS_HIDETRAYVAL_CHECKBOX_ID
/* Per-game prefs */ /* Per-game prefs */
ROW XW_PREFS_ROBOTSMART_CHECKBOX_ID ROW XW_PREFS_ROBOTSMART_CHECKBOX_ID

View file

@ -89,7 +89,7 @@ newGameHandleEvent( EventPtr event )
CurGameInfo* gi; CurGameInfo* gi;
PalmNewGameState* state; PalmNewGameState* state;
Int16 chosen; Int16 chosen;
XP_U16 itemId; XP_S16 itemId;
Boolean on; Boolean on;
CALLBACK_PROLOGUE(); CALLBACK_PROLOGUE();
@ -153,10 +153,12 @@ newGameHandleEvent( EventPtr event )
#ifdef XWFEATURE_FIVEWAY #ifdef XWFEATURE_FIVEWAY
case keyDownEvent: case keyDownEvent:
itemId = getFocusOwner(); itemId = getFocusOwner();
result = tryRockerKey( event->data.keyDown.chr, itemId, if ( itemId >= 0 ) {
XW_SOLO_GADGET_ID, XW_CLIENT_GADGET_ID ); result = tryRockerKey( event->data.keyDown.chr, itemId,
if ( result ) { XW_SOLO_GADGET_ID, XW_CLIENT_GADGET_ID );
changeGadgetHilite( globals, itemId ); if ( result ) {
changeGadgetHilite( globals, itemId );
}
} }
break; break;
#endif #endif

View file

@ -392,11 +392,15 @@ drawOneGadget( UInt16 id, const char* text, Boolean hilite )
} /* drawOneGadget */ } /* drawOneGadget */
#ifdef XWFEATURE_FIVEWAY #ifdef XWFEATURE_FIVEWAY
XP_U16 XP_S16
getFocusOwner( void ) getFocusOwner( void )
{ {
FormPtr form = FrmGetActiveForm(); 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; return ownerID;
} /* getFocusOwner */ } /* getFocusOwner */

View file

@ -76,7 +76,7 @@ void drawGadgetsFromList( ListPtr list, XP_U16 idLow, XP_U16 idHigh,
XP_Bool penInGadget( const EventType* event, UInt16* whichGadget ); XP_Bool penInGadget( const EventType* event, UInt16* whichGadget );
void drawOneGadget( UInt16 id, const char* text, Boolean hilite ); void drawOneGadget( UInt16 id, const char* text, Boolean hilite );
# ifdef XWFEATURE_FIVEWAY # ifdef XWFEATURE_FIVEWAY
XP_U16 getFocusOwner( void ); XP_S16 getFocusOwner( void );
void drawFocusRingOnGadget( XP_U16 idLow, XP_U16 idHigh ); void drawFocusRingOnGadget( XP_U16 idLow, XP_U16 idHigh );
XP_Bool considerGadgetFocus( const EventType* event, XP_U16 idLow, XP_Bool considerGadgetFocus( const EventType* event, XP_U16 idLow,
XP_U16 idHigh ); XP_U16 idHigh );

View file

@ -44,7 +44,7 @@ PrefsFormHandleEvent( EventPtr event )
FormPtr form; FormPtr form;
EventType eventToPost; EventType eventToPost;
Int16 chosen; Int16 chosen;
XP_U16 selGadget; XP_S16 selGadget;
CALLBACK_PROLOGUE(); CALLBACK_PROLOGUE();
globals = getFormRefcon(); globals = getFormRefcon();
@ -86,14 +86,16 @@ PrefsFormHandleEvent( EventPtr event )
#ifdef XWFEATURE_FIVEWAY #ifdef XWFEATURE_FIVEWAY
case keyDownEvent: case keyDownEvent:
selGadget = getFocusOwner(); selGadget = getFocusOwner();
if ( tryRockerKey( event->data.keyDown.chr, selGadget, if ( selGadget >= 0 ) {
XW_PREFS_ALLGAMES_GADGET_ID, if ( tryRockerKey( event->data.keyDown.chr, selGadget,
XW_PREFS_ONEGAME_GADGET_ID ) ) { XW_PREFS_ALLGAMES_GADGET_ID,
checkPrefsHiliteGadget( globals, selGadget ); XW_PREFS_ONEGAME_GADGET_ID ) ) {
result = XP_TRUE; checkPrefsHiliteGadget( globals, selGadget );
} else if ( !globals->isNewGame result = XP_TRUE;
&& vchrRockerCenter == event->data.keyDown.chr ) { } else if ( !globals->isNewGame
result = ignoredUnlessNewgame( selGadget ); && vchrRockerCenter == event->data.keyDown.chr ) {
result = ignoredUnlessNewgame( selGadget );
}
} }
break; break;
@ -281,6 +283,9 @@ localPrefsToControls( PrefsDlgState* state )
setBooleanCtrl( XW_PREFS_SHOWARROW_CHECKBOX_ID, state->cp.showBoardArrow ); setBooleanCtrl( XW_PREFS_SHOWARROW_CHECKBOX_ID, state->cp.showBoardArrow );
setBooleanCtrl( XW_PREFS_ROBOTSCORE_CHECKBOX_ID, setBooleanCtrl( XW_PREFS_ROBOTSCORE_CHECKBOX_ID,
state->cp.showRobotScores ); state->cp.showRobotScores );
setBooleanCtrl( XW_PREFS_HIDETRAYVAL_CHECKBOX_ID,
state->cp.hideTileValues );
setBooleanCtrl( XW_PREFS_TIMERON_CHECKBOX_ID, state->timerEnabled ); setBooleanCtrl( XW_PREFS_TIMERON_CHECKBOX_ID, state->timerEnabled );
#ifdef FEATURE_TRAY_EDIT #ifdef FEATURE_TRAY_EDIT
@ -311,6 +316,9 @@ controlsToLocalPrefs( PrefsDlgState* state )
getBooleanCtrl( XW_PREFS_SHOWARROW_CHECKBOX_ID ); getBooleanCtrl( XW_PREFS_SHOWARROW_CHECKBOX_ID );
state->cp.showRobotScores = state->cp.showRobotScores =
getBooleanCtrl( XW_PREFS_ROBOTSCORE_CHECKBOX_ID ); getBooleanCtrl( XW_PREFS_ROBOTSCORE_CHECKBOX_ID );
state->cp.hideTileValues =
getBooleanCtrl( XW_PREFS_HIDETRAYVAL_CHECKBOX_ID );
state->showProgress = getBooleanCtrl( XW_PREFS_PROGRESSBAR_CHECKBOX_ID ); state->showProgress = getBooleanCtrl( XW_PREFS_PROGRESSBAR_CHECKBOX_ID );
/* trapping ctlEnterEvent should mean it can't have changed, so no need /* trapping ctlEnterEvent should mean it can't have changed, so no need

View file

@ -266,6 +266,7 @@
#define XW_PREFS_SHOWGRID_CHECKBOX_ID 2710 #define XW_PREFS_SHOWGRID_CHECKBOX_ID 2710
#define XW_PREFS_SHOWARROW_CHECKBOX_ID 2711 #define XW_PREFS_SHOWARROW_CHECKBOX_ID 2711
#define XW_PREFS_ROBOTSCORE_CHECKBOX_ID 2712 #define XW_PREFS_ROBOTSCORE_CHECKBOX_ID 2712
#define XW_PREFS_HIDETRAYVAL_CHECKBOX_ID 2713
/* per-game */ /* per-game */
#define XW_PREFS_ROBOTSMART_CHECKBOX_ID 2715 #define XW_PREFS_ROBOTSMART_CHECKBOX_ID 2715
@ -295,7 +296,7 @@
/* These are used to set/clear the "pages" of the prefs dialog. */ /* 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_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 #define XW_PREFS_FIRST_PERGAME_ID XW_PREFS_ROBOTSMART_CHECKBOX_ID
#if defined XWFEATURE_SEARCHLIMIT #if defined XWFEATURE_SEARCHLIMIT