mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-27 09:58:45 +01:00
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.
This commit is contained in:
parent
086d480fe3
commit
98e175965d
9 changed files with 73 additions and 23 deletions
BIN
xwords4/wince/bmps/status0.bmp
Normal file
BIN
xwords4/wince/bmps/status0.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 822 B |
BIN
xwords4/wince/bmps/status1.bmp
Normal file
BIN
xwords4/wince/bmps/status1.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 822 B |
BIN
xwords4/wince/bmps/status2.bmp
Normal file
BIN
xwords4/wince/bmps/status2.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 822 B |
BIN
xwords4/wince/bmps/status3.bmp
Normal file
BIN
xwords4/wince/bmps/status3.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 822 B |
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue