mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-12-01 00:21:43 +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 ()
|
DBaseStatusBar::DBaseStatusBar ()
|
||||||
{
|
{
|
||||||
CompleteBorder = false;
|
CompleteBorder = false;
|
||||||
|
@ -347,20 +376,13 @@ DBaseStatusBar::DBaseStatusBar ()
|
||||||
ShowLog = false;
|
ShowLog = false;
|
||||||
defaultScale = { (double)CleanXfac, (double)CleanYfac };
|
defaultScale = { (double)CleanXfac, (double)CleanYfac };
|
||||||
|
|
||||||
// Create the AltHud object. Todo: Make class type configurable.
|
// Create the AltHud object.
|
||||||
FName classname = "AltHud";
|
AltHud = CreateAltHud(gameinfo.althudclass);
|
||||||
auto cls = PClass::FindClass(classname);
|
|
||||||
if (cls)
|
|
||||||
{
|
|
||||||
AltHud = cls->CreateNew();
|
|
||||||
|
|
||||||
VMFunction * func = PClass::FindFunction(classname, "Init");
|
if (!AltHud)
|
||||||
if (func != nullptr)
|
AltHud = CreateAltHud(NAME_AltHud);
|
||||||
{
|
|
||||||
VMValue params[] = { AltHud };
|
assert(AltHud);
|
||||||
VMCall(func, params, countof(params), nullptr, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ValidateResolution(int &hres, int &vres)
|
static void ValidateResolution(int &hres, int &vres)
|
||||||
|
|
|
@ -390,6 +390,7 @@ void FMapInfoParser::ParseGameInfo()
|
||||||
GAMEINFOKEY_STRING(backpacktype, "backpacktype")
|
GAMEINFOKEY_STRING(backpacktype, "backpacktype")
|
||||||
GAMEINFOKEY_STRING_STAMPED(statusbar, "statusbar", statusbarfile)
|
GAMEINFOKEY_STRING_STAMPED(statusbar, "statusbar", statusbarfile)
|
||||||
GAMEINFOKEY_STRING_STAMPED(statusbarclass, "statusbarclass", statusbarclassfile)
|
GAMEINFOKEY_STRING_STAMPED(statusbarclass, "statusbarclass", statusbarclassfile)
|
||||||
|
GAMEINFOKEY_STRING(althudclass, "althudclass")
|
||||||
GAMEINFOKEY_MUSIC(intermissionMusic, intermissionOrder, "intermissionMusic")
|
GAMEINFOKEY_MUSIC(intermissionMusic, intermissionOrder, "intermissionMusic")
|
||||||
GAMEINFOKEY_STRING(CursorPic, "CursorPic")
|
GAMEINFOKEY_STRING(CursorPic, "CursorPic")
|
||||||
GAMEINFOKEY_STRING(MessageBoxClass, "MessageBoxClass")
|
GAMEINFOKEY_STRING(MessageBoxClass, "MessageBoxClass")
|
||||||
|
|
|
@ -158,6 +158,7 @@ struct gameinfo_t
|
||||||
FString statusbar;
|
FString statusbar;
|
||||||
int statusbarfile = -1;
|
int statusbarfile = -1;
|
||||||
FName statusbarclass;
|
FName statusbarclass;
|
||||||
|
FName althudclass;
|
||||||
int statusbarclassfile = -1;
|
int statusbarclassfile = -1;
|
||||||
FName MessageBoxClass;
|
FName MessageBoxClass;
|
||||||
FName backpacktype;
|
FName backpacktype;
|
||||||
|
|
|
@ -1088,3 +1088,4 @@ xx(PlayerTeam)
|
||||||
xx(PlayerColors)
|
xx(PlayerColors)
|
||||||
xx(PlayerSkin)
|
xx(PlayerSkin)
|
||||||
xx(NewPlayerMenu)
|
xx(NewPlayerMenu)
|
||||||
|
xx(AltHud)
|
||||||
|
|
|
@ -44,7 +44,7 @@ class AltHud ui
|
||||||
const POWERUPICONSIZE = 32;
|
const POWERUPICONSIZE = 32;
|
||||||
|
|
||||||
|
|
||||||
void Init()
|
virtual void Init()
|
||||||
{
|
{
|
||||||
switch (gameinfo.gametype)
|
switch (gameinfo.gametype)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue