From b0a38ea4c8a5d0c7a9e672f8bb3763d0114ae227 Mon Sep 17 00:00:00 2001 From: BinarryCode <53833277+BinarryCode@users.noreply.github.com> Date: Thu, 3 Oct 2024 09:18:19 -0700 Subject: [PATCH 1/2] Add new SBARINFO top level "AppendStatusBar", allowing for extra SBARINFO code to be added to custom SBARINFO definitions. --- src/g_statusbar/sbarinfo.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index 6bb27d1798d..cb2ddcd0e1f 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -381,6 +381,7 @@ enum //Key words SBARINFO_MUGSHOT, SBARINFO_CREATEPOPUP, SBARINFO_PROTRUSION, + SBARINFO_APPENDSTATUSBAR, }; enum //Bar types @@ -410,6 +411,7 @@ static const char *SBarInfoTopLevel[] = "mugshot", "createpopup", "protrusion", + "appendstatusbar", NULL }; @@ -629,6 +631,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; @@ -638,11 +641,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 = (sc.MustMatchString(SBarInfoTopLevel) == SBARINFO_APPENDSTATUSBAR); + 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; From 4e3a1d016788bf0a6de1399c8e40dbb4ae23d43d Mon Sep 17 00:00:00 2001 From: BinarryCode <53833277+BinarryCode@users.noreply.github.com> Date: Fri, 4 Oct 2024 16:48:28 -0700 Subject: [PATCH 2/2] Fix Pull Request Review 2346387627 --- src/g_statusbar/sbarinfo.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index cb2ddcd0e1f..13d77dbe605 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -490,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: @@ -642,7 +647,7 @@ void SBarInfo::ParseSBarInfo(int lump) barNum = sc.MustMatchString(StatusBars); } // SBARINFO_APPENDSTATUSBAR shouldn't delete the old HUD if it exists. - const bool append = (sc.MustMatchString(SBarInfoTopLevel) == SBARINFO_APPENDSTATUSBAR); + const bool append = (SBarInfoTopLevelString.CompareNoCase("appendstatusbar") == 0); if (!append) { if (this->huds[barNum] != NULL)