show current tray in pick dialog; begin work of letting user specify

how many tiles to use in hint.
This commit is contained in:
ehouse 2003-11-30 18:57:57 +00:00
parent 3475c93952
commit 41801ea74e

View file

@ -114,7 +114,7 @@ static Boolean applicationHandleEvent( PalmAppGlobals* globals,
static Boolean mainViewHandleEvent( EventPtr event ); static Boolean mainViewHandleEvent( EventPtr event );
static UInt16 romVersion( void ); static UInt16 romVersion( void );
static Boolean handleHintRequest( PalmAppGlobals* globals ); static Boolean handleHintRequest( PalmAppGlobals* globals, XP_Bool askNTiles );
/* callbacks */ /* callbacks */
static VTableMgr* palm_util_getVTManager( XW_UtilCtxt* uc ); static VTableMgr* palm_util_getVTManager( XW_UtilCtxt* uc );
@ -1304,7 +1304,7 @@ handleNilEvent( PalmAppGlobals* globals, EventPtr event )
# endif # endif
#endif #endif
} else if ( globals->hintPending ) { } else if ( globals->hintPending ) {
handled = handleHintRequest( globals ); handled = handleHintRequest( globals, XP_FALSE );
} else if ( globals->penTimerFireAt != TIMER_OFF && } else if ( globals->penTimerFireAt != TIMER_OFF &&
globals->penTimerFireAt <= TimGetTicks() ) { globals->penTimerFireAt <= TimGetTicks() ) {
@ -1359,12 +1359,21 @@ handleHideTray( PalmAppGlobals* globals )
} /* handleHideTray */ } /* handleHideTray */
static Boolean static Boolean
handleHintRequest( PalmAppGlobals* globals ) handleHintRequest( PalmAppGlobals* globals, XP_Bool askNTiles )
{ {
Boolean notDone; Boolean notDone;
Boolean draw; Boolean draw;
XP_U16 nTiles;
XP_ASSERT( !!globals->game.board ); XP_ASSERT( !!globals->game.board );
draw = board_requestHint( globals->game.board, &notDone );
if ( askNTiles ) {
nTiles = 3;
} else {
nTiles = MAX_TRAY_TILES;
}
draw = board_requestHint( globals->game.board, nTiles, &notDone );
globals->hintPending = notDone; globals->hintPending = notDone;
return draw; return draw;
} /* handleHintRequest */ } /* handleHintRequest */
@ -1426,6 +1435,7 @@ drawFormButtons( PalmAppGlobals* globals )
XW_MAIN_FLIP_BUTTON_ID, FLIP_BUTTON_BMP_RES_ID, XP_TRUE, XW_MAIN_FLIP_BUTTON_ID, FLIP_BUTTON_BMP_RES_ID, XP_TRUE,
XW_MAIN_VALUE_BUTTON_ID, VALUE_BUTTON_BMP_RES_ID, XP_TRUE, XW_MAIN_VALUE_BUTTON_ID, VALUE_BUTTON_BMP_RES_ID, XP_TRUE,
XW_MAIN_HINT_BUTTON_ID, HINT_BUTTON_BMP_RES_ID, XP_TRUE, XW_MAIN_HINT_BUTTON_ID, HINT_BUTTON_BMP_RES_ID, XP_TRUE,
XW_MAIN_NHINT_BUTTON_ID, NHINT_BUTTON_BMP_RES_ID, XP_TRUE,
#ifndef EIGHT_TILES #ifndef EIGHT_TILES
XW_MAIN_HIDE_BUTTON_ID, TRAY_BUTTONS_BMP_RES_ID, XP_TRUE, XW_MAIN_HIDE_BUTTON_ID, TRAY_BUTTONS_BMP_RES_ID, XP_TRUE,
#endif #endif
@ -1476,6 +1486,9 @@ palmSetCtrlsForTray( PalmAppGlobals* globals )
disOrEnable( form, XW_MAIN_HINT_BUTTON_ID, disOrEnable( form, XW_MAIN_HINT_BUTTON_ID,
(state==TRAY_REVEALED) && (state==TRAY_REVEALED) &&
!globals->gameInfo.hintsNotAllowed ); !globals->gameInfo.hintsNotAllowed );
disOrEnable( form, XW_MAIN_NHINT_BUTTON_ID,
(state==TRAY_REVEALED) &&
!globals->gameInfo.hintsNotAllowed );
#ifndef EIGHT_TILES #ifndef EIGHT_TILES
disOrEnable( form, XW_MAIN_DONE_BUTTON_ID, state==TRAY_REVEALED ); disOrEnable( form, XW_MAIN_DONE_BUTTON_ID, state==TRAY_REVEALED );
@ -1608,6 +1621,7 @@ updateForLefty( PalmAppGlobals* globals, FormPtr form )
XW_MAIN_FLIP_BUTTON_ID, 0, XW_MAIN_FLIP_BUTTON_ID, 0,
XW_MAIN_VALUE_BUTTON_ID, 0, XW_MAIN_VALUE_BUTTON_ID, 0,
XW_MAIN_HINT_BUTTON_ID, 0, XW_MAIN_HINT_BUTTON_ID, 0,
XW_MAIN_NHINT_BUTTON_ID, 0,
XW_MAIN_SCROLLBAR_ID, 0, XW_MAIN_SCROLLBAR_ID, 0,
XW_MAIN_SHOWTRAY_BUTTON_ID, 0, XW_MAIN_SHOWTRAY_BUTTON_ID, 0,
@ -1985,7 +1999,7 @@ mainViewHandleEvent( EventPtr event )
case XW_HINT_PULLDOWN_ID: case XW_HINT_PULLDOWN_ID:
board_resetEngine( globals->game.board ); board_resetEngine( globals->game.board );
case XW_NEXTHINT_PULLDOWN_ID: case XW_NEXTHINT_PULLDOWN_ID:
draw = handleHintRequest( globals ); draw = handleHintRequest( globals, XP_FALSE );
break; break;
case XW_UNDOCUR_PULLDOWN_ID: case XW_UNDOCUR_PULLDOWN_ID:
@ -2136,7 +2150,10 @@ mainViewHandleEvent( EventPtr event )
draw = handleValueToggle( globals ); draw = handleValueToggle( globals );
break; break;
case XW_MAIN_HINT_BUTTON_ID: case XW_MAIN_HINT_BUTTON_ID:
draw = handleHintRequest( globals ); draw = handleHintRequest( globals, XP_FALSE );
break;
case XW_MAIN_NHINT_BUTTON_ID:
draw = handleHintRequest( globals, XP_TRUE );
break; break;
#ifndef EIGHT_TILES #ifndef EIGHT_TILES
case XW_MAIN_DONE_BUTTON_ID: case XW_MAIN_DONE_BUTTON_ID:
@ -2648,7 +2665,6 @@ askBlankValue( PalmAppGlobals* globals, XP_U16 playerNum, PickInfo* pi,
LstSetSelection( lettersList, 0 ); LstSetSelection( lettersList, 0 );
fld = getActiveObjectPtr( XW_BLANK_LABEL_FIELD_ID );
name = globals->gameInfo.players[playerNum].name; name = globals->gameInfo.players[playerNum].name;
labelFmt = getResString( globals, labelFmt = getResString( globals,
#ifdef FEATURE_TRAY_EDIT #ifdef FEATURE_TRAY_EDIT
@ -2659,12 +2675,21 @@ askBlankValue( PalmAppGlobals* globals, XP_U16 playerNum, PickInfo* pi,
#ifdef FEATURE_TRAY_EDIT #ifdef FEATURE_TRAY_EDIT
if ( !forBlank ) { if ( !forBlank ) {
XP_U16 lenSoFar = XP_STRLEN(labelBuf); XP_U16 lenSoFar;
XP_SNPRINTF( labelBuf + lenSoFar, sizeof(labelBuf) - lenSoFar, XP_U16 i;
" (%d/%d)", pi->thisPick, pi->nTotal );
lenSoFar = XP_STRLEN(labelBuf);
lenSoFar += XP_SNPRINTF( labelBuf + lenSoFar, sizeof(labelBuf) - lenSoFar,
" (%d/%d)\nCur", pi->thisPick, pi->nTotal );
for ( i = 0; i < pi->nCurTiles; ++i ) {
lenSoFar += XP_SNPRINTF( labelBuf+lenSoFar, sizeof(labelBuf)-lenSoFar, "%s%s",
i==0?": ":", ", pi->curTiles[i] );
}
} }
#endif #endif
fld = getActiveObjectPtr( XW_BLANK_LABEL_FIELD_ID );
FldSetTextPtr( fld, labelBuf ); FldSetTextPtr( fld, labelBuf );
FldRecalculateField( fld, false ); FldRecalculateField( fld, false );