- implement ccmd 'togglehud' for taking screenshots

- it disables most 2D drawing in order to favor a fullscreen output view for screenshot taking
  - enabling the console or any menu should cancel it
  - it does use several CVARs but their state should be restored when this mode is canceled
This commit is contained in:
Rachael Alexanderson 2019-11-03 03:51:22 -05:00
parent bd90a768f5
commit e55a935220
3 changed files with 133 additions and 75 deletions

View file

@ -73,6 +73,9 @@
#define RIGHTMARGIN 8 #define RIGHTMARGIN 8
#define BOTTOMARGIN 12 #define BOTTOMARGIN 12
extern bool hud_toggled;
void D_ToggleHud();
CUSTOM_CVAR(Int, con_buffersize, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CUSTOM_CVAR(Int, con_buffersize, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{ {
@ -1256,6 +1259,8 @@ void C_DrawConsole ()
void C_FullConsole () void C_FullConsole ()
{ {
if (hud_toggled)
D_ToggleHud();
if (demoplayback) if (demoplayback)
G_CheckDemoStatus (); G_CheckDemoStatus ();
D_QuitNetGame (); D_QuitNetGame ();
@ -1290,6 +1295,8 @@ void C_ToggleConsole ()
HistPos = NULL; HistPos = NULL;
TabbedLast = false; TabbedLast = false;
TabbedList = false; TabbedList = false;
if (hud_toggled)
D_ToggleHud();
} }
else if (gamestate != GS_FULLCONSOLE && gamestate != GS_STARTUP) else if (gamestate != GS_FULLCONSOLE && gamestate != GS_STARTUP)
{ {

View file

@ -161,6 +161,8 @@ EXTERN_CVAR (Int, screenblocks)
EXTERN_CVAR (Bool, sv_cheats) EXTERN_CVAR (Bool, sv_cheats)
EXTERN_CVAR (Bool, sv_unlimited_pickup) EXTERN_CVAR (Bool, sv_unlimited_pickup)
EXTERN_CVAR (Bool, I_FriendlyWindowTitle) EXTERN_CVAR (Bool, I_FriendlyWindowTitle)
EXTERN_CVAR (Bool, r_drawplayersprites)
EXTERN_CVAR (Bool, show_messages)
extern bool setmodeneeded; extern bool setmodeneeded;
extern bool gameisdead; extern bool gameisdead;
@ -218,6 +220,7 @@ CVAR (Bool, autoloadbrightmaps, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLO
CVAR (Bool, autoloadlights, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) CVAR (Bool, autoloadlights, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG)
CVAR (Bool, r_debug_disable_vis_filter, false, 0) CVAR (Bool, r_debug_disable_vis_filter, false, 0)
bool hud_toggled = false;
bool wantToRestart; bool wantToRestart;
bool DrawFSHUD; // [RH] Draw fullscreen HUD? bool DrawFSHUD; // [RH] Draw fullscreen HUD?
TArray<FString> allwads; TArray<FString> allwads;
@ -259,6 +262,42 @@ static int pagetic;
// CODE -------------------------------------------------------------------- // CODE --------------------------------------------------------------------
//==========================================================================
//
// D_ToggleHud
//
// Turns off 2D drawing temporarily.
//
//==========================================================================
void D_ToggleHud()
{
static int saved_screenblocks;
static bool saved_drawplayersprite, saved_showmessages;
if (hud_toggled = !hud_toggled)
{
saved_screenblocks = screenblocks;
saved_drawplayersprite = r_drawplayersprites;
saved_showmessages = show_messages;
screenblocks = 12;
r_drawplayersprites = false;
show_messages = false;
C_HideConsole();
M_ClearMenus();
}
else
{
screenblocks = saved_screenblocks;
r_drawplayersprites = saved_drawplayersprite;
show_messages = saved_showmessages;
}
}
CCMD(togglehud)
{
D_ToggleHud();
}
//========================================================================== //==========================================================================
// //
// D_ProcessEvents // D_ProcessEvents
@ -793,46 +832,49 @@ void D_Display ()
}, true); }, true);
screen->Begin2D(); screen->Begin2D();
screen->DrawBlend(viewsec); if (!hud_toggled)
if (automapactive)
{ {
primaryLevel->automap->Drawer ((hud_althud && viewheight == SCREENHEIGHT) ? viewheight : StatusBar->GetTopOfStatusbar()); screen->DrawBlend(viewsec);
} if (automapactive)
// for timing the statusbar code.
//cycle_t stb;
//stb.Reset();
//stb.Clock();
if (!automapactive || viewactive)
{
StatusBar->RefreshViewBorder ();
}
if (hud_althud && viewheight == SCREENHEIGHT && screenblocks > 10)
{
StatusBar->DrawBottomStuff (HUD_AltHud);
if (DrawFSHUD || automapactive) StatusBar->DrawAltHUD();
if (players[consoleplayer].camera && players[consoleplayer].camera->player && !automapactive)
{ {
StatusBar->DrawCrosshair(); primaryLevel->automap->Drawer ((hud_althud && viewheight == SCREENHEIGHT) ? viewheight : StatusBar->GetTopOfStatusbar());
} }
StatusBar->CallDraw (HUD_AltHud, vp.TicFrac);
StatusBar->DrawTopStuff (HUD_AltHud); // for timing the statusbar code.
//cycle_t stb;
//stb.Reset();
//stb.Clock();
if (!automapactive || viewactive)
{
StatusBar->RefreshViewBorder ();
}
if (hud_althud && viewheight == SCREENHEIGHT && screenblocks > 10)
{
StatusBar->DrawBottomStuff (HUD_AltHud);
if (DrawFSHUD || automapactive) StatusBar->DrawAltHUD();
if (players[consoleplayer].camera && players[consoleplayer].camera->player && !automapactive)
{
StatusBar->DrawCrosshair();
}
StatusBar->CallDraw (HUD_AltHud, vp.TicFrac);
StatusBar->DrawTopStuff (HUD_AltHud);
}
else if (viewheight == SCREENHEIGHT && viewactive && screenblocks > 10)
{
EHudState state = DrawFSHUD ? HUD_Fullscreen : HUD_None;
StatusBar->DrawBottomStuff (state);
StatusBar->CallDraw (state, vp.TicFrac);
StatusBar->DrawTopStuff (state);
}
else
{
StatusBar->DrawBottomStuff (HUD_StatusBar);
StatusBar->CallDraw (HUD_StatusBar, vp.TicFrac);
StatusBar->DrawTopStuff (HUD_StatusBar);
}
//stb.Unclock();
//Printf("Stbar = %f\n", stb.TimeMS());
} }
else if (viewheight == SCREENHEIGHT && viewactive && screenblocks > 10)
{
EHudState state = DrawFSHUD ? HUD_Fullscreen : HUD_None;
StatusBar->DrawBottomStuff (state);
StatusBar->CallDraw (state, vp.TicFrac);
StatusBar->DrawTopStuff (state);
}
else
{
StatusBar->DrawBottomStuff (HUD_StatusBar);
StatusBar->CallDraw (HUD_StatusBar, vp.TicFrac);
StatusBar->DrawTopStuff (HUD_StatusBar);
}
//stb.Unclock();
//Printf("Stbar = %f\n", stb.TimeMS());
} }
else else
{ {
@ -862,50 +904,53 @@ void D_Display ()
break; break;
} }
} }
CT_Drawer (); if (!hud_toggled)
// draw pause pic
if ((paused || pauseext) && menuactive == MENU_Off)
{ {
FTexture *tex; CT_Drawer ();
int x;
tex = TexMan.GetTextureByName(gameinfo.PauseSign, true); // draw pause pic
x = (SCREENWIDTH - tex->GetDisplayWidth() * CleanXfac)/2 + if ((paused || pauseext) && menuactive == MENU_Off)
tex->GetDisplayLeftOffset() * CleanXfac;
screen->DrawTexture (tex, x, 4, DTA_CleanNoMove, true, TAG_DONE);
if (paused && multiplayer)
{ {
FFont *font = generic_ui? NewSmallFont : SmallFont; FTexture *tex;
FString pstring = GStrings("TXT_BY"); int x;
pstring.Substitute("%s", players[paused - 1].userinfo.GetName());
screen->DrawText(font, CR_RED, tex = TexMan.GetTextureByName(gameinfo.PauseSign, true);
(screen->GetWidth() - font->StringWidth(pstring)*CleanXfac) / 2, x = (SCREENWIDTH - tex->GetDisplayWidth() * CleanXfac)/2 +
(tex->GetDisplayHeight() * CleanYfac) + 4, pstring, DTA_CleanNoMove, true, TAG_DONE); tex->GetDisplayLeftOffset() * CleanXfac;
screen->DrawTexture (tex, x, 4, DTA_CleanNoMove, true, TAG_DONE);
if (paused && multiplayer)
{
FFont *font = generic_ui? NewSmallFont : SmallFont;
FString pstring = GStrings("TXT_BY");
pstring.Substitute("%s", players[paused - 1].userinfo.GetName());
screen->DrawText(font, CR_RED,
(screen->GetWidth() - font->StringWidth(pstring)*CleanXfac) / 2,
(tex->GetDisplayHeight() * CleanYfac) + 4, pstring, DTA_CleanNoMove, true, TAG_DONE);
}
}
// [RH] Draw icon, if any
if (D_DrawIcon)
{
FTextureID picnum = TexMan.CheckForTexture (D_DrawIcon, ETextureType::MiscPatch);
D_DrawIcon = NULL;
if (picnum.isValid())
{
FTexture *tex = TexMan.GetTexture(picnum);
screen->DrawTexture (tex, 160 - tex->GetDisplayWidth()/2, 100 - tex->GetDisplayHeight()/2,
DTA_320x200, true, TAG_DONE);
}
NoWipe = 10;
}
if (snd_drawoutput)
{
GSnd->DrawWaveDebug(snd_drawoutput);
} }
} }
// [RH] Draw icon, if any if (!wipe || NoWipe < 0 || wipe_type == wipe_None || hud_toggled)
if (D_DrawIcon)
{
FTextureID picnum = TexMan.CheckForTexture (D_DrawIcon, ETextureType::MiscPatch);
D_DrawIcon = NULL;
if (picnum.isValid())
{
FTexture *tex = TexMan.GetTexture(picnum);
screen->DrawTexture (tex, 160 - tex->GetDisplayWidth()/2, 100 - tex->GetDisplayHeight()/2,
DTA_320x200, true, TAG_DONE);
}
NoWipe = 10;
}
if (snd_drawoutput)
{
GSnd->DrawWaveDebug(snd_drawoutput);
}
if (!wipe || NoWipe < 0 || wipe_type == wipe_None)
{ {
if (wipe != nullptr) delete wipe; if (wipe != nullptr) delete wipe;
wipe = nullptr; wipe = nullptr;
@ -914,7 +959,8 @@ void D_Display ()
// draw ZScript UI stuff // draw ZScript UI stuff
C_DrawConsole (); // draw console C_DrawConsole (); // draw console
M_Drawer (); // menu is drawn even on top of everything M_Drawer (); // menu is drawn even on top of everything
FStat::PrintStat (); if (!hud_toggled)
FStat::PrintStat ();
screen->End2DAndUpdate (); screen->End2DAndUpdate ();
} }
else else

View file

@ -119,6 +119,8 @@ int MenuTime;
extern PClass *DefaultListMenuClass; extern PClass *DefaultListMenuClass;
extern PClass *DefaultOptionMenuClass; extern PClass *DefaultOptionMenuClass;
extern bool hud_toggled;
void D_ToggleHud();
#define KEY_REPEAT_DELAY (TICRATE*5/12) #define KEY_REPEAT_DELAY (TICRATE*5/12)
@ -350,6 +352,9 @@ bool DMenu::TranslateKeyboardEvents()
void M_StartControlPanel (bool makeSound, bool scaleoverride) void M_StartControlPanel (bool makeSound, bool scaleoverride)
{ {
if (hud_toggled)
D_ToggleHud();
// intro might call this repeatedly // intro might call this repeatedly
if (CurrentMenu != nullptr) if (CurrentMenu != nullptr)
return; return;