From 781cb32dcf763c8184616d4a608f0ac027be5af1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 15 May 2021 16:46:08 +0200 Subject: [PATCH] - fixed all issues with Duke's/RR's status bar. --- .../common/scripting/interface/vmnatives.cpp | 2 +- source/core/gamecontrol.cpp | 15 +++++++------ source/games/duke/src/game_misc.cpp | 4 +--- source/games/duke/src/sbar.cpp | 21 +++++++++++++++++++ source/games/duke/src/sbar.h | 1 + source/games/duke/src/sbar_r.cpp | 3 +++ wadsrc/static/zscript/games/duke/ui/sbar.zs | 4 +++- wadsrc/static/zscript/games/duke/ui/sbar_r.zs | 12 +++++------ wadsrc/static/zscript/statusbar.zs | 2 +- 9 files changed, 46 insertions(+), 18 deletions(-) diff --git a/source/common/scripting/interface/vmnatives.cpp b/source/common/scripting/interface/vmnatives.cpp index de97b2974..6276ac906 100644 --- a/source/common/scripting/interface/vmnatives.cpp +++ b/source/common/scripting/interface/vmnatives.cpp @@ -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) diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 5b86234b9..96c88815a 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -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(stbarclass->CreateNew()); + StatusBar2 = isRR() ? Duke3d::CreateRedneckStatusBar() : Duke3d::CreateDukeStatusBar(); + + //stbarclass = PClass::FindClass("NativeExhumedStatusBar"); + //StatusBar2 = static_cast(stbarclass->CreateNew()); StatusBar2->SetSize(0, 320, 200); StatusBar2->Release(); - */ } diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index 0ec3b38e3..8aecf9472 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -291,9 +291,7 @@ void drawoverlays(double smoothratio) } } - DrawBorder(); - - StatusBar->UpdateStatusBar(); + DrawStatusBar(); if (ps[myconnectindex].newOwner == nullptr && ud.cameraactor == nullptr) { diff --git a/source/games/duke/src/sbar.cpp b/source/games/duke/src/sbar.cpp index cca87b7d3..b4e79d8b0 100644 --- a/source/games/duke/src/sbar.cpp +++ b/source/games/duke/src/sbar.cpp @@ -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 diff --git a/source/games/duke/src/sbar.h b/source/games/duke/src/sbar.h index 20b02a9ea..caab35eac 100644 --- a/source/games/duke/src/sbar.h +++ b/source/games/duke/src/sbar.h @@ -31,5 +31,6 @@ public: }; void DrawBorder(); +void DrawStatusBar(); END_DUKE_NS diff --git a/source/games/duke/src/sbar_r.cpp b/source/games/duke/src/sbar_r.cpp index 92696965f..b5ab34167 100644 --- a/source/games/duke/src/sbar_r.cpp +++ b/source/games/duke/src/sbar_r.cpp @@ -57,6 +57,9 @@ public: numberFont = Create(BigFont, 0, Off, 1, 1 ); miniFont = Create(SmallFont2, 0, Off, 1, 1 ); digiFont = Create(DigiFont, 2, Off, 1, 1 ); + numberFont->Release(); + miniFont->Release(); + digiFont->Release(); // optionally draw at the top of the screen. SetSize(tileHeight(BOTTOMSTATUSBAR)); diff --git a/wadsrc/static/zscript/games/duke/ui/sbar.zs b/wadsrc/static/zscript/games/duke/ui/sbar.zs index 77b9a5e4f..c8434bf50 100644 --- a/wadsrc/static/zscript/games/duke/ui/sbar.zs +++ b/wadsrc/static/zscript/games/duke/ui/sbar.zs @@ -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; } diff --git a/wadsrc/static/zscript/games/duke/ui/sbar_r.zs b/wadsrc/static/zscript/games/duke/ui/sbar_r.zs index d033f051f..67c446997 100644 --- a/wadsrc/static/zscript/games/duke/ui/sbar_r.zs +++ b/wadsrc/static/zscript/games/duke/ui/sbar_r.zs @@ -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) { diff --git a/wadsrc/static/zscript/statusbar.zs b/wadsrc/static/zscript/statusbar.zs index 8f9f12d44..9f8a50878 100644 --- a/wadsrc/static/zscript/statusbar.zs +++ b/wadsrc/static/zscript/statusbar.zs @@ -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);