From 4d8dfd2437e02601f6ee326cdd196ca4bd6134a1 Mon Sep 17 00:00:00 2001 From: Ed the Bat Date: Sun, 24 Nov 2019 16:17:58 -0500 Subject: [PATCH 1/6] More level_compatibility map fixes These maps have actors not marked for any game mode (single, cooperative, deathmatch). That works in Zandronum, but GZDoom requires this fix. --- wadsrc/static/zscript/level_compatibility.zs | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/wadsrc/static/zscript/level_compatibility.zs b/wadsrc/static/zscript/level_compatibility.zs index 20356935b..36b828c1d 100644 --- a/wadsrc/static/zscript/level_compatibility.zs +++ b/wadsrc/static/zscript/level_compatibility.zs @@ -1478,6 +1478,15 @@ class LevelCompatibility : LevelPostProcessor break; } + case '25E178C981BAC28BA586B3B0A2A0FD72': // swan fox doom v2.4.wad map13 + { + //Actors with no game mode will now appear + SetThingFlags(0, MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH); + for(int i = 2; i < 452; i++) + SetThingFlags(i, MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH); + break; + } + case 'FDFB3D209CC0F3706AAF3E51646003D5': // swan fox doom v2.4.wad map23 { //Fix the exit portal to allow walking into it instead of shooting it @@ -1486,6 +1495,24 @@ class LevelCompatibility : LevelPostProcessor ClearLineSpecial(2010); break; } + + case 'BC969ED0191CCD9B69B316864362B0D7': // swan fox doom v2.4.wad map24 + { + //Actors with no game mode will now appear + for(int i = 1; i < 88; i++) + SetThingFlags(i, MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH); + break; + } + + case 'ED740248422026326650F6A4BC1C0A5A': // swan fox doom v2.4.wad map25 + { + //Actors with no game mode will now appear + for(int i = 0; i < 8; i++) + SetThingFlags(i, MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH); + for(int i = 9; i < 26; i++) + SetThingFlags(i, MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH); + break; + } case '52F532F95E2D5862E56F7214FA5C5C59': // Toon Doom II (toon2b.wad) map10 { @@ -1661,6 +1688,15 @@ class LevelCompatibility : LevelPostProcessor OffsetSectorPlane(65, Sector.ceiling, 8); break; } + + case '75E2685CA8AB29108DBF1AC98C5450AC': // Ancient Beliefs (beliefs.wad) map01 + { + //Actors with no game mode will now appear + SetThingFlags(0, MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH); + for(int i = 2; i < 7; i++) + SetThingFlags(i, MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH); + break; + } } } } From 20d3752fddd6010c34735e5cda5faf0725d7a4ca Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 25 Nov 2019 17:37:56 +0200 Subject: [PATCH 2/6] - exported several Wads.GetLump...() methods to ZScript * GetLumpName() returns 8-characters lump name * GetLumpFullName() returns full name with path and extension * GetLumpNamespace() returns lump's namespace * GetNumLumps() returns total number of lumps https://forum.zdoom.org/viewtopic.php?t=66285 --- src/gamedata/w_wad.cpp | 29 +++++++++++++++++++++++++++++ wadsrc/static/zscript/base.zs | 5 +++++ 2 files changed, 34 insertions(+) diff --git a/src/gamedata/w_wad.cpp b/src/gamedata/w_wad.cpp index d7d9911d8..5c37a5998 100644 --- a/src/gamedata/w_wad.cpp +++ b/src/gamedata/w_wad.cpp @@ -371,6 +371,12 @@ int FWadCollection::GetNumLumps () const return NumLumps; } +DEFINE_ACTION_FUNCTION(_Wads, GetNumLumps) +{ + PARAM_PROLOGUE; + ACTION_RETURN_INT(Wads.GetNumLumps()); +} + //========================================================================== // // GetNumFiles @@ -1220,6 +1226,15 @@ void FWadCollection::GetLumpName(FString &to, int lump) const } } +DEFINE_ACTION_FUNCTION(_Wads, GetLumpName) +{ + PARAM_PROLOGUE; + PARAM_INT(lump); + FString lumpname; + Wads.GetLumpName(lumpname, lump); + ACTION_RETURN_STRING(lumpname); +} + //========================================================================== // // FWadCollection :: GetLumpFullName @@ -1238,6 +1253,13 @@ const char *FWadCollection::GetLumpFullName (int lump) const return LumpInfo[lump].lump->Name; } +DEFINE_ACTION_FUNCTION(_Wads, GetLumpFullName) +{ + PARAM_PROLOGUE; + PARAM_INT(lump); + ACTION_RETURN_STRING(Wads.GetLumpFullName(lump)); +} + //========================================================================== // // FWadCollection :: GetLumpFullPath @@ -1271,6 +1293,13 @@ int FWadCollection::GetLumpNamespace (int lump) const return LumpInfo[lump].lump->Namespace; } +DEFINE_ACTION_FUNCTION(_Wads, GetLumpNamespace) +{ + PARAM_PROLOGUE; + PARAM_INT(lump); + ACTION_RETURN_INT(Wads.GetLumpNamespace(lump)); +} + //========================================================================== // // FWadCollection :: GetLumpIndexNum diff --git a/wadsrc/static/zscript/base.zs b/wadsrc/static/zscript/base.zs index 0f617050a..e3d4c0a32 100644 --- a/wadsrc/static/zscript/base.zs +++ b/wadsrc/static/zscript/base.zs @@ -873,6 +873,11 @@ struct Wads native static int CheckNumForFullName(string name); native static int FindLump(string name, int startlump = 0, FindLumpNamespace ns = GlobalNamespace); native static string ReadLump(int lump); + + native static int GetNumLumps(); + native static string GetLumpName(int lump); + native static string GetLumpFullName(int lump); + native static int GetLumpNamespace(int lump); } struct TerrainDef native From a3741abbf359537998f5532f9afcc5d36059c3ed Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson <18584402+madame-rachelle@users.noreply.github.com> Date: Tue, 26 Nov 2019 07:46:18 -0500 Subject: [PATCH 3/6] =?UTF-8?q?-=20add=20cvar=20'cl=5Fdisableinvertedcolor?= =?UTF-8?q?map'=20-=20changes=20the=20invulnerability=E2=80=A6=20(#972)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * - add cvar 'cl_disableinvertedcolormap' - changes the invulnerability sphere to instead be a regular desaturated colormap that transitions from deep blue to pale yellow * - add menu option for cl_disableinvertedcolormap * - added customization for invulnerability colormap * - fixed custom colormap being calculated incorrectly * - disable custom invulnerability map before the main game loop --- src/d_main.cpp | 5 +++++ src/r_data/colormaps.cpp | 37 ++++++++++++++++++++++++++++++++++++- src/r_data/colormaps.h | 2 +- wadsrc/static/menudef.txt | 3 +++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index d12b93ad5..73cc1927a 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -106,6 +106,7 @@ EXTERN_CVAR(Bool, hud_althud) EXTERN_CVAR(Int, vr_mode) +EXTERN_CVAR(Bool, cl_customizeinvulmap) void DrawHUD(); void D_DoAnonStats(); void I_DetectOS(); @@ -2752,6 +2753,10 @@ static int D_DoomMain_Internal (void) C_RunDelayedCommands(); gamestate = GS_STARTUP; + // enable custom invulnerability map here + if (cl_customizeinvulmap) + R_InitColormaps(true); + if (!restart) { // start the apropriate game based on parms diff --git a/src/r_data/colormaps.cpp b/src/r_data/colormaps.cpp index 5c5ed6a3b..b9944c765 100644 --- a/src/r_data/colormaps.cpp +++ b/src/r_data/colormaps.cpp @@ -44,6 +44,22 @@ #include "colormaps.h" #include "templates.h" +CUSTOM_CVAR(Bool, cl_customizeinvulmap, false, CVAR_ARCHIVE|CVAR_NOINITCALL) +{ + R_InitColormaps(true); +} +CUSTOM_CVAR(Color, cl_custominvulmapcolor1, 0x00001a, CVAR_ARCHIVE|CVAR_NOINITCALL) +{ + if (cl_customizeinvulmap) + R_InitColormaps(true); +} +CUSTOM_CVAR(Color, cl_custominvulmapcolor2, 0xa6a67a, CVAR_ARCHIVE|CVAR_NOINITCALL) +{ + if (cl_customizeinvulmap) + R_InitColormaps(true); +} + + TArray fakecmaps; TArray SpecialColormaps; @@ -164,7 +180,7 @@ void R_DeinitColormaps () // //========================================================================== -void R_InitColormaps () +void R_InitColormaps (bool allowCustomColormap) { // [RH] Try and convert BOOM colormaps into blending values. // This is a really rough hack, but it's better than @@ -242,6 +258,25 @@ void R_InitColormaps () } } + // some of us really don't like Doom's idea of an invulnerability sphere colormap + // this hack will override that + if (allowCustomColormap && cl_customizeinvulmap) + { + uint32_t color1 = cl_custominvulmapcolor1; + uint32_t color2 = cl_custominvulmapcolor2; + float r1 = (float)((color1 & 0xff0000) >> 16) / 128.f; + float g1 = (float)((color1 & 0x00ff00) >> 8) / 128.f; + float b1 = (float)((color1 & 0x0000ff) >> 0) / 128.f; + float r2 = (float)((color2 & 0xff0000) >> 16) / 128.f; + float g2 = (float)((color2 & 0x00ff00) >> 8) / 128.f; + float b2 = (float)((color2 & 0x0000ff) >> 0) / 128.f; + SpecialColormapParms[0] = {{r1, g1, b1}, {r2, g2, b2}}; + } + else + { + SpecialColormapParms[0] = {{1.0, 1.0, 1.0}, {0.0, 0.0, 0.0}}; + } + // build default special maps (e.g. invulnerability) for (unsigned i = 0; i < countof(SpecialColormapParms); ++i) diff --git a/src/r_data/colormaps.h b/src/r_data/colormaps.h index cb57f8b79..97d4d8902 100644 --- a/src/r_data/colormaps.h +++ b/src/r_data/colormaps.h @@ -5,7 +5,7 @@ struct lightlist_t; -void R_InitColormaps (); +void R_InitColormaps (bool allowCustomColormap = false); void R_DeinitColormaps (); uint32_t R_ColormapNumForName(const char *name); // killough 4/4/98 diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index fa46b7307..d4d325e05 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -925,6 +925,9 @@ OptionMenu "VideoOptions" protected Slider "$DSPLYMNU_CONTRAST", "vid_contrast", 0.1, 3.0, 0.1 Slider "$DSPLYMNU_SATURATION", "vid_saturation", -3.0, 3.0, 0.25, 2 StaticText " " + Option "$DSPLYMNU_CUSTOMINVERTMAP", "cl_customizeinvulmap", "OnOff" + ColorPicker "$DSPLYMNU_CUSTOMINVERTC1", "cl_custominvulmapcolor1" + ColorPicker "$DSPLYMNU_CUSTOMINVERTC2", "cl_custominvulmapcolor2" Option "$DSPLYMNU_WIPETYPE", "wipetype", "Wipes" Option "$DSPLYMNU_DRAWFUZZ", "r_drawfuzz", "Fuzziness" Option "$DSPLYMNU_OLDTRANS", "r_vanillatrans", "VanillaTrans" From a7f2df4fef49709a7d8b520b4501acdf5d9a5e02 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 20 Nov 2019 18:33:22 +0200 Subject: [PATCH 4/6] - added ability to set custom alternative HUD Use GAMEINFO key 'althudclass' to specify own class derived from AltHud https://forum.zdoom.org/viewtopic.php?t=66422 --- src/g_statusbar/shared_sbar.cpp | 48 ++++++++++++++----- src/gamedata/gi.cpp | 1 + src/gamedata/gi.h | 1 + src/utility/namedef.h | 1 + wadsrc/static/zscript/ui/statusbar/alt_hud.zs | 2 +- 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index aa0967080..cb7296894 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -335,6 +335,35 @@ void ST_CreateStatusBar(bool bTitleLevel) // //--------------------------------------------------------------------------- +static DObject* CreateAltHud(const FName classname) +{ + if (classname == NAME_None) + return nullptr; + + auto cls = PClass::FindClass(classname); + if (!cls) + { + Printf(TEXTCOLOR_RED "Unknown alternative HUD class \"%s\"\n", classname.GetChars()); + return nullptr; + } + + if (!cls->IsDescendantOf(NAME_AltHud)) + { + Printf(TEXTCOLOR_RED "Alternative HUD class \"%s\" is not derived from AltHud\n", classname.GetChars()); + return nullptr; + } + + auto althud = cls->CreateNew(); + + IFVIRTUALPTRNAME(althud, NAME_AltHud, Init) + { + VMValue params[] = { althud }; + VMCall(func, params, countof(params), nullptr, 0); + } + + return althud; +} + DBaseStatusBar::DBaseStatusBar () { CompleteBorder = false; @@ -347,20 +376,13 @@ DBaseStatusBar::DBaseStatusBar () ShowLog = false; defaultScale = { (double)CleanXfac, (double)CleanYfac }; - // Create the AltHud object. Todo: Make class type configurable. - FName classname = "AltHud"; - auto cls = PClass::FindClass(classname); - if (cls) - { - AltHud = cls->CreateNew(); + // Create the AltHud object. + AltHud = CreateAltHud(gameinfo.althudclass); - VMFunction * func = PClass::FindFunction(classname, "Init"); - if (func != nullptr) - { - VMValue params[] = { AltHud }; - VMCall(func, params, countof(params), nullptr, 0); - } - } + if (!AltHud) + AltHud = CreateAltHud(NAME_AltHud); + + assert(AltHud); } static void ValidateResolution(int &hres, int &vres) diff --git a/src/gamedata/gi.cpp b/src/gamedata/gi.cpp index 380fc66b6..a952313a5 100644 --- a/src/gamedata/gi.cpp +++ b/src/gamedata/gi.cpp @@ -390,6 +390,7 @@ void FMapInfoParser::ParseGameInfo() GAMEINFOKEY_STRING(backpacktype, "backpacktype") GAMEINFOKEY_STRING_STAMPED(statusbar, "statusbar", statusbarfile) GAMEINFOKEY_STRING_STAMPED(statusbarclass, "statusbarclass", statusbarclassfile) + GAMEINFOKEY_STRING(althudclass, "althudclass") GAMEINFOKEY_MUSIC(intermissionMusic, intermissionOrder, "intermissionMusic") GAMEINFOKEY_STRING(CursorPic, "CursorPic") GAMEINFOKEY_STRING(MessageBoxClass, "MessageBoxClass") diff --git a/src/gamedata/gi.h b/src/gamedata/gi.h index 8a57cfbd5..d1dc534e3 100644 --- a/src/gamedata/gi.h +++ b/src/gamedata/gi.h @@ -158,6 +158,7 @@ struct gameinfo_t FString statusbar; int statusbarfile = -1; FName statusbarclass; + FName althudclass; int statusbarclassfile = -1; FName MessageBoxClass; FName backpacktype; diff --git a/src/utility/namedef.h b/src/utility/namedef.h index ec9d4b6bd..e2063f8a7 100644 --- a/src/utility/namedef.h +++ b/src/utility/namedef.h @@ -1088,3 +1088,4 @@ xx(PlayerTeam) xx(PlayerColors) xx(PlayerSkin) xx(NewPlayerMenu) +xx(AltHud) diff --git a/wadsrc/static/zscript/ui/statusbar/alt_hud.zs b/wadsrc/static/zscript/ui/statusbar/alt_hud.zs index b0efdc541..b791c899f 100644 --- a/wadsrc/static/zscript/ui/statusbar/alt_hud.zs +++ b/wadsrc/static/zscript/ui/statusbar/alt_hud.zs @@ -44,7 +44,7 @@ class AltHud ui const POWERUPICONSIZE = 32; - void Init() + virtual void Init() { switch (gameinfo.gametype) { From e21c9e0ef890e101b5b1951ec607895a3fdd7704 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 26 Nov 2019 12:02:19 +0200 Subject: [PATCH 5/6] - made most of AltHud class functions virtual This allows arbitrary customization of alternative HUD --- wadsrc/static/zscript/ui/statusbar/alt_hud.zs | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/wadsrc/static/zscript/ui/statusbar/alt_hud.zs b/wadsrc/static/zscript/ui/statusbar/alt_hud.zs index b791c899f..7ddbf902d 100644 --- a/wadsrc/static/zscript/ui/statusbar/alt_hud.zs +++ b/wadsrc/static/zscript/ui/statusbar/alt_hud.zs @@ -131,7 +131,7 @@ class AltHud ui // //--------------------------------------------------------------------------- - void DrawHudNumber(Font fnt, int color, int num, int x, int y, double trans = 0.75) + void DrawHudNumber(Font fnt, int color, int num, int x, int y, double trans = 0.75) { DrawHudText(fnt, color, String.Format("%d", num), x, y, trans); } @@ -142,7 +142,7 @@ class AltHud ui // //--------------------------------------------------------------------------- - void DrawTimeString(Font fnt, int color, int timer, int x, int y, double trans = 0.75) + virtual void DrawTimeString(Font fnt, int color, int timer, int x, int y, double trans = 0.75) { let seconds = Thinker.Tics2Seconds(timer); String s = String.Format("%02i:%02i:%02i", seconds / 3600, (seconds % 3600) / 60, seconds % 60); @@ -156,7 +156,7 @@ class AltHud ui // //=========================================================================== - void DrawStatLine(int x, in out int y, String prefix, String text) + virtual void DrawStatLine(int x, in out int y, String prefix, String text) { y -= SmallFont.GetHeight()-1; screen.DrawText(SmallFont, hudcolor_statnames, x, y, prefix, @@ -168,7 +168,7 @@ class AltHud ui DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0.75); } - void DrawStatus(PlayerInfo CPlayer, int x, int y) + virtual void DrawStatus(PlayerInfo CPlayer, int x, int y) { let mo = CPlayer.mo; if (hud_showscore) @@ -209,7 +209,7 @@ class AltHud ui // //=========================================================================== - void DrawHealth(PlayerInfo CPlayer, int x, int y) + virtual void DrawHealth(PlayerInfo CPlayer, int x, int y) { int health = CPlayer.health; @@ -235,7 +235,7 @@ class AltHud ui // //=========================================================================== - void DrawArmor(BasicArmor barmor, HexenArmor harmor, int x, int y) + virtual void DrawArmor(BasicArmor barmor, HexenArmor harmor, int x, int y) { int ap = 0; int bestslot = 4; @@ -304,7 +304,7 @@ class AltHud ui // //--------------------------------------------------------------------------- - bool DrawOneKey(int xo, int x, int y, in out int c, Key inv) + virtual bool DrawOneKey(int xo, int x, int y, in out int c, Key inv) { TextureID icon; @@ -340,7 +340,7 @@ class AltHud ui // //--------------------------------------------------------------------------- - int DrawKeys(PlayerInfo CPlayer, int x, int y) + virtual int DrawKeys(PlayerInfo CPlayer, int x, int y) { int yo = y; int xo = x; @@ -445,7 +445,7 @@ class AltHud ui // //--------------------------------------------------------------------------- - int DrawAmmo(PlayerInfo CPlayer, int x, int y) + virtual int DrawAmmo(PlayerInfo CPlayer, int x, int y) { int i,j,k; @@ -558,7 +558,7 @@ class AltHud ui // //--------------------------------------------------------------------------- - void DrawOneWeapon(PlayerInfo CPlayer, int x, in out int y, Weapon weapon) + virtual void DrawOneWeapon(PlayerInfo CPlayer, int x, in out int y, Weapon weapon) { double trans; @@ -594,7 +594,7 @@ class AltHud ui } - void DrawWeapons(PlayerInfo CPlayer, int x, int y) + virtual void DrawWeapons(PlayerInfo CPlayer, int x, int y) { int k,j; Inventory inv; @@ -631,7 +631,7 @@ class AltHud ui // //--------------------------------------------------------------------------- - void DrawInventory(PlayerInfo CPlayer, int x,int y) + virtual void DrawInventory(PlayerInfo CPlayer, int x,int y) { Inventory rover; int numitems = (hudwidth - 2*x) / 32; @@ -690,7 +690,7 @@ class AltHud ui // //--------------------------------------------------------------------------- - void DrawFrags(PlayerInfo CPlayer, int x, int y) + virtual void DrawFrags(PlayerInfo CPlayer, int x, int y) { DrawImageToBox(fragpic, x, y, 31, 17); DrawHudNumber(HudFont, Font.CR_GRAY, CPlayer.fragcount, x + 33, y + 17); @@ -709,7 +709,7 @@ class AltHud ui DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight); } - void DrawCoordinates(PlayerInfo CPlayer, bool withmapname) + virtual void DrawCoordinates(PlayerInfo CPlayer, bool withmapname) { Vector3 pos; String coordstr; @@ -772,7 +772,7 @@ class AltHud ui //--------------------------------------------------------------------------- private native static int GetRealTime(); - bool DrawTime(int y) + virtual bool DrawTime(int y) { if (hud_showtime > 0 && hud_showtime <= 9) { @@ -833,7 +833,7 @@ class AltHud ui //--------------------------------------------------------------------------- native static int, int, int GetLatency(); - bool DrawLatency(int y) + virtual bool DrawLatency(int y) { if ((hud_showlag == 1 && netgame) || hud_showlag == 2) { @@ -858,7 +858,7 @@ class AltHud ui // //--------------------------------------------------------------------------- - void DrawPowerups(PlayerInfo CPlayer, int y) + virtual void DrawPowerups(PlayerInfo CPlayer, int y) { // Each icon gets a 32x32 block to draw itself in. int x, y; @@ -969,7 +969,7 @@ class AltHud ui // //--------------------------------------------------------------------------- - void Draw(PlayerInfo CPlayer, int w, int h) + virtual void Draw(PlayerInfo CPlayer, int w, int h) { hudwidth = w; hudheight = h; From fdd17403e586e35c9c00f5b31e31df2e005378f0 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 26 Nov 2019 12:05:29 +0200 Subject: [PATCH 6/6] - added ability to force internal alternative HUD Set hud_althud_forceinternal CVAR to disable unwanted HUD customizations --- src/g_statusbar/sbar.h | 2 ++ src/g_statusbar/shared_hud.cpp | 59 +++++++++++++++++++++++++++++++++ src/g_statusbar/shared_sbar.cpp | 38 +-------------------- 3 files changed, 62 insertions(+), 37 deletions(-) diff --git a/src/g_statusbar/sbar.h b/src/g_statusbar/sbar.h index 1f53859c0..350d13502 100644 --- a/src/g_statusbar/sbar.h +++ b/src/g_statusbar/sbar.h @@ -434,6 +434,8 @@ public: virtual void SetMugShotState (const char *state_name, bool wait_till_done=false, bool reset=false); void DrawLog(); uint32_t GetTranslation() const; + + void CreateAltHUD(); void DrawAltHUD(); void DrawGraphic(FTextureID texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY); diff --git a/src/g_statusbar/shared_hud.cpp b/src/g_statusbar/shared_hud.cpp index 998d3f514..2a3e467f5 100644 --- a/src/g_statusbar/shared_hud.cpp +++ b/src/g_statusbar/shared_hud.cpp @@ -93,6 +93,65 @@ CVAR (Int, hudcolor_stats, CR_GREEN, CVAR_ARCHIVE) // For the stats values the CVAR(Bool, map_point_coordinates, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // show player or map coordinates? +//--------------------------------------------------------------------------- +// +// Create Alternative HUD +// +//--------------------------------------------------------------------------- + +CUSTOM_CVAR(Bool, hud_althud_forceinternal, false, CVAR_ARCHIVE | CVAR_NOINITCALL) +{ + if (StatusBar) + StatusBar->CreateAltHUD(); +} + +static DObject* DoCreateAltHUD(const FName classname) +{ + if (classname == NAME_None) + return nullptr; + + const auto cls = PClass::FindClass(classname); + if (!cls) + { + Printf(TEXTCOLOR_RED "Unknown alternative HUD class \"%s\"\n", classname.GetChars()); + return nullptr; + } + + if (!cls->IsDescendantOf(NAME_AltHud)) + { + Printf(TEXTCOLOR_RED "Alternative HUD class \"%s\" is not derived from AltHud\n", classname.GetChars()); + return nullptr; + } + + const auto althud = cls->CreateNew(); + + IFVIRTUALPTRNAME(althud, NAME_AltHud, Init) + { + VMValue params[] = { althud }; + VMCall(func, params, countof(params), nullptr, 0); + } + + return althud; +} + +void DBaseStatusBar::CreateAltHUD() +{ + if (AltHud) + { + AltHud->Destroy(); + AltHud = nullptr; + } + + if (!hud_althud_forceinternal) + AltHud = DoCreateAltHUD(gameinfo.althudclass); + + if (!AltHud) + AltHud = DoCreateAltHUD(NAME_AltHud); + + assert(AltHud); +} + + //--------------------------------------------------------------------------- // // draw the HUD diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index cb7296894..a86253b12 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -334,36 +334,6 @@ void ST_CreateStatusBar(bool bTitleLevel) // Constructor // //--------------------------------------------------------------------------- - -static DObject* CreateAltHud(const FName classname) -{ - if (classname == NAME_None) - return nullptr; - - auto cls = PClass::FindClass(classname); - if (!cls) - { - Printf(TEXTCOLOR_RED "Unknown alternative HUD class \"%s\"\n", classname.GetChars()); - return nullptr; - } - - if (!cls->IsDescendantOf(NAME_AltHud)) - { - Printf(TEXTCOLOR_RED "Alternative HUD class \"%s\" is not derived from AltHud\n", classname.GetChars()); - return nullptr; - } - - auto althud = cls->CreateNew(); - - IFVIRTUALPTRNAME(althud, NAME_AltHud, Init) - { - VMValue params[] = { althud }; - VMCall(func, params, countof(params), nullptr, 0); - } - - return althud; -} - DBaseStatusBar::DBaseStatusBar () { CompleteBorder = false; @@ -376,13 +346,7 @@ DBaseStatusBar::DBaseStatusBar () ShowLog = false; defaultScale = { (double)CleanXfac, (double)CleanYfac }; - // Create the AltHud object. - AltHud = CreateAltHud(gameinfo.althudclass); - - if (!AltHud) - AltHud = CreateAltHud(NAME_AltHud); - - assert(AltHud); + CreateAltHUD(); } static void ValidateResolution(int &hres, int &vres)