- added ability to force internal alternative HUD

Set hud_althud_forceinternal CVAR to disable unwanted HUD customizations
This commit is contained in:
alexey.lysiuk 2019-11-26 12:05:29 +02:00
parent e21c9e0ef8
commit fdd17403e5
3 changed files with 62 additions and 37 deletions

View file

@ -434,6 +434,8 @@ public:
virtual void SetMugShotState (const char *state_name, bool wait_till_done=false, bool reset=false); virtual void SetMugShotState (const char *state_name, bool wait_till_done=false, bool reset=false);
void DrawLog(); void DrawLog();
uint32_t GetTranslation() const; uint32_t GetTranslation() const;
void CreateAltHUD();
void DrawAltHUD(); void DrawAltHUD();
void DrawGraphic(FTextureID texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY); void DrawGraphic(FTextureID texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY);

View file

@ -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? 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 // draw the HUD

View file

@ -334,36 +334,6 @@ void ST_CreateStatusBar(bool bTitleLevel)
// Constructor // 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 () DBaseStatusBar::DBaseStatusBar ()
{ {
CompleteBorder = false; CompleteBorder = false;
@ -376,13 +346,7 @@ DBaseStatusBar::DBaseStatusBar ()
ShowLog = false; ShowLog = false;
defaultScale = { (double)CleanXfac, (double)CleanYfac }; defaultScale = { (double)CleanXfac, (double)CleanYfac };
// Create the AltHud object. CreateAltHUD();
AltHud = CreateAltHud(gameinfo.althudclass);
if (!AltHud)
AltHud = CreateAltHud(NAME_AltHud);
assert(AltHud);
} }
static void ValidateResolution(int &hres, int &vres) static void ValidateResolution(int &hres, int &vres)