mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-14 11:50:49 +00:00
- make DHUDFont an object.
This commit is contained in:
parent
7de6528a1f
commit
7a482c6284
14 changed files with 349 additions and 87 deletions
|
@ -116,13 +116,13 @@ class DBloodStatusBar : public DBaseStatusBar
|
||||||
RS_CENTERBOTTOM = 16384,
|
RS_CENTERBOTTOM = 16384,
|
||||||
};
|
};
|
||||||
|
|
||||||
DHUDFont smallf, tinyf;
|
TObjPtr<DHUDFont*> smallf, tinyf;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DBloodStatusBar()
|
DBloodStatusBar()
|
||||||
{
|
{
|
||||||
smallf = { SmallFont, 0, Off, 0, 0 };
|
smallf = Create<DHUDFont>(SmallFont, 0, Off, 0, 0 );
|
||||||
tinyf = { gFont[4], 4, CellRight, 0, 0 };
|
tinyf = Create<DHUDFont>(gFont[4], 4, CellRight, 0, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -433,9 +433,9 @@ private:
|
||||||
gTempStr.Format("%s [%d]", name, gProfile[p].skill);
|
gTempStr.Format("%s [%d]", name, gProfile[p].skill);
|
||||||
|
|
||||||
int color = CR_UNDEFINED;// todo: remap the colors. (11+col)
|
int color = CR_UNDEFINED;// todo: remap the colors. (11+col)
|
||||||
SBar_DrawString(this, &tinyf, gTempStr, x + 4, y, DI_SCREEN_CENTER_TOP, color, 1., -1, -1, 1, 1);
|
SBar_DrawString(this, tinyf, gTempStr, x + 4, y, DI_SCREEN_CENTER_TOP, color, 1., -1, -1, 1, 1);
|
||||||
gTempStr.Format("%2d", gPlayer[p].fragCount);
|
gTempStr.Format("%2d", gPlayer[p].fragCount);
|
||||||
SBar_DrawString(this, &tinyf, gTempStr, x + 76, y, DI_SCREEN_CENTER_TOP, color, 1., -1, -1, 1, 1);
|
SBar_DrawString(this, tinyf, gTempStr, x + 76, y, DI_SCREEN_CENTER_TOP, color, 1., -1, -1, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -461,18 +461,18 @@ private:
|
||||||
gTempStr.Format("%s [%d]", name, gProfile[p].skill);
|
gTempStr.Format("%s [%d]", name, gProfile[p].skill);
|
||||||
gTempStr.ToUpper();
|
gTempStr.ToUpper();
|
||||||
int color = CR_UNDEFINED;// todo: remap the colors.
|
int color = CR_UNDEFINED;// todo: remap the colors.
|
||||||
SBar_DrawString(this, &tinyf, gTempStr, x + 4, y, DI_SCREEN_CENTER_TOP, color, 1., -1, -1, 1, 1);
|
SBar_DrawString(this, tinyf, gTempStr, x + 4, y, DI_SCREEN_CENTER_TOP, color, 1., -1, -1, 1, 1);
|
||||||
|
|
||||||
gTempStr = "F";
|
gTempStr = "F";
|
||||||
x += 76;
|
x += 76;
|
||||||
if (gPlayer[p].hasFlag & 2)
|
if (gPlayer[p].hasFlag & 2)
|
||||||
{
|
{
|
||||||
SBar_DrawString(this, &tinyf, gTempStr, x, y, DI_SCREEN_CENTER_TOP, CR_GREEN/*12*/, 1., -1, -1, 1, 1);
|
SBar_DrawString(this, tinyf, gTempStr, x, y, DI_SCREEN_CENTER_TOP, CR_GREEN/*12*/, 1., -1, -1, 1, 1);
|
||||||
x -= 6;
|
x -= 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gPlayer[p].hasFlag & 1)
|
if (gPlayer[p].hasFlag & 1)
|
||||||
SBar_DrawString(this, &tinyf, gTempStr, x, y, DI_SCREEN_CENTER_TOP, CR_RED/*11*/, 1., -1, -1, 1, 1);
|
SBar_DrawString(this, tinyf, gTempStr, x, y, DI_SCREEN_CENTER_TOP, CR_RED/*11*/, 1., -1, -1, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,16 +489,16 @@ private:
|
||||||
int x = 1, y = 1;
|
int x = 1, y = 1;
|
||||||
if (dword_21EFD0[0] == 0 || (gFrameClock & 8))
|
if (dword_21EFD0[0] == 0 || (gFrameClock & 8))
|
||||||
{
|
{
|
||||||
SBar_DrawString(this, &smallf, GStrings("TXT_COLOR_BLUE"), x, y, 0, CR_LIGHTBLUE, 1., -1, -1, 1, 1);
|
SBar_DrawString(this, smallf, GStrings("TXT_COLOR_BLUE"), x, y, 0, CR_LIGHTBLUE, 1., -1, -1, 1, 1);
|
||||||
gTempStr.Format("%-3d", dword_21EFB0[0]);
|
gTempStr.Format("%-3d", dword_21EFB0[0]);
|
||||||
SBar_DrawString(this, &smallf, gTempStr, x, y + 10, 0, CR_LIGHTBLUE, 1., -1, -1, 1, 1);
|
SBar_DrawString(this, smallf, gTempStr, x, y + 10, 0, CR_LIGHTBLUE, 1., -1, -1, 1, 1);
|
||||||
}
|
}
|
||||||
x = -2;
|
x = -2;
|
||||||
if (dword_21EFD0[1] == 0 || (gFrameClock & 8))
|
if (dword_21EFD0[1] == 0 || (gFrameClock & 8))
|
||||||
{
|
{
|
||||||
SBar_DrawString(this, &smallf, GStrings("TXT_COLOR_RED"), x, y, DI_TEXT_ALIGN_RIGHT, CR_BRICK, 1., -1, -1, 1, 1);
|
SBar_DrawString(this, smallf, GStrings("TXT_COLOR_RED"), x, y, DI_TEXT_ALIGN_RIGHT, CR_BRICK, 1., -1, -1, 1, 1);
|
||||||
gTempStr.Format("%3d", dword_21EFB0[1]);
|
gTempStr.Format("%3d", dword_21EFB0[1]);
|
||||||
SBar_DrawString(this, &smallf, gTempStr, x, y + 10, DI_TEXT_ALIGN_RIGHT, CR_BRICK, 1., -1, -1, 1, 1);
|
SBar_DrawString(this, smallf, gTempStr, x, y + 10, DI_TEXT_ALIGN_RIGHT, CR_BRICK, 1., -1, -1, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -289,7 +289,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, BeginHUD, BeginHUD)
|
||||||
|
|
||||||
DHUDFont* CreateHudFont(FFont* fnt, int spac, int mono, int sx, int sy)
|
DHUDFont* CreateHudFont(FFont* fnt, int spac, int mono, int sx, int sy)
|
||||||
{
|
{
|
||||||
return nullptr;// (Create<DHUDFont>(fnt, spac, EMonospacing(mono), sy, sy));
|
return Create<DHUDFont>(fnt, spac, EMonospacing(mono), sy, sy);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION_NATIVE(DHUDFont, Create, CreateHudFont)
|
DEFINE_ACTION_FUNCTION_NATIVE(DHUDFont, Create, CreateHudFont)
|
||||||
|
|
|
@ -52,7 +52,7 @@ static int CrosshairNum;
|
||||||
|
|
||||||
|
|
||||||
IMPLEMENT_CLASS(DStatusBarCore, true, false)
|
IMPLEMENT_CLASS(DStatusBarCore, true, false)
|
||||||
//IMPLEMENT_CLASS(DHUDFont, true, false);
|
IMPLEMENT_CLASS(DHUDFont, false, false);
|
||||||
|
|
||||||
|
|
||||||
CVAR(Color, crosshaircolor, 0xff0000, CVAR_ARCHIVE);
|
CVAR(Color, crosshaircolor, 0xff0000, CVAR_ARCHIVE);
|
||||||
|
|
|
@ -104,10 +104,10 @@ enum DI_Flags
|
||||||
//
|
//
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
class DHUDFont //: public DObject - need to keep it POD for now.
|
class DHUDFont : public DObject
|
||||||
{
|
{
|
||||||
// this blocks CreateNew on this class which is the intent here.
|
// this blocks CreateNew on this class which is the intent here.
|
||||||
//DECLARE_ABSTRACT_CLASS(DHUDFont, DObject);
|
DECLARE_CLASS(DHUDFont, DObject);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FFont* mFont;
|
FFont* mFont;
|
||||||
|
|
|
@ -453,6 +453,9 @@ void CheckUserMap()
|
||||||
namespace Duke3d
|
namespace Duke3d
|
||||||
{
|
{
|
||||||
::GameInterface* CreateInterface();
|
::GameInterface* CreateInterface();
|
||||||
|
DBaseStatusBar* CreateDukeStatusBar();
|
||||||
|
DBaseStatusBar* CreateRedneckStatusBar();
|
||||||
|
|
||||||
}
|
}
|
||||||
namespace Blood
|
namespace Blood
|
||||||
{
|
{
|
||||||
|
@ -772,6 +775,7 @@ void CreateStatusBar()
|
||||||
int flags = g_gameType;
|
int flags = g_gameType;
|
||||||
PClass* stbarclass = nullptr;
|
PClass* stbarclass = nullptr;
|
||||||
|
|
||||||
|
GC::AddMarkerFunc([]() { GC::Mark(StatusBar); });
|
||||||
if (flags & GAMEFLAG_BLOOD)
|
if (flags & GAMEFLAG_BLOOD)
|
||||||
{
|
{
|
||||||
stbarclass = PClass::FindClass("BloodStatusBar");
|
stbarclass = PClass::FindClass("BloodStatusBar");
|
||||||
|
@ -786,14 +790,14 @@ void CreateStatusBar()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stbarclass = PClass::FindClass(isRR() ? "RedneckStatusBar" : "DukeStatusBar");
|
StatusBar = isRR() ? Duke3d::CreateRedneckStatusBar() : Duke3d::CreateDukeStatusBar();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (!stbarclass)
|
if (!stbarclass)
|
||||||
{
|
{
|
||||||
I_FatalError("No status bar defined");
|
I_FatalError("No status bar defined");
|
||||||
}
|
}
|
||||||
StatusBar = static_cast<DBaseStatusBar*>(stbarclass->CreateNew());
|
StatusBar = static_cast<DBaseStatusBar*>(stbarclass->CreateNew());
|
||||||
GC::AddMarkerFunc([]() { GC::Mark(StatusBar); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -515,14 +515,15 @@ void MoveStatus()
|
||||||
class DExhumedStatusBar : public DBaseStatusBar
|
class DExhumedStatusBar : public DBaseStatusBar
|
||||||
{
|
{
|
||||||
DECLARE_CLASS(DExhumedStatusBar, DBaseStatusBar)
|
DECLARE_CLASS(DExhumedStatusBar, DBaseStatusBar)
|
||||||
|
HAS_OBJECT_POINTERS
|
||||||
|
|
||||||
DHUDFont textfont, numberFont;
|
TObjPtr<DHUDFont*> textfont, numberFont;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DExhumedStatusBar()
|
DExhumedStatusBar()
|
||||||
{
|
{
|
||||||
textfont = { SmallFont, 1, Off, 1, 1 };
|
textfont = Create<DHUDFont>(SmallFont, 1, Off, 1, 1 );
|
||||||
numberFont = { BigFont, 0, Off, 1, 1 };
|
numberFont = Create<DHUDFont>(BigFont, 0, Off, 1, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -689,7 +690,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(stringBuf, "%d", nPlayerScore[i]);
|
sprintf(stringBuf, "%d", nPlayerScore[i]);
|
||||||
SBar_DrawString(this, &textfont, stringBuf, x, 0, DI_ITEM_TOP|DI_TEXT_ALIGN_CENTER, i != nLocalPlayer ? CR_UNTRANSLATED : CR_GOLD, 1, -1, 0, 1, 1);
|
SBar_DrawString(this, textfont, stringBuf, x, 0, DI_ITEM_TOP|DI_TEXT_ALIGN_CENTER, i != nLocalPlayer ? CR_UNTRANSLATED : CR_GOLD, 1, -1, 0, 1, 1);
|
||||||
x += xx;
|
x += xx;
|
||||||
nTile++;
|
nTile++;
|
||||||
}
|
}
|
||||||
|
@ -708,7 +709,7 @@ private:
|
||||||
|
|
||||||
y += 20;
|
y += 20;
|
||||||
nNetTime -= 29;
|
nNetTime -= 29;
|
||||||
SBar_DrawString(this, &textfont, stringBuf, 0, 10, DI_ITEM_TOP | DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, -1, 0, 1, 1);
|
SBar_DrawString(this, textfont, stringBuf, 0, 10, DI_ITEM_TOP | DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, -1, 0, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,7 +731,7 @@ private:
|
||||||
FString format;
|
FString format;
|
||||||
FGameTexture* img;
|
FGameTexture* img;
|
||||||
double imgScale;
|
double imgScale;
|
||||||
double baseScale = numberFont.mFont->GetHeight() * 0.75;
|
double baseScale = numberFont->mFont->GetHeight() * 0.75;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -748,7 +749,7 @@ private:
|
||||||
int intens = clamp(255 - 4 * s, 0, 255);
|
int intens = clamp(255 - 4 * s, 0, 255);
|
||||||
auto pe = PalEntry(255, intens, intens, intens);
|
auto pe = PalEntry(255, intens, intens, intens);
|
||||||
format.Format("%d", pp->nHealth >> 3);
|
format.Format("%d", pp->nHealth >> 3);
|
||||||
SBar_DrawString(this, &numberFont, format, 13, -numberFont.mFont->GetHeight()+3, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
SBar_DrawString(this, numberFont, format, 13, -numberFont->mFont->GetHeight()+3, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -772,7 +773,7 @@ private:
|
||||||
DrawGraphic(img, 70, -1, DI_ITEM_CENTER_BOTTOM, 1., -1, -1, imgScale, imgScale);
|
DrawGraphic(img, 70, -1, DI_ITEM_CENTER_BOTTOM, 1., -1, -1, imgScale, imgScale);
|
||||||
|
|
||||||
format.Format("%d", pp->nMagic / 10);
|
format.Format("%d", pp->nMagic / 10);
|
||||||
SBar_DrawString(this, &numberFont, format, 79.5, -numberFont.mFont->GetHeight()+3, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
SBar_DrawString(this, numberFont, format, 79.5, -numberFont->mFont->GetHeight()+3, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Weapon
|
// Weapon
|
||||||
|
@ -797,7 +798,7 @@ private:
|
||||||
|
|
||||||
if ((!althud_flashing || leveltime & 8 || ammo > 10))// (DamageData[weapon].max_ammo / 10)))
|
if ((!althud_flashing || leveltime & 8 || ammo > 10))// (DamageData[weapon].max_ammo / 10)))
|
||||||
{
|
{
|
||||||
SBar_DrawString(this, &numberFont, format, -3, -numberFont.mFont->GetHeight()+3, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
SBar_DrawString(this, numberFont, format, -3, -numberFont->mFont->GetHeight()+3, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//DrawGraphic(img, -imgX, -1, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, imgScale, imgScale);
|
//DrawGraphic(img, -imgX, -1, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, imgScale, imgScale);
|
||||||
|
@ -917,7 +918,7 @@ private:
|
||||||
if (nSnakeCam >= 0)
|
if (nSnakeCam >= 0)
|
||||||
{
|
{
|
||||||
BeginHUD(320, 200, 1);
|
BeginHUD(320, 200, 1);
|
||||||
SBar_DrawString(this, &textfont, "S E R P E N T C A M", 0, 0, DI_TEXT_ALIGN_CENTER | DI_SCREEN_CENTER_TOP, CR_UNTRANSLATED, 1, -1, 0, 1, 1);
|
SBar_DrawString(this, textfont, "S E R P E N T C A M", 0, 0, DI_TEXT_ALIGN_CENTER | DI_SCREEN_CENTER_TOP, CR_UNTRANSLATED, 1, -1, 0, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -970,8 +971,11 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_CLASS(DExhumedStatusBar, false, false)
|
IMPLEMENT_CLASS(DExhumedStatusBar, false, true)
|
||||||
|
IMPLEMENT_POINTERS_START(DExhumedStatusBar)
|
||||||
|
IMPLEMENT_POINTER(textfont)
|
||||||
|
IMPLEMENT_POINTER(numberFont)
|
||||||
|
IMPLEMENT_POINTERS_END
|
||||||
|
|
||||||
void UpdateFrame()
|
void UpdateFrame()
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,7 +44,14 @@ source as it is released.
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
IMPLEMENT_CLASS(DDukeCommonStatusBar, true, false)
|
IMPLEMENT_CLASS(DDukeCommonStatusBar, true, true)
|
||||||
|
IMPLEMENT_POINTERS_START(DDukeCommonStatusBar)
|
||||||
|
IMPLEMENT_POINTER(miniFont)
|
||||||
|
IMPLEMENT_POINTER(numberFont)
|
||||||
|
IMPLEMENT_POINTER(digiFont)
|
||||||
|
IMPLEMENT_POINTER(indexFont)
|
||||||
|
IMPLEMENT_POINTERS_END
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// very much a dummy to access the methods.
|
// very much a dummy to access the methods.
|
||||||
|
|
|
@ -10,12 +10,13 @@ BEGIN_DUKE_NS
|
||||||
class DDukeCommonStatusBar : public DBaseStatusBar
|
class DDukeCommonStatusBar : public DBaseStatusBar
|
||||||
{
|
{
|
||||||
DECLARE_ABSTRACT_CLASS(DDukeCommonStatusBar, DBaseStatusBar)
|
DECLARE_ABSTRACT_CLASS(DDukeCommonStatusBar, DBaseStatusBar)
|
||||||
|
HAS_OBJECT_POINTERS
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DHUDFont numberFont;
|
TObjPtr<DHUDFont*> numberFont;
|
||||||
DHUDFont indexFont;
|
TObjPtr<DHUDFont*> indexFont;
|
||||||
DHUDFont miniFont;
|
TObjPtr<DHUDFont*> miniFont;
|
||||||
DHUDFont digiFont;
|
TObjPtr<DHUDFont*> digiFont;
|
||||||
double scale = 1;
|
double scale = 1;
|
||||||
std::array<int, MAX_WEAPONS> ammo_sprites;
|
std::array<int, MAX_WEAPONS> ammo_sprites;
|
||||||
std::array<int, 8> item_icons;
|
std::array<int, 8> item_icons;
|
||||||
|
|
|
@ -56,12 +56,13 @@ class DDukeStatusBar : public DDukeCommonStatusBar
|
||||||
{
|
{
|
||||||
DECLARE_CLASS(DDukeStatusBar, DDukeCommonStatusBar)
|
DECLARE_CLASS(DDukeStatusBar, DDukeCommonStatusBar)
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DDukeStatusBar()
|
DDukeStatusBar()
|
||||||
{
|
{
|
||||||
numberFont = { BigFont, 0, Off, 1, 1 };
|
numberFont = Create<DHUDFont>( BigFont, 0, Off, 1, 1 );
|
||||||
indexFont = { IndexFont, 4, CellRight, 1, 1 };
|
indexFont = Create<DHUDFont>(IndexFont, 4, CellRight, 1, 1 );
|
||||||
miniFont = { SmallFont2, 0, Off, 1, 1 };
|
miniFont = Create<DHUDFont>(SmallFont2, 0, Off, 1, 1 );
|
||||||
digiFont = { DigiFont, 1, Off, 1, 1 };
|
digiFont = Create<DHUDFont>(DigiFont, 1, Off, 1, 1 );
|
||||||
|
|
||||||
// optionally draw at the top of the screen.
|
// optionally draw at the top of the screen.
|
||||||
SetSize(tilesiz[TILE_BOTTOMSTATUSBAR].y);
|
SetSize(tilesiz[TILE_BOTTOMSTATUSBAR].y);
|
||||||
|
@ -120,8 +121,8 @@ public:
|
||||||
FString format;
|
FString format;
|
||||||
FGameTexture* img;
|
FGameTexture* img;
|
||||||
double imgScale;
|
double imgScale;
|
||||||
double baseScale = (scale * numberFont.mFont->GetHeight()) * (isNamWW2GI() ? 0.65 : !isPlutoPak() ? 0.75 : 0.7);
|
double baseScale = (scale * numberFont->mFont->GetHeight()) * (isNamWW2GI() ? 0.65 : !isPlutoPak() ? 0.75 : 0.7);
|
||||||
double texty = -numberFont.mFont->GetHeight() + (isNamWW2GI() ? 2.5 : !isPlutoPak() ? 3.5 : 4.5);
|
double texty = -numberFont->mFont->GetHeight() + (isNamWW2GI() ? 2.5 : !isPlutoPak() ? 3.5 : 4.5);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Health
|
// Health
|
||||||
|
@ -137,7 +138,7 @@ public:
|
||||||
s += (sintable[(I_GetBuildTime() << 5) & 2047] / 768);
|
s += (sintable[(I_GetBuildTime() << 5) & 2047] / 768);
|
||||||
int intens = clamp(255 - 6 * s, 0, 255);
|
int intens = clamp(255 - 6 * s, 0, 255);
|
||||||
format.Format("%d", p->last_extra);
|
format.Format("%d", p->last_extra);
|
||||||
SBar_DrawString(this, &numberFont, format, 25, texty, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, intens / 255., 0, 0, 1, 1);
|
SBar_DrawString(this, numberFont, format, 25, texty, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, intens / 255., 0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -148,7 +149,7 @@ public:
|
||||||
DrawGraphic(img, 67.375, -1.5, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, imgScale, imgScale);
|
DrawGraphic(img, 67.375, -1.5, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, imgScale, imgScale);
|
||||||
|
|
||||||
format.Format("%d", GetMoraleOrShield(p, snum));
|
format.Format("%d", GetMoraleOrShield(p, snum));
|
||||||
SBar_DrawString(this, &numberFont, format, 85, texty, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
SBar_DrawString(this, numberFont, format, 85, texty, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Weapon
|
// Weapon
|
||||||
|
@ -181,7 +182,7 @@ public:
|
||||||
|
|
||||||
if (weapon != KNEE_WEAPON && (!althud_flashing || ud.levelclock & 32 || ammo > (max_ammo_amount[weapon] / 10)))
|
if (weapon != KNEE_WEAPON && (!althud_flashing || ud.levelclock & 32 || ammo > (max_ammo_amount[weapon] / 10)))
|
||||||
{
|
{
|
||||||
SBar_DrawString(this, &numberFont, format, -3, texty, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
SBar_DrawString(this, numberFont, format, -3, texty, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawGraphic(img, -imgX, -1.5, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, imgScale, imgScale);
|
DrawGraphic(img, -imgX, -1.5, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, imgScale, imgScale);
|
||||||
|
@ -205,10 +206,10 @@ public:
|
||||||
int percentv = getinvamount(p);
|
int percentv = getinvamount(p);
|
||||||
format.Format("%3d%%", percentv);
|
format.Format("%3d%%", percentv);
|
||||||
EColorRange color = percentv > 50 ? CR_GREEN : percentv > 25 ? CR_GOLD : CR_RED;
|
EColorRange color = percentv > 50 ? CR_GREEN : percentv > 25 ? CR_GOLD : CR_RED;
|
||||||
SBar_DrawString(this, &indexFont, format, x + 36.5, -indexFont.mFont->GetHeight() + 0.5, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1);
|
SBar_DrawString(this, indexFont, format, x + 36.5, -indexFont->mFont->GetHeight() + 0.5, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1);
|
||||||
|
|
||||||
auto text = ontext(p);
|
auto text = ontext(p);
|
||||||
if (text.first) SBar_DrawString(this, &miniFont, text.first, x + 36.5, -miniFont.mFont->GetHeight() - 9.5, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1);
|
if (text.first) SBar_DrawString(this, miniFont, text.first, x + 36.5, -miniFont->mFont->GetHeight() - 9.5, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -234,7 +235,7 @@ public:
|
||||||
DrawGraphic(tileGetTexture(HEALTHBOX), 5, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale);
|
DrawGraphic(tileGetTexture(HEALTHBOX), 5, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale);
|
||||||
int health = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra;
|
int health = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra;
|
||||||
FStringf format("%d", health);
|
FStringf format("%d", health);
|
||||||
SBar_DrawString(this, &digiFont, format, 20, -digiFont.mFont->GetHeight() * scale - 3, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
SBar_DrawString(this, digiFont, format, 20, -digiFont->mFont->GetHeight() * scale - 3, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
||||||
|
|
||||||
//
|
//
|
||||||
// ammo
|
// ammo
|
||||||
|
@ -242,7 +243,7 @@ public:
|
||||||
DrawGraphic(tileGetTexture(AMMOBOX), 37, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale);
|
DrawGraphic(tileGetTexture(AMMOBOX), 37, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale);
|
||||||
int wp = (p->curr_weapon == HANDREMOTE_WEAPON) ? HANDBOMB_WEAPON : p->curr_weapon;
|
int wp = (p->curr_weapon == HANDREMOTE_WEAPON) ? HANDBOMB_WEAPON : p->curr_weapon;
|
||||||
format.Format("%d", p->ammo_amount[wp]);
|
format.Format("%d", p->ammo_amount[wp]);
|
||||||
SBar_DrawString(this, &digiFont, format, 52, -digiFont.mFont->GetHeight() * scale - 3, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
SBar_DrawString(this, digiFont, format, 52, -digiFont->mFont->GetHeight() * scale - 3, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
||||||
|
|
||||||
//
|
//
|
||||||
// inventory
|
// inventory
|
||||||
|
@ -258,10 +259,10 @@ public:
|
||||||
int percentv = getinvamount(p);
|
int percentv = getinvamount(p);
|
||||||
format.Format("%3d%%", percentv);
|
format.Format("%3d%%", percentv);
|
||||||
EColorRange color = percentv > 50 ? CR_GREEN : percentv > 25 ? CR_GOLD : CR_RED;
|
EColorRange color = percentv > 50 ? CR_GREEN : percentv > 25 ? CR_GOLD : CR_RED;
|
||||||
SBar_DrawString(this, &indexFont, format, x + 34, -indexFont.mFont->GetHeight() - 3, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1);
|
SBar_DrawString(this, indexFont, format, x + 34, -indexFont->mFont->GetHeight() - 3, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1);
|
||||||
|
|
||||||
auto text = ontext(p);
|
auto text = ontext(p);
|
||||||
if (text.first) SBar_DrawString(this, &miniFont, text.first, x + 34, -miniFont.mFont->GetHeight() - 14, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1);
|
if (text.first) SBar_DrawString(this, miniFont, text.first, x + 34, -miniFont->mFont->GetHeight() - 14, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +398,7 @@ public:
|
||||||
{
|
{
|
||||||
DrawGraphic(tileGetTexture(KILLSICON), 228, top + 8, DI_ITEM_OFFSETS, 1, 0, 0, 1, 1);
|
DrawGraphic(tileGetTexture(KILLSICON), 228, top + 8, DI_ITEM_OFFSETS, 1, 0, 0, 1, 1);
|
||||||
format.Format("%d", max(p->frag - p->fraggedself, 0));
|
format.Format("%d", max(p->frag - p->fraggedself, 0));
|
||||||
SBar_DrawString(this, &digiFont, format, 287, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
SBar_DrawString(this, digiFont, format, 287, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -410,15 +411,15 @@ public:
|
||||||
|
|
||||||
int num = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra;
|
int num = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra;
|
||||||
format.Format("%d", num);
|
format.Format("%d", num);
|
||||||
SBar_DrawString(this, &digiFont, format, 31, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
SBar_DrawString(this, digiFont, format, 31, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
||||||
format.Format("%d", GetMoraleOrShield(p, snum));
|
format.Format("%d", GetMoraleOrShield(p, snum));
|
||||||
SBar_DrawString(this, &digiFont, format, 63, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
SBar_DrawString(this, digiFont, format, 63, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
||||||
|
|
||||||
if (p->curr_weapon != KNEE_WEAPON)
|
if (p->curr_weapon != KNEE_WEAPON)
|
||||||
{
|
{
|
||||||
int wep = (p->curr_weapon == HANDREMOTE_WEAPON)? HANDBOMB_WEAPON : p->curr_weapon;
|
int wep = (p->curr_weapon == HANDREMOTE_WEAPON)? HANDBOMB_WEAPON : p->curr_weapon;
|
||||||
format.Format("%d", p->ammo_amount[wep]);
|
format.Format("%d", p->ammo_amount[wep]);
|
||||||
SBar_DrawString(this, &digiFont, format, 207, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
SBar_DrawString(this, digiFont, format, 207, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int icon = p->inven_icon;
|
int icon = p->inven_icon;
|
||||||
|
@ -431,10 +432,10 @@ public:
|
||||||
int percentv = getinvamount(p);
|
int percentv = getinvamount(p);
|
||||||
format.Format("%3d%%", percentv);
|
format.Format("%3d%%", percentv);
|
||||||
EColorRange color = percentv > 50 ? CR_GREEN : percentv > 25 ? CR_GOLD : CR_RED;
|
EColorRange color = percentv > 50 ? CR_GREEN : percentv > 25 ? CR_GOLD : CR_RED;
|
||||||
SBar_DrawString(this, &indexFont, format, x + 34, top + 24, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1);
|
SBar_DrawString(this, indexFont, format, x + 34, top + 24, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1);
|
||||||
|
|
||||||
auto text = ontext(p);
|
auto text = ontext(p);
|
||||||
if (text.first) SBar_DrawString(this, &miniFont, text.first, x + 34, top + 14, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1);
|
if (text.first) SBar_DrawString(this, miniFont, text.first, x + 34, top + 14, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
PrintLevelStats(-1);
|
PrintLevelStats(-1);
|
||||||
}
|
}
|
||||||
|
@ -454,5 +455,9 @@ public:
|
||||||
|
|
||||||
IMPLEMENT_CLASS(DDukeStatusBar, false, false)
|
IMPLEMENT_CLASS(DDukeStatusBar, false, false)
|
||||||
|
|
||||||
|
DBaseStatusBar* CreateDukeStatusBar()
|
||||||
|
{
|
||||||
|
return Create<DDukeStatusBar>();
|
||||||
|
}
|
||||||
|
|
||||||
END_DUKE_NS
|
END_DUKE_NS
|
||||||
|
|
|
@ -51,9 +51,9 @@ class DRedneckStatusBar : public DDukeCommonStatusBar
|
||||||
public:
|
public:
|
||||||
DRedneckStatusBar()
|
DRedneckStatusBar()
|
||||||
{
|
{
|
||||||
numberFont = { BigFont, 0, Off, 1, 1 };
|
numberFont = Create<DHUDFont>(BigFont, 0, Off, 1, 1 );
|
||||||
miniFont = { SmallFont2, 0, Off, 1, 1 };
|
miniFont = Create<DHUDFont>(SmallFont2, 0, Off, 1, 1 );
|
||||||
digiFont = { DigiFont, 2, Off, 1, 1 };
|
digiFont = Create<DHUDFont>(DigiFont, 2, Off, 1, 1 );
|
||||||
|
|
||||||
// optionally draw at the top of the screen.
|
// optionally draw at the top of the screen.
|
||||||
SetSize(tilesiz[BOTTOMSTATUSBAR].y);
|
SetSize(tilesiz[BOTTOMSTATUSBAR].y);
|
||||||
|
@ -98,7 +98,7 @@ public:
|
||||||
FString format;
|
FString format;
|
||||||
FGameTexture* img;
|
FGameTexture* img;
|
||||||
double imgScale;
|
double imgScale;
|
||||||
double baseScale = (scale * numberFont.mFont->GetHeight()) * 0.76;
|
double baseScale = (scale * numberFont->mFont->GetHeight()) * 0.76;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Health
|
// Health
|
||||||
|
@ -114,7 +114,7 @@ public:
|
||||||
s += (sintable[(I_GetBuildTime() << 5) & 2047] / 768);
|
s += (sintable[(I_GetBuildTime() << 5) & 2047] / 768);
|
||||||
int intens = clamp(255 - 6 * s, 0, 255);
|
int intens = clamp(255 - 6 * s, 0, 255);
|
||||||
format.Format("%d", p->last_extra);
|
format.Format("%d", p->last_extra);
|
||||||
SBar_DrawString(this, &numberFont, format, 26.5, -numberFont.mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, intens / 255., 0, 0, scale, scale);
|
SBar_DrawString(this, numberFont, format, 26.5, -numberFont->mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, intens / 255., 0, 0, scale, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -124,7 +124,7 @@ public:
|
||||||
imgScale = baseScale / img->GetDisplayHeight();
|
imgScale = baseScale / img->GetDisplayHeight();
|
||||||
DrawGraphic(img, 74, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, imgScale, imgScale);
|
DrawGraphic(img, 74, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, imgScale, imgScale);
|
||||||
format.Format("%d", p->drink_amt);
|
format.Format("%d", p->drink_amt);
|
||||||
SBar_DrawString(this, &numberFont, format, 86, -numberFont.mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
SBar_DrawString(this, numberFont, format, 86, -numberFont->mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
||||||
|
|
||||||
//
|
//
|
||||||
// eat
|
// eat
|
||||||
|
@ -133,7 +133,7 @@ public:
|
||||||
imgScale = baseScale / img->GetDisplayHeight();
|
imgScale = baseScale / img->GetDisplayHeight();
|
||||||
DrawGraphic(img, 133.5, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, imgScale, imgScale);
|
DrawGraphic(img, 133.5, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, imgScale, imgScale);
|
||||||
format.Format("%d", p->eat);
|
format.Format("%d", p->eat);
|
||||||
SBar_DrawString(this, &numberFont, format, 173, -numberFont.mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
SBar_DrawString(this, numberFont, format, 173, -numberFont->mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
||||||
|
|
||||||
//
|
//
|
||||||
// selected weapon
|
// selected weapon
|
||||||
|
@ -176,7 +176,7 @@ public:
|
||||||
|
|
||||||
if (weapon != KNEE_WEAPON && weapon != SLINGBLADE_WEAPON && (!althud_flashing || ud.levelclock & 32 || ammo > (max_ammo_amount[weapon] / 10)))
|
if (weapon != KNEE_WEAPON && weapon != SLINGBLADE_WEAPON && (!althud_flashing || ud.levelclock & 32 || ammo > (max_ammo_amount[weapon] / 10)))
|
||||||
{
|
{
|
||||||
SBar_DrawString(this, &numberFont, format, -1, -numberFont.mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
SBar_DrawString(this, numberFont, format, -1, -numberFont->mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawGraphic(img, -imgX, -2, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, imgScale, imgScale);
|
DrawGraphic(img, -imgX, -2, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, imgScale, imgScale);
|
||||||
|
@ -200,10 +200,10 @@ public:
|
||||||
int percentv = getinvamount(p);
|
int percentv = getinvamount(p);
|
||||||
if (icon <= 2) format.Format("%d%%", percentv);
|
if (icon <= 2) format.Format("%d%%", percentv);
|
||||||
else format.Format("%d", percentv);
|
else format.Format("%d", percentv);
|
||||||
SBar_DrawString(this, &miniFont, format, x + 19, -miniFont.mFont->GetHeight() * scale - 1, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
SBar_DrawString(this, miniFont, format, x + 19, -miniFont->mFont->GetHeight() * scale - 1, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
||||||
|
|
||||||
auto text = ontext(p);
|
auto text = ontext(p);
|
||||||
if (text.first) SBar_DrawString(this, &miniFont, text.first, x + 20, -miniFont.mFont->GetHeight() * scale - 15, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
if (text.first) SBar_DrawString(this, miniFont, text.first, x + 20, -miniFont->mFont->GetHeight() * scale - 15, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -229,7 +229,7 @@ public:
|
||||||
DrawGraphic(tileGetTexture(HEALTHBOX), 2, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale);
|
DrawGraphic(tileGetTexture(HEALTHBOX), 2, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale);
|
||||||
int health = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra;
|
int health = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra;
|
||||||
FStringf format("%d", health);
|
FStringf format("%d", health);
|
||||||
SBar_DrawString(this, &digiFont, format, 21.5, -digiFont.mFont->GetHeight() * scale - 5.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
SBar_DrawString(this, digiFont, format, 21.5, -digiFont->mFont->GetHeight() * scale - 5.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
||||||
|
|
||||||
//
|
//
|
||||||
// ammo
|
// ammo
|
||||||
|
@ -237,7 +237,7 @@ public:
|
||||||
DrawGraphic(tileGetTexture(AMMOBOX), 41, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale);
|
DrawGraphic(tileGetTexture(AMMOBOX), 41, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale);
|
||||||
int wp = p->curr_weapon == THROWINGDYNAMITE_WEAPON? DYNAMITE_WEAPON : p->curr_weapon;
|
int wp = p->curr_weapon == THROWINGDYNAMITE_WEAPON? DYNAMITE_WEAPON : p->curr_weapon;
|
||||||
format.Format("%d", p->ammo_amount[wp]);
|
format.Format("%d", p->ammo_amount[wp]);
|
||||||
SBar_DrawString(this, &digiFont, format, 60.25, -digiFont.mFont->GetHeight() * scale - 5.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
SBar_DrawString(this, digiFont, format, 60.25, -digiFont->mFont->GetHeight() * scale - 5.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
||||||
|
|
||||||
//
|
//
|
||||||
// inventory
|
// inventory
|
||||||
|
@ -253,7 +253,7 @@ public:
|
||||||
int percentv = getinvamount(p);
|
int percentv = getinvamount(p);
|
||||||
if (icon <= 2) format.Format("%d%%", percentv);
|
if (icon <= 2) format.Format("%d%%", percentv);
|
||||||
else format.Format("%d", percentv);
|
else format.Format("%d", percentv);
|
||||||
SBar_DrawString(this, &miniFont, format, x + 31.5, -miniFont.mFont->GetHeight() * scale - 6.5, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
SBar_DrawString(this, miniFont, format, x + 31.5, -miniFont->mFont->GetHeight() * scale - 6.5, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ public:
|
||||||
|
|
||||||
if (format.Len())
|
if (format.Len())
|
||||||
{
|
{
|
||||||
SBar_DrawString(this, &miniFont, format, 38 + i * 32, 162.75 - miniFont.mFont->GetHeight() * scale * 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale * .875, scale * .875);
|
SBar_DrawString(this, miniFont, format, 38 + i * 32, 162.75 - miniFont->mFont->GetHeight() * scale * 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale * .875, scale * .875);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -366,7 +366,7 @@ public:
|
||||||
{
|
{
|
||||||
DrawGraphic(tileGetTexture(KILLSICON), 228, top + 8, DI_ITEM_OFFSETS, 1, 0, 0, 1, 1);
|
DrawGraphic(tileGetTexture(KILLSICON), 228, top + 8, DI_ITEM_OFFSETS, 1, 0, 0, 1, 1);
|
||||||
format.Format("%d", max(p->frag - p->fraggedself, 0));
|
format.Format("%d", max(p->frag - p->fraggedself, 0));
|
||||||
SBar_DrawString(this, &digiFont, format, 287, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
SBar_DrawString(this, digiFont, format, 287, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -378,13 +378,13 @@ public:
|
||||||
|
|
||||||
int num = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra;
|
int num = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra;
|
||||||
format.Format("%d", num);
|
format.Format("%d", num);
|
||||||
SBar_DrawString(this, &digiFont, format, 66.5, top + 16, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
SBar_DrawString(this, digiFont, format, 66.5, top + 16, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
||||||
|
|
||||||
if (p->curr_weapon != KNEE_WEAPON)
|
if (p->curr_weapon != KNEE_WEAPON)
|
||||||
{
|
{
|
||||||
int wep = (p->curr_weapon == HANDREMOTE_WEAPON) ? DYNAMITE_WEAPON : p->curr_weapon;
|
int wep = (p->curr_weapon == HANDREMOTE_WEAPON) ? DYNAMITE_WEAPON : p->curr_weapon;
|
||||||
format.Format("%d", p->ammo_amount[wep]);
|
format.Format("%d", p->ammo_amount[wep]);
|
||||||
SBar_DrawString(this, &digiFont, format, 110, top + 16, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
SBar_DrawString(this, digiFont, format, 110, top + 16, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
int icon = p->inven_icon;
|
int icon = p->inven_icon;
|
||||||
|
@ -397,10 +397,10 @@ public:
|
||||||
int percentv = getinvamount(p);
|
int percentv = getinvamount(p);
|
||||||
if (icon <= 2) format.Format("%d%%", percentv);
|
if (icon <= 2) format.Format("%d%%", percentv);
|
||||||
else format.Format("%d", percentv);
|
else format.Format("%d", percentv);
|
||||||
SBar_DrawString(this, &miniFont, format, x + 38, top + 23.5, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
SBar_DrawString(this, miniFont, format, x + 38, top + 23.5, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
||||||
|
|
||||||
if (p->inven_icon == ICON_SCUBA || p->inven_icon == ICON_BOOTS)
|
if (p->inven_icon == ICON_SCUBA || p->inven_icon == ICON_BOOTS)
|
||||||
SBar_DrawString(this, &miniFont, "AUTO", x + 39, top + 13, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
SBar_DrawString(this, miniFont, "AUTO", x + 39, top + 13, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
p->drunkang = ((p->drink_amt * 8) + 1647) & 2047;
|
p->drunkang = ((p->drink_amt * 8) + 1647) & 2047;
|
||||||
|
@ -466,5 +466,10 @@ public:
|
||||||
|
|
||||||
IMPLEMENT_CLASS(DRedneckStatusBar, false, false)
|
IMPLEMENT_CLASS(DRedneckStatusBar, false, false)
|
||||||
|
|
||||||
|
DBaseStatusBar* CreateRedneckStatusBar()
|
||||||
|
{
|
||||||
|
return Create<DRedneckStatusBar>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
END_DUKE_NS
|
END_DUKE_NS
|
||||||
|
|
|
@ -70,8 +70,9 @@ static const short icons[] = {
|
||||||
class DSWStatusBar : public DBaseStatusBar
|
class DSWStatusBar : public DBaseStatusBar
|
||||||
{
|
{
|
||||||
DECLARE_CLASS(DSWStatusBar, DBaseStatusBar)
|
DECLARE_CLASS(DSWStatusBar, DBaseStatusBar)
|
||||||
|
HAS_OBJECT_POINTERS
|
||||||
|
|
||||||
DHUDFont miniFont, numberFont;
|
TObjPtr<DHUDFont*> miniFont, numberFont;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -149,8 +150,8 @@ class DSWStatusBar : public DBaseStatusBar
|
||||||
public:
|
public:
|
||||||
DSWStatusBar()
|
DSWStatusBar()
|
||||||
{
|
{
|
||||||
numberFont = { BigFont, 0, Off, 1, 1 };
|
numberFont = Create<DHUDFont>( BigFont, 0, Off, 1, 1 );
|
||||||
miniFont = { SmallFont2, 0, Off, 1, 1 };
|
miniFont = Create<DHUDFont>(SmallFont2, 0, Off, 1, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -241,7 +242,7 @@ private:
|
||||||
|
|
||||||
void DisplayTinyString(double xs, double ys, const char* buffer, int pal)
|
void DisplayTinyString(double xs, double ys, const char* buffer, int pal)
|
||||||
{
|
{
|
||||||
SBar_DrawString(this, &miniFont, buffer, xs, ys, DI_ITEM_LEFT_TOP, TRANSLATION(Translation_Remap, pal), 1, -1, -1, 1, 1);
|
SBar_DrawString(this, miniFont, buffer, xs, ys, DI_ITEM_LEFT_TOP, TRANSLATION(Translation_Remap, pal), 1, -1, -1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayFragString(PLAYERp pp, double xs, double ys, const char* buffer)
|
void DisplayFragString(PLAYERp pp, double xs, double ys, const char* buffer)
|
||||||
|
@ -789,7 +790,7 @@ private:
|
||||||
FString format;
|
FString format;
|
||||||
FGameTexture* img;
|
FGameTexture* img;
|
||||||
double imgScale;
|
double imgScale;
|
||||||
double baseScale = numberFont.mFont->GetHeight() * 0.83125;
|
double baseScale = numberFont->mFont->GetHeight() * 0.83125;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Health
|
// Health
|
||||||
|
@ -806,7 +807,7 @@ private:
|
||||||
int intens = clamp(255 - 4 * s, 0, 255);
|
int intens = clamp(255 - 4 * s, 0, 255);
|
||||||
auto pe = PalEntry(255, intens, intens, intens);
|
auto pe = PalEntry(255, intens, intens, intens);
|
||||||
format.Format("%d", u->Health);
|
format.Format("%d", u->Health);
|
||||||
SBar_DrawString(this, &numberFont, format, 24.25, -numberFont.mFont->GetHeight() + 2, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
SBar_DrawString(this, numberFont, format, 24.25, -numberFont->mFont->GetHeight() + 2, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -817,7 +818,7 @@ private:
|
||||||
DrawGraphic(img, 80.75, -1, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, imgScale, imgScale);
|
DrawGraphic(img, 80.75, -1, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, imgScale, imgScale);
|
||||||
|
|
||||||
format.Format("%d", pp->Armor);
|
format.Format("%d", pp->Armor);
|
||||||
SBar_DrawString(this, &numberFont, format, 108.5, -numberFont.mFont->GetHeight() + 2, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
SBar_DrawString(this, numberFont, format, 108.5, -numberFont->mFont->GetHeight() + 2, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Weapon
|
// Weapon
|
||||||
|
@ -862,7 +863,7 @@ private:
|
||||||
|
|
||||||
if ((!althud_flashing || PlayClock & 32 || ammo > (DamageData[weapon].max_ammo / 10)))
|
if ((!althud_flashing || PlayClock & 32 || ammo > (DamageData[weapon].max_ammo / 10)))
|
||||||
{
|
{
|
||||||
SBar_DrawString(this, &numberFont, format, -1.5, -numberFont.mFont->GetHeight() + 2, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
SBar_DrawString(this, numberFont, format, -1.5, -numberFont->mFont->GetHeight() + 2, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawGraphic(img, -imgX, -1, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, imgScale, imgScale);
|
DrawGraphic(img, -imgX, -1, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, imgScale, imgScale);
|
||||||
|
@ -1036,7 +1037,11 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_CLASS(DSWStatusBar, false, false)
|
IMPLEMENT_CLASS(DSWStatusBar, false, true)
|
||||||
|
IMPLEMENT_POINTERS_START(DSWStatusBar)
|
||||||
|
IMPLEMENT_POINTER(miniFont)
|
||||||
|
IMPLEMENT_POINTER(numberFont)
|
||||||
|
IMPLEMENT_POINTERS_END
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|
|
@ -5,6 +5,9 @@ version "4.3"
|
||||||
#include "zscript/events.zs"
|
#include "zscript/events.zs"
|
||||||
#include "zscript/dictionary.zs"
|
#include "zscript/dictionary.zs"
|
||||||
#include "zscript/gamescreen.zs"
|
#include "zscript/gamescreen.zs"
|
||||||
|
|
||||||
|
#include "zscript/engine/ui/statusbar/statusbarcore.zs"
|
||||||
|
|
||||||
#include "zscript/razebase.zs"
|
#include "zscript/razebase.zs"
|
||||||
|
|
||||||
#include "zscript/ui/menu/colorpickermenu.zs"
|
#include "zscript/ui/menu/colorpickermenu.zs"
|
||||||
|
|
231
wadsrc/static/zscript/engine/ui/statusbar/statusbarcore.zs
Normal file
231
wadsrc/static/zscript/engine/ui/statusbar/statusbarcore.zs
Normal file
|
@ -0,0 +1,231 @@
|
||||||
|
class HUDFont native ui
|
||||||
|
{
|
||||||
|
native Font mFont;
|
||||||
|
native static HUDFont Create(Font fnt, int spacing = 0, EMonospacing monospacing = Mono_Off, int shadowx = 0, int shadowy = 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
class StatusBarCore native ui
|
||||||
|
{
|
||||||
|
enum DI_Flags
|
||||||
|
{
|
||||||
|
DI_SKIPICON = 0x1,
|
||||||
|
DI_SKIPALTICON = 0x2,
|
||||||
|
DI_SKIPSPAWN = 0x4,
|
||||||
|
DI_SKIPREADY = 0x8,
|
||||||
|
DI_ALTICONFIRST = 0x10,
|
||||||
|
DI_TRANSLATABLE = 0x20,
|
||||||
|
DI_FORCESCALE = 0x40,
|
||||||
|
DI_DIM = 0x80,
|
||||||
|
DI_DRAWCURSORFIRST = 0x100, // only for DrawInventoryBar.
|
||||||
|
DI_ALWAYSSHOWCOUNT = 0x200, // only for DrawInventoryBar.
|
||||||
|
DI_DIMDEPLETED = 0x400,
|
||||||
|
DI_DONTANIMATE = 0x800, // do not animate the texture
|
||||||
|
DI_MIRROR = 0x1000, // flip the texture horizontally, like a mirror
|
||||||
|
DI_ITEM_RELCENTER = 0x2000,
|
||||||
|
DI_MIRRORY = 0x40000000,
|
||||||
|
|
||||||
|
DI_SCREEN_AUTO = 0, // decide based on given offsets.
|
||||||
|
DI_SCREEN_MANUAL_ALIGN = 0x4000, // If this is on, the following flags will have an effect
|
||||||
|
|
||||||
|
DI_SCREEN_TOP = DI_SCREEN_MANUAL_ALIGN,
|
||||||
|
DI_SCREEN_VCENTER = 0x8000 | DI_SCREEN_MANUAL_ALIGN,
|
||||||
|
DI_SCREEN_BOTTOM = 0x10000 | DI_SCREEN_MANUAL_ALIGN,
|
||||||
|
DI_SCREEN_VOFFSET = 0x18000 | DI_SCREEN_MANUAL_ALIGN,
|
||||||
|
DI_SCREEN_VMASK = 0x18000 | DI_SCREEN_MANUAL_ALIGN,
|
||||||
|
|
||||||
|
DI_SCREEN_LEFT = DI_SCREEN_MANUAL_ALIGN,
|
||||||
|
DI_SCREEN_HCENTER = 0x20000 | DI_SCREEN_MANUAL_ALIGN,
|
||||||
|
DI_SCREEN_RIGHT = 0x40000 | DI_SCREEN_MANUAL_ALIGN,
|
||||||
|
DI_SCREEN_HOFFSET = 0x60000 | DI_SCREEN_MANUAL_ALIGN,
|
||||||
|
DI_SCREEN_HMASK = 0x60000 | DI_SCREEN_MANUAL_ALIGN,
|
||||||
|
|
||||||
|
DI_SCREEN_LEFT_TOP = DI_SCREEN_TOP|DI_SCREEN_LEFT,
|
||||||
|
DI_SCREEN_RIGHT_TOP = DI_SCREEN_TOP|DI_SCREEN_RIGHT,
|
||||||
|
DI_SCREEN_LEFT_BOTTOM = DI_SCREEN_BOTTOM|DI_SCREEN_LEFT,
|
||||||
|
DI_SCREEN_RIGHT_BOTTOM = DI_SCREEN_BOTTOM|DI_SCREEN_RIGHT,
|
||||||
|
DI_SCREEN_CENTER = DI_SCREEN_VCENTER|DI_SCREEN_HCENTER,
|
||||||
|
DI_SCREEN_CENTER_BOTTOM = DI_SCREEN_BOTTOM|DI_SCREEN_HCENTER,
|
||||||
|
DI_SCREEN_OFFSETS = DI_SCREEN_HOFFSET|DI_SCREEN_VOFFSET,
|
||||||
|
|
||||||
|
DI_ITEM_AUTO = 0, // equivalent with bottom center, which is the default alignment.
|
||||||
|
|
||||||
|
DI_ITEM_TOP = 0x80000,
|
||||||
|
DI_ITEM_VCENTER = 0x100000,
|
||||||
|
DI_ITEM_BOTTOM = 0, // this is the default vertical alignment
|
||||||
|
DI_ITEM_VOFFSET = 0x180000,
|
||||||
|
DI_ITEM_VMASK = 0x180000,
|
||||||
|
|
||||||
|
DI_ITEM_LEFT = 0x200000,
|
||||||
|
DI_ITEM_HCENTER = 0, // this is the default horizontal alignment
|
||||||
|
DI_ITEM_RIGHT = 0x400000,
|
||||||
|
DI_ITEM_HOFFSET = 0x600000,
|
||||||
|
DI_ITEM_HMASK = 0x600000,
|
||||||
|
|
||||||
|
DI_ITEM_LEFT_TOP = DI_ITEM_TOP|DI_ITEM_LEFT,
|
||||||
|
DI_ITEM_RIGHT_TOP = DI_ITEM_TOP|DI_ITEM_RIGHT,
|
||||||
|
DI_ITEM_LEFT_BOTTOM = DI_ITEM_BOTTOM|DI_ITEM_LEFT,
|
||||||
|
DI_ITEM_RIGHT_BOTTOM = DI_ITEM_BOTTOM|DI_ITEM_RIGHT,
|
||||||
|
DI_ITEM_CENTER = DI_ITEM_VCENTER|DI_ITEM_HCENTER,
|
||||||
|
DI_ITEM_CENTER_BOTTOM = DI_ITEM_BOTTOM|DI_ITEM_HCENTER,
|
||||||
|
DI_ITEM_OFFSETS = DI_ITEM_HOFFSET|DI_ITEM_VOFFSET,
|
||||||
|
|
||||||
|
DI_TEXT_ALIGN_LEFT = 0,
|
||||||
|
DI_TEXT_ALIGN_RIGHT = 0x800000,
|
||||||
|
DI_TEXT_ALIGN_CENTER = 0x1000000,
|
||||||
|
DI_TEXT_ALIGN = 0x1800000,
|
||||||
|
|
||||||
|
DI_ALPHAMAPPED = 0x2000000,
|
||||||
|
DI_NOSHADOW = 0x4000000,
|
||||||
|
DI_ALWAYSSHOWCOUNTERS = 0x8000000,
|
||||||
|
DI_ARTIFLASH = 0x10000000,
|
||||||
|
DI_FORCEFILL = 0x20000000,
|
||||||
|
|
||||||
|
// These 2 flags are only used by SBARINFO so these duplicate other flags not used by SBARINFO
|
||||||
|
DI_DRAWINBOX = DI_TEXT_ALIGN_RIGHT,
|
||||||
|
DI_ALTERNATEONFAIL = DI_TEXT_ALIGN_CENTER,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ENumFlags
|
||||||
|
{
|
||||||
|
FNF_WHENNOTZERO = 0x1,
|
||||||
|
FNF_FILLZEROS = 0x2,
|
||||||
|
}
|
||||||
|
|
||||||
|
// These are block properties for the drawers. A child class can set them to have a block of items use the same settings.
|
||||||
|
native double Alpha;
|
||||||
|
native Vector2 drawOffset; // can be set by subclasses to offset drawing operations
|
||||||
|
native double drawClip[4]; // defines a clipping rectangle (not used yet)
|
||||||
|
native bool fullscreenOffsets; // current screen is displayed with fullscreen behavior.
|
||||||
|
native int RelTop;
|
||||||
|
native int HorizontalResolution, VerticalResolution;
|
||||||
|
native bool CompleteBorder;
|
||||||
|
native Vector2 defaultScale; // factor for fully scaled fullscreen display.
|
||||||
|
|
||||||
|
|
||||||
|
native static String FormatNumber(int number, int minsize = 0, int maxsize = 0, int format = 0, String prefix = "");
|
||||||
|
native double, double, double, double StatusbarToRealCoords(double x, double y=0, double w=0, double h=0);
|
||||||
|
native void DrawTexture(TextureID texture, Vector2 pos, int flags = 0, double Alpha = 1., Vector2 box = (-1, -1), Vector2 scale = (1, 1));
|
||||||
|
native void DrawImage(String texture, Vector2 pos, int flags = 0, double Alpha = 1., Vector2 box = (-1, -1), Vector2 scale = (1, 1));
|
||||||
|
native void DrawString(HUDFont font, String string, Vector2 pos, int flags = 0, int translation = Font.CR_UNTRANSLATED, double Alpha = 1., int wrapwidth = -1, int linespacing = 4, Vector2 scale = (1, 1));
|
||||||
|
native double, double, double, double TransformRect(double x, double y, double w, double h, int flags = 0);
|
||||||
|
native void Fill(Color col, double x, double y, double w, double h, int flags = 0);
|
||||||
|
native void SetClipRect(double x, double y, double w, double h, int flags = 0);
|
||||||
|
|
||||||
|
native void SetSize(int height, int vwidth, int vheight, int hwidth = -1, int hheight = -1);
|
||||||
|
native Vector2 GetHUDScale();
|
||||||
|
native void BeginStatusBar(bool forceScaled = false, int resW = -1, int resH = -1, int rel = -1);
|
||||||
|
native void BeginHUD(double Alpha = 1., bool forcescaled = false, int resW = -1, int resH = -1);
|
||||||
|
|
||||||
|
void ClearClipRect()
|
||||||
|
{
|
||||||
|
screen.ClearClipRect();
|
||||||
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
//
|
||||||
|
// Returns how much the status bar's graphics extend into the view
|
||||||
|
// Used for automap text positioning
|
||||||
|
// The parameter specifies how much of the status bar area will be covered
|
||||||
|
// by the element requesting this information.
|
||||||
|
//
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
virtual int GetProtrusion(double scaleratio) const
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
//
|
||||||
|
// a generic value interpolator for status bar elements that can change
|
||||||
|
// gradually to their new value.
|
||||||
|
//
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
class LinearValueInterpolator : Object
|
||||||
|
{
|
||||||
|
int mCurrentValue;
|
||||||
|
int mMaxChange;
|
||||||
|
|
||||||
|
static LinearValueInterpolator Create(int startval, int maxchange)
|
||||||
|
{
|
||||||
|
let v = new("LinearValueInterpolator");
|
||||||
|
v.mCurrentValue = startval;
|
||||||
|
v.mMaxChange = maxchange;
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Reset(int value)
|
||||||
|
{
|
||||||
|
mCurrentValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This must be called periodically in the status bar's Tick function.
|
||||||
|
// Do not call this in the Draw function because that may skip some frames!
|
||||||
|
void Update(int destvalue)
|
||||||
|
{
|
||||||
|
if (mCurrentValue > destvalue)
|
||||||
|
{
|
||||||
|
mCurrentValue = max(destvalue, mCurrentValue - mMaxChange);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mCurrentValue = min(destvalue, mCurrentValue + mMaxChange);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This must be called in the draw function to retrieve the value for output.
|
||||||
|
int GetValue()
|
||||||
|
{
|
||||||
|
return mCurrentValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DynamicValueInterpolator : Object
|
||||||
|
{
|
||||||
|
int mCurrentValue;
|
||||||
|
int mMinChange;
|
||||||
|
int mMaxChange;
|
||||||
|
double mChangeFactor;
|
||||||
|
|
||||||
|
|
||||||
|
static DynamicValueInterpolator Create(int startval, double changefactor, int minchange, int maxchange)
|
||||||
|
{
|
||||||
|
let v = new("DynamicValueInterpolator");
|
||||||
|
v.mCurrentValue = startval;
|
||||||
|
v.mMinChange = minchange;
|
||||||
|
v.mMaxChange = maxchange;
|
||||||
|
v.mChangeFactor = changefactor;
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Reset(int value)
|
||||||
|
{
|
||||||
|
mCurrentValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This must be called periodically in the status bar's Tick function.
|
||||||
|
// Do not call this in the Draw function because that may skip some frames!
|
||||||
|
void Update(int destvalue)
|
||||||
|
{
|
||||||
|
int diff = int(clamp(abs(destvalue - mCurrentValue) * mChangeFactor, mMinChange, mMaxChange));
|
||||||
|
if (mCurrentValue > destvalue)
|
||||||
|
{
|
||||||
|
mCurrentValue = max(destvalue, mCurrentValue - diff);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mCurrentValue = min(destvalue, mCurrentValue + diff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This must be called in the draw function to retrieve the value for output.
|
||||||
|
int GetValue()
|
||||||
|
{
|
||||||
|
return mCurrentValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -56,9 +56,6 @@ class RazeMenuDelegate : MenuDelegateBase
|
||||||
|
|
||||||
// dummy definitions for the status bar. We need them to create the class descriptors
|
// dummy definitions for the status bar. We need them to create the class descriptors
|
||||||
|
|
||||||
class StatusBarCore native ui
|
|
||||||
{}
|
|
||||||
|
|
||||||
class BaseStatusBar : StatusBarCore native
|
class BaseStatusBar : StatusBarCore native
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue