From 31cd741cb052d01dbcf3796c20e49e8aee35d35d Mon Sep 17 00:00:00 2001 From: DyNaM1Kk Date: Mon, 5 May 2025 23:49:49 +0400 Subject: [PATCH] Scriptified DBaseStatusBar::Draw --- src/g_statusbar/sbar.h | 1 - src/g_statusbar/shared_sbar.cpp | 39 ------------------- src/scripting/vmthunks.cpp | 15 ------- .../static/zscript/ui/statusbar/statusbar.zs | 31 ++++++++++++++- 4 files changed, 30 insertions(+), 56 deletions(-) diff --git a/src/g_statusbar/sbar.h b/src/g_statusbar/sbar.h index 5d3f9794d6..9141009c82 100644 --- a/src/g_statusbar/sbar.h +++ b/src/g_statusbar/sbar.h @@ -388,7 +388,6 @@ public: void SetScale(); virtual void Tick (); void CallTick(); - virtual void Draw (EHudState state, double ticFrac); void CallDraw(EHudState state, double ticFrac); void DrawBottomStuff (EHudState state); void DrawTopStuff (EHudState state); diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index 663ab8f965..27575a5c64 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -1088,44 +1088,6 @@ void DBaseStatusBar::DrawMessages (int layer, int bottom) // //--------------------------------------------------------------------------- -void DBaseStatusBar::Draw (EHudState state, double ticFrac) -{ - // HUD_AltHud state is for popups only - if (state == HUD_AltHud) - return; - - if (state == HUD_StatusBar) - { - RefreshBackground (); - } - - if (idmypos) - { - // Draw current coordinates - IFVIRTUAL(DBaseStatusBar, DrawMyPos) - { - VMValue params[] = { (DObject*)this }; - VMCall(func, params, countof(params), nullptr, 0); - } - } - - if (viewactive) - { - if (CPlayer && CPlayer->camera && CPlayer->camera->player) - { - DrawCrosshair (ticFrac); - } - } - else if (automapactive) - { - IFVIRTUAL(DBaseStatusBar, DrawAutomapHUD) - { - VMValue params[] = { (DObject*)this, r_viewpoint.TicFrac }; - VMCall(func, params, countof(params), nullptr, 0); - } - } -} - void DBaseStatusBar::CallDraw(EHudState state, double ticFrac) { IFVIRTUAL(DBaseStatusBar, Draw) @@ -1133,7 +1095,6 @@ void DBaseStatusBar::CallDraw(EHudState state, double ticFrac) VMValue params[] = { (DObject*)this, state, ticFrac }; VMCall(func, params, countof(params), nullptr, 0); } - else Draw(state, ticFrac); twod->ClearClipRect(); // make sure the scripts don't leave a valid clipping rect behind. BeginStatusBar(BaseSBarHorizontalResolution, BaseSBarVerticalResolution, BaseRelTop, false); } diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index 977d72de42..5d3aea03f0 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -2108,21 +2108,6 @@ DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, DetachAllMessages, SBar_DetachAllM return 0; } -static void SBar_Draw(DBaseStatusBar *self, int state, double ticFrac) -{ - self->Draw((EHudState)state, ticFrac); -} - - -DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, Draw, SBar_Draw) -{ - PARAM_SELF_PROLOGUE(DBaseStatusBar); - PARAM_INT(state); - PARAM_FLOAT(ticFrac); - self->Draw((EHudState)state, ticFrac); - return 0; -} - static void SetMugshotState(DBaseStatusBar *self, const FString &statename, bool wait, bool reset) { self->mugshot.SetState(statename.GetChars(), wait, reset); diff --git a/wadsrc/static/zscript/ui/statusbar/statusbar.zs b/wadsrc/static/zscript/ui/statusbar/statusbar.zs index 8d42b22309..fa2b66c6b1 100644 --- a/wadsrc/static/zscript/ui/statusbar/statusbar.zs +++ b/wadsrc/static/zscript/ui/statusbar/statusbar.zs @@ -216,8 +216,37 @@ class BaseStatusBar : StatusBarCore native { } + virtual void Draw (int state, double TicFrac) + { + // HUD_AltHud state is for popups only + if (state == HUD_AltHud) + return; + + if (state == HUD_StatusBar) + { + RefreshBackground(); + } + + if (idmypos) + { + // Draw current coordinates + DrawMyPos(); + } + + if (viewactive) + { + if (CPlayer && CPlayer.camera && CPlayer.camera.player) + { + DrawCrosshair(TicFrac); + } + } + else if (automapactive) + { + DrawAutomapHUD(TicFrac); + } + } + native virtual void Tick (); - native virtual void Draw (int state, double TicFrac); native virtual void ScreenSizeChanged (); native virtual clearscope void ReceivedWeapon (Weapon weapn); native virtual clearscope void SetMugShotState (String state_name, bool wait_till_done=false, bool reset=false);