- status bar interface work.

This commit is contained in:
Christoph Oelckers 2021-05-13 19:48:27 +02:00
parent c716900a3c
commit 5a6121d424
7 changed files with 44 additions and 8 deletions

View file

@ -827,6 +827,7 @@ void CreateStatusBar()
} }
StatusBar = static_cast<DBaseStatusBar*>(stbarclass->CreateNew()); StatusBar = static_cast<DBaseStatusBar*>(stbarclass->CreateNew());
StatusBar->SetSize(0, 320, 200); StatusBar->SetSize(0, 320, 200);
InitStatusBar();
// this is for comparing the scriptification with the C++ versions // this is for comparing the scriptification with the C++ versions
//stbarclass = PClass::FindClass("NativeBloodStatusBar"); //stbarclass = PClass::FindClass("NativeBloodStatusBar");
//StatusBar2 = static_cast<DBaseStatusBar*>(stbarclass->CreateNew()); //StatusBar2 = static_cast<DBaseStatusBar*>(stbarclass->CreateNew());

View file

@ -150,6 +150,7 @@ void NewGame(MapRecord* map, int skill, bool ns = false)
newGameStarted = true; newGameStarted = true;
ShowIntermission(nullptr, map, nullptr, [=](bool) { ShowIntermission(nullptr, map, nullptr, [=](bool) {
gi->NewGame(map, skill, ns); gi->NewGame(map, skill, ns);
ResetStatusBar();
}); });
} }
@ -199,6 +200,7 @@ static void GameTicker()
gi->FreeLevelData(); gi->FreeLevelData();
gameaction = ga_level; gameaction = ga_level;
gi->NextLevel(g_nextmap, g_nextskill); gi->NextLevel(g_nextmap, g_nextskill);
ResetStatusBar();
} }
else else
{ {
@ -211,6 +213,7 @@ static void GameTicker()
gi->FreeLevelData(); gi->FreeLevelData();
gameaction = ga_level; gameaction = ga_level;
gi->NextLevel(g_nextmap, g_nextskill); gi->NextLevel(g_nextmap, g_nextskill);
ResetStatusBar();
break; break;
case ga_newgame: case ga_newgame:
@ -360,6 +363,7 @@ static void GameTicker()
gameupdatetime.Reset(); gameupdatetime.Reset();
gameupdatetime.Clock(); gameupdatetime.Clock();
gi->Ticker(); gi->Ticker();
TickStatusBar();
levelTextTime--; levelTextTime--;
gameupdatetime.Unclock(); gameupdatetime.Unclock();
break; break;

View file

@ -147,5 +147,8 @@ void SerializeHud(FSerializer &arc);
extern int levelTextTime; extern int levelTextTime;
struct SummaryInfo; struct SummaryInfo;
void UpdateStatusBar(SummaryInfo* info); void UpdateStatusBar(SummaryInfo* info);
void TickStatusBar();
void ResetStatusBar();
void InitStatusBar();
#endif /* __SBAR_H__ */ #endif /* __SBAR_H__ */

View file

@ -387,3 +387,31 @@ void UpdateStatusBar(SummaryInfo* info)
VMCall(func, params, 2, nullptr, 0); VMCall(func, params, 2, nullptr, 0);
} }
} }
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);
}
}

View file

@ -30,7 +30,7 @@ class BloodStatusBar : RazeStatusBar
int team_score[2], team_ticker[2]; // placeholders for MP display int team_score[2], team_ticker[2]; // placeholders for MP display
bool gBlueFlagDropped, gRedFlagDropped; // also placeholders until we know where MP will go. 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); smallf = HUDFont.Create(SmallFont, 0, Mono_Off, 0, 0);
tinyf = HUDFont.Create(Font.FindFont("DIGIFONT"), 4, Mono_CellRight, 0, 0); tinyf = HUDFont.Create(Font.FindFont("DIGIFONT"), 4, Mono_CellRight, 0, 0);

View file

@ -18,12 +18,12 @@ struct StatsPrintInfo
class RazeStatusBar : StatusBarCore class RazeStatusBar : StatusBarCore
{ {
void Init() virtual void Init()
{ {
SetSize(0, 320, 200);
} }
virtual void Tick() {} virtual void Tick() {}
virtual void Reset() {}
virtual void UpdateStatusBar(SummaryInfo info) {} virtual void UpdateStatusBar(SummaryInfo info) {}
void drawStatText(Font statFont, int x, int y, String text, double scale) void drawStatText(Font statFont, int x, int y, String text, double scale)