mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
Merge remote-tracking branch 'origin/friendly_window_title'
This commit is contained in:
commit
6d43c5cdc6
4 changed files with 84 additions and 3 deletions
|
@ -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, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE|CVAR_NOINITCALL)
|
||||
{
|
||||
if (self)
|
||||
I_SetWindowTitle(DoomStartupInfo.Name.GetChars());
|
||||
else
|
||||
I_SetWindowTitle(NULL);
|
||||
}
|
|
@ -197,9 +197,12 @@ namespace
|
|||
|
||||
@interface CocoaWindow : NSWindow
|
||||
{
|
||||
NSString* m_title;
|
||||
}
|
||||
|
||||
- (BOOL)canBecomeKeyWindow;
|
||||
- (void)setTitle:(NSString*)title;
|
||||
- (void)updateTitle;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -211,6 +214,23 @@ namespace
|
|||
return true;
|
||||
}
|
||||
|
||||
- (void)setTitle:(NSString*)title
|
||||
{
|
||||
m_title = title;
|
||||
|
||||
[self updateTitle];
|
||||
}
|
||||
|
||||
- (void)updateTitle
|
||||
{
|
||||
if (nil == m_title)
|
||||
{
|
||||
m_title = [NSString stringWithFormat:@"%s %s", GAMESIG, GetVersionString()];
|
||||
}
|
||||
|
||||
[super setTitle:m_title];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@ -271,6 +291,7 @@ public:
|
|||
static void UseHiDPI(bool hiDPI);
|
||||
static void SetCursor(NSCursor* cursor);
|
||||
static void SetWindowVisible(bool visible);
|
||||
static void SetWindowTitle(const char* title);
|
||||
|
||||
private:
|
||||
struct ModeIterator
|
||||
|
@ -717,6 +738,16 @@ void CocoaVideo::SetWindowVisible(bool visible)
|
|||
}
|
||||
}
|
||||
|
||||
void CocoaVideo::SetWindowTitle(const char* title)
|
||||
{
|
||||
if (CocoaVideo* const video = GetInstance())
|
||||
{
|
||||
NSString* const nsTitle = nullptr == title ? nil :
|
||||
[NSString stringWithCString:title encoding:NSISOLatin1StringEncoding];
|
||||
[video->m_window setTitle:nsTitle];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CocoaVideo::SetFullscreenMode(const int width, const int height)
|
||||
{
|
||||
|
@ -813,9 +844,7 @@ void CocoaVideo::SetMode(const int width, const int height, const bool fullscree
|
|||
|
||||
[[NSOpenGLContext currentContext] flushBuffer];
|
||||
|
||||
static NSString* const TITLE_STRING =
|
||||
[NSString stringWithFormat:@"%s %s", GAMESIG, GetVersionString()];
|
||||
[m_window setTitle:TITLE_STRING];
|
||||
[m_window updateTitle];
|
||||
|
||||
if (![m_window isKeyWindow])
|
||||
{
|
||||
|
@ -1519,3 +1548,9 @@ void I_SetMainWindowVisible(bool visible)
|
|||
{
|
||||
CocoaVideo::SetWindowVisible(visible);
|
||||
}
|
||||
|
||||
// each platform has its own specific version of this function.
|
||||
void I_SetWindowTitle(const char* title)
|
||||
{
|
||||
CocoaVideo::SetWindowTitle(title);
|
||||
}
|
||||
|
|
|
@ -551,3 +551,18 @@ 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)
|
||||
{
|
||||
auto Screen = static_cast<SDLFB *>(screen)->GetSDLWindow();
|
||||
if (caption)
|
||||
SDL_SetWindowTitle(static_cast<SDLFB *>(screen)->GetSDLWindow(), caption);
|
||||
else
|
||||
{
|
||||
FString default_caption;
|
||||
default_caption.Format(GAMESIG " %s (%s)", GetVersionString(), GetGitTime());
|
||||
SDL_SetWindowTitle(static_cast<SDLFB *>(screen)->GetSDLWindow(), default_caption);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue