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/5] 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/5] 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) From 529b21279a783ccafe0058a46f1d1f0cdc7ad105 Mon Sep 17 00:00:00 2001 From: BinarryCode <53833277+BinarryCode@users.noreply.github.com> Date: Mon, 18 Nov 2024 09:30:57 -0800 Subject: [PATCH 3/5] Update sbarinfo.cpp Update code to be consistent with patch for Zandronum --- src/g_statusbar/sbarinfo.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index 13d77dbe605..e626efbd88a 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -490,12 +490,9 @@ 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)) + // Store the command, used for the switch statement and case SBARINFO_APPENDSTATUSBAR. + const int command = sc.MustMatchString(SBarInfoTopLevel); + switch(command) { case SBARINFO_BASE: baseSet = true; @@ -647,8 +644,7 @@ void SBarInfo::ParseSBarInfo(int lump) barNum = sc.MustMatchString(StatusBars); } // SBARINFO_APPENDSTATUSBAR shouldn't delete the old HUD if it exists. - const bool append = (SBarInfoTopLevelString.CompareNoCase("appendstatusbar") == 0); - if (!append) + if (command != SBARINFO_APPENDSTATUSBAR) { if (this->huds[barNum] != NULL) { @@ -656,6 +652,10 @@ void SBarInfo::ParseSBarInfo(int lump) } this->huds[barNum] = new SBarInfoMainBlock(this); } + else if (this->huds[barNum] == NULL) + { + sc.ScriptError( "AppendStatusBar can't be used on a HUD that doesn't exist yet." ); + } if(barNum == STBAR_AUTOMAP) { automapbar = true; From f7fc39bf9f316a5765f70911017121021a019c72 Mon Sep 17 00:00:00 2001 From: BinarryCode <53833277+BinarryCode@users.noreply.github.com> Date: Sat, 23 Nov 2024 08:25:05 -0800 Subject: [PATCH 4/5] tweak error message --- src/g_statusbar/sbarinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index e626efbd88a..f84440ac9ea 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -654,7 +654,7 @@ void SBarInfo::ParseSBarInfo(int lump) } else if (this->huds[barNum] == NULL) { - sc.ScriptError( "AppendStatusBar can't be used on a HUD that doesn't exist yet." ); + sc.ScriptError("Status bar '%s' has not been created and cannot be appended to. Use 'StatusBar' instead.", StatusBars[barNum]); } if(barNum == STBAR_AUTOMAP) { From 9729381d30627d39816c71d7dc89f0511a95e1d4 Mon Sep 17 00:00:00 2001 From: BinarryCode <53833277+BinarryCode@users.noreply.github.com> Date: Sun, 24 Nov 2024 13:10:21 -0800 Subject: [PATCH 5/5] make if-checks for AppendStatusBar consistent with Zandronum implementation --- src/g_statusbar/sbarinfo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index f84440ac9ea..82aba42631b 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -644,7 +644,7 @@ void SBarInfo::ParseSBarInfo(int lump) barNum = sc.MustMatchString(StatusBars); } // SBARINFO_APPENDSTATUSBAR shouldn't delete the old HUD if it exists. - if (command != SBARINFO_APPENDSTATUSBAR) + if(command != SBARINFO_APPENDSTATUSBAR) { if (this->huds[barNum] != NULL) { @@ -652,7 +652,7 @@ void SBarInfo::ParseSBarInfo(int lump) } this->huds[barNum] = new SBarInfoMainBlock(this); } - else if (this->huds[barNum] == NULL) + else if(this->huds[barNum] == NULL) { sc.ScriptError("Status bar '%s' has not been created and cannot be appended to. Use 'StatusBar' instead.", StatusBars[barNum]); }