mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
change signature to fit API changes (but don't use new params yet);
add new strings; fix formatting.
This commit is contained in:
parent
7dbcdf4ca5
commit
810c3475be
1 changed files with 282 additions and 267 deletions
|
@ -89,8 +89,8 @@ CMenuBar MainMenuBar( MENUBAR_WINDOW_ID, 23 );
|
|||
static VTableMgr* frank_util_getVTManager( XW_UtilCtxt* uc );
|
||||
static DictionaryCtxt* frank_util_makeEmptyDict( XW_UtilCtxt* uc );
|
||||
static void frank_util_userError( XW_UtilCtxt* uc, UtilErrID id );
|
||||
static XP_U16 frank_util_userQuery( XW_UtilCtxt* uc, UtilQueryID id,
|
||||
XWStreamCtxt* stream );
|
||||
static XP_Bool frank_util_userQuery( XW_UtilCtxt* uc, UtilQueryID id,
|
||||
XWStreamCtxt* stream );
|
||||
static XP_S16 frank_util_userPickTile( XW_UtilCtxt* uc, PickInfo* pi,
|
||||
XP_U16 playerNum,
|
||||
XP_UCHAR4* texts, XP_U16 nTiles );
|
||||
|
@ -150,6 +150,7 @@ class CXWordsWindow : public CWindow {
|
|||
BOOL drawInProgress;
|
||||
BOOL userEventPending;
|
||||
XP_Bool fRobotHalted;
|
||||
XP_Bool fAskTrayLimits;
|
||||
|
||||
public:
|
||||
CXWordsWindow( MPFORMAL FrankDictList* dlist );
|
||||
|
@ -283,6 +284,8 @@ CXWordsWindow::CXWordsWindow(MPFORMAL FrankDictList* dlist )
|
|||
fGame.server = (ServerCtxt*)NULL;
|
||||
fGame.board = (BoardCtxt*)NULL;
|
||||
|
||||
fAskTrayLimits = XP_FALSE;
|
||||
|
||||
gi_initPlayerInfo( MEMPOOL(this) &fGameInfo, (XP_UCHAR*)"Player %d" );
|
||||
|
||||
U16 nRecords = gamesDB->countRecords();
|
||||
|
@ -314,10 +317,10 @@ XWStreamCtxt*
|
|||
CXWordsWindow::makeMemStream()
|
||||
{
|
||||
XWStreamCtxt* stream = mem_stream_make( MEMPOOL(this)
|
||||
fVTableMgr,
|
||||
this,
|
||||
CHANNEL_NONE,
|
||||
(MemStreamCloseCallback)NULL );
|
||||
fVTableMgr,
|
||||
this,
|
||||
CHANNEL_NONE,
|
||||
(MemStreamCloseCallback)NULL );
|
||||
return stream;
|
||||
} /* makeMemStream */
|
||||
|
||||
|
@ -340,21 +343,21 @@ void
|
|||
CXWordsWindow::positionBoard()
|
||||
{
|
||||
board_setPos( fGame.board, BOARD_LEFT, BOARD_TOP,
|
||||
XP_FALSE );
|
||||
XP_FALSE );
|
||||
board_setScale( fGame.board, BOARD_SCALE, BOARD_SCALE );
|
||||
|
||||
board_setScoreboardLoc( fGame.board, SCORE_LEFT, SCORE_TOP,
|
||||
this->GetWidth()-SCORE_LEFT-TIMER_WIDTH,
|
||||
SCORE_HEIGHT, XP_TRUE );
|
||||
this->GetWidth()-SCORE_LEFT-TIMER_WIDTH,
|
||||
SCORE_HEIGHT, XP_TRUE );
|
||||
|
||||
U16 trayTop = BOARD_TOP + (BOARD_SCALE * 15) + 2;
|
||||
board_setTrayLoc( fGame.board, TRAY_LEFT, trayTop,
|
||||
MIN_TRAY_SCALE, MIN_TRAY_SCALE,
|
||||
FRANK_DIVIDER_WIDTH );
|
||||
MIN_TRAY_SCALE, MIN_TRAY_SCALE,
|
||||
FRANK_DIVIDER_WIDTH );
|
||||
|
||||
board_setTimerLoc( fGame.board,
|
||||
this->GetWidth() - TIMER_WIDTH,
|
||||
SCORE_TOP, TIMER_WIDTH, TIMER_HEIGHT );
|
||||
this->GetWidth() - TIMER_WIDTH,
|
||||
SCORE_TOP, TIMER_WIDTH, TIMER_HEIGHT );
|
||||
} /* positionBoard */
|
||||
|
||||
void
|
||||
|
@ -388,7 +391,7 @@ CXWordsWindow::addButtonAtBitmap( short id, short x, short y, const char* c,
|
|||
IMAGE* img )
|
||||
{
|
||||
CButton* button = new CButton( id, 0, 0, (const char*)NULL,
|
||||
img, (IMAGE*)NULL, (IMAGE*)NULL );
|
||||
img, (IMAGE*)NULL, (IMAGE*)NULL );
|
||||
this->AddChild( button, x+1, y );
|
||||
|
||||
return button;
|
||||
|
@ -444,12 +447,12 @@ CXWordsWindow::~CXWordsWindow()
|
|||
void CXWordsWindow::Draw()
|
||||
{
|
||||
if ( !this->drawInProgress ) {
|
||||
this->drawInProgress = TRUE;
|
||||
// don't call CWindow::Draw(); It erases the entire board
|
||||
board_draw( fGame.board );
|
||||
this->drawInProgress = TRUE;
|
||||
// don't call CWindow::Draw(); It erases the entire board
|
||||
board_draw( fGame.board );
|
||||
|
||||
this->DrawChildren();
|
||||
this->drawInProgress = FALSE;
|
||||
this->DrawChildren();
|
||||
this->drawInProgress = FALSE;
|
||||
}
|
||||
} // CXWordsWindow::Draw
|
||||
|
||||
|
@ -461,6 +464,7 @@ CXWordsWindow::MsgHandler( MSG_TYPE type, CViewable *from, S32 data )
|
|||
S16 drag_x;
|
||||
S16 drag_y;
|
||||
XWTimerReason reason;
|
||||
XP_Bool handled;
|
||||
|
||||
drag_x = (S16) (data >> 16);
|
||||
drag_y = (S16) data;
|
||||
|
@ -469,154 +473,154 @@ CXWordsWindow::MsgHandler( MSG_TYPE type, CViewable *from, S32 data )
|
|||
switch (type) {
|
||||
|
||||
case MSG_USER:
|
||||
switch ( data ) {
|
||||
case HINT_REQUEST:
|
||||
doHint( XP_FALSE ); /* will reset if fails */
|
||||
break;
|
||||
case SERVER_TIME_REQUEST:
|
||||
this->clearUserEventPending(); /* clear before calling server! */
|
||||
if ( server_do( fGame.server ) ) {
|
||||
GUI_NeedUpdate();
|
||||
}
|
||||
break;
|
||||
case NEWGAME_REQUEST:
|
||||
this->newGame( XP_FALSE );
|
||||
break;
|
||||
case FINALSCORE_REQUEST:
|
||||
this->displayFinalScores();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
switch ( data ) {
|
||||
case HINT_REQUEST:
|
||||
doHint( XP_FALSE ); /* will reset if fails */
|
||||
break;
|
||||
case SERVER_TIME_REQUEST:
|
||||
this->clearUserEventPending(); /* clear before calling server! */
|
||||
if ( server_do( fGame.server ) ) {
|
||||
GUI_NeedUpdate();
|
||||
}
|
||||
break;
|
||||
case NEWGAME_REQUEST:
|
||||
this->newGame( XP_FALSE );
|
||||
break;
|
||||
case FINALSCORE_REQUEST:
|
||||
this->displayFinalScores();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case MSG_PEN_DOWN:
|
||||
this->penDown = TRUE;
|
||||
if ( board_handlePenDown( fGame.board, drag_x, drag_y, 0 ) ) {
|
||||
GUI_NeedUpdate();
|
||||
result = 1;
|
||||
}
|
||||
board_pushTimerSave( fGame.board );
|
||||
break;
|
||||
this->penDown = TRUE;
|
||||
if ( board_handlePenDown( fGame.board, drag_x, drag_y, 0, &handled ) ) {
|
||||
GUI_NeedUpdate();
|
||||
result = 1;
|
||||
}
|
||||
board_pushTimerSave( fGame.board );
|
||||
break;
|
||||
|
||||
case MSG_PEN_TRACK:
|
||||
if ( this->penDown ) {
|
||||
if ( board_handlePenMove( fGame.board, drag_x, drag_y ) ) {
|
||||
GUI_NeedUpdate();
|
||||
result = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
if ( this->penDown ) {
|
||||
if ( board_handlePenMove( fGame.board, drag_x, drag_y ) ) {
|
||||
GUI_NeedUpdate();
|
||||
result = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MSG_PEN_UP:
|
||||
if ( this->penDown ) {
|
||||
board_popTimerSave( fGame.board );
|
||||
if ( board_handlePenUp( fGame.board, drag_x, drag_y, 0 ) ) {
|
||||
GUI_NeedUpdate();
|
||||
result = 1;
|
||||
}
|
||||
this->penDown = FALSE;
|
||||
}
|
||||
break;
|
||||
if ( this->penDown ) {
|
||||
board_popTimerSave( fGame.board );
|
||||
if ( board_handlePenUp( fGame.board, drag_x, drag_y, 0 ) ) {
|
||||
GUI_NeedUpdate();
|
||||
result = 1;
|
||||
}
|
||||
this->penDown = FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case MSG_TIMER:
|
||||
reason = this->fTimers[TIMER_PENDOWN]?
|
||||
TIMER_PENDOWN:TIMER_TIMERTICK;
|
||||
fTimers[reason] = XP_FALSE; /* clear now; board may set it again */
|
||||
board_timerFired( fGame.board, reason );
|
||||
setTimerIfNeeded();
|
||||
GUI_NeedUpdate(); /* Needed off-emulator? PENDING */
|
||||
break;
|
||||
reason = this->fTimers[TIMER_PENDOWN]?
|
||||
TIMER_PENDOWN:TIMER_TIMERTICK;
|
||||
fTimers[reason] = XP_FALSE; /* clear now; board may set it again */
|
||||
board_timerFired( fGame.board, reason );
|
||||
setTimerIfNeeded();
|
||||
GUI_NeedUpdate(); /* Needed off-emulator? PENDING */
|
||||
break;
|
||||
|
||||
case MSG_BUTTON_SELECT:
|
||||
result = 1;
|
||||
switch (from->GetID()) {
|
||||
case MAIN_FLIP_BUTTON_ID:
|
||||
if ( board_flip( fGame.board ) ) {
|
||||
GUI_NeedUpdate();
|
||||
}
|
||||
break;
|
||||
result = 1;
|
||||
switch (from->GetID()) {
|
||||
case MAIN_FLIP_BUTTON_ID:
|
||||
if ( board_flip( fGame.board ) ) {
|
||||
GUI_NeedUpdate();
|
||||
}
|
||||
break;
|
||||
|
||||
case MAIN_VALUE_BUTTON_ID:
|
||||
if ( board_toggle_showValues( fGame.board ) ) {
|
||||
GUI_NeedUpdate();
|
||||
}
|
||||
break;
|
||||
case MAIN_VALUE_BUTTON_ID:
|
||||
if ( board_toggle_showValues( fGame.board ) ) {
|
||||
GUI_NeedUpdate();
|
||||
}
|
||||
break;
|
||||
|
||||
case MAIN_HINT_BUTTON_ID:
|
||||
this->doHint( XP_FALSE );
|
||||
break;
|
||||
case MAIN_HINT_BUTTON_ID:
|
||||
this->doHint( XP_FALSE );
|
||||
break;
|
||||
|
||||
case MAIN_UNDO_BUTTON_ID:
|
||||
this->doUndo();
|
||||
break;
|
||||
case MAIN_UNDO_BUTTON_ID:
|
||||
this->doUndo();
|
||||
break;
|
||||
|
||||
case MAIN_COMMIT_BUTTON_ID:
|
||||
this->doCommit();
|
||||
break;
|
||||
case MAIN_COMMIT_BUTTON_ID:
|
||||
this->doCommit();
|
||||
break;
|
||||
|
||||
case MAIN_TRADE_BUTTON_ID:
|
||||
if ( board_beginTrade( fGame.board ) ) {
|
||||
GUI_NeedUpdate();
|
||||
}
|
||||
break;
|
||||
case MAIN_TRADE_BUTTON_ID:
|
||||
if ( board_beginTrade( fGame.board ) ) {
|
||||
GUI_NeedUpdate();
|
||||
}
|
||||
break;
|
||||
|
||||
case MAIN_JUGGLE_BUTTON_ID:
|
||||
if ( board_juggleTray( fGame.board ) ) {
|
||||
GUI_NeedUpdate();
|
||||
}
|
||||
break;
|
||||
case MAIN_HIDE_BUTTON_ID:
|
||||
this->doHideTray();
|
||||
break;
|
||||
default:
|
||||
result = 0;
|
||||
}
|
||||
break;
|
||||
case MAIN_JUGGLE_BUTTON_ID:
|
||||
if ( board_juggleTray( fGame.board ) ) {
|
||||
GUI_NeedUpdate();
|
||||
}
|
||||
break;
|
||||
case MAIN_HIDE_BUTTON_ID:
|
||||
this->doHideTray();
|
||||
break;
|
||||
default:
|
||||
result = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case MSG_KEY:
|
||||
xpkey = XP_KEY_NONE;
|
||||
switch( data ) {
|
||||
xpkey = XP_KEY_NONE;
|
||||
switch( data ) {
|
||||
|
||||
case K_JOG_ENTER:
|
||||
xpkey = XP_RETURN_KEY;
|
||||
break;
|
||||
case K_JOG_ENTER:
|
||||
xpkey = XP_RETURN_KEY;
|
||||
break;
|
||||
|
||||
case K_JOG_DOWN:
|
||||
xpkey = XP_CURSOR_KEY_RIGHT;
|
||||
break;
|
||||
case K_JOG_DOWN:
|
||||
xpkey = XP_CURSOR_KEY_RIGHT;
|
||||
break;
|
||||
|
||||
case K_JOG_UP:
|
||||
xpkey = XP_CURSOR_KEY_LEFT;
|
||||
break;
|
||||
case K_JOG_UP:
|
||||
xpkey = XP_CURSOR_KEY_LEFT;
|
||||
break;
|
||||
|
||||
case K_DELETE:
|
||||
case K_BACKSPACE:
|
||||
xpkey = XP_CURSOR_KEY_DEL;
|
||||
break;
|
||||
case K_DELETE:
|
||||
case K_BACKSPACE:
|
||||
xpkey = XP_CURSOR_KEY_DEL;
|
||||
break;
|
||||
|
||||
default:
|
||||
if ( isalpha( data ) ) {
|
||||
xpkey = (XP_Key)toupper(data);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ( isalpha( data ) ) {
|
||||
xpkey = (XP_Key)toupper(data);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( xpkey != XP_KEY_NONE ) {
|
||||
if ( board_handleKey( fGame.board, xpkey ) ) {
|
||||
GUI_NeedUpdate();
|
||||
result = 1;
|
||||
}
|
||||
}
|
||||
if ( xpkey != XP_KEY_NONE ) {
|
||||
if ( board_handleKey( fGame.board, xpkey ) ) {
|
||||
GUI_NeedUpdate();
|
||||
result = 1;
|
||||
}
|
||||
}
|
||||
|
||||
break; /* MSG_KEY */
|
||||
break; /* MSG_KEY */
|
||||
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
GUI_EnableTimers();
|
||||
|
||||
if ( result == 0 ) {
|
||||
result = CWindow::MsgHandler( type, from, data );
|
||||
result = CWindow::MsgHandler( type, from, data );
|
||||
}
|
||||
return result;
|
||||
} // CXWordsWindow::MsgHandler
|
||||
|
@ -626,13 +630,13 @@ CXWordsWindow::setTimerIfNeeded()
|
|||
{
|
||||
U32 mSeconds;
|
||||
if ( fTimers[TIMER_PENDOWN] ) { /* faster, so higher priority */
|
||||
mSeconds = (U32)450;
|
||||
XP_DEBUGF( "setting timer %d", TIMER_PENDOWN );
|
||||
mSeconds = (U32)450;
|
||||
XP_DEBUGF( "setting timer %d", TIMER_PENDOWN );
|
||||
} else if ( fTimers[TIMER_TIMERTICK] ) {
|
||||
mSeconds = (U32)1000;
|
||||
XP_DEBUGF( "setting timer %d", TIMER_TIMERTICK );
|
||||
mSeconds = (U32)1000;
|
||||
XP_DEBUGF( "setting timer %d", TIMER_TIMERTICK );
|
||||
} else {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
SetTimer( mSeconds, XP_FALSE, 0L );
|
||||
|
@ -643,9 +647,9 @@ CXWordsWindow::disOrEnableFrank( U16 id, XP_Bool enable )
|
|||
{
|
||||
CButton* button = (CButton*)GetChildID( id );
|
||||
if ( enable ) {
|
||||
button->Enable();
|
||||
button->Enable();
|
||||
} else {
|
||||
button->Disable();
|
||||
button->Disable();
|
||||
}
|
||||
} /* disOrEnableFrank */
|
||||
|
||||
|
@ -668,10 +672,10 @@ CXWordsWindow::startProgressBar()
|
|||
{
|
||||
if ( fState.showProgress ) {
|
||||
|
||||
DrawRectFilled( &fProgressRect, COLOR_WHITE );
|
||||
DrawRect( &fProgressRect, COLOR_BLACK );
|
||||
DrawRectFilled( &fProgressRect, COLOR_WHITE );
|
||||
DrawRect( &fProgressRect, COLOR_BLACK );
|
||||
|
||||
fProgressCurLine = 0;
|
||||
fProgressCurLine = 0;
|
||||
}
|
||||
} /* startProgressBar */
|
||||
|
||||
|
@ -679,7 +683,7 @@ void
|
|||
CXWordsWindow::finishProgressBar()
|
||||
{
|
||||
if ( fState.showProgress ) {
|
||||
DrawRectFilled( &fProgressRect, COLOR_WHITE );
|
||||
DrawRectFilled( &fProgressRect, COLOR_WHITE );
|
||||
}
|
||||
} /* finishProgressBar */
|
||||
|
||||
|
@ -687,27 +691,27 @@ void
|
|||
CXWordsWindow::advanceProgressBar()
|
||||
{
|
||||
if ( fState.showProgress ) {
|
||||
U16 line;
|
||||
U16 height = fProgressRect.height - 2; /* don't overwrite top and
|
||||
bottom */
|
||||
XP_Bool draw;
|
||||
COLOR color;
|
||||
U16 line;
|
||||
U16 height = fProgressRect.height - 2; /* don't overwrite top and
|
||||
bottom */
|
||||
XP_Bool draw;
|
||||
COLOR color;
|
||||
|
||||
fProgressCurLine %= height * 2;
|
||||
draw = fProgressCurLine < height;
|
||||
fProgressCurLine %= height * 2;
|
||||
draw = fProgressCurLine < height;
|
||||
|
||||
line = fProgressCurLine % (height) + 1;
|
||||
line = fProgressRect.y + height - line + 1;
|
||||
if ( draw ) {
|
||||
color = COLOR_BLACK;
|
||||
} else {
|
||||
color = COLOR_WHITE;
|
||||
}
|
||||
line = fProgressCurLine % (height) + 1;
|
||||
line = fProgressRect.y + height - line + 1;
|
||||
if ( draw ) {
|
||||
color = COLOR_BLACK;
|
||||
} else {
|
||||
color = COLOR_WHITE;
|
||||
}
|
||||
|
||||
DrawLine( fProgressRect.x+1, line,
|
||||
fProgressRect.x + fProgressRect.width - 1, line, color );
|
||||
DrawLine( fProgressRect.x+1, line,
|
||||
fProgressRect.x + fProgressRect.width - 1, line, color );
|
||||
|
||||
++fProgressCurLine;
|
||||
++fProgressCurLine;
|
||||
}
|
||||
} /* advanceProgressBar */
|
||||
|
||||
|
@ -807,7 +811,7 @@ Init_Menu()
|
|||
menu->SetRow( row++, GAMEMENU_HISTORY, "Game history", 's' );
|
||||
menu->SetRow( row++, GAMEMENU_FINALSCORES, "Final scores", 'f' );
|
||||
MainMenuBar.AddButton( new CPushButton(GAMEMENU_BUTTON_ID,0,0,"Game"),
|
||||
menu );
|
||||
menu );
|
||||
|
||||
menu = new CMenu( MOVEMENU_WINDOW_ID );
|
||||
menu->SetNumRows( 9 );
|
||||
|
@ -841,11 +845,11 @@ void
|
|||
MyErrorHandler( const char *filename, int lineno, const char *failexpr )
|
||||
{
|
||||
if (lineno != -1 || strcmp( failexpr, "Out of memory" )) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
GUI_Alert( ALERT_WARNING,
|
||||
"Operation cancelled - insufficient memory" );
|
||||
"Operation cancelled - insufficient memory" );
|
||||
GUI_SetMallocReserve( 1536 );
|
||||
GUI_ClearStack();
|
||||
}
|
||||
|
@ -977,14 +981,15 @@ CXWordsWindow::doHint( XP_Bool reset )
|
|||
XP_Bool done;
|
||||
|
||||
if ( reset ) {
|
||||
board_resetEngine( fGame.board );
|
||||
board_resetEngine( fGame.board );
|
||||
}
|
||||
done = board_requestHint( fGame.board, &workRemains );
|
||||
done = board_requestHint( fGame.board,
|
||||
fAskTrayLimits, &workRemains );
|
||||
if ( done ) {
|
||||
GUI_NeedUpdate();
|
||||
GUI_NeedUpdate();
|
||||
}
|
||||
if ( workRemains ) {
|
||||
GUI_EventMessage( MSG_USER, this, HINT_REQUEST );
|
||||
GUI_EventMessage( MSG_USER, this, HINT_REQUEST );
|
||||
}
|
||||
} /* handleHintMenu */
|
||||
|
||||
|
@ -992,7 +997,7 @@ void
|
|||
CXWordsWindow::doUndo()
|
||||
{
|
||||
if ( server_handleUndo( fGame.server ) ) {
|
||||
GUI_NeedUpdate();
|
||||
GUI_NeedUpdate();
|
||||
}
|
||||
} /* doUndo */
|
||||
|
||||
|
@ -1000,7 +1005,7 @@ void
|
|||
CXWordsWindow::doHideTray()
|
||||
{
|
||||
if ( board_hideTray( fGame.board ) ) {
|
||||
GUI_NeedUpdate();
|
||||
GUI_NeedUpdate();
|
||||
}
|
||||
} /* doHideTray */
|
||||
|
||||
|
@ -1024,7 +1029,7 @@ void
|
|||
CXWordsWindow::doCommit()
|
||||
{
|
||||
if ( board_commitTurn( fGame.board ) ) {
|
||||
GUI_NeedUpdate();
|
||||
GUI_NeedUpdate();
|
||||
}
|
||||
} /* doCommit */
|
||||
|
||||
|
@ -1042,9 +1047,9 @@ CXWordsWindow::doNewGameMenu()
|
|||
"game." ) ) {
|
||||
makeNewGame( this->gamesDB->countRecords() );
|
||||
} else if ( 0 == GUI_Alert( ALERT_OK,
|
||||
"Are you sure you want to replace"
|
||||
" the existing game?" ) ) {
|
||||
doit = XP_FALSE;
|
||||
"Are you sure you want to replace"
|
||||
" the existing game?" ) ) {
|
||||
doit = XP_FALSE;
|
||||
}
|
||||
|
||||
if ( doit && newGame( XP_FALSE ) ) { /* don't let user cancel; too late! */
|
||||
|
@ -1061,19 +1066,19 @@ CXWordsWindow::doSavedGames()
|
|||
{
|
||||
U16 openIndex; /* what index am I to open? */
|
||||
U16 curIndex = fState.curGameIndex; /* may change if lower-index
|
||||
game deleted */
|
||||
game deleted */
|
||||
saveCurrentGame(); /* so can be duped */
|
||||
wrappedEventLoop( new CSavedGamesWindow( this->gamesDB, &openIndex,
|
||||
&curIndex) );
|
||||
&curIndex) );
|
||||
|
||||
fState.curGameIndex = curIndex;
|
||||
if ( curIndex != openIndex ) {
|
||||
fState.curGameIndex = openIndex;
|
||||
loadCurrentGame();
|
||||
positionBoard();
|
||||
server_do( fGame.server ); /* in case there's a robot */
|
||||
board_invalAll( fGame.board );
|
||||
GUI_NeedUpdate();
|
||||
fState.curGameIndex = openIndex;
|
||||
loadCurrentGame();
|
||||
positionBoard();
|
||||
server_do( fGame.server ); /* in case there's a robot */
|
||||
board_invalAll( fGame.board );
|
||||
GUI_NeedUpdate();
|
||||
}
|
||||
} /* doSavedGames */
|
||||
#endif
|
||||
|
@ -1085,28 +1090,28 @@ CXWordsWindow::doAbout()
|
|||
XWStreamCtxt* stream;
|
||||
|
||||
stream = makeMemStream();
|
||||
char* txt = "Crosswords" VERSION_STRING "\n"
|
||||
"Copyright 2000-2002 by Eric House (fixin@peak.org).\n"
|
||||
"All rights reserved.\n"
|
||||
"For further information see www.peak.org/~fixin/xwords/ebm.html.";
|
||||
char* txt = "Crosswords " VERSION_STRING "\n"
|
||||
"Copyright 2000-2004 by Eric House (fixin@peak.org).\n"
|
||||
"All rights reserved.\n"
|
||||
"For further information see www.peak.org/~fixin/xwords/ebm.html.";
|
||||
stream_putBytes( stream, txt, strlen(txt) );
|
||||
stream_putU8( stream, '\0' );
|
||||
|
||||
wrappedEventLoop( new CShowTextWindow( MEMPOOL(this) stream,
|
||||
"About Crosswords",
|
||||
true, false,
|
||||
&ignore ) );
|
||||
"About Crosswords",
|
||||
true, false,
|
||||
&ignore ) );
|
||||
} /* doAbout */
|
||||
|
||||
void
|
||||
CXWordsWindow::doEndGame()
|
||||
{
|
||||
if ( server_getGameIsOver( fGame.server ) ) {
|
||||
this->displayFinalScores();
|
||||
this->displayFinalScores();
|
||||
} else if ( GUI_Alert( ALERT_OK,
|
||||
"Are you sure you want to end the game now?" )
|
||||
!= 0 ) {
|
||||
server_endGame( fGame.server );
|
||||
"Are you sure you want to end the game now?" )
|
||||
!= 0 ) {
|
||||
server_endGame( fGame.server );
|
||||
}
|
||||
GUI_NeedUpdate();
|
||||
} /* doEndGame */
|
||||
|
@ -1182,7 +1187,7 @@ CXWordsWindow::writeGameToStream( XWStreamCtxt* stream, U16 index )
|
|||
XP_UCHAR* dictName = dict_getName( dict );
|
||||
stream_putU8( stream, !!dictName );
|
||||
if ( !!dictName ) {
|
||||
stringToStream( stream, dictName );
|
||||
stringToStream( stream, dictName );
|
||||
}
|
||||
|
||||
game_saveToStream( &fGame, &fGameInfo, stream );
|
||||
|
@ -1225,14 +1230,14 @@ CXWordsWindow::displayFinalScores()
|
|||
|
||||
XP_U16
|
||||
CXWordsWindow::displayTextFromStream( XWStreamCtxt* stream,
|
||||
const char* title, /* should be ID!!! */
|
||||
BOOL killStream,
|
||||
BOOL includeCancel )
|
||||
const char* title, /* should be ID!!! */
|
||||
BOOL killStream,
|
||||
BOOL includeCancel )
|
||||
{
|
||||
XP_U16 result = 0;
|
||||
wrappedEventLoop( new CShowTextWindow( MEMPOOL(this) stream, title,
|
||||
killStream, includeCancel,
|
||||
&result ) );
|
||||
killStream, includeCancel,
|
||||
&result ) );
|
||||
return result;
|
||||
} /* displayTextFromStream */
|
||||
|
||||
|
@ -1241,30 +1246,30 @@ extern "C" {
|
|||
int
|
||||
frank_snprintf( XP_UCHAR* buf, XP_U16 len, XP_UCHAR* format, ... )
|
||||
{
|
||||
va_list ap;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
va_start(ap, format);
|
||||
|
||||
vsnprintf((char*)buf, len, (char*)format, ap);
|
||||
vsnprintf((char*)buf, len, (char*)format, ap);
|
||||
|
||||
va_end(ap);
|
||||
va_end(ap);
|
||||
|
||||
return strlen((char*)buf);
|
||||
return strlen((char*)buf);
|
||||
} /* frank_snprintf */
|
||||
|
||||
void
|
||||
frank_debugf( char* format, ... )
|
||||
{
|
||||
char buf[256];
|
||||
va_list ap;
|
||||
char buf[256];
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
va_start(ap, format);
|
||||
|
||||
vsprintf(buf, format, ap);
|
||||
vsprintf(buf, format, ap);
|
||||
|
||||
va_end(ap);
|
||||
va_end(ap);
|
||||
|
||||
perror(buf);
|
||||
perror(buf);
|
||||
} // debugf
|
||||
|
||||
XP_UCHAR*
|
||||
|
@ -1331,34 +1336,34 @@ frank_util_userError( XW_UtilCtxt* uc, UtilErrID id )
|
|||
*/
|
||||
switch( id ) {
|
||||
case ERR_TILES_NOT_IN_LINE:
|
||||
message = "All tiles played must be in a line.";
|
||||
break;
|
||||
message = "All tiles played must be in a line.";
|
||||
break;
|
||||
case ERR_NO_EMPTIES_IN_TURN:
|
||||
message = "Empty squares cannot separate tiles played.";
|
||||
break;
|
||||
message = "Empty squares cannot separate tiles played.";
|
||||
break;
|
||||
|
||||
case ERR_TWO_TILES_FIRST_MOVE:
|
||||
message = "Must play two or more pieces on the first move.";
|
||||
break;
|
||||
message = "Must play two or more pieces on the first move.";
|
||||
break;
|
||||
case ERR_TILES_MUST_CONTACT:
|
||||
message = "New pieces must contact others already in place (or "
|
||||
"the middle square on the first move).";
|
||||
break;
|
||||
message = "New pieces must contact others already in place (or "
|
||||
"the middle square on the first move).";
|
||||
break;
|
||||
case ERR_NOT_YOUR_TURN:
|
||||
message = "You can't do that; it's not your turn!";
|
||||
break;
|
||||
message = "You can't do that; it's not your turn!";
|
||||
break;
|
||||
case ERR_NO_PEEK_ROBOT_TILES:
|
||||
message = "No peeking at the robot's tiles!";
|
||||
break;
|
||||
message = "No peeking at the robot's tiles!";
|
||||
break;
|
||||
case ERR_CANT_TRADE_MID_MOVE:
|
||||
message = "Remove played tiles before trading.";
|
||||
break;
|
||||
message = "Remove played tiles before trading.";
|
||||
break;
|
||||
case ERR_TOO_FEW_TILES_LEFT_TO_TRADE:
|
||||
message = "Too few tiles left to trade.";
|
||||
break;
|
||||
message = "Too few tiles left to trade.";
|
||||
break;
|
||||
default:
|
||||
message = "unknown errorcode ID!!!";
|
||||
break;
|
||||
message = "unknown errorcode ID!!!";
|
||||
break;
|
||||
}
|
||||
|
||||
(void)GUI_Alert( ALERT_ERROR, message );
|
||||
|
@ -1367,7 +1372,7 @@ frank_util_userError( XW_UtilCtxt* uc, UtilErrID id )
|
|||
GUI_NeedUpdate();
|
||||
} /* frank_util_userError */
|
||||
|
||||
static XP_U16
|
||||
static XP_Bool
|
||||
frank_util_userQuery( XW_UtilCtxt* uc, UtilQueryID id, XWStreamCtxt* stream )
|
||||
{
|
||||
char* question;
|
||||
|
@ -1397,7 +1402,7 @@ frank_util_userQuery( XW_UtilCtxt* uc, UtilQueryID id, XWStreamCtxt* stream )
|
|||
askResult = GUI_Alert( ALERT_OK, question );
|
||||
board_invalAll( self->fGame.board );
|
||||
GUI_NeedUpdate();
|
||||
return askResult;
|
||||
return askResult != 0;
|
||||
} /* frank_util_userQuery */
|
||||
|
||||
static XP_S16
|
||||
|
@ -1445,7 +1450,7 @@ frank_util_hiliteCell( XW_UtilCtxt* uc, XP_U16 col, XP_U16 row )
|
|||
CXWordsWindow* self = (CXWordsWindow*)uc->closure;
|
||||
XP_Bool halted = self->robotIsHalted();
|
||||
if ( !halted ) {
|
||||
board_hiliteCellAt( self->fGame.board, col, row );
|
||||
board_hiliteCellAt( self->fGame.board, col, row );
|
||||
}
|
||||
BOOL waiting = EVNT_IsWaiting();
|
||||
return !waiting && !halted;
|
||||
|
@ -1470,7 +1475,7 @@ frank_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why )
|
|||
CXWordsWindow* self = (CXWordsWindow*)uc->closure;
|
||||
|
||||
XP_ASSERT( why == TIMER_PENDOWN ||
|
||||
why == TIMER_TIMERTICK );
|
||||
why == TIMER_TIMERTICK );
|
||||
|
||||
self->fTimers[why] = XP_TRUE;
|
||||
self->setTimerIfNeeded();
|
||||
|
@ -1481,8 +1486,8 @@ frank_util_requestTime( XW_UtilCtxt* uc )
|
|||
{
|
||||
CXWordsWindow* self = (CXWordsWindow*)uc->closure;
|
||||
if ( !self->getUserEventPending() ) {
|
||||
GUI_EventMessage( MSG_USER, self, SERVER_TIME_REQUEST );
|
||||
self->setUserEventPending();
|
||||
GUI_EventMessage( MSG_USER, self, SERVER_TIME_REQUEST );
|
||||
self->setUserEventPending();
|
||||
}
|
||||
} /* frank_util_requestTime */
|
||||
|
||||
|
@ -1505,29 +1510,28 @@ frank_util_getSquareBonus( XW_UtilCtxt* uc, ModelCtxt* model,
|
|||
XP_U16 col, XP_U16 row )
|
||||
{
|
||||
XP_U16 index;
|
||||
/* This must be static or won't compile under multilink (for Palm).
|
||||
Fix! */
|
||||
const char scrabbleBoard[8*8] = {
|
||||
TW,EM,EM,DL,EM,EM,EM,TW,
|
||||
EM,DW,EM,EM,EM,TL,EM,EM,
|
||||
|
||||
EM,EM,DW,EM,EM,EM,DL,EM,
|
||||
DL,EM,EM,DW,EM,EM,EM,DL,
|
||||
const char scrabbleBoard[8*8] = {
|
||||
TW,EM,EM,DL,EM,EM,EM,TW,
|
||||
EM,DW,EM,EM,EM,TL,EM,EM,
|
||||
|
||||
EM,EM,DW,EM,EM,EM,DL,EM,
|
||||
DL,EM,EM,DW,EM,EM,EM,DL,
|
||||
|
||||
EM,EM,EM,EM,DW,EM,EM,EM,
|
||||
EM,TL,EM,EM,EM,TL,EM,EM,
|
||||
EM,EM,EM,EM,DW,EM,EM,EM,
|
||||
EM,TL,EM,EM,EM,TL,EM,EM,
|
||||
|
||||
EM,EM,DL,EM,EM,EM,DL,EM,
|
||||
TW,EM,EM,DL,EM,EM,EM,DW,
|
||||
EM,EM,DL,EM,EM,EM,DL,EM,
|
||||
TW,EM,EM,DL,EM,EM,EM,DW,
|
||||
}; /* scrabbleBoard */
|
||||
|
||||
if ( col > 7 ) col = 14 - col;
|
||||
if ( row > 7 ) row = 14 - row;
|
||||
index = (row*8) + col;
|
||||
if ( index >= 8*8 ) {
|
||||
return (XWBonusType)EM;
|
||||
return (XWBonusType)EM;
|
||||
} else {
|
||||
return (XWBonusType)scrabbleBoard[index];
|
||||
return (XWBonusType)scrabbleBoard[index];
|
||||
}
|
||||
} /* frank_util_getSquareBonus */
|
||||
|
||||
|
@ -1547,6 +1551,8 @@ frank_util_getUserString( XW_UtilCtxt* uc, XP_U16 stringCode )
|
|||
return (XP_UCHAR*)"Commit the current move?\n";
|
||||
case STR_NONLOCAL_NAME:
|
||||
return (XP_UCHAR*)"%s (remote)";
|
||||
case STR_LOCAL_NAME:
|
||||
return (XP_UCHAR*)"%s";
|
||||
case STRD_TIME_PENALTY_SUB:
|
||||
return (XP_UCHAR*)" - %d [time]";
|
||||
|
||||
|
@ -1572,6 +1578,15 @@ frank_util_getUserString( XW_UtilCtxt* uc, XP_U16 stringCode )
|
|||
case STR_ROBOT_MOVED:
|
||||
return (XP_UCHAR*)"The robot made this move:\n";
|
||||
|
||||
case STR_PASSED:
|
||||
return (XP_UCHAR*)"Passed";
|
||||
case STRSD_SUMMARYSCORED:
|
||||
return (XP_UCHAR*)"%s:%d";
|
||||
case STRD_TRADED:
|
||||
return (XP_UCHAR*)"Traded %d";
|
||||
case STR_LOSTTURN:
|
||||
return (XP_UCHAR*)"Lost turn";
|
||||
|
||||
default:
|
||||
return (XP_UCHAR*)"unknown code ";
|
||||
}
|
||||
|
@ -1583,13 +1598,13 @@ formatBadWords( BadWordInfo* bwi, char buf[] )
|
|||
XP_U16 i;
|
||||
|
||||
for ( i = 0, buf[0] = '\0'; ; ) {
|
||||
char wordBuf[18];
|
||||
sprintf( wordBuf, "\"%s\"", bwi->words[i] );
|
||||
strcat( buf, wordBuf );
|
||||
if ( ++i == bwi->nWords ) {
|
||||
break;
|
||||
}
|
||||
strcat( buf, ", " );
|
||||
char wordBuf[18];
|
||||
sprintf( wordBuf, "\"%s\"", bwi->words[i] );
|
||||
strcat( buf, wordBuf );
|
||||
if ( ++i == bwi->nWords ) {
|
||||
break;
|
||||
}
|
||||
strcat( buf, ", " );
|
||||
}
|
||||
} /* formatBadWords */
|
||||
|
||||
|
@ -1605,17 +1620,17 @@ frank_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi,
|
|||
formatBadWords( bwi, wordsBuf );
|
||||
|
||||
if ( turnLost ) {
|
||||
XP_UCHAR* name = self->fGameInfo.players[turn].name;
|
||||
XP_ASSERT( !!name );
|
||||
sprintf( buf, "Player %d (%s) played illegal word[s] "
|
||||
"%s; loses turn",
|
||||
turn+1, name, wordsBuf );
|
||||
(void)GUI_Alert( ALERT_ERROR, buf );
|
||||
result = XP_TRUE;
|
||||
XP_UCHAR* name = self->fGameInfo.players[turn].name;
|
||||
XP_ASSERT( !!name );
|
||||
sprintf( buf, "Player %d (%s) played illegal word[s] "
|
||||
"%s; loses turn",
|
||||
turn+1, name, wordsBuf );
|
||||
(void)GUI_Alert( ALERT_ERROR, buf );
|
||||
result = XP_TRUE;
|
||||
} else {
|
||||
sprintf( buf, "Word %s not in the current dictionary. "
|
||||
"Use it anyway?", wordsBuf );
|
||||
result = GUI_Alert( ALERT_OK, buf );
|
||||
sprintf( buf, "Word %s not in the current dictionary. "
|
||||
"Use it anyway?", wordsBuf );
|
||||
result = GUI_Alert( ALERT_OK, buf );
|
||||
}
|
||||
return result;
|
||||
} /* frank_util_warnIllegalWord */
|
||||
|
|
Loading…
Add table
Reference in a new issue