mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-06 20:45:54 +01:00
rebase, and handle changed draw api
This commit is contained in:
parent
96829b5478
commit
fddac79dd8
3 changed files with 37 additions and 6 deletions
|
@ -44,9 +44,10 @@ DEFINES += -DPLATFORM_WASM
|
||||||
DEFINES += -DXWFEATURE_CROSSHAIRS
|
DEFINES += -DXWFEATURE_CROSSHAIRS
|
||||||
DEFINES += -DNATIVE_NLI
|
DEFINES += -DNATIVE_NLI
|
||||||
DEFINES += -DDEBUG_REF
|
DEFINES += -DDEBUG_REF
|
||||||
|
DEFINES += -Wno-switch
|
||||||
|
|
||||||
ifeq ($(MEMDEBUG),TRUE)
|
ifeq ($(MEMDEBUG),TRUE)
|
||||||
DEFINES += -DMEM_DEBUG -DDEBUG -O
|
DEFINES += -DMEM_DEBUG -DDEBUG -O0
|
||||||
else
|
else
|
||||||
DEFINES += -O3
|
DEFINES += -O3
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -556,7 +556,8 @@ button( void* closure, const char* msg )
|
||||||
draw = board_redoReplacedTiles( board, NULL )
|
draw = board_redoReplacedTiles( board, NULL )
|
||||||
|| board_replaceTiles( board, NULL );
|
|| board_replaceTiles( board, NULL );
|
||||||
} else if ( 0 == strcmp(msg, "vals") ) {
|
} else if ( 0 == strcmp(msg, "vals") ) {
|
||||||
draw = board_toggle_showValues( board );
|
globals->cp.tvType = (globals->cp.tvType + 1) % TVT_N_ENTRIES;
|
||||||
|
draw = board_prefsChanged( board, &globals->cp );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( draw ) {
|
if ( draw ) {
|
||||||
|
|
|
@ -42,6 +42,7 @@ typedef struct _WasmDrawCtx {
|
||||||
|
|
||||||
int trayOwner;
|
int trayOwner;
|
||||||
XP_Bool inTrade;
|
XP_Bool inTrade;
|
||||||
|
TileValueType tvType;
|
||||||
|
|
||||||
MPSLOT;
|
MPSLOT;
|
||||||
} WasmDrawCtx;
|
} WasmDrawCtx;
|
||||||
|
@ -265,8 +266,10 @@ static XP_Bool
|
||||||
wasm_draw_boardBegin( DrawCtx* dctx, XWEnv xwe,
|
wasm_draw_boardBegin( DrawCtx* dctx, XWEnv xwe,
|
||||||
const XP_Rect* rect,
|
const XP_Rect* rect,
|
||||||
XP_U16 hScale, XP_U16 vScale,
|
XP_U16 hScale, XP_U16 vScale,
|
||||||
DrawFocusState dfs )
|
DrawFocusState dfs, TileValueType tvType )
|
||||||
{
|
{
|
||||||
|
WasmDrawCtx* wdctx = (WasmDrawCtx*)dctx;
|
||||||
|
wdctx->tvType = tvType;
|
||||||
return XP_TRUE;
|
return XP_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,8 +411,7 @@ static XP_Bool
|
||||||
wasm_draw_drawCell( DrawCtx* dctx, XWEnv xwe, const XP_Rect* rect,
|
wasm_draw_drawCell( DrawCtx* dctx, XWEnv xwe, const XP_Rect* rect,
|
||||||
/* at least one of these two will be
|
/* at least one of these two will be
|
||||||
null */
|
null */
|
||||||
const XP_UCHAR* text,
|
const XP_UCHAR* text, const XP_Bitmaps* bitmaps,
|
||||||
const XP_Bitmaps* bitmaps,
|
|
||||||
Tile tile, XP_U16 value,
|
Tile tile, XP_U16 value,
|
||||||
XP_S16 owner, /* -1 means don't use */
|
XP_S16 owner, /* -1 means don't use */
|
||||||
XWBonusType bonus, HintAtts hintAtts,
|
XWBonusType bonus, HintAtts hintAtts,
|
||||||
|
@ -461,7 +463,34 @@ wasm_draw_drawCell( DrawCtx* dctx, XWEnv xwe, const XP_Rect* rect,
|
||||||
textInRect( wdctx, bonusStr, rect, color );
|
textInRect( wdctx, bonusStr, rect, color );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
textInRect( wdctx, text, rect, foreColor );
|
XP_UCHAR valBuf[4];
|
||||||
|
XP_SNPRINTF( valBuf, sizeof(valBuf), "%d", value );
|
||||||
|
const XP_UCHAR* valueStr = valBuf;
|
||||||
|
switch ( wdctx->tvType ) {
|
||||||
|
case TVT_BOTH:
|
||||||
|
break;
|
||||||
|
case TVT_FACES:
|
||||||
|
valueStr = NULL;
|
||||||
|
break;
|
||||||
|
case TVT_VALUES:
|
||||||
|
text = valueStr;
|
||||||
|
valueStr = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
XP_Rect tmpRect = *rect;
|
||||||
|
if ( !!valueStr ) {
|
||||||
|
tmpRect.width = tmpRect.width * 4 / 5;
|
||||||
|
tmpRect.height = tmpRect.height * 4 / 5;
|
||||||
|
}
|
||||||
|
textInRect( wdctx, text, &tmpRect, foreColor );
|
||||||
|
if ( !!valueStr ) {
|
||||||
|
XP_Rect tmpRect = *rect;
|
||||||
|
tmpRect.left += tmpRect.width * 2 / 3;
|
||||||
|
tmpRect.top += tmpRect.height * 2 / 3;
|
||||||
|
tmpRect.width /= 3;
|
||||||
|
tmpRect.height /= 3;
|
||||||
|
textInRect( wdctx, valueStr, &tmpRect, foreColor );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (CELL_ISBLANK & flags) != 0 ) {
|
if ( (CELL_ISBLANK & flags) != 0 ) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue