Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add system for modular SBARINFO #2742

Merged
merged 5 commits into from
Nov 24, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/g_statusbar/sbarinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ enum //Key words
SBARINFO_MUGSHOT,
SBARINFO_CREATEPOPUP,
SBARINFO_PROTRUSION,
SBARINFO_APPENDSTATUSBAR,
};

enum //Bar types
Expand Down Expand Up @@ -410,6 +411,7 @@ static const char *SBarInfoTopLevel[] =
"mugshot",
"createpopup",
"protrusion",
"appendstatusbar",
NULL
};

Expand Down Expand Up @@ -488,6 +490,11 @@ void SBarInfo::ParseSBarInfo(int lump)
continue;
}
int baselump = -2;
FString SBarInfoTopLevelString;
if(sc.GetString(SBarInfoTopLevelString))
{ // Store the string if the next token is a string, and revert scanner state afterwards
sc.UnGet();
}
switch(sc.MustMatchString(SBarInfoTopLevel))
{
case SBARINFO_BASE:
Expand Down Expand Up @@ -629,6 +636,7 @@ void SBarInfo::ParseSBarInfo(int lump)
sc.MustGetToken(';');
break;
case SBARINFO_STATUSBAR:
case SBARINFO_APPENDSTATUSBAR:
{
if(!baseSet) //If the user didn't explicitly define a base, do so now.
gameType = GAME_Any;
Expand All @@ -638,11 +646,16 @@ void SBarInfo::ParseSBarInfo(int lump)
sc.MustGetToken(TK_Identifier);
barNum = sc.MustMatchString(StatusBars);
}
if (this->huds[barNum] != NULL)
// SBARINFO_APPENDSTATUSBAR shouldn't delete the old HUD if it exists.
const bool append = (SBarInfoTopLevelString.CompareNoCase("appendstatusbar") == 0);
if (!append)
{
delete this->huds[barNum];
if (this->huds[barNum] != NULL)
{
delete this->huds[barNum];
}
this->huds[barNum] = new SBarInfoMainBlock(this);
}
this->huds[barNum] = new SBarInfoMainBlock(this);
if(barNum == STBAR_AUTOMAP)
{
automapbar = true;
Expand Down
Loading