Skip to content

Commit

Permalink
- status bar interface work.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed May 15, 2021
1 parent c716900 commit 5a6121d
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 8 deletions.
1 change: 1 addition & 0 deletions source/core/gamecontrol.cpp
Expand Up @@ -827,6 +827,7 @@ void CreateStatusBar()
}
StatusBar = static_cast<DBaseStatusBar*>(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<DBaseStatusBar*>(stbarclass->CreateNew());
Expand Down
4 changes: 4 additions & 0 deletions source/core/mainloop.cpp
Expand Up @@ -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();
});
}

Expand Down Expand Up @@ -199,6 +200,7 @@ static void GameTicker()
gi->FreeLevelData();
gameaction = ga_level;
gi->NextLevel(g_nextmap, g_nextskill);
ResetStatusBar();
}
else
{
Expand All @@ -211,6 +213,7 @@ static void GameTicker()
gi->FreeLevelData();
gameaction = ga_level;
gi->NextLevel(g_nextmap, g_nextskill);
ResetStatusBar();
break;

case ga_newgame:
Expand Down Expand Up @@ -360,6 +363,7 @@ static void GameTicker()
gameupdatetime.Reset();
gameupdatetime.Clock();
gi->Ticker();
TickStatusBar();
levelTextTime--;
gameupdatetime.Unclock();
break;
Expand Down
3 changes: 3 additions & 0 deletions source/core/statusbar.h
Expand Up @@ -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__ */
30 changes: 29 additions & 1 deletion source/core/statusbar2.cpp
Expand Up @@ -386,4 +386,32 @@ void UpdateStatusBar(SummaryInfo* info)
VMValue params[] = { StatusBar, info };
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);
}
}

8 changes: 4 additions & 4 deletions source/games/duke/src/premap.cpp
Expand Up @@ -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;
}

//---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion wadsrc/static/zscript/games/blood/ui/sbar.zs
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions wadsrc/static/zscript/statusbar.zs
Expand Up @@ -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)
Expand Down

0 comments on commit 5a6121d

Please sign in to comment.