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
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_OBJ = $(OBJDIR$)/$(patsubst %.rc,%.rc.o,$(notdir $(BASE_LANG_SRC)))
#DLLS = $(patsubst %.rc,%.dll,$(addprefix $(OBJDIR)/l10n/,$(notdir $(DLL_SRCS))))
DLLS = \
$(BUILTDIR)/xwords4_french.dll \
$(BUILTDIR)/xwords4_caps.dll \
$(BUILTDIR)/xwords4_polish.dll \
$(BUILTDIR)/xwords4_english.dll \
# filter out the one we're building in. Can always build it as .dll
# manually...
DLLS = $(patsubst %.rc,$(BUILTDIR)/%.dll,\
$(notdir $(patsubst ./$(BASE_LANG_SRC),,$(DLL_SRCS))))
WINCESRC = \
ceaskpwd.c \
@ -181,6 +183,11 @@ WINCEICONS = bmps/xwords4_ico_16x16.png \
bmps/xwords4_ico_22x22.png \
bmps/xwords4_ico_32x32.png \
BMPS = bmps/rightarrow.bmp \
bmps/downarro.bmp \
bmps/origin.bmp \
bmps/netarrow.bmp
include ../common/config.mk
COMMONOBJ = $(addprefix $(OBJDIR)/,$(patsubst %.c,%.o,$(notdir $(COMMONSRC))))
@ -229,7 +236,7 @@ $(OBJDIR)/%.o : ../common/%.c $(INCLUDES)
mkdir -p $(dir $@)
$(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 $@ $<
$(OBJDIR)/l10n/%.rc.o : l10n/%.rc $(WINCE_INCLUDES)
@ -247,6 +254,9 @@ $(BUILTDIR)/%.dll: $(OBJDIR)/l10n/%.rc.o
$(CC) -shared -o $@ $<
$(STRIP) $@
bmps/netarrow.bmp: bmps/netarrow.pgm
ppmtobmp $< > $@
# 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
# out how to script GIMP and replace the below.
@ -269,7 +279,7 @@ test:
echo $(COMMONOBJ)
clean :
rm -rf $(OBJDIR) $(TARGET)
rm -rf $(OBJDIR) $(TARGET) bmps/netarrow.bmp
help:
@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 downArrow;
HBITMAP origin;
#ifndef XWFEATURE_STANDALONE_ONLY
HBITMAP netStatus[4];
#ifdef XWFEATURE_RELAY
HBITMAP netArrow;
#endif
XP_U16 trayOwner;
XP_U16 miniLineHt;
@ -1379,14 +1379,18 @@ DRAW_FUNC_NAME(scoreBegin)( DrawCtx* p_dctx, const XP_Rect* xprect,
DrawFocusState XP_UNUSED(dfs) )
{
CEDrawCtx* dctx = (CEDrawCtx*)p_dctx;
CEAppGlobals* globals = dctx->globals;
XP_ASSERT( !!globals->hdc );
ceSetBkColor( globals->hdc, dctx, CE_BKG_COLOR );
RECT rt;
HDC hdc = dctx->globals->hdc;
XP_ASSERT( !!hdc );
ceSetBkColor( hdc, dctx, CE_BKG_COLOR );
dctx->scoreIsVertical = xprect->height > xprect->width;
/* I don't think the clip rect's set at this point but drawing seems fine
anyway.... ceClearToBkground() is definitely needed here. */
XPRtoRECT( &rt, xprect );
ceClipToRect( hdc, &rt );
ceClearToBkground( (CEDrawCtx*)p_dctx, xprect );
} /* ce_draw_scoreBegin */
@ -1798,10 +1802,8 @@ DRAW_FUNC_NAME(destroyCtxt)( DrawCtx* p_dctx )
DeleteObject( dctx->downArrow );
DeleteObject( dctx->origin );
#ifdef XWFEATURE_STANDALONE_ONLY
for ( ii = 0; ii < VSIZE(dctx->status); ++ii ) {
DeleteObject( dctx->netStatusii] );
}
#ifdef XWFEATURE_RELAY
DeleteObject( dctx->netArrow );
#endif
#ifndef DRAW_LINK_DIRECT
@ -1916,13 +1918,45 @@ void
ce_draw_status( CEDrawCtx* dctx, const RECT* rect, CeNetState state )
{
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 );
XP_ASSERT( state < VSIZE(dctx->netStatus) );
ceDrawBitmapInRect( globals->hdc, &localR, dctx->netStatus[state],
XP_TRUE );
/* static int count = 0; */
/* 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
@ -1991,12 +2025,9 @@ ce_drawctxt_make( MPFORMAL HWND mainWin, CEAppGlobals* globals )
dctx->origin = LoadBitmap( globals->hInst,
MAKEINTRESOURCE(IDB_ORIGIN) );
#ifndef XWFEATURE_STANDALONE_ONLY
int ii;
for ( ii = 0; ii < VSIZE(dctx->netStatus); ++ii ) {
dctx->netStatus[ii] = LoadBitmap( globals->hInst,
MAKEINTRESOURCE(IDB_STATUS_0+ii) );
}
#ifdef XWFEATURE_RELAY
dctx->netArrow = LoadBitmap( globals->hInst,
MAKEINTRESOURCE(IDB_NETARROW) );
#endif
return dctx;

View file

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

View file

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

View file

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

View file

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

View file

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