Merge branch 'friendly_window_title' of ../gzdoom

This commit is contained in:
Rachael Alexanderson 2017-11-18 00:52:21 -05:00
commit 8bbb462276
4 changed files with 55 additions and 0 deletions

View file

@ -128,6 +128,7 @@ void DrawHUD();
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
extern void I_SetWindowTitle(const char* caption);
extern void ReadStatistics();
extern void M_RestoreMode ();
extern void M_SetDefaultMode ();
@ -164,6 +165,7 @@ EXTERN_CVAR (Bool, lookstrafe)
EXTERN_CVAR (Int, screenblocks)
EXTERN_CVAR (Bool, sv_cheats)
EXTERN_CVAR (Bool, sv_unlimited_pickup)
EXTERN_CVAR (Bool, I_FriendlyWindowTitle)
extern int testingmode;
extern bool setmodeneeded;
@ -2742,6 +2744,9 @@ void D_DoomMain (void)
setmodeneeded = false; // This may be set to true here, but isn't needed for a restart
}
if (I_FriendlyWindowTitle)
I_SetWindowTitle(DoomStartupInfo.Name.GetChars());
D_DoomLoop (); // this only returns if a 'restart' CCMD is given.
//
// Clean up after a restart
@ -2777,6 +2782,10 @@ void D_DoomMain (void)
FS_Close(); // destroy the global FraggleScript.
DeinitMenus();
// delete DoomStartupInfo data
DoomStartupInfo.Name = (const char*)0;
DoomStartupInfo.BkColor = DoomStartupInfo.FgColor = DoomStartupInfo.Type = 0;
GC::FullGC(); // clean up before taking down the object list.
// Delete the reference to the VM functions here which were deleted and will be recreated after the restart.
@ -2896,3 +2905,12 @@ DEFINE_FIELD_X(InputEventData, event_t, data2)
DEFINE_FIELD_X(InputEventData, event_t, data3)
DEFINE_FIELD_X(InputEventData, event_t, x)
DEFINE_FIELD_X(InputEventData, event_t, y)
CUSTOM_CVAR(Bool, I_FriendlyWindowTitle, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE|CVAR_NOINITCALL)
{
if (self)
I_SetWindowTitle(DoomStartupInfo.Name.GetChars());
else
I_SetWindowTitle(NULL);
}

View file

@ -1519,3 +1519,14 @@ void I_SetMainWindowVisible(bool visible)
{
CocoaVideo::SetWindowVisible(visible);
}
// each platform has its own specific version of this function.
void I_SetWindowTitle(const char* title)
{
static NSString* const TITLE_STRING;
if (title)
TITLE_STRING = [NSString stringWithFormat:@"%s", title];
else
TITLE_STRING = [NSString stringWithFormat:@"%s %s", GAMESIG, GetVersionString()];
[m_window setTitle:TITLE_STRING];
}

View file

@ -551,3 +551,16 @@ ADD_STAT (blit)
BlitCycles.TimeMS(), SDLFlipCycles.TimeMS());
return out;
}
// each platform has its own specific version of this function.
void I_SetWindowTitle(const char* caption)
{
if (caption)
SDL_SetWindowTitle(Screen, caption);
else
{
FString default_caption;
default_caption.Format(GAMESIG " %s (%s)", GetVersionString(), GetGitTime());
SDL_SetWindowTitle(Screen, default_caption);
}
}

View file

@ -1360,3 +1360,16 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE nothing, LPSTR cmdline, int n
MainThread = INVALID_HANDLE_VALUE;
return 0;
}
// each platform has its own specific version of this function.
void DFrameBuffer::I_SetWindowTitle(const char* caption)
{
if (caption)
SetWindowText(Window, (LPCTSTR)caption);
else
{
char default_caption[100];
mysnprintf(default_caption, countof(default_caption), "" GAMESIG " %s " X64 " (%s)", GetVersionString(), GetGitTime());
SetWindowText(Window, default_caption);
}
}