mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-17 18:12:01 +01:00
Use new dict API to get rid of XP_UCHAR4 type, replacing with const XP_UCHAR*.
This commit is contained in:
parent
2838f421a5
commit
669e423ca8
15 changed files with 67 additions and 57 deletions
|
@ -55,8 +55,6 @@ typedef XP_U8 Tile;
|
|||
|
||||
typedef void* XP_Bitmap;
|
||||
|
||||
typedef XP_UCHAR XP_UCHAR4[4];
|
||||
|
||||
typedef enum {
|
||||
TRI_ENAB_NONE
|
||||
,TRI_ENAB_HIDDEN
|
||||
|
|
|
@ -909,7 +909,7 @@ model_removePlayerTile( ModelCtxt* model, XP_S16 turn, XP_S16 index )
|
|||
void
|
||||
model_packTilesUtil( ModelCtxt* model, PoolContext* pool,
|
||||
XP_Bool includeBlank,
|
||||
XP_U16* nUsed, XP_UCHAR4* texts,
|
||||
XP_U16* nUsed, const XP_UCHAR** texts,
|
||||
Tile* tiles )
|
||||
{
|
||||
DictionaryCtxt* dict = model->vol.dict;
|
||||
|
@ -921,8 +921,6 @@ model_packTilesUtil( ModelCtxt* model, PoolContext* pool,
|
|||
XP_ASSERT( nFaces <= *nUsed );
|
||||
|
||||
for ( tile = 0; tile < nFaces; ++tile ) {
|
||||
XP_U16 nChars;
|
||||
|
||||
if ( includeBlank ) {
|
||||
XP_ASSERT( !!pool );
|
||||
if ( pool_getNTilesLeftFor( pool, tile ) == 0 ) {
|
||||
|
@ -933,10 +931,7 @@ model_packTilesUtil( ModelCtxt* model, PoolContext* pool,
|
|||
}
|
||||
|
||||
tiles[nFacesAvail] = tile;
|
||||
nChars = dict_tilesToString( dict, &tile, 1,
|
||||
(XP_UCHAR*)&texts[nFacesAvail],
|
||||
sizeof(texts[0]) );
|
||||
XP_ASSERT( nChars < sizeof(texts[0]) );
|
||||
texts[nFacesAvail] = dict_getTileString( dict, tile );
|
||||
++nFacesAvail;
|
||||
}
|
||||
|
||||
|
@ -949,7 +944,7 @@ askBlankTile( ModelCtxt* model, XP_U16 turn )
|
|||
{
|
||||
XP_U16 nUsed = MAX_UNIQUE_TILES;
|
||||
XP_S16 chosen;
|
||||
XP_UCHAR4 tfaces[MAX_UNIQUE_TILES];
|
||||
const XP_UCHAR* tfaces[MAX_UNIQUE_TILES];
|
||||
Tile tiles[MAX_UNIQUE_TILES];
|
||||
PickInfo pi;
|
||||
|
||||
|
@ -961,7 +956,7 @@ askBlankTile( ModelCtxt* model, XP_U16 turn )
|
|||
&nUsed, tfaces, tiles );
|
||||
|
||||
chosen = util_userPickTile( model->vol.util, &pi,
|
||||
turn, (const XP_UCHAR4*)tfaces, nUsed );
|
||||
turn, tfaces, nUsed );
|
||||
|
||||
if ( chosen < 0 ) {
|
||||
chosen = 0;
|
||||
|
|
|
@ -255,7 +255,7 @@ void model_store( ModelCtxt* model, XP_Stream* outStream );
|
|||
/* a utility function needed by server too. Not a clean design, this. */
|
||||
void model_packTilesUtil( ModelCtxt* model, PoolContext* pool,
|
||||
XP_Bool includeBlank,
|
||||
XP_U16* nUsed, XP_UCHAR4* texts,
|
||||
XP_U16* nUsed, const XP_UCHAR** texts,
|
||||
Tile* tiles );
|
||||
|
||||
|
||||
|
|
|
@ -1354,7 +1354,7 @@ makeNotAVowel( ServerCtxt* server, Tile* newTile )
|
|||
|
||||
static void
|
||||
curTrayAsTexts( ServerCtxt* server, XP_U16 turn, const TrayTileSet* notInTray,
|
||||
XP_U16* nUsedP, XP_UCHAR4* curTrayText )
|
||||
XP_U16* nUsedP, const XP_UCHAR** curTrayText )
|
||||
{
|
||||
const TrayTileSet* tileSet = model_getPlayerTiles( server->vol.model, turn );
|
||||
DictionaryCtxt* dict = model_getDictionary( server->vol.model );
|
||||
|
@ -1387,9 +1387,7 @@ curTrayAsTexts( ServerCtxt* server, XP_U16 turn, const TrayTileSet* notInTray,
|
|||
}
|
||||
|
||||
if ( !toBeTraded ) {
|
||||
dict_tilesToString( dict, &tile, 1,
|
||||
(XP_UCHAR*)&curTrayText[nUsed++],
|
||||
sizeof(curTrayText[0]) );
|
||||
curTrayText[nUsed++] = dict_getTileString( dict, tile );
|
||||
}
|
||||
}
|
||||
*nUsedP = nUsed;
|
||||
|
@ -1408,7 +1406,7 @@ fetchTiles( ServerCtxt* server, XP_U16 playerNum, XP_U16 nToFetch,
|
|||
PoolContext* pool = server->pool;
|
||||
TrayTileSet oneTile;
|
||||
PickInfo pi;
|
||||
XP_UCHAR4 curTray[MAX_TRAY_TILES];
|
||||
const XP_UCHAR* curTray[MAX_TRAY_TILES];
|
||||
#ifdef FEATURE_TRAY_EDIT
|
||||
DictionaryCtxt* dict = model_getDictionary( server->vol.model );
|
||||
#endif
|
||||
|
@ -1438,7 +1436,7 @@ fetchTiles( ServerCtxt* server, XP_U16 playerNum, XP_U16 nToFetch,
|
|||
#ifdef FEATURE_TRAY_EDIT /* good compiler would note ask==0, but... */
|
||||
/* First ask until cancelled */
|
||||
for ( nSoFar = 0; ask && nSoFar < nToFetch; ) {
|
||||
XP_UCHAR4 texts[MAX_UNIQUE_TILES];
|
||||
const XP_UCHAR* texts[MAX_UNIQUE_TILES];
|
||||
Tile tiles[MAX_UNIQUE_TILES];
|
||||
XP_S16 chosen;
|
||||
XP_U16 nUsed = MAX_UNIQUE_TILES;
|
||||
|
@ -1447,7 +1445,7 @@ fetchTiles( ServerCtxt* server, XP_U16 playerNum, XP_U16 nToFetch,
|
|||
XP_TRUE, &nUsed, texts, tiles );
|
||||
|
||||
chosen = util_userPickTile( server->vol.util, &pi, playerNum,
|
||||
(const XP_UCHAR4*)texts, nUsed );
|
||||
texts, nUsed );
|
||||
|
||||
if ( chosen == PICKER_PICKALL ) {
|
||||
ask = XP_FALSE;
|
||||
|
@ -1464,10 +1462,7 @@ fetchTiles( ServerCtxt* server, XP_U16 playerNum, XP_U16 nToFetch,
|
|||
Tile tile = tiles[chosen];
|
||||
oneTile.tiles[0] = tile;
|
||||
pool_removeTiles( pool, &oneTile );
|
||||
|
||||
(void)dict_tilesToString( dict, &tile, 1,
|
||||
(XP_UCHAR*)&curTray[pi.nCurTiles++],
|
||||
sizeof(curTray[0]) );
|
||||
curTray[pi.nCurTiles++] = dict_getTileString( dict, tile );
|
||||
resultTiles->tiles[nSoFar++] = tile;
|
||||
++pi.thisPick;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ typedef enum {
|
|||
#define PICKER_BACKUP -2
|
||||
|
||||
typedef struct PickInfo {
|
||||
XP_UCHAR4* curTiles;
|
||||
const XP_UCHAR** curTiles;
|
||||
XP_U16 nCurTiles;
|
||||
XP_U16 nTotal; /* count to fetch for turn, <= MAX_TRAY_TILES */
|
||||
XP_U16 thisPick; /* <= nTotal */
|
||||
|
@ -117,7 +117,7 @@ typedef struct UtilVtable {
|
|||
/* return of < 0 means computer should pick */
|
||||
XP_S16 (*m_util_userPickTile)( XW_UtilCtxt* uc, const PickInfo* pi,
|
||||
XP_U16 playerNum,
|
||||
const XP_UCHAR4* texts, XP_U16 nTiles );
|
||||
const XP_UCHAR** texts, XP_U16 nTiles );
|
||||
|
||||
XP_Bool (*m_util_askPassword)( XW_UtilCtxt* uc, const XP_UCHAR* name,
|
||||
XP_UCHAR* buf, XP_U16* len );
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "cursesdlgutil.h"
|
||||
|
||||
#define MAX_TILE_BUTTON_ROWS 10
|
||||
#define MAX_TILE_BUTTON_WIDTH (sizeof(XP_UCHAR4) + 2)
|
||||
#define MAX_TILE_BUTTON_WIDTH 6
|
||||
|
||||
static void
|
||||
sizeTextsAsButtons( XP_U16 maxLen, XP_U16 nTiles, XP_U16* textsCols,
|
||||
|
@ -48,7 +48,7 @@ sizeTextsAsButtons( XP_U16 maxLen, XP_U16 nTiles, XP_U16* textsCols,
|
|||
|
||||
XP_S16
|
||||
curses_askLetter( CursesAppGlobals* globals, XP_UCHAR* query,
|
||||
const XP_UCHAR4* texts, XP_U16 nTiles )
|
||||
const XP_UCHAR** texts, XP_U16 nTiles )
|
||||
{
|
||||
XP_S16 result;
|
||||
WINDOW* confWin;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "cursesmain.h"
|
||||
|
||||
XP_S16 curses_askLetter( CursesAppGlobals* globals, XP_UCHAR* query,
|
||||
const XP_UCHAR4* texts, XP_U16 nTiles );
|
||||
const XP_UCHAR** texts, XP_U16 nTiles );
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -223,7 +223,7 @@ cursesUserError( CursesAppGlobals* globals, const char* format, ... )
|
|||
|
||||
static XP_S16
|
||||
curses_util_userPickTile( XW_UtilCtxt* uc, const PickInfo* XP_UNUSED(pi),
|
||||
XP_U16 playerNum, const XP_UCHAR4* texts,
|
||||
XP_U16 playerNum, const XP_UCHAR** texts,
|
||||
XP_U16 nTiles )
|
||||
{
|
||||
CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2000 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
* Copyright 2000-2009 by Eric House (xwords@eehouse.org). All rights
|
||||
* reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -42,8 +43,8 @@ abort_button_event( GtkWidget* XP_UNUSED(widget), gpointer XP_UNUSED(closure) )
|
|||
#define BUTTONS_PER_ROW 13
|
||||
|
||||
XP_S16
|
||||
gtkletterask( XP_Bool forBlank, XP_UCHAR* name,
|
||||
XP_U16 nTiles, const XP_UCHAR4* texts )
|
||||
gtkletterask( const PickInfo* pi, const XP_UCHAR* name,
|
||||
XP_U16 nTiles, const XP_UCHAR** texts )
|
||||
{
|
||||
GtkWidget* dialog;
|
||||
GtkWidget* label;
|
||||
|
@ -51,7 +52,7 @@ gtkletterask( XP_Bool forBlank, XP_UCHAR* name,
|
|||
GtkWidget* vbox;
|
||||
GtkWidget* hbox = NULL;
|
||||
char* txt;
|
||||
XP_S16 i;
|
||||
XP_S16 ii;
|
||||
GtkWidget* button;
|
||||
XP_UCHAR buf[64];
|
||||
|
||||
|
@ -59,19 +60,19 @@ gtkletterask( XP_Bool forBlank, XP_UCHAR* name,
|
|||
|
||||
vbox = gtk_vbox_new( FALSE, 0 );
|
||||
|
||||
for ( i = 0; i < nTiles; ++i ) {
|
||||
for ( ii = 0; ii < nTiles; ++ii ) {
|
||||
|
||||
if ( i % BUTTONS_PER_ROW == 0 ) {
|
||||
if ( ii % BUTTONS_PER_ROW == 0 ) {
|
||||
hbox = gtk_hbox_new( FALSE, 0 );
|
||||
}
|
||||
button = gtk_button_new_with_label( texts[i] );
|
||||
button = gtk_button_new_with_label( texts[ii] );
|
||||
|
||||
gtk_box_pack_start( GTK_BOX(hbox), button, FALSE, TRUE, 0 );
|
||||
g_signal_connect( GTK_OBJECT(button), "clicked",
|
||||
G_CALLBACK(button_event), &results[i] );
|
||||
G_CALLBACK(button_event), &results[ii] );
|
||||
gtk_widget_show( button );
|
||||
|
||||
if ( i+1 == nTiles || (i % BUTTONS_PER_ROW == 0) ) {
|
||||
if ( ii+1 == nTiles || (ii % BUTTONS_PER_ROW == 0) ) {
|
||||
gtk_widget_show( hbox );
|
||||
gtk_box_pack_start( GTK_BOX(vbox), hbox, FALSE, TRUE, 0 );
|
||||
}
|
||||
|
@ -94,6 +95,7 @@ gtkletterask( XP_Bool forBlank, XP_UCHAR* name,
|
|||
dialog = gtk_dialog_new();
|
||||
gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
|
||||
|
||||
XP_Bool forBlank = PICK_FOR_BLANK == pi->why;
|
||||
if ( forBlank ) {
|
||||
txt = "Choose a letter for your blank.";
|
||||
} else {
|
||||
|
@ -102,9 +104,23 @@ gtkletterask( XP_Bool forBlank, XP_UCHAR* name,
|
|||
txt = buf;
|
||||
}
|
||||
label = gtk_label_new( txt );
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),
|
||||
label);
|
||||
|
||||
if ( !forBlank ) {
|
||||
char curTilesBuf[64];
|
||||
int len = snprintf( curTilesBuf, sizeof(curTilesBuf), "%s",
|
||||
"Tiles so far: " );
|
||||
for ( ii = 0; ii < pi->nCurTiles; ++ii ) {
|
||||
len += snprintf( &curTilesBuf[len], sizeof(curTilesBuf) - len, "%s ",
|
||||
pi->curTiles[ii] );
|
||||
}
|
||||
|
||||
GtkWidget* curTilesLabel = gtk_label_new( curTilesBuf );
|
||||
gtk_container_add( GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),
|
||||
curTilesLabel );
|
||||
}
|
||||
|
||||
gtk_container_add( GTK_CONTAINER( GTK_DIALOG(dialog)->action_area), vbox);
|
||||
gtk_widget_show_all( dialog );
|
||||
|
||||
|
@ -112,16 +128,16 @@ gtkletterask( XP_Bool forBlank, XP_UCHAR* name,
|
|||
|
||||
gtk_widget_destroy( dialog );
|
||||
|
||||
for ( i = 0; i < nTiles; ++i ) {
|
||||
if ( results[i] ) {
|
||||
for ( ii = 0; ii < nTiles; ++ii ) {
|
||||
if ( results[ii] ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( i == nTiles ) {
|
||||
i = -1;
|
||||
if ( ii == nTiles ) {
|
||||
ii = -1;
|
||||
}
|
||||
|
||||
return i;
|
||||
return ii;
|
||||
} /* gtkletterask */
|
||||
|
||||
#endif /* PLATFORM_GTK */
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2001 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
* Copyright 2001-2009 by Eric House (xwords@eehouse.org). All rights
|
||||
* reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -25,8 +26,8 @@
|
|||
|
||||
#include "gtkmain.h"
|
||||
|
||||
XP_S16 gtkletterask( XP_Bool forBlank, XP_UCHAR* name, XP_U16 nTiles,
|
||||
const XP_UCHAR4* texts );
|
||||
XP_S16 gtkletterask( const PickInfo* pi, const XP_UCHAR* name,
|
||||
XP_U16 nTiles, const XP_UCHAR** texts );
|
||||
|
||||
|
||||
#endif /* _GTKLETTERASK_H_ */
|
||||
|
|
|
@ -1060,14 +1060,14 @@ gtk_util_getVTManager(XW_UtilCtxt* uc)
|
|||
|
||||
static XP_S16
|
||||
gtk_util_userPickTile( XW_UtilCtxt* uc, const PickInfo* pi,
|
||||
XP_U16 playerNum,
|
||||
const XP_UCHAR4* texts, XP_U16 nTiles )
|
||||
XP_U16 playerNum, const XP_UCHAR** texts,
|
||||
XP_U16 nTiles )
|
||||
{
|
||||
XP_S16 chosen;
|
||||
GtkAppGlobals* globals = (GtkAppGlobals*)uc->closure;
|
||||
XP_UCHAR* name = globals->cGlobals.params->gi.players[playerNum].name;
|
||||
|
||||
chosen = gtkletterask( pi->why == PICK_FOR_BLANK, name, nTiles, texts );
|
||||
chosen = gtkletterask( pi, name, nTiles, texts );
|
||||
return chosen;
|
||||
} /* gtk_util_userPickTile */
|
||||
|
||||
|
|
|
@ -203,6 +203,7 @@ usage( char* appName, char* msg )
|
|||
"\t [-V] # hide values in tray\n"
|
||||
"\t [-m] # make the robot duMb (smart is default)\n"
|
||||
"\t [-l] # disallow hints\n"
|
||||
"\t [-P] # pick tiles face up\n"
|
||||
"\t [-c] # explain robot scores after each move\n"
|
||||
"\t [-C COOKIE] # cookie used to groups games on relay\n"
|
||||
"\t\t # (max of four players total, local and remote)\n"
|
||||
|
@ -741,7 +742,7 @@ main( int argc, char** argv )
|
|||
#if defined PLATFORM_GTK
|
||||
"h:I"
|
||||
#endif
|
||||
"kKf:ln:Nsd:e:r:b:q:w:Sit:UmvcV"
|
||||
"kKf:ln:Nsd:e:r:b:q:w:Sit:UmvcVP"
|
||||
#ifdef XWFEATURE_SMS
|
||||
"M:"
|
||||
#endif
|
||||
|
@ -817,6 +818,9 @@ main( int argc, char** argv )
|
|||
case 'l':
|
||||
mainParams.gi.hintsNotAllowed = XP_TRUE;
|
||||
break;
|
||||
case 'P':
|
||||
mainParams.gi.allowPickTiles = XP_TRUE;
|
||||
break;
|
||||
case 'n':
|
||||
index = mainParams.gi.nPlayers++;
|
||||
++mainParams.nLocalPlayers;
|
||||
|
|
|
@ -30,7 +30,7 @@ loadLettersList( BlankDialogState* bState )
|
|||
XP_U16 nTiles = bState->nTiles;
|
||||
HWND hDlg = bState->dlgHdr.hDlg;
|
||||
CEAppGlobals* globals = bState->dlgHdr.globals;
|
||||
const XP_UCHAR4* texts = bState->texts;
|
||||
const XP_UCHAR** texts = bState->texts;
|
||||
UINT codePage = ceCurDictIsUTF8(globals)? CP_UTF8 : CP_ACP;
|
||||
|
||||
for ( i = 0; i < nTiles; ++i ) {
|
||||
|
|
|
@ -28,7 +28,7 @@ typedef struct BlankDialogState {
|
|||
CeDlgHdr dlgHdr;
|
||||
const PickInfo* pi;
|
||||
XP_U16 playerNum;
|
||||
const XP_UCHAR4* texts;
|
||||
const XP_UCHAR** texts;
|
||||
XP_U16 nTiles;
|
||||
XP_S16 result;
|
||||
XP_Bool canBackup;
|
||||
|
|
|
@ -102,7 +102,7 @@ static XWBonusType ce_util_getSquareBonus( XW_UtilCtxt* uc,
|
|||
XP_U16 col, XP_U16 row );
|
||||
static XP_S16 ce_util_userPickTile( XW_UtilCtxt* uc, const PickInfo* pi,
|
||||
XP_U16 playerNum,
|
||||
const XP_UCHAR4* texts, XP_U16 nTiles );
|
||||
const XP_UCHAR** texts, XP_U16 nTiles );
|
||||
static XP_Bool ce_util_askPassword( XW_UtilCtxt* uc, const XP_UCHAR* name,
|
||||
XP_UCHAR* buf, XP_U16* len );
|
||||
static void ce_util_trayHiddenChange( XW_UtilCtxt* uc,
|
||||
|
@ -1795,8 +1795,9 @@ ceSaveCurGame( CEAppGlobals* globals, XP_Bool autoSave )
|
|||
} else {
|
||||
wchar_t nameBuf[MAX_PATH];
|
||||
|
||||
confirmed = ceConfirmUniqueName( globals, globals->hWnd, IDS_SAVENAME,
|
||||
nameBuf, VSIZE(nameBuf) );
|
||||
confirmed = ceConfirmUniqueName( globals, globals->hWnd,
|
||||
IDS_SAVENAME, nameBuf,
|
||||
VSIZE(nameBuf) );
|
||||
if ( confirmed ) {
|
||||
XP_U16 len = wcslen(nameBuf);
|
||||
newName = XP_MALLOC( globals->mpool, len + 1 );
|
||||
|
@ -3066,7 +3067,7 @@ ce_util_getSquareBonus( XW_UtilCtxt* uc, const ModelCtxt* XP_UNUSED(model),
|
|||
static XP_S16
|
||||
ce_util_userPickTile( XW_UtilCtxt* uc, const PickInfo* pi,
|
||||
XP_U16 playerNum,
|
||||
const XP_UCHAR4* texts, XP_U16 nTiles )
|
||||
const XP_UCHAR** texts, XP_U16 nTiles )
|
||||
{
|
||||
BlankDialogState state;
|
||||
CEAppGlobals* globals = (CEAppGlobals*)uc->closure;
|
||||
|
|
Loading…
Reference in a new issue