mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 20:21:26 +00:00
- Strip out any color escape sequences before setting a window title.
This commit is contained in:
parent
1881cb45d2
commit
1279ec081a
1 changed files with 30 additions and 3 deletions
|
@ -3898,20 +3898,47 @@ CUSTOM_CVAR(Int, I_FriendlyWindowTitle, 1, CVAR_GLOBALCONFIG|CVAR_ARCHIVE|CVAR_N
|
|||
|
||||
void I_UpdateWindowTitle()
|
||||
{
|
||||
FString titlestr;
|
||||
switch (I_FriendlyWindowTitle)
|
||||
{
|
||||
case 1:
|
||||
if (level.LevelName && level.LevelName.GetChars()[0])
|
||||
{
|
||||
FString titlestr;
|
||||
titlestr.Format("%s - %s", level.LevelName.GetChars(), GameStartupInfo.Name.GetChars());
|
||||
I_SetWindowTitle(titlestr.GetChars());
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
I_SetWindowTitle(GameStartupInfo.Name.GetChars());
|
||||
titlestr = GameStartupInfo.Name;
|
||||
break;
|
||||
default:
|
||||
I_SetWindowTitle(NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
// Strip out any color escape sequences before setting a window title
|
||||
TArray<char> copy(titlestr.Len() + 1);
|
||||
const char* srcp = titlestr;
|
||||
char* dstp = copy.Data();
|
||||
|
||||
while (*srcp != 0)
|
||||
{
|
||||
|
||||
if (*srcp != TEXTCOLOR_ESCAPE)
|
||||
{
|
||||
*dstp++ = *srcp++;
|
||||
}
|
||||
else if (srcp[1] == '[')
|
||||
{
|
||||
srcp += 2;
|
||||
while (*srcp != ']' && *srcp != 0) srcp++;
|
||||
if (*srcp == ']') srcp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (srcp[1] != 0) srcp += 2;
|
||||
else break;
|
||||
}
|
||||
}
|
||||
*dstp = 0;
|
||||
I_SetWindowTitle(copy.Data());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue