From 5a6121d424decbfe352369712fcb3e6527b13520 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 13 May 2021 19:48:27 +0200 Subject: [PATCH] - status bar interface work. --- source/core/gamecontrol.cpp | 1 + source/core/mainloop.cpp | 4 +++ source/core/statusbar.h | 3 ++ source/core/statusbar2.cpp | 30 +++++++++++++++++++- source/games/duke/src/premap.cpp | 8 +++--- wadsrc/static/zscript/games/blood/ui/sbar.zs | 2 +- wadsrc/static/zscript/statusbar.zs | 4 +-- 7 files changed, 44 insertions(+), 8 deletions(-) diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index b1bdafd0f..ff84ecb97 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -827,6 +827,7 @@ void CreateStatusBar() } StatusBar = static_cast(stbarclass->CreateNew()); StatusBar->SetSize(0, 320, 200); + InitStatusBar(); // this is for comparing the scriptification with the C++ versions //stbarclass = PClass::FindClass("NativeBloodStatusBar"); //StatusBar2 = static_cast(stbarclass->CreateNew()); diff --git a/source/core/mainloop.cpp b/source/core/mainloop.cpp index c3f9aa61b..124a7e61b 100644 --- a/source/core/mainloop.cpp +++ b/source/core/mainloop.cpp @@ -150,6 +150,7 @@ void NewGame(MapRecord* map, int skill, bool ns = false) newGameStarted = true; ShowIntermission(nullptr, map, nullptr, [=](bool) { gi->NewGame(map, skill, ns); + ResetStatusBar(); }); } @@ -199,6 +200,7 @@ static void GameTicker() gi->FreeLevelData(); gameaction = ga_level; gi->NextLevel(g_nextmap, g_nextskill); + ResetStatusBar(); } else { @@ -211,6 +213,7 @@ static void GameTicker() gi->FreeLevelData(); gameaction = ga_level; gi->NextLevel(g_nextmap, g_nextskill); + ResetStatusBar(); break; case ga_newgame: @@ -360,6 +363,7 @@ static void GameTicker() gameupdatetime.Reset(); gameupdatetime.Clock(); gi->Ticker(); + TickStatusBar(); levelTextTime--; gameupdatetime.Unclock(); break; diff --git a/source/core/statusbar.h b/source/core/statusbar.h index 614cfa4da..0dbde56a8 100644 --- a/source/core/statusbar.h +++ b/source/core/statusbar.h @@ -147,5 +147,8 @@ void SerializeHud(FSerializer &arc); extern int levelTextTime; struct SummaryInfo; void UpdateStatusBar(SummaryInfo* info); +void TickStatusBar(); +void ResetStatusBar(); +void InitStatusBar(); #endif /* __SBAR_H__ */ diff --git a/source/core/statusbar2.cpp b/source/core/statusbar2.cpp index ab1e1254e..fd08c88c2 100644 --- a/source/core/statusbar2.cpp +++ b/source/core/statusbar2.cpp @@ -386,4 +386,32 @@ void UpdateStatusBar(SummaryInfo* info) VMValue params[] = { StatusBar, info }; VMCall(func, params, 2, nullptr, 0); } -} \ No newline at end of file +} + +void TickStatusBar() +{ + IFVIRTUALPTRNAME(StatusBar, NAME_RazeStatusBar, Tick) + { + VMValue params[] = { StatusBar }; + VMCall(func, params, 1, nullptr, 0); + } +} + +void ResetStatusBar() +{ + IFVIRTUALPTRNAME(StatusBar, NAME_RazeStatusBar, Reset) + { + VMValue params[] = { StatusBar }; + VMCall(func, params, 1, nullptr, 0); + } +} + +void InitStatusBar() +{ + IFVIRTUALPTRNAME(StatusBar, NAME_RazeStatusBar, Init) + { + VMValue params[] = { StatusBar }; + VMCall(func, params, 1, nullptr, 0); + } +} + diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index d3ff8350c..b9ad8a3b6 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -1086,12 +1086,12 @@ void GameInterface::NewGame(MapRecord* map, int skill, bool) ud.multimode = 1; donewgame(map, skill); - enterlevel(map, 0); + enterlevel(map, 0); if (isShareware() && ud.recstat != 2) FTA(QUOTE_F1HELP, &ps[myconnectindex]); - PlayerColorChanged(); - inputState.ClearAllInput(); - gameaction = ga_level; + PlayerColorChanged(); + inputState.ClearAllInput(); + gameaction = ga_level; } //--------------------------------------------------------------------------- diff --git a/wadsrc/static/zscript/games/blood/ui/sbar.zs b/wadsrc/static/zscript/games/blood/ui/sbar.zs index b336c787d..b597dd3bc 100644 --- a/wadsrc/static/zscript/games/blood/ui/sbar.zs +++ b/wadsrc/static/zscript/games/blood/ui/sbar.zs @@ -30,7 +30,7 @@ class BloodStatusBar : RazeStatusBar int team_score[2], team_ticker[2]; // placeholders for MP display bool gBlueFlagDropped, gRedFlagDropped; // also placeholders until we know where MP will go. - void Init() + override void Init() { smallf = HUDFont.Create(SmallFont, 0, Mono_Off, 0, 0); tinyf = HUDFont.Create(Font.FindFont("DIGIFONT"), 4, Mono_CellRight, 0, 0); diff --git a/wadsrc/static/zscript/statusbar.zs b/wadsrc/static/zscript/statusbar.zs index 41898be23..8f9f12d44 100644 --- a/wadsrc/static/zscript/statusbar.zs +++ b/wadsrc/static/zscript/statusbar.zs @@ -18,12 +18,12 @@ struct StatsPrintInfo class RazeStatusBar : StatusBarCore { - void Init() + virtual void Init() { - SetSize(0, 320, 200); } virtual void Tick() {} + virtual void Reset() {} virtual void UpdateStatusBar(SummaryInfo info) {} void drawStatText(Font statFont, int x, int y, String text, double scale)