From bb12dabe2bb71d8a5d51f1e4b9fecf05a9a89750 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 5 May 2017 19:32:37 +0200 Subject: [PATCH] - added a 'protrusion' property to SBARINFO so that the map name display can properly be handled here as well. Until now it was only working for scripted status bars. --- src/g_statusbar/sbarinfo.cpp | 34 +++++++++++++++++++ src/g_statusbar/sbarinfo.h | 1 + wadsrc/static/sbarinfo/heretic.txt | 1 + wadsrc/static/sbarinfo/hexen.txt | 1 + .../zscript/statusbar/sbarinfowrapper.txt | 6 ++++ 5 files changed, 43 insertions(+) diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index 6d9baea24..1846ecbc6 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -386,6 +386,7 @@ enum //Key words SBARINFO_STATUSBAR, SBARINFO_MUGSHOT, SBARINFO_CREATEPOPUP, + SBARINFO_PROTRUSION, }; enum //Bar types @@ -414,6 +415,7 @@ static const char *SBarInfoTopLevel[] = "statusbar", "mugshot", "createpopup", + "protrusion", NULL }; @@ -743,6 +745,21 @@ void SBarInfo::ParseSBarInfo(int lump) sc.MustGetToken(';'); break; } + case SBARINFO_PROTRUSION: + { + double lastvalue = -DBL_EPSILON; + do + { + sc.MustGetToken(TK_FloatConst); + if (sc.Float <= lastvalue) sc.ScriptError("Protrusion factors must be in ascending order"); + lastvalue = sc.Float; + sc.MustGetToken(','); + sc.MustGetToken(TK_IntConst); + protrusions.Push({ lastvalue, sc.Number }); + } while (sc.CheckToken(',')); + sc.MustGetToken(';'); + break; + } } } } @@ -1160,6 +1177,17 @@ public: } } + int _GetProtrusion(double scalefac) + { + int returnval = 0; + for (auto &prot : script->protrusions) + { + if (prot.first > scalefac) break; + returnval = prot.second; + } + return returnval; + } + //draws an image with the specified flags void DrawGraphic(FTexture* texture, SBarInfoCoordinate x, SBarInfoCoordinate y, int xOffset, int yOffset, double Alpha, bool fullScreenOffsets, bool translate=false, bool dim=false, int offsetflags=0, bool alphaMap=false, int forceWidth=-1, int forceHeight=-1, const double *clip = nulclip, bool clearDontDraw=false) const { @@ -1538,6 +1566,12 @@ DEFINE_ACTION_FUNCTION(DSBarInfo, ShowPop) return 0; } +DEFINE_ACTION_FUNCTION(DSBarInfo, GetProtrusion) +{ + PARAM_SELF_STRUCT_PROLOGUE(DSBarInfo); + PARAM_FLOAT(scalefac); + ACTION_RETURN_INT(self->_GetProtrusion(scalefac)); +} DBaseStatusBar *CreateCustomStatusBar(int scriptno) { diff --git a/src/g_statusbar/sbarinfo.h b/src/g_statusbar/sbarinfo.h index 136f814f7..cfc3395d8 100644 --- a/src/g_statusbar/sbarinfo.h +++ b/src/g_statusbar/sbarinfo.h @@ -101,6 +101,7 @@ struct SBarInfo bool completeBorder; bool lowerHealthCap; char spacingCharacter; + TArray> protrusions; MonospaceAlignment spacingAlignment; int interpolationSpeed; int armorInterpolationSpeed; diff --git a/wadsrc/static/sbarinfo/heretic.txt b/wadsrc/static/sbarinfo/heretic.txt index 7f312be77..1515a1769 100755 --- a/wadsrc/static/sbarinfo/heretic.txt +++ b/wadsrc/static/sbarinfo/heretic.txt @@ -10,6 +10,7 @@ ******************************************************************************/ height 42; +protrusion 0.7, 8; monospacefonts true, "0", center; statusbar fullscreen, fullscreenoffsets diff --git a/wadsrc/static/sbarinfo/hexen.txt b/wadsrc/static/sbarinfo/hexen.txt index 583f02779..bd62cc52c 100755 --- a/wadsrc/static/sbarinfo/hexen.txt +++ b/wadsrc/static/sbarinfo/hexen.txt @@ -10,6 +10,7 @@ ******************************************************************************/ height 38; +protrusion 0.0, 12, 0.85, 28; monospacefonts true, "0", center; statusbar fullscreen, fullscreenoffsets diff --git a/wadsrc/static/zscript/statusbar/sbarinfowrapper.txt b/wadsrc/static/zscript/statusbar/sbarinfowrapper.txt index 7a7aaea4f..efc6bedc8 100644 --- a/wadsrc/static/zscript/statusbar/sbarinfowrapper.txt +++ b/wadsrc/static/zscript/statusbar/sbarinfowrapper.txt @@ -8,6 +8,7 @@ struct SBarInfo native ui native bool MustDrawLog(int state); native void Tick(); native void ShowPop(int popnum); + native int GetProtrusion(double scalefac); } @@ -62,5 +63,10 @@ class SBarInfoWrapper : BaseStatusBar core.ShowPop(popnum); } + override int GetProtrusion(double scaleratio) const + { + return core.GetProtrusion(scaleratio); + } + } \ No newline at end of file