From 98e175965d0f598bafda30a5acd88b4c78c7e082 Mon Sep 17 00:00:00 2001 From: ehouse Date: Tue, 22 Sep 2009 03:49:26 +0000 Subject: [PATCH] Replace letters as indicators of network status with icons. So far just rects that change from red to green as we connect -- which could be done in less space by painting. --- xwords4/wince/bmps/status0.bmp | Bin 0 -> 822 bytes xwords4/wince/bmps/status1.bmp | Bin 0 -> 822 bytes xwords4/wince/bmps/status2.bmp | Bin 0 -> 822 bytes xwords4/wince/bmps/status3.bmp | Bin 0 -> 822 bytes xwords4/wince/cedraw.c | 30 +++++++++++++++++------ xwords4/wince/cedraw.h | 10 +++++++- xwords4/wince/cemain.c | 42 +++++++++++++++++++++------------ xwords4/wince/common_rsrc.rc | 7 ++++++ xwords4/wince/resource.h | 7 ++++++ 9 files changed, 73 insertions(+), 23 deletions(-) create mode 100644 xwords4/wince/bmps/status0.bmp create mode 100644 xwords4/wince/bmps/status1.bmp create mode 100644 xwords4/wince/bmps/status2.bmp create mode 100644 xwords4/wince/bmps/status3.bmp diff --git a/xwords4/wince/bmps/status0.bmp b/xwords4/wince/bmps/status0.bmp new file mode 100644 index 0000000000000000000000000000000000000000..744afa2cf9b5d51c5157d649984307d9535868c9 GIT binary patch literal 822 ucmZ?rHDhJ~12Z700mK4O%*Y@C7H0s;3v)v-M1X-oQu56x8V!LF8v+3J!XK^x literal 0 HcmV?d00001 diff --git a/xwords4/wince/bmps/status1.bmp b/xwords4/wince/bmps/status1.bmp new file mode 100644 index 0000000000000000000000000000000000000000..0edbb7f8549fc4b61dbd61849d4037620bea7626 GIT binary patch literal 822 zcmZ?rHDhJ~12Z700mK4O%*Y@C7H0s;3v)v-M1X-oeT~$JLXwhiM$u>pz(W84Z(tB! literal 0 HcmV?d00001 diff --git a/xwords4/wince/bmps/status2.bmp b/xwords4/wince/bmps/status2.bmp new file mode 100644 index 0000000000000000000000000000000000000000..63728f7af7eb7b71ee741783850c1a3f2dcb2934 GIT binary patch literal 822 zcmZ?rHDhJ~12Z700mK4O%*Y@C7H0s;3v)v-M1X-oeT~#88Vvz>2uMo48BquTD4YH7 literal 0 HcmV?d00001 diff --git a/xwords4/wince/bmps/status3.bmp b/xwords4/wince/bmps/status3.bmp new file mode 100644 index 0000000000000000000000000000000000000000..df862f212ea1f1127a19f039220f5a0a8dc77e9c GIT binary patch literal 822 ucmZ?rHDhJ~12Z700mK4O%*Y@C7H0s;3v)v-M1X-oeT~#88V!LF8v+113hti( literal 0 HcmV?d00001 diff --git a/xwords4/wince/cedraw.c b/xwords4/wince/cedraw.c index 5b3b6f244..011225a6a 100755 --- a/xwords4/wince/cedraw.c +++ b/xwords4/wince/cedraw.c @@ -116,7 +116,9 @@ struct CEDrawCtx { HBITMAP rightArrow; HBITMAP downArrow; HBITMAP origin; - +#ifndef XWFEATURE_STANDALONE_ONLY + HBITMAP netStatus[4]; +#endif XP_U16 trayOwner; XP_U16 miniLineHt; XP_Bool scoreIsVertical; @@ -1796,6 +1798,12 @@ 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] ); + } +#endif + #ifndef DRAW_LINK_DIRECT XP_FREE( dctx->mpool, p_dctx->vtable ); #endif @@ -1905,16 +1913,16 @@ ce_draw_focus( CEDrawCtx* dctx, const RECT* invalR ) } void -ce_draw_status( CEDrawCtx* dctx, const RECT* rect, wchar_t stateCh ) +ce_draw_status( CEDrawCtx* dctx, const RECT* rect, CeNetState state ) { + RECT localR = *rect; CEAppGlobals* globals = dctx->globals; FillRect( globals->hdc, rect, dctx->brushes[CE_BKG_COLOR] ); - - DrawText( globals->hdc, &stateCh, 1, (RECT*)rect, - dctx->scoreIsVertical? - DT_CENTER | DT_BOTTOM : - DT_VCENTER | DT_RIGHT ); + InsetRect( &localR, 1, 1 ); + XP_ASSERT( state < VSIZE(dctx->netStatus) ); + ceDrawBitmapInRect( globals->hdc, &localR, dctx->netStatus[state], + XP_TRUE ); } #ifndef _WIN32_WCE @@ -1983,6 +1991,14 @@ 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) ); + } +#endif + return dctx; } /* ce_drawctxt_make */ diff --git a/xwords4/wince/cedraw.h b/xwords4/wince/cedraw.h index 170108b22..a169e4114 100644 --- a/xwords4/wince/cedraw.h +++ b/xwords4/wince/cedraw.h @@ -24,11 +24,19 @@ typedef struct CEDrawCtx CEDrawCtx; +/* Should match number of icons */ +typedef enum { + CENSTATE_NONE + ,CENSTATE_TRYING_RELAY + ,CENSTATE_HAVE_RELAY + ,CENSTATE_ALL_HERE +} CeNetState; + CEDrawCtx* ce_drawctxt_make( MPFORMAL HWND mainWin, CEAppGlobals* globals ); void ce_draw_update( CEDrawCtx* dctx ); void ce_draw_erase( CEDrawCtx* dctx, const RECT* invalR ); void ce_draw_focus( CEDrawCtx* dctx, const RECT* invalR ); -void ce_draw_status( CEDrawCtx* dctx, const RECT* invalR, wchar_t stateCh ); +void ce_draw_status( CEDrawCtx* dctx, const RECT* invalR, CeNetState state ); #ifndef _WIN32_WCE HBRUSH ce_draw_getFocusBrush( const CEDrawCtx* dctx ); diff --git a/xwords4/wince/cemain.c b/xwords4/wince/cemain.c index 61b7c1754..1d748268e 100755 --- a/xwords4/wince/cemain.c +++ b/xwords4/wince/cemain.c @@ -1370,6 +1370,8 @@ InitInstance(HINSTANCE hInstance, int nCmdShow // search as we change title to include game name hWnd = FindWindow( szWindowClass, NULL ); if ( hWnd ) { + XP_LOGF( "Looks like I'm running already; " + "calling SetForegroundWindow and exiting" ); SetForegroundWindow( (HWND)((ULONG) hWnd | 0x00000001) ); goto exit; } @@ -1632,33 +1634,43 @@ ceDoHistory( CEAppGlobals* globals ) MB_OK | MB_ICONINFORMATION, XP_TRUE ); } /* ceDoHistory */ -static wchar_t -ceStateChar( const CEAppGlobals* globals ) +static CeNetState +ceFlattenState( const CEAppGlobals* globals ) { /* Idea is to give user a clue how the network connection's coming. Relay only matters if we have a socket open. So use that first. */ CommsRelayState relayState = globals->relayState; CeConnState socketState = globals->socketState; - wchar_t ch = L'A'; /* keep compiler quiet */ + CeNetState state = CENSTATE_NONE; if ( socketState == CE_IPST_CONNECTED ) { switch( relayState ) { - case COMMS_RELAYSTATE_UNCONNECTED: ch = L'D'; break; - case COMMS_RELAYSTATE_CONNECT_PENDING: ch = L'C'; break; - case COMMS_RELAYSTATE_CONNECTED: ch = L'B'; break; - case COMMS_RELAYSTATE_ALLCONNECTED: /*ch = L'A'; */ break; + case COMMS_RELAYSTATE_UNCONNECTED: + case COMMS_RELAYSTATE_CONNECT_PENDING: + state = CENSTATE_TRYING_RELAY; + break; + case COMMS_RELAYSTATE_CONNECTED: + state = CENSTATE_HAVE_RELAY; + break; + case COMMS_RELAYSTATE_ALLCONNECTED: + state = CENSTATE_ALL_HERE; + break; } } else { switch( socketState ) { case CE_IPST_START: - case CE_IPST_RESOLVINGHOST: ch = L'4'; break; - case CE_IPST_HOSTRESOLVED: ch = L'3'; break; - case CE_IPST_CONNECTING: ch = L'2'; break; - case CE_IPST_CONNECTED: ch = L'1'; break; + case CE_IPST_RESOLVINGHOST: +/* state = CENSTATE_NONE; */ + break; + case CE_IPST_HOSTRESOLVED: + case CE_IPST_CONNECTING: + case CE_IPST_CONNECTED: + state = CENSTATE_TRYING_RELAY; + break; } } - return ch; -} + return state; +} /* ceFlattenState */ static void drawInsidePaint( CEAppGlobals* globals, const RECT* invalR ) @@ -1685,8 +1697,8 @@ drawInsidePaint( CEAppGlobals* globals, const RECT* invalR ) #ifndef XWFEATURE_STANDALONE_ONLY if ( IntersectRect( &interR, invalR, &globals->relayStatusR ) ) { - wchar_t ch = ceStateChar( globals ); - ce_draw_status( globals->draw, &globals->relayStatusR, ch ); + CeNetState state = ceFlattenState( globals ); + ce_draw_status( globals->draw, &globals->relayStatusR, state ); } #endif diff --git a/xwords4/wince/common_rsrc.rc b/xwords4/wince/common_rsrc.rc index 41b0bdb66..f14b9109d 100644 --- a/xwords4/wince/common_rsrc.rc +++ b/xwords4/wince/common_rsrc.rc @@ -18,6 +18,13 @@ 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" +#endif + ///////////////////////////////////////////////////////////////////////////// // // CLRS diff --git a/xwords4/wince/resource.h b/xwords4/wince/resource.h index ea0d1da98..2f746ccf8 100755 --- a/xwords4/wince/resource.h +++ b/xwords4/wince/resource.h @@ -41,6 +41,13 @@ #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 +#endif + #define REMOTE_CHECK1 1005 #define NAME_EDIT1 1006 #define ROBOT_CHECK1 1007