mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
make stuff better
This commit is contained in:
parent
d5b1e429ea
commit
b386abcf9d
5 changed files with 46 additions and 24 deletions
|
@ -530,7 +530,7 @@ initDeviceGlobals( Globals* globals )
|
|||
{
|
||||
globals->cp.showBoardArrow = XP_TRUE;
|
||||
globals->cp.allowPeek = XP_TRUE;
|
||||
// globals->cp.showRobotScores = XP_TRUE;
|
||||
globals->cp.showRobotScores = XP_TRUE;
|
||||
globals->cp.sortNewTiles = XP_TRUE;
|
||||
globals->cp.showColors = XP_TRUE;
|
||||
|
||||
|
@ -619,13 +619,14 @@ onReplaceConfirmed( void* closure, bool confirmed )
|
|||
XP_MEMSET( &globals->gs.gi, 0, sizeof(globals->gs.gi) );
|
||||
|
||||
globals->gs.util = wasm_util_make( MPPARM(globals->mpool) &globals->gs.gi,
|
||||
globals->dutil, globals );
|
||||
globals->dutil, globals );
|
||||
|
||||
game_makeFromInvite( MPPARM(globals->mpool) NULL, &ars->invite,
|
||||
&globals->gs.game, &globals->gs.gi,
|
||||
globals->dict, NULL,
|
||||
globals->gs.util, globals->draw,
|
||||
&globals->cp, &globals->procs );
|
||||
ensureName( globals );
|
||||
|
||||
const char* name = get_stored_value( KEY_PLAYER_NAME );
|
||||
if ( NULL != name ) {
|
||||
|
@ -682,7 +683,7 @@ loadSavedGame( Globals* globals, const char* key )
|
|||
if ( 0 < stream_getSize( stream ) ) {
|
||||
XP_ASSERT( !globals->gs.util );
|
||||
globals->gs.util = wasm_util_make( MPPARM(globals->mpool) &globals->gs.gi,
|
||||
globals->dutil, globals );
|
||||
globals->dutil, globals );
|
||||
|
||||
XP_LOGFF( "there's a saved game!!" );
|
||||
loaded = game_makeFromStream( MPPARM(globals->mpool) NULL, stream,
|
||||
|
@ -789,7 +790,7 @@ loadAndDraw( Globals* globals, const NetLaunchInfo* invite,
|
|||
&globals->gs.game, &globals->gs.gi,
|
||||
globals->gs.util, globals->draw,
|
||||
&globals->cp, &globals->procs );
|
||||
nameGame( globals );
|
||||
ensureName( globals );
|
||||
if ( !!globals->gs.game.comms ) {
|
||||
CommsAddrRec addr = {0};
|
||||
makeSelfAddr( globals, &addr );
|
||||
|
@ -817,7 +818,7 @@ main_onGameMessage( Globals* globals, XP_U32 gameID,
|
|||
updateScreen( globals, true );
|
||||
}
|
||||
} else {
|
||||
XP_LOGFF( "dropping packet for wrong game" );
|
||||
call_alert( "dropping packet for wrong game" );
|
||||
|
||||
XWStreamCtxt* stream = mem_stream_make_raw( MPPARM(globals->mpool)
|
||||
globals->vtMgr );
|
||||
|
@ -1127,6 +1128,12 @@ updateScreen( Globals* globals, bool doSave )
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
main_updateScreen( Globals* globals )
|
||||
{
|
||||
updateScreen( globals, true );
|
||||
}
|
||||
|
||||
static void
|
||||
looper( void* closure )
|
||||
{
|
||||
|
|
|
@ -82,5 +82,6 @@ void main_showGameOver( Globals* globals );
|
|||
void main_showRemaining( Globals* globals );
|
||||
void main_pickBlank( Globals* globals, int playerNum, int col, int row,
|
||||
const char** tileFaces, int nTiles );
|
||||
void main_updateScreen( Globals* globals );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -27,7 +27,7 @@ typedef struct _WasmUtilCtx {
|
|||
XW_UtilCtxt super;
|
||||
|
||||
XW_DUtilCtxt* dctxt;
|
||||
void* closure;
|
||||
Globals* closure;
|
||||
} WasmUtilCtx;
|
||||
|
||||
static XWStreamCtxt*
|
||||
|
@ -36,7 +36,7 @@ wasm_util_makeStreamFromAddr( XW_UtilCtxt* uc, XWEnv xwe, XP_PlayerAddr channelN
|
|||
LOG_FUNC();
|
||||
|
||||
WasmUtilCtx* wuctxt = (WasmUtilCtx*)uc;
|
||||
Globals* globals = (Globals*)wuctxt->closure;
|
||||
Globals* globals = wuctxt->closure;
|
||||
XWStreamCtxt* stream = mem_stream_make( MPPARM(uc->mpool)
|
||||
globals->vtMgr, globals,
|
||||
channelNo, main_sendOnClose );
|
||||
|
@ -216,7 +216,7 @@ static void
|
|||
wasm_util_userError( XW_UtilCtxt* uc, XWEnv xwe, UtilErrID id )
|
||||
{
|
||||
WasmUtilCtx* wuctxt = (WasmUtilCtx*)uc;
|
||||
Globals* globals = (Globals*)wuctxt->closure;
|
||||
Globals* globals = wuctxt->closure;
|
||||
XP_Bool silent;
|
||||
const XP_UCHAR* str = wasm_getErrString( id, &silent );
|
||||
if ( !silent ) {
|
||||
|
@ -229,10 +229,10 @@ query_proc_notifyMove( void* closure, XP_Bool confirmed )
|
|||
{
|
||||
if ( confirmed ) {
|
||||
WasmUtilCtx* wuctxt = (WasmUtilCtx*)closure;
|
||||
Globals* globals = (Globals*)wuctxt->closure;
|
||||
Globals* globals = wuctxt->closure;
|
||||
if ( board_commitTurn( globals->gs.game.board, NULL,
|
||||
XP_TRUE, XP_TRUE, NULL ) ) {
|
||||
board_draw( globals->gs.game.board, NULL );
|
||||
main_updateScreen( globals );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ static void
|
|||
wasm_util_notifyMove( XW_UtilCtxt* uc, XWEnv xwe, XWStreamCtxt* stream )
|
||||
{
|
||||
WasmUtilCtx* wuctxt = (WasmUtilCtx*)uc;
|
||||
Globals* globals = (Globals*)wuctxt->closure;
|
||||
Globals* globals = wuctxt->closure;
|
||||
|
||||
XP_U16 len = stream_getSize( stream );
|
||||
XP_UCHAR buf[len+1];
|
||||
|
@ -255,7 +255,7 @@ wasm_util_notifyTrade( XW_UtilCtxt* uc, XWEnv xwe, const XP_UCHAR** tiles,
|
|||
XP_U16 nTiles )
|
||||
{
|
||||
WasmUtilCtx* wuctxt = (WasmUtilCtx*)uc;
|
||||
Globals* globals = (Globals*)wuctxt->closure;
|
||||
Globals* globals = wuctxt->closure;
|
||||
XP_UCHAR buf[128];
|
||||
XP_SNPRINTF( buf, sizeof(buf),
|
||||
"Are you sure you want to trade the %d selected tiles?", nTiles );
|
||||
|
@ -268,7 +268,7 @@ wasm_util_notifyPickTileBlank( XW_UtilCtxt* uc, XWEnv xwe, XP_U16 playerNum,
|
|||
const XP_UCHAR** tileFaces, XP_U16 nTiles )
|
||||
{
|
||||
WasmUtilCtx* wuctxt = (WasmUtilCtx*)uc;
|
||||
Globals* globals = (Globals*)wuctxt->closure;
|
||||
Globals* globals = wuctxt->closure;
|
||||
main_pickBlank( globals, playerNum, col, row, tileFaces, nTiles );
|
||||
}
|
||||
|
||||
|
@ -327,7 +327,7 @@ wasm_util_informMove( XW_UtilCtxt* uc, XWEnv xwe, XP_S16 turn,
|
|||
buf[len] = '\0';
|
||||
|
||||
WasmUtilCtx* wuctxt = (WasmUtilCtx*)uc;
|
||||
Globals* globals = (Globals*)wuctxt->closure;
|
||||
Globals* globals = wuctxt->closure;
|
||||
main_alert( globals, buf );
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,7 @@ static void
|
|||
wasm_util_notifyGameOver( XW_UtilCtxt* uc, XWEnv xwe, XP_S16 quitter )
|
||||
{
|
||||
WasmUtilCtx* wuctxt = (WasmUtilCtx*)uc;
|
||||
Globals* globals = (Globals*)wuctxt->closure;
|
||||
Globals* globals = wuctxt->closure;
|
||||
main_showGameOver( globals );
|
||||
}
|
||||
|
||||
|
@ -368,7 +368,7 @@ wasm_util_setTimer( XW_UtilCtxt* uc, XWEnv xwe, XWTimerReason why, XP_U16 when,
|
|||
{
|
||||
XP_LOGFF( "(why: %d)", why );
|
||||
WasmUtilCtx* wuctxt = (WasmUtilCtx*)uc;
|
||||
Globals* globals = (Globals*)wuctxt->closure;
|
||||
Globals* globals = wuctxt->closure;
|
||||
main_set_timer( globals, why, when, proc, closure );
|
||||
LOG_RETURN_VOID();
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ wasm_util_clearTimer( XW_UtilCtxt* uc, XWEnv xwe, XWTimerReason why )
|
|||
{
|
||||
LOG_FUNC();
|
||||
WasmUtilCtx* wuctxt = (WasmUtilCtx*)uc;
|
||||
Globals* globals = (Globals*)wuctxt->closure;
|
||||
Globals* globals = wuctxt->closure;
|
||||
main_clear_timer( globals, why );
|
||||
}
|
||||
|
||||
|
@ -386,7 +386,7 @@ static XP_Bool
|
|||
on_idle( void* closure )
|
||||
{
|
||||
WasmUtilCtx* wuctxt = (WasmUtilCtx*)closure;
|
||||
Globals* globals = (Globals*)wuctxt->closure;
|
||||
Globals* globals = wuctxt->closure;
|
||||
return server_do( globals->gs.game.server, NULL );
|
||||
}
|
||||
|
||||
|
@ -394,7 +394,7 @@ static void
|
|||
wasm_util_requestTime( XW_UtilCtxt* uc, XWEnv xwe )
|
||||
{
|
||||
WasmUtilCtx* wuctxt = (WasmUtilCtx*)uc;
|
||||
Globals* globals = (Globals*)wuctxt->closure;
|
||||
Globals* globals = wuctxt->closure;
|
||||
main_set_idle( globals, on_idle, wuctxt );
|
||||
}
|
||||
|
||||
|
@ -433,7 +433,7 @@ wasm_util_notifyIllegalWords( XW_UtilCtxt* uc, XWEnv xwe, BadWordInfo* bwi,
|
|||
"dictionary (%s). Use anyway?", words, bwi->dictName );
|
||||
|
||||
WasmUtilCtx* wuctxt = (WasmUtilCtx*)uc;
|
||||
Globals* globals = (Globals*)wuctxt->closure;
|
||||
Globals* globals = wuctxt->closure;
|
||||
main_query( globals, buf, query_proc_notifyMove, uc );
|
||||
}
|
||||
|
||||
|
@ -441,7 +441,7 @@ static void
|
|||
wasm_util_remSelected( XW_UtilCtxt* uc, XWEnv xwe )
|
||||
{
|
||||
WasmUtilCtx* wuctxt = (WasmUtilCtx*)uc;
|
||||
Globals* globals = (Globals*)wuctxt->closure;
|
||||
Globals* globals = wuctxt->closure;
|
||||
main_showRemaining( globals );
|
||||
}
|
||||
|
||||
|
@ -471,7 +471,7 @@ static void
|
|||
wasm_util_playerScoreHeld( XW_UtilCtxt* uc, XWEnv xwe, XP_U16 player )
|
||||
{
|
||||
WasmUtilCtx* wuctxt = (WasmUtilCtx*)uc;
|
||||
Globals* globals = (Globals*)wuctxt->closure;
|
||||
Globals* globals = wuctxt->closure;
|
||||
main_playerScoreHeld( globals, player );
|
||||
}
|
||||
|
||||
|
@ -529,7 +529,7 @@ wasm_util_getDevUtilCtxt( XW_UtilCtxt* uc, XWEnv xwe )
|
|||
}
|
||||
|
||||
XW_UtilCtxt*
|
||||
wasm_util_make( MPFORMAL CurGameInfo* gi, XW_DUtilCtxt* dctxt, void* closure )
|
||||
wasm_util_make( MPFORMAL CurGameInfo* gi, XW_DUtilCtxt* dctxt, Globals* closure )
|
||||
{
|
||||
LOG_FUNC();
|
||||
WasmUtilCtx* wuctxt = XP_MALLOC( mpool, sizeof(*wuctxt) );
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "dutil.h"
|
||||
|
||||
XW_UtilCtxt* wasm_util_make( MPFORMAL CurGameInfo* gi, XW_DUtilCtxt* dutil,
|
||||
void* closure );
|
||||
Globals* closure );
|
||||
void wasm_util_destroy( XW_UtilCtxt* util );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -87,6 +87,15 @@ function mqttSend( topic, ptr ) {
|
|||
return canSend;
|
||||
}
|
||||
|
||||
function addDepthNote(dlg) {
|
||||
let depth = dlg.parentNode.childElementCount;
|
||||
if ( depth > 1 ) {
|
||||
let div = document.createElement('div');
|
||||
div.textContent = '(Depth: ' + depth + ')';
|
||||
dlg.appendChild(div);
|
||||
}
|
||||
}
|
||||
|
||||
function newDlgWMsg(msg) {
|
||||
let container = document.getElementById('nbalert');
|
||||
|
||||
|
@ -124,6 +133,7 @@ function nbDialog(msg, buttons, proc, closure) {
|
|||
dlg.parentNode.removeChild(dlg);
|
||||
}
|
||||
dlg.appendChild( newButtonDiv( buttons, butProc ) );
|
||||
addDepthNote(dlg);
|
||||
}
|
||||
|
||||
function nbBlankPick(title, buttons, proc, closure) {
|
||||
|
@ -139,6 +149,7 @@ function nbBlankPick(title, buttons, proc, closure) {
|
|||
for (ii = 0; ii < buttons.length; ii += ROWLEN) {
|
||||
dlg.appendChild( newButtonDiv( buttons.slice(ii, ii + ROWLEN), butProc ) );
|
||||
}
|
||||
addDepthNote(dlg);
|
||||
}
|
||||
|
||||
function nbGamePick(title, gameMap, proc, closure) {
|
||||
|
@ -159,6 +170,7 @@ function nbGamePick(title, gameMap, proc, closure) {
|
|||
}
|
||||
|
||||
dlg.appendChild( newButtonDiv( buttons, butProc ) );
|
||||
addDepthNote(dlg);
|
||||
}
|
||||
|
||||
function setDivButtons(divid, buttons, proc, closure) {
|
||||
|
@ -198,6 +210,7 @@ function nbGetString(msg, dflt, proc, closure) {
|
|||
}
|
||||
}
|
||||
dlg.appendChild( newButtonDiv( buttons, butProc ) );
|
||||
addDepthNote(dlg);
|
||||
}
|
||||
|
||||
function newRadio(txt, id, proc) {
|
||||
|
@ -238,6 +251,7 @@ function nbGetNewGame(closure, msg) {
|
|||
}
|
||||
|
||||
dlg.appendChild( newButtonDiv( ['Cancel', 'OK'], butProc ) );
|
||||
addDepthNote(dlg);
|
||||
}
|
||||
|
||||
for ( let one of ['paho-mqtt.js'] ) {
|
||||
|
|
Loading…
Reference in a new issue