mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +00:00
- 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
This commit is contained in:
parent
a3741abbf3
commit
a7f2df4fef
5 changed files with 39 additions and 14 deletions
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -158,6 +158,7 @@ struct gameinfo_t
|
|||
FString statusbar;
|
||||
int statusbarfile = -1;
|
||||
FName statusbarclass;
|
||||
FName althudclass;
|
||||
int statusbarclassfile = -1;
|
||||
FName MessageBoxClass;
|
||||
FName backpacktype;
|
||||
|
|
|
@ -1088,3 +1088,4 @@ xx(PlayerTeam)
|
|||
xx(PlayerColors)
|
||||
xx(PlayerSkin)
|
||||
xx(NewPlayerMenu)
|
||||
xx(AltHud)
|
||||
|
|
|
@ -44,7 +44,7 @@ class AltHud ui
|
|||
const POWERUPICONSIZE = 32;
|
||||
|
||||
|
||||
void Init()
|
||||
virtual void Init()
|
||||
{
|
||||
switch (gameinfo.gametype)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue