- fixed all issues with Duke's/RR's status bar.

This commit is contained in:
Christoph Oelckers 2021-05-15 16:46:08 +02:00
parent f84f58e714
commit 781cb32dcf
9 changed files with 46 additions and 18 deletions

View file

@ -136,7 +136,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawImage, SBar_DrawImage)
void SBar_DrawImageRotated(DStatusBarCore* self, const FString& texid, double x, double y, int flags, double angle, double alpha, double scaleX, double scaleY, int style, int color, int translation)
{
if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
self->DrawRotated(TexMan.CheckForTexture(texid, ETextureType::Any), x, y, flags, alpha, scaleX, scaleY, color, translation, style);
self->DrawRotated(TexMan.CheckForTexture(texid, ETextureType::Any), x, y, flags, angle, alpha, scaleX, scaleY, color, translation, (ERenderStyle)style);
}
DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawImageRotated, SBar_DrawImageRotated)

View file

@ -816,10 +816,13 @@ void CreateStatusBar()
{
stbarclass = PClass::FindClass("ExhumedStatusBar");
}
else if (flags & GAMEFLAG_RRALL)
{
stbarclass = PClass::FindClass("RedneckStatusBar");
}
else
{
StatusBar = isRR() ? Duke3d::CreateRedneckStatusBar() : Duke3d::CreateDukeStatusBar();
return;
stbarclass = PClass::FindClass("DukeStatusBar");
}
if (!stbarclass)
{
@ -829,12 +832,12 @@ void CreateStatusBar()
StatusBar->SetSize(0, 320, 200);
InitStatusBar();
// this is for comparing the scriptification with the C++ versions
/*
stbarclass = PClass::FindClass("NativeExhumedStatusBar");
StatusBar2 = static_cast<DBaseStatusBar*>(stbarclass->CreateNew());
StatusBar2 = isRR() ? Duke3d::CreateRedneckStatusBar() : Duke3d::CreateDukeStatusBar();
//stbarclass = PClass::FindClass("NativeExhumedStatusBar");
//StatusBar2 = static_cast<DBaseStatusBar*>(stbarclass->CreateNew());
StatusBar2->SetSize(0, 320, 200);
StatusBar2->Release();
*/
}

View file

@ -291,9 +291,7 @@ void drawoverlays(double smoothratio)
}
}
DrawBorder();
StatusBar->UpdateStatusBar();
DrawStatusBar();
if (ps[myconnectindex].newOwner == nullptr && ud.cameraactor == nullptr)
{

View file

@ -298,6 +298,27 @@ void DrawBorder()
}
}
CVAR(Bool, old_sb, false, 0)
void DrawStatusBar()
{
DrawBorder();
if (old_sb)
{
StatusBar2->UpdateStatusBar();
return;
}
SummaryInfo info{};
info.kills = ps[0].actors_killed;
info.maxkills = ps[0].max_actors_killed;
info.secrets = ps[0].secret_rooms;
info.maxsecrets = ps[0].max_secret_rooms;
info.time = Scale(PlayClock, 1000, 120);
UpdateStatusBar(&info);
}
//==========================================================================
//
// view sizing game interface

View file

@ -31,5 +31,6 @@ public:
};
void DrawBorder();
void DrawStatusBar();
END_DUKE_NS

View file

@ -57,6 +57,9 @@ public:
numberFont = Create<DHUDFont>(BigFont, 0, Off, 1, 1 );
miniFont = Create<DHUDFont>(SmallFont2, 0, Off, 1, 1 );
digiFont = Create<DHUDFont>(DigiFont, 2, Off, 1, 1 );
numberFont->Release();
miniFont->Release();
digiFont->Release();
// optionally draw at the top of the screen.
SetSize(tileHeight(BOTTOMSTATUSBAR));

View file

@ -194,20 +194,22 @@ class DukeCommonStatusBar : RazeStatusBar
}
else if (hud_stats)
{
stats.spacing = Raze.isRR() ? 10 : 7;
stats.letterColor = Font.TEXTCOLOR_ORANGE;
if (Raze.isNamWW2GI())
{
stats.spacing = 8;
stats.standardColor = Font.TEXTCOLOR_YELLOW;
stats.completeColor = Font.TEXTCOLOR_FIRE;
}
else if (!Raze.isRR())
{
stats.spacing = 7;
stats.standardColor = Font.TEXTCOLOR_CREAM;
stats.completeColor = Font.TEXTCOLOR_FIRE;
}
else
{
stats.spacing = 10;
stats.standardColor =
stats.completeColor = Font.TEXTCOLOR_UNTRANSLATED;
}

View file

@ -221,7 +221,7 @@ class RedneckStatusBar : DukeCommonStatusBar
//
// ammo
//
DrawImage("AMMOBOX", (37, -2), DI_ITEM_LEFT_BOTTOM, scale:(scale, scale));
DrawImage("AMMOBOX", (41, -2), DI_ITEM_LEFT_BOTTOM, scale:(scale, scale));
int wp = p.curr_weapon == RRWpn.THROWINGDYNAMITE_WEAPON? RRWpn.DYNAMITE_WEAPON : p.curr_weapon;
format = String.Format("%d", p.ammo_amount[wp]);
DrawString(digiFont, format, (60.25, -digiFont.mFont.GetHeight() * scale - 5.5), DI_TEXT_ALIGN_CENTER, scale:(scale, scale));
@ -233,7 +233,7 @@ class RedneckStatusBar : DukeCommonStatusBar
if (icon > 0)
{
int x = 84;
DrawImage("INVENTORYBOX", (69, -2), DI_ITEM_LEFT_BOTTOM, scale:(scale, scale));
DrawImage("INVENTORYBOX", (77, -2), DI_ITEM_LEFT_BOTTOM, scale:(scale, scale));
if (icon < Duke.ICON_MAX)
DrawImage(item_icons[icon], (x, -15.375), DI_ITEM_LEFT|DI_ITEM_VCENTER, scale:(scale, scale));
@ -252,7 +252,7 @@ class RedneckStatusBar : DukeCommonStatusBar
void DrawHud(DukePlayer p, int style, SummaryInfo info)
{
BeginHUD(320, 200, 1.f);
BeginHUD(1, false, 320, 200);
if (style == 1)
{
double y = -40;
@ -324,7 +324,7 @@ class RedneckStatusBar : DukeCommonStatusBar
void Statusbar(DukePlayer p)
{
let bsb = TexMan.CheckForTexture("BOTTOMSTATUSBAR", Texman.Type_Any);
let siz = TexMan.GetScaledSize(bsb);
let siz = TexMan.GetScaledSize(bsb) * scale;
double wh = 0;
if (hud_size < Hud_Stbar) wh = tileHeight("WEAPONBAR") * scale;
@ -393,8 +393,8 @@ class RedneckStatusBar : DukeCommonStatusBar
p.drunkang = 400;
}
DrawImageRotated("GUTMETER", (256, top + 15), DI_ITEM_RELCENTER, p.drunkang * -Raze.BAngToDegree, 1, (scale, scale), 0xffffffff, 0);
DrawImageRotated("GUTMETER", (292, top + 15), DI_ITEM_RELCENTER, p.eatang * -Raze.BAngToDegree, 1, (scale, scale), 0xffffffff, 0);
DrawImageRotated("GUTMETER", (256, top + 15), DI_ITEM_RELCENTER, p.drunkang * -Raze.BAngToDegree, 1, (scale, scale));
DrawImageRotated("GUTMETER", (292, top + 15), DI_ITEM_RELCENTER, p.eatang * -Raze.BAngToDegree, 1, (scale, scale));
if (p.drink_amt >= 0 && p.drink_amt <= 30)
{

View file

@ -26,7 +26,7 @@ class RazeStatusBar : StatusBarCore
virtual void Reset() {}
virtual void UpdateStatusBar(SummaryInfo info) {}
void drawStatText(Font statFont, int x, int y, String text, double scale)
void drawStatText(Font statFont, double x, double y, String text, double scale)
{
Screen.DrawText(statfont, Font.CR_UNTRANSLATED, x + scale, y + scale, text, DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200,
DTA_KeepRatio, true, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_LegacyRenderStyle, STYLE_TranslucentStencil, DTA_Color, 0);