From e55a9352203678e3ad5109129d351148f3df8da5 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 3 Nov 2019 03:51:22 -0500 Subject: [PATCH 1/4] - 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 --- src/console/c_console.cpp | 7 ++ src/d_main.cpp | 196 +++++++++++++++++++++++--------------- src/menu/menu.cpp | 5 + 3 files changed, 133 insertions(+), 75 deletions(-) diff --git a/src/console/c_console.cpp b/src/console/c_console.cpp index 0d5e9cc1e..38cf1a82a 100644 --- a/src/console/c_console.cpp +++ b/src/console/c_console.cpp @@ -73,6 +73,9 @@ #define RIGHTMARGIN 8 #define BOTTOMARGIN 12 +extern bool hud_toggled; +void D_ToggleHud(); + CUSTOM_CVAR(Int, con_buffersize, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { @@ -1256,6 +1259,8 @@ void C_DrawConsole () void C_FullConsole () { + if (hud_toggled) + D_ToggleHud(); if (demoplayback) G_CheckDemoStatus (); D_QuitNetGame (); @@ -1290,6 +1295,8 @@ void C_ToggleConsole () HistPos = NULL; TabbedLast = false; TabbedList = false; + if (hud_toggled) + D_ToggleHud(); } else if (gamestate != GS_FULLCONSOLE && gamestate != GS_STARTUP) { diff --git a/src/d_main.cpp b/src/d_main.cpp index 90efa16ab..0f25c583c 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -161,6 +161,8 @@ EXTERN_CVAR (Int, screenblocks) EXTERN_CVAR (Bool, sv_cheats) EXTERN_CVAR (Bool, sv_unlimited_pickup) EXTERN_CVAR (Bool, I_FriendlyWindowTitle) +EXTERN_CVAR (Bool, r_drawplayersprites) +EXTERN_CVAR (Bool, show_messages) extern bool setmodeneeded; 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, r_debug_disable_vis_filter, false, 0) +bool hud_toggled = false; bool wantToRestart; bool DrawFSHUD; // [RH] Draw fullscreen HUD? TArray allwads; @@ -259,6 +262,42 @@ static int pagetic; // 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 @@ -793,46 +832,49 @@ void D_Display () }, true); screen->Begin2D(); - screen->DrawBlend(viewsec); - if (automapactive) + if (!hud_toggled) { - primaryLevel->automap->Drawer ((hud_althud && viewheight == SCREENHEIGHT) ? viewheight : StatusBar->GetTopOfStatusbar()); - } - - // 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) + screen->DrawBlend(viewsec); + if (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 { @@ -862,50 +904,53 @@ void D_Display () break; } } - CT_Drawer (); - - // draw pause pic - if ((paused || pauseext) && menuactive == MENU_Off) + if (!hud_toggled) { - FTexture *tex; - int x; + CT_Drawer (); - tex = TexMan.GetTextureByName(gameinfo.PauseSign, true); - x = (SCREENWIDTH - tex->GetDisplayWidth() * CleanXfac)/2 + - tex->GetDisplayLeftOffset() * CleanXfac; - screen->DrawTexture (tex, x, 4, DTA_CleanNoMove, true, TAG_DONE); - if (paused && multiplayer) + // draw pause pic + if ((paused || pauseext) && menuactive == MENU_Off) { - 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); + FTexture *tex; + int x; + + tex = TexMan.GetTextureByName(gameinfo.PauseSign, true); + x = (SCREENWIDTH - tex->GetDisplayWidth() * CleanXfac)/2 + + 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 (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 || NoWipe < 0 || wipe_type == wipe_None || hud_toggled) { if (wipe != nullptr) delete wipe; wipe = nullptr; @@ -914,7 +959,8 @@ void D_Display () // draw ZScript UI stuff C_DrawConsole (); // draw console M_Drawer (); // menu is drawn even on top of everything - FStat::PrintStat (); + if (!hud_toggled) + FStat::PrintStat (); screen->End2DAndUpdate (); } else diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 768d8d06c..a7863a864 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -119,6 +119,8 @@ int MenuTime; extern PClass *DefaultListMenuClass; extern PClass *DefaultOptionMenuClass; +extern bool hud_toggled; +void D_ToggleHud(); #define KEY_REPEAT_DELAY (TICRATE*5/12) @@ -350,6 +352,9 @@ bool DMenu::TranslateKeyboardEvents() void M_StartControlPanel (bool makeSound, bool scaleoverride) { + if (hud_toggled) + D_ToggleHud(); + // intro might call this repeatedly if (CurrentMenu != nullptr) return; From 077d4e08bbdede34ad238d6a3af89cacc83fbd93 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Nov 2019 15:53:41 +0100 Subject: [PATCH 2/4] - fixed: lump filters without any dot in the name did not work. --- src/gamedata/resourcefiles/resourcefile.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gamedata/resourcefiles/resourcefile.cpp b/src/gamedata/resourcefiles/resourcefile.cpp index ab1baa57c..6c0131b02 100644 --- a/src/gamedata/resourcefiles/resourcefile.cpp +++ b/src/gamedata/resourcefiles/resourcefile.cpp @@ -413,8 +413,11 @@ void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize) long len; int lastpos = -1; FString file; - - while ((len = LumpFilterIWAD.IndexOf('.', lastpos+1)) > 0) + if (LumpFilter.IndexOf('.') < 0) + { + max -= FilterLumps(LumpFilter, lumps, lumpsize, max); + } + else while ((len = LumpFilterIWAD.IndexOf('.', lastpos+1)) > 0) { max -= FilterLumps(LumpFilterIWAD.Left(len), lumps, lumpsize, max); lastpos = len; From be8009d9cabf0413565da511e91c29be879a390e Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 3 Nov 2019 16:55:39 +0200 Subject: [PATCH 3/4] - fixed: IfGame else branch was ignored in MENUDEF https://forum.zdoom.org/viewtopic.php?t=66282 --- src/menu/menudef.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index 90f4fa2b0..9b76cdbd6 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -203,7 +203,7 @@ static bool CheckSkipGameBlock(FScanner &sc) if (!filter) { SkipSubBlock(sc); - return true; + return !sc.CheckString("else"); } return false; } From 2ae3f6d326d372cbd60bbecb83efa392abd87123 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 4 Nov 2019 00:08:06 +0100 Subject: [PATCH 4/4] - fixed bad variable name for lump filter --- src/gamedata/resourcefiles/resourcefile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gamedata/resourcefiles/resourcefile.cpp b/src/gamedata/resourcefiles/resourcefile.cpp index 6c0131b02..db56d4e55 100644 --- a/src/gamedata/resourcefiles/resourcefile.cpp +++ b/src/gamedata/resourcefiles/resourcefile.cpp @@ -413,9 +413,9 @@ void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize) long len; int lastpos = -1; FString file; - if (LumpFilter.IndexOf('.') < 0) + if (LumpFilterIWAD.IndexOf('.') < 0) { - max -= FilterLumps(LumpFilter, lumps, lumpsize, max); + max -= FilterLumps(LumpFilterIWAD, lumps, lumpsize, max); } else while ((len = LumpFilterIWAD.IndexOf('.', lastpos+1)) > 0) {