mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
Put game name in title bar on launch as well as after opening saved
game. Clear when opening unnamed/defaultnamed game
This commit is contained in:
parent
37af03cae3
commit
536de24e1d
1 changed files with 27 additions and 18 deletions
|
@ -155,6 +155,7 @@ static XP_Bool ceSetDictName( const wchar_t* wPath, XP_U16 index, void* ctxt );
|
||||||
static int messageBoxStream( CEAppGlobals* globals, XWStreamCtxt* stream,
|
static int messageBoxStream( CEAppGlobals* globals, XWStreamCtxt* stream,
|
||||||
wchar_t* title, XP_U16 buttons );
|
wchar_t* title, XP_U16 buttons );
|
||||||
static XP_Bool ceQueryFromStream( CEAppGlobals* globals, XWStreamCtxt* stream);
|
static XP_Bool ceQueryFromStream( CEAppGlobals* globals, XWStreamCtxt* stream);
|
||||||
|
static XP_Bool isDefaultName( const XP_UCHAR* name );
|
||||||
|
|
||||||
|
|
||||||
#if defined DEBUG && ! defined _WIN32_WCE
|
#if defined DEBUG && ! defined _WIN32_WCE
|
||||||
|
@ -629,19 +630,24 @@ ceSetTitleFromName( CEAppGlobals* globals )
|
||||||
wchar_t widebuf[256];
|
wchar_t widebuf[256];
|
||||||
wchar_t* colonPos;
|
wchar_t* colonPos;
|
||||||
XP_UCHAR* baseStart;
|
XP_UCHAR* baseStart;
|
||||||
XP_UCHAR* gameName;
|
const XP_UCHAR* gameName = globals->curGameName;
|
||||||
|
|
||||||
XP_U16 len = (XP_U16)SendMessage( globals->hWnd, WM_GETTEXT,
|
XP_U16 len = (XP_U16)SendMessage( globals->hWnd, WM_GETTEXT,
|
||||||
sizeof(widebuf), (long)widebuf );
|
sizeof(widebuf), (long)widebuf );
|
||||||
colonPos = wcsstr( widebuf, L":" );
|
colonPos = wcsstr( widebuf, L":" );
|
||||||
|
|
||||||
|
/* if default name, remove any current name */
|
||||||
|
if ( !gameName || isDefaultName( gameName ) ) {
|
||||||
|
if ( NULL != colonPos ) {
|
||||||
|
*colonPos = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if ( colonPos == NULL ) {
|
if ( colonPos == NULL ) {
|
||||||
wcscat( widebuf, L":" );
|
wcscat( widebuf, L":" );
|
||||||
colonPos = widebuf + len; /* we'll write at the end */
|
colonPos = widebuf + len; /* we'll write at the end */
|
||||||
}
|
}
|
||||||
++colonPos; /* skip the colon */
|
++colonPos; /* skip the colon */
|
||||||
|
|
||||||
gameName = globals->curGameName;
|
|
||||||
baseStart = strrchr( gameName, '\\' );
|
baseStart = strrchr( gameName, '\\' );
|
||||||
++baseStart;
|
++baseStart;
|
||||||
len = (XP_U16)XP_STRLEN( baseStart );
|
len = (XP_U16)XP_STRLEN( baseStart );
|
||||||
|
@ -654,6 +660,7 @@ ceSetTitleFromName( CEAppGlobals* globals )
|
||||||
if ( colonPos != NULL ) {
|
if ( colonPos != NULL ) {
|
||||||
*colonPos = 0;
|
*colonPos = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SendMessage( globals->hWnd, WM_SETTEXT, 0, (long)widebuf );
|
SendMessage( globals->hWnd, WM_SETTEXT, 0, (long)widebuf );
|
||||||
} /* ceSetTitleFromName */
|
} /* ceSetTitleFromName */
|
||||||
|
@ -996,6 +1003,8 @@ ceLoadSavedGame( CEAppGlobals* globals )
|
||||||
}
|
}
|
||||||
|
|
||||||
stream_destroy( stream );
|
stream_destroy( stream );
|
||||||
|
|
||||||
|
ceSetTitleFromName( globals );
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
@ -1474,6 +1483,7 @@ ceDoNewGame( CEAppGlobals* globals )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ceInitAndStartBoard( globals, XP_TRUE, addr );
|
ceInitAndStartBoard( globals, XP_TRUE, addr );
|
||||||
|
ceSetTitleFromName( globals );
|
||||||
changed = XP_TRUE;
|
changed = XP_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1509,7 +1519,6 @@ ceChooseAndOpen( CEAppGlobals* globals )
|
||||||
globals->curGameName = name;
|
globals->curGameName = name;
|
||||||
if ( ceLoadSavedGame( globals ) ) {
|
if ( ceLoadSavedGame( globals ) ) {
|
||||||
ceInitAndStartBoard( globals, XP_FALSE, NULL );
|
ceInitAndStartBoard( globals, XP_FALSE, NULL );
|
||||||
ceSetTitleFromName( globals );
|
|
||||||
} else {
|
} else {
|
||||||
XP_LOGF( "failed to open chosen game" );
|
XP_LOGF( "failed to open chosen game" );
|
||||||
}
|
}
|
||||||
|
@ -1593,7 +1602,7 @@ ceWriteToFile( XWStreamCtxt* stream, void* closure )
|
||||||
} /* ceWriteToFile */
|
} /* ceWriteToFile */
|
||||||
|
|
||||||
static XP_Bool
|
static XP_Bool
|
||||||
isDefaultName( XP_UCHAR* name )
|
isDefaultName( const XP_UCHAR* name )
|
||||||
{
|
{
|
||||||
return 0 == XP_STRCMP( UNSAVEDGAMEFILENAME, name );
|
return 0 == XP_STRCMP( UNSAVEDGAMEFILENAME, name );
|
||||||
} /* isDefaultName */
|
} /* isDefaultName */
|
||||||
|
|
Loading…
Reference in a new issue