Replace four bitmaps with one drawn on top of background of green and

red based on connection progress.  Store the bitmap as a pgm, and
generate the .bmp from it at build time.
This commit is contained in:
ehouse 2009-09-24 04:26:28 +00:00
parent ef8c85734e
commit 91ccf3bac5
12 changed files with 112 additions and 56 deletions

View file

@ -142,17 +142,19 @@ endif
BUILTDIR=$(OBJDIR)/built BUILTDIR=$(OBJDIR)/built
TARGET = $(BUILTDIR)/xwords4_$(SVNREV).exe TARGET = $(BUILTDIR)/xwords4_$(SVNREV).exe
DLL_SRCS = $(shell ls ./l10n/*.rc) DLL_SRCS = \
./l10n/xwords4_french.rc \
./l10n/xwords4_caps.rc \
./l10n/xwords4_polish.rc \
./l10n/xwords4_english.rc \
BASE_LANG_SRC = l10n/xwords4_english.rc BASE_LANG_SRC = l10n/xwords4_english.rc
BASE_LANG_OBJ = $(OBJDIR$)/$(patsubst %.rc,%.rc.o,$(notdir $(BASE_LANG_SRC))) BASE_LANG_OBJ = $(OBJDIR$)/$(patsubst %.rc,%.rc.o,$(notdir $(BASE_LANG_SRC)))
#DLLS = $(patsubst %.rc,%.dll,$(addprefix $(OBJDIR)/l10n/,$(notdir $(DLL_SRCS)))) # filter out the one we're building in. Can always build it as .dll
DLLS = \ # manually...
$(BUILTDIR)/xwords4_french.dll \ DLLS = $(patsubst %.rc,$(BUILTDIR)/%.dll,\
$(BUILTDIR)/xwords4_caps.dll \ $(notdir $(patsubst ./$(BASE_LANG_SRC),,$(DLL_SRCS))))
$(BUILTDIR)/xwords4_polish.dll \
$(BUILTDIR)/xwords4_english.dll \
WINCESRC = \ WINCESRC = \
ceaskpwd.c \ ceaskpwd.c \
@ -181,6 +183,11 @@ WINCEICONS = bmps/xwords4_ico_16x16.png \
bmps/xwords4_ico_22x22.png \ bmps/xwords4_ico_22x22.png \
bmps/xwords4_ico_32x32.png \ bmps/xwords4_ico_32x32.png \
BMPS = bmps/rightarrow.bmp \
bmps/downarro.bmp \
bmps/origin.bmp \
bmps/netarrow.bmp
include ../common/config.mk include ../common/config.mk
COMMONOBJ = $(addprefix $(OBJDIR)/,$(patsubst %.c,%.o,$(notdir $(COMMONSRC)))) COMMONOBJ = $(addprefix $(OBJDIR)/,$(patsubst %.c,%.o,$(notdir $(COMMONSRC))))
@ -229,7 +236,7 @@ $(OBJDIR)/%.o : ../common/%.c $(INCLUDES)
mkdir -p $(dir $@) mkdir -p $(dir $@)
$(CC) -c $(CFLAGS) -o $@ $< $(CC) -c $(CFLAGS) -o $@ $<
$(BASE_LANG_OBJ) : $(BASE_LANG_SRC) $(INCLUDES) xwords4.ico $(BASE_LANG_OBJ) : $(BASE_LANG_SRC) $(INCLUDES) xwords4.ico common_rsrc.rc $(BMPS)
$(WINDRES) -v $(MINGW_INC_PATH) $(RESFLAGS) -DAM_BASE_LANGUAGE -o $@ $< $(WINDRES) -v $(MINGW_INC_PATH) $(RESFLAGS) -DAM_BASE_LANGUAGE -o $@ $<
$(OBJDIR)/l10n/%.rc.o : l10n/%.rc $(WINCE_INCLUDES) $(OBJDIR)/l10n/%.rc.o : l10n/%.rc $(WINCE_INCLUDES)
@ -247,6 +254,9 @@ $(BUILTDIR)/%.dll: $(OBJDIR)/l10n/%.rc.o
$(CC) -shared -o $@ $< $(CC) -shared -o $@ $<
$(STRIP) $@ $(STRIP) $@
bmps/netarrow.bmp: bmps/netarrow.pgm
ppmtobmp $< > $@
# Checking in xwords4.ico for now. Hand-built using GIMP and layers # Checking in xwords4.ico for now. Hand-built using GIMP and layers
# it's 1/4 the size (because it has only two colors). Should figure # it's 1/4 the size (because it has only two colors). Should figure
# out how to script GIMP and replace the below. # out how to script GIMP and replace the below.
@ -269,7 +279,7 @@ test:
echo $(COMMONOBJ) echo $(COMMONOBJ)
clean : clean :
rm -rf $(OBJDIR) $(TARGET) rm -rf $(OBJDIR) $(TARGET) bmps/netarrow.bmp
help: help:
@echo "try 'make TARGET_OS=wince [DEBUG=TRUE]'" @echo "try 'make TARGET_OS=wince [DEBUG=TRUE]'"

View file

@ -0,0 +1,19 @@
P2
16 16
1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 822 B

View file

@ -116,8 +116,8 @@ struct CEDrawCtx {
HBITMAP rightArrow; HBITMAP rightArrow;
HBITMAP downArrow; HBITMAP downArrow;
HBITMAP origin; HBITMAP origin;
#ifndef XWFEATURE_STANDALONE_ONLY #ifdef XWFEATURE_RELAY
HBITMAP netStatus[4]; HBITMAP netArrow;
#endif #endif
XP_U16 trayOwner; XP_U16 trayOwner;
XP_U16 miniLineHt; XP_U16 miniLineHt;
@ -1379,14 +1379,18 @@ DRAW_FUNC_NAME(scoreBegin)( DrawCtx* p_dctx, const XP_Rect* xprect,
DrawFocusState XP_UNUSED(dfs) ) DrawFocusState XP_UNUSED(dfs) )
{ {
CEDrawCtx* dctx = (CEDrawCtx*)p_dctx; CEDrawCtx* dctx = (CEDrawCtx*)p_dctx;
CEAppGlobals* globals = dctx->globals; RECT rt;
XP_ASSERT( !!globals->hdc ); HDC hdc = dctx->globals->hdc;
ceSetBkColor( globals->hdc, dctx, CE_BKG_COLOR );
XP_ASSERT( !!hdc );
ceSetBkColor( hdc, dctx, CE_BKG_COLOR );
dctx->scoreIsVertical = xprect->height > xprect->width; dctx->scoreIsVertical = xprect->height > xprect->width;
/* I don't think the clip rect's set at this point but drawing seems fine /* I don't think the clip rect's set at this point but drawing seems fine
anyway.... ceClearToBkground() is definitely needed here. */ anyway.... ceClearToBkground() is definitely needed here. */
XPRtoRECT( &rt, xprect );
ceClipToRect( hdc, &rt );
ceClearToBkground( (CEDrawCtx*)p_dctx, xprect ); ceClearToBkground( (CEDrawCtx*)p_dctx, xprect );
} /* ce_draw_scoreBegin */ } /* ce_draw_scoreBegin */
@ -1798,10 +1802,8 @@ DRAW_FUNC_NAME(destroyCtxt)( DrawCtx* p_dctx )
DeleteObject( dctx->downArrow ); DeleteObject( dctx->downArrow );
DeleteObject( dctx->origin ); DeleteObject( dctx->origin );
#ifdef XWFEATURE_STANDALONE_ONLY #ifdef XWFEATURE_RELAY
for ( ii = 0; ii < VSIZE(dctx->status); ++ii ) { DeleteObject( dctx->netArrow );
DeleteObject( dctx->netStatusii] );
}
#endif #endif
#ifndef DRAW_LINK_DIRECT #ifndef DRAW_LINK_DIRECT
@ -1916,13 +1918,45 @@ void
ce_draw_status( CEDrawCtx* dctx, const RECT* rect, CeNetState state ) ce_draw_status( CEDrawCtx* dctx, const RECT* rect, CeNetState state )
{ {
RECT localR = *rect; RECT localR = *rect;
CEAppGlobals* globals = dctx->globals; XP_U16 share;
HDC hdc = dctx->globals->hdc;
XP_Bool hasRed;
FillRect( globals->hdc, rect, dctx->brushes[CE_BKG_COLOR] ); FillRect( hdc, &localR, dctx->brushes[CE_BKG_COLOR] );
InsetRect( &localR, 1, 1 ); InsetRect( &localR, 1, 1 );
XP_ASSERT( state < VSIZE(dctx->netStatus) );
ceDrawBitmapInRect( globals->hdc, &localR, dctx->netStatus[state], /* static int count = 0; */
XP_TRUE ); /* state = count++ % CENSTATE_NSTATES; */
hasRed = state < (CENSTATE_NSTATES - 1);
/* First state is all-red. Last is all-green. In between we have red on
the right, green on the left. */
share = localR.right - localR.left;
if ( hasRed ) {
ceSetTextColor( hdc, dctx, CE_BKG_COLOR );
share /= CENSTATE_NSTATES-1;
share *= state;
} else {
ceSetTextColor( hdc, dctx, CE_BLACK_COLOR );
}
if ( share > 0 ) {
XP_U16 oldRight = localR.right;
localR.right = localR.left + share;
ceClipToRect( hdc, &localR );
ceSetBkColor( hdc, dctx, CE_PLAYER3_COLOR );
ceDrawBitmapInRect( hdc, rect, dctx->netArrow, XP_TRUE );
localR.right = oldRight;
}
if ( hasRed ) {
localR.left += share;
ceClipToRect( hdc, &localR );
ceSetBkColor( hdc, dctx, CE_PLAYER1_COLOR );
ceDrawBitmapInRect( hdc, rect, dctx->netArrow, XP_TRUE );
}
} }
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
@ -1991,12 +2025,9 @@ ce_drawctxt_make( MPFORMAL HWND mainWin, CEAppGlobals* globals )
dctx->origin = LoadBitmap( globals->hInst, dctx->origin = LoadBitmap( globals->hInst,
MAKEINTRESOURCE(IDB_ORIGIN) ); MAKEINTRESOURCE(IDB_ORIGIN) );
#ifndef XWFEATURE_STANDALONE_ONLY #ifdef XWFEATURE_RELAY
int ii; dctx->netArrow = LoadBitmap( globals->hInst,
for ( ii = 0; ii < VSIZE(dctx->netStatus); ++ii ) { MAKEINTRESOURCE(IDB_NETARROW) );
dctx->netStatus[ii] = LoadBitmap( globals->hInst,
MAKEINTRESOURCE(IDB_STATUS_0+ii) );
}
#endif #endif
return dctx; return dctx;

View file

@ -30,6 +30,8 @@ typedef enum {
,CENSTATE_TRYING_RELAY ,CENSTATE_TRYING_RELAY
,CENSTATE_HAVE_RELAY ,CENSTATE_HAVE_RELAY
,CENSTATE_ALL_HERE ,CENSTATE_ALL_HERE
,CENSTATE_NSTATES
} CeNetState; } CeNetState;
CEDrawCtx* ce_drawctxt_make( MPFORMAL HWND mainWin, CEAppGlobals* globals ); CEDrawCtx* ce_drawctxt_make( MPFORMAL HWND mainWin, CEAppGlobals* globals );

View file

@ -779,7 +779,7 @@ cePositionBoard( CEAppGlobals* globals )
figureBoardParms( globals, nCols, &bparms ); figureBoardParms( globals, nCols, &bparms );
setOwnedRects( globals, nCols, &bparms ); setOwnedRects( globals, nCols, &bparms );
#ifndef XWFEATURE_STANDALONE_ONLY #ifdef XWFEATURE_RELAY
if ( !!globals->game.comms ) { if ( !!globals->game.comms ) {
globals->relayStatusR.left = bparms.adjLeft + bparms.netstatLeft; globals->relayStatusR.left = bparms.adjLeft + bparms.netstatLeft;
globals->relayStatusR.top = bparms.adjTop + bparms.netstatTop; globals->relayStatusR.top = bparms.adjTop + bparms.netstatTop;
@ -1659,9 +1659,9 @@ ceFlattenState( const CEAppGlobals* globals )
} else { } else {
switch( socketState ) { switch( socketState ) {
case CE_IPST_START: case CE_IPST_START:
case CE_IPST_RESOLVINGHOST:
/* state = CENSTATE_NONE; */ /* state = CENSTATE_NONE; */
break; break;
case CE_IPST_RESOLVINGHOST:
case CE_IPST_HOSTRESOLVED: case CE_IPST_HOSTRESOLVED:
case CE_IPST_CONNECTING: case CE_IPST_CONNECTING:
case CE_IPST_CONNECTED: case CE_IPST_CONNECTED:
@ -1695,7 +1695,7 @@ drawInsidePaint( CEAppGlobals* globals, const RECT* invalR )
} }
} }
#ifndef XWFEATURE_STANDALONE_ONLY #ifdef XWFEATURE_RELAY
if ( IntersectRect( &interR, invalR, &globals->relayStatusR ) ) { if ( IntersectRect( &interR, invalR, &globals->relayStatusR ) ) {
CeNetState state = ceFlattenState( globals ); CeNetState state = ceFlattenState( globals );
ce_draw_status( globals->draw, &globals->relayStatusR, state ); ce_draw_status( globals->draw, &globals->relayStatusR, state );

View file

@ -173,7 +173,7 @@ typedef struct _CEAppGlobals {
XP_Bool hintPending; XP_Bool hintPending;
XP_Bool doGlobalPrefs; XP_Bool doGlobalPrefs;
#ifndef XWFEATURE_STANDALONE_ONLY #ifdef XWFEATURE_RELAY
CommsRelayState relayState; CommsRelayState relayState;
CeConnState socketState; CeConnState socketState;
RECT relayStatusR; RECT relayStatusR;

View file

@ -18,11 +18,8 @@ IDB_RIGHTARROW BITMAP DISCARDABLE "bmps/rightarrow.bmp"
IDB_DOWNARROW BITMAP DISCARDABLE "bmps/downarro.bmp" IDB_DOWNARROW BITMAP DISCARDABLE "bmps/downarro.bmp"
IDB_ORIGIN BITMAP DISCARDABLE "bmps/origin.bmp" IDB_ORIGIN BITMAP DISCARDABLE "bmps/origin.bmp"
#ifndef XWFEATURE_STANDALONE_ONLY #ifdef XWFEATURE_RELAY
IDB_STATUS_0 BITMAP DISCARDABLE "bmps/status0.bmp" IDB_NETARROW BITMAP DISCARDABLE "bmps/netarrow.bmp"
IDB_STATUS_1 BITMAP DISCARDABLE "bmps/status1.bmp"
IDB_STATUS_2 BITMAP DISCARDABLE "bmps/status2.bmp"
IDB_STATUS_3 BITMAP DISCARDABLE "bmps/status3.bmp"
#endif #endif
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -32,19 +29,19 @@ IDB_STATUS_3 BITMAP DISCARDABLE "bmps/status3.bmp"
ID_COLORS_RES CLRS MOVEABLE PURE ID_COLORS_RES CLRS MOVEABLE PURE
BEGIN BEGIN
0xAF, 0xAF, 0x00, /* bonus 1 */ 0xAF, 0xAF, 0x00 /* bonus 1 */
0x00, 0xAF, 0xAF, ,0x00, 0xAF, 0xAF
0xAF, 0x00, 0xAF, ,0xAF, 0x00, 0xAF
0xAF, 0xAF, 0xAF, ,0xAF, 0xAF, 0xAF
0xFF, 0xFF, 0xFF, /* empty cells/CE_BKG_COLOR */ ,0xFF, 0xFF, 0xFF /* empty cells/CE_BKG_COLOR */
0xFF, 0xFF, 0x99, /* tile background */ ,0xFF, 0xFF, 0x99 /* tile background */
0x70, 0x70, 0xFF, /* focus */ ,0x70, 0x70, 0xFF /* focus */
0x00, 0x00, 0x00, /* player 1 */ ,0x00, 0x00, 0x00 /* player 1 */
0xFF, 0x00, 0x00, ,0xFF, 0x00, 0x00
0x00, 0x00, 0xFF, ,0x00, 0x00, 0xFF
0x00, 0x8F, 0x00, /* 8F: full-green contrasts badly with background */ ,0x00, 0x8F, 0x00 /* 8F: full-green contrasts badly with background */
0x00, 0x00, 0x00, /* black */ ,0x00, 0x00, 0x00 /* black */
0xFF, 0xFF, 0xFF /* white */ ,0xFF, 0xFF, 0xFF /* white */
END END
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////

View file

@ -41,11 +41,8 @@
#endif #endif
#define IDD_LOCALESDLG 128 #define IDD_LOCALESDLG 128
#ifndef XWFEATURE_STANDALONE_ONLY #ifdef XWFEATURE_RELAY
# define IDB_STATUS_0 129 # define IDB_NETARROW 129
# define IDB_STATUS_1 130
# define IDB_STATUS_2 131
# define IDB_STATUS_3 132
#endif #endif
#define REMOTE_CHECK1 1005 #define REMOTE_CHECK1 1005