From 2f06c09681de7e00ee29ce49e56fbdfb86a69243 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Mar 2017 10:36:16 +0200 Subject: [PATCH 01/15] - fixed map name display on the automap HUD This would cut off overlong names and the handling for status bars with protruding elements was far too simplistic and worse, making assumptions based on game mode. It now uses a virtual function to query the status bar itself for returning this information so it can be overridden and uses V_BreakLines to split the text if it is wider than the display. --- src/g_statusbar/sbarinfo.cpp | 1 - src/g_statusbar/shared_sbar.cpp | 77 ++++++++----------- .../static/zscript/statusbar/heretic_sbar.txt | 5 ++ .../static/zscript/statusbar/hexen_sbar.txt | 5 ++ wadsrc/static/zscript/statusbar/statusbar.txt | 14 ++++ .../static/zscript/statusbar/strife_sbar.txt | 5 ++ 6 files changed, 61 insertions(+), 46 deletions(-) diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index 8c775dd84..a28205ae2 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -1586,7 +1586,6 @@ DBaseStatusBar *CreateCustomStatusBar(int scriptno) auto core = new DSBarInfo(sbar, script); sbar->PointerVar("core") = core; sbar->SetSize(script->height, script->_resW, script->_resH); - sbar->SetScaled(sbar->Scaled); sbar->CompleteBorder = script->completeBorder; return sbar; } diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index f6b0644cc..a5ed1f78a 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -1025,63 +1025,50 @@ void DBaseStatusBar::Draw (EHudState state) EColorRange highlight = (gameinfo.gametype & GAME_DoomChex) ? CR_UNTRANSLATED : CR_YELLOW; - height = SmallFont->GetHeight () * CleanYfac; + height = SmallFont->GetHeight() * CleanYfac; // Draw timer y = 8; if (am_showtime) { - mysnprintf (line, countof(line), "%02d:%02d:%02d", time/3600, (time%3600)/60, time%60); // Time - screen->DrawText (SmallFont, CR_GREY, SCREENWIDTH - 80*CleanXfac, y, line, DTA_CleanNoMove, true, TAG_DONE); - y+=8*CleanYfac; + mysnprintf(line, countof(line), "%02d:%02d:%02d", time / 3600, (time % 3600) / 60, time % 60); // Time + screen->DrawText(SmallFont, CR_GREY, SCREENWIDTH - 80 * CleanXfac, y, line, DTA_CleanNoMove, true, TAG_DONE); + y += 8 * CleanYfac; } if (am_showtotaltime) { - mysnprintf (line, countof(line), "%02d:%02d:%02d", totaltime/3600, (totaltime%3600)/60, totaltime%60); // Total time - screen->DrawText (SmallFont, CR_GREY, SCREENWIDTH - 80*CleanXfac, y, line, DTA_CleanNoMove, true, TAG_DONE); + mysnprintf(line, countof(line), "%02d:%02d:%02d", totaltime / 3600, (totaltime % 3600) / 60, totaltime % 60); // Total time + screen->DrawText(SmallFont, CR_GREY, SCREENWIDTH - 80 * CleanXfac, y, line, DTA_CleanNoMove, true, TAG_DONE); } + FString mapname; + unsigned int numlines; + ST_FormatMapName(mapname, TEXTCOLOR_GREY); + int width = SmallFont->StringWidth(mapname); + FBrokenLines *lines = V_BreakLines(SmallFont, SCREENWIDTH / CleanXfac, mapname, true, &numlines); + int finalwidth = lines[numlines - 1].Width * CleanXfac; + double tmp = 0; + double hres = HorizontalResolution; + StatusbarToRealCoords(tmp, tmp, hres, tmp); + int protrusion = 0; + + IFVIRTUAL(DBaseStatusBar, GetProtrusion) + { + VMValue params[] = { (DObject*)this, finalwidth / hres }; + VMReturn ret(&protrusion); + GlobalVMStack.Call(func, params, 2, &ret, 1); + } + hres = protrusion; + StatusbarToRealCoords(tmp, tmp, tmp, hres); + // Draw map name - y = gST_Y - height; - if (gameinfo.gametype == GAME_Heretic && SCREENWIDTH > 320 && !Scaled) - { - y -= 8; - } - else if (gameinfo.gametype == GAME_Hexen) - { - if (Scaled) - { - y -= Scale (11, SCREENHEIGHT, 200); - } - else - { - if (SCREENWIDTH < 640) - { - y -= 12; - } - else - { // Get past the tops of the gargoyles' wings - y -= 28; - } - } - } - else if (gameinfo.gametype == GAME_Strife) - { - if (Scaled) - { - y -= Scale (8, SCREENHEIGHT, 200); - } - else - { - y -= 8; - } - } - FString mapname; + y = gST_Y - height * numlines - int(hres); - ST_FormatMapName(mapname, TEXTCOLOR_GREY); - screen->DrawText (SmallFont, highlight, - (SCREENWIDTH - SmallFont->StringWidth (mapname)*CleanXfac)/2, y, mapname, - DTA_CleanNoMove, true, TAG_DONE); + for(unsigned i = 0; i < numlines; i++) + { + screen->DrawText(SmallFont, highlight, (SCREENWIDTH - lines[i].Width * CleanXfac) / 2, y, lines[i].Text, DTA_CleanNoMove, true, TAG_DONE); + y += height; + } if (!deathmatch) { diff --git a/wadsrc/static/zscript/statusbar/heretic_sbar.txt b/wadsrc/static/zscript/statusbar/heretic_sbar.txt index 1273ad4ce..821621d97 100644 --- a/wadsrc/static/zscript/statusbar/heretic_sbar.txt +++ b/wadsrc/static/zscript/statusbar/heretic_sbar.txt @@ -25,6 +25,11 @@ class HereticStatusBar : BaseStatusBar mHealthInterpolator = DynamicValueInterpolator.Create(0, 0.25, 1, 8); } + override int GetProtrusion(double scaleratio) const + { + return scaleratio > 0.7? 8 : 0; + } + override void NewGame () { Super.NewGame(); diff --git a/wadsrc/static/zscript/statusbar/hexen_sbar.txt b/wadsrc/static/zscript/statusbar/hexen_sbar.txt index f1ff81693..f88c70070 100644 --- a/wadsrc/static/zscript/statusbar/hexen_sbar.txt +++ b/wadsrc/static/zscript/statusbar/hexen_sbar.txt @@ -34,6 +34,11 @@ class HexenStatusBar : BaseStatusBar mHealthInterpolator2.Reset (0); } + override int GetProtrusion(double scaleratio) const + { + return scaleratio > 0.85? 20 : 12; // need to get past the gargoyle's wings + } + override void Tick() { Super.Tick(); diff --git a/wadsrc/static/zscript/statusbar/statusbar.txt b/wadsrc/static/zscript/statusbar/statusbar.txt index 01fbcc7ae..7ce351c74 100644 --- a/wadsrc/static/zscript/statusbar/statusbar.txt +++ b/wadsrc/static/zscript/statusbar/statusbar.txt @@ -381,6 +381,20 @@ class BaseStatusBar native ui return icon, scale; } + //============================================================================ + // + // Returns how much the status bar's graphics extend into the view + // Used for automap text positioning + // The parameter specifies how much of the status bar area will be covered + // by the element requesting this information. + // + //============================================================================ + + virtual int GetProtrusion(double scaleratio) const + { + return 0; + } + //============================================================================ // // Convenience functions to retrieve item tags diff --git a/wadsrc/static/zscript/statusbar/strife_sbar.txt b/wadsrc/static/zscript/statusbar/strife_sbar.txt index 148b1e237..c302eebe0 100644 --- a/wadsrc/static/zscript/statusbar/strife_sbar.txt +++ b/wadsrc/static/zscript/statusbar/strife_sbar.txt @@ -74,6 +74,11 @@ class StrifeStatusBar : BaseStatusBar Reset (); } + override int GetProtrusion(double scaleratio) const + { + return 8; + } + override void Draw (int state, double TicFrac) { Super.Draw (state, TicFrac); From 7ba68601029e9c91bd2850fffb1076ae223261ae Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Mar 2017 14:20:22 +0200 Subject: [PATCH 02/15] - scriptified the automap HUD and made it obey hud_scale instead of always being fully scaled. --- src/cmdlib.cpp | 4 +- src/g_statusbar/sbar.h | 1 + src/g_statusbar/shared_sbar.cpp | 121 ++++++------------ wadsrc/static/zscript/base.txt | 5 +- wadsrc/static/zscript/statusbar/doom_sbar.txt | 6 + .../static/zscript/statusbar/hexen_sbar.txt | 2 +- wadsrc/static/zscript/statusbar/statusbar.txt | 96 +++++++++++++- .../static/zscript/statusbar/strife_sbar.txt | 2 +- 8 files changed, 148 insertions(+), 89 deletions(-) diff --git a/src/cmdlib.cpp b/src/cmdlib.cpp index 6fc253ff3..342ce05aa 100644 --- a/src/cmdlib.cpp +++ b/src/cmdlib.cpp @@ -596,7 +596,7 @@ int strbin (char *str) case '5': case '6': case '7': - c = 0; + c = *p - '0'; for (i = 0; i < 2; i++) { p++; @@ -699,7 +699,7 @@ FString strbin1 (const char *start) case '5': case '6': case '7': - c = 0; + c = *p - '0'; for (i = 0; i < 2; i++) { p++; diff --git a/src/g_statusbar/sbar.h b/src/g_statusbar/sbar.h index 3ac2681f1..c27977b1b 100644 --- a/src/g_statusbar/sbar.h +++ b/src/g_statusbar/sbar.h @@ -403,6 +403,7 @@ public: void BeginHUD(int resW, int resH, double Alpha, bool forceScaled = false); void ForceHUDScale(bool on) { ForcedScale = on; } // This is for SBARINFO which should not use BeginStatusBar or BeginHUD. void StatusbarToRealCoords(double &x, double &y, double &w, double &h) const; + double GetTopOfStatusbar() const; //protected: void DrawPowerups (); diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index a5ed1f78a..78394038b 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -149,6 +149,16 @@ void ST_FormatMapName(FString &mapname, const char *mapnamecolor) mapname << mapnamecolor << level.LevelName; } +DEFINE_ACTION_FUNCTION(FLevelLocals, FormatMapName) +{ + PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); + PARAM_INT(cr); + char mapnamecolor[3] = { '\34', char(cr + 'A'), 0 }; + FString rets; + ST_FormatMapName(rets, mapnamecolor); + ACTION_RETURN_STRING(rets); +} + //--------------------------------------------------------------------------- // // Load crosshair definitions @@ -1020,88 +1030,10 @@ void DBaseStatusBar::Draw (EHudState state) } else if (automapactive) { - int y, time = Tics2Seconds(level.time), height; - int totaltime = Tics2Seconds(level.totaltime); - EColorRange highlight = (gameinfo.gametype & GAME_DoomChex) ? - CR_UNTRANSLATED : CR_YELLOW; - - height = SmallFont->GetHeight() * CleanYfac; - - // Draw timer - y = 8; - if (am_showtime) + IFVIRTUAL(DBaseStatusBar, DrawAutomapHUD) { - mysnprintf(line, countof(line), "%02d:%02d:%02d", time / 3600, (time % 3600) / 60, time % 60); // Time - screen->DrawText(SmallFont, CR_GREY, SCREENWIDTH - 80 * CleanXfac, y, line, DTA_CleanNoMove, true, TAG_DONE); - y += 8 * CleanYfac; - } - if (am_showtotaltime) - { - mysnprintf(line, countof(line), "%02d:%02d:%02d", totaltime / 3600, (totaltime % 3600) / 60, totaltime % 60); // Total time - screen->DrawText(SmallFont, CR_GREY, SCREENWIDTH - 80 * CleanXfac, y, line, DTA_CleanNoMove, true, TAG_DONE); - } - - FString mapname; - unsigned int numlines; - ST_FormatMapName(mapname, TEXTCOLOR_GREY); - int width = SmallFont->StringWidth(mapname); - FBrokenLines *lines = V_BreakLines(SmallFont, SCREENWIDTH / CleanXfac, mapname, true, &numlines); - int finalwidth = lines[numlines - 1].Width * CleanXfac; - double tmp = 0; - double hres = HorizontalResolution; - StatusbarToRealCoords(tmp, tmp, hres, tmp); - int protrusion = 0; - - IFVIRTUAL(DBaseStatusBar, GetProtrusion) - { - VMValue params[] = { (DObject*)this, finalwidth / hres }; - VMReturn ret(&protrusion); - GlobalVMStack.Call(func, params, 2, &ret, 1); - } - hres = protrusion; - StatusbarToRealCoords(tmp, tmp, tmp, hres); - - // Draw map name - y = gST_Y - height * numlines - int(hres); - - for(unsigned i = 0; i < numlines; i++) - { - screen->DrawText(SmallFont, highlight, (SCREENWIDTH - lines[i].Width * CleanXfac) / 2, y, lines[i].Text, DTA_CleanNoMove, true, TAG_DONE); - y += height; - } - - if (!deathmatch) - { - int y = 8; - - // Draw monster count - if (am_showmonsters) - { - mysnprintf (line, countof(line), "%s" TEXTCOLOR_GREY " %d/%d", - GStrings("AM_MONSTERS"), level.killed_monsters, level.total_monsters); - screen->DrawText (SmallFont, highlight, 8, y, line, - DTA_CleanNoMove, true, TAG_DONE); - y += height; - } - - // Draw secret count - if (am_showsecrets) - { - mysnprintf (line, countof(line), "%s" TEXTCOLOR_GREY " %d/%d", - GStrings("AM_SECRETS"), level.found_secrets, level.total_secrets); - screen->DrawText (SmallFont, highlight, 8, y, line, - DTA_CleanNoMove, true, TAG_DONE); - y += height; - } - - // Draw item count - if (am_showitems) - { - mysnprintf (line, countof(line), "%s" TEXTCOLOR_GREY " %d/%d", - GStrings("AM_ITEMS"), level.found_items, level.total_items); - screen->DrawText (SmallFont, highlight, 8, y, line, - DTA_CleanNoMove, true, TAG_DONE); - } + VMValue params[] = { (DObject*)this, r_viewpoint.TicFrac }; + GlobalVMStack.Call(func, params, countof(params), nullptr, 0); } } } @@ -1564,6 +1496,33 @@ void DBaseStatusBar::StatusbarToRealCoords(double &x, double &y, double &w, doub } } +DEFINE_ACTION_FUNCTION(DBaseStatusBar, StatusbarToRealCoords) +{ + PARAM_SELF_PROLOGUE(DBaseStatusBar); + PARAM_FLOAT(x); + PARAM_FLOAT_DEF(y); + PARAM_FLOAT_DEF(w); + PARAM_FLOAT_DEF(h); + self->StatusbarToRealCoords(x, y, w, h); + if (numret > 0) ret[0].SetFloat(x); + if (numret > 1) ret[1].SetFloat(y); + if (numret > 2) ret[2].SetFloat(w); + if (numret > 3) ret[3].SetFloat(h); + return MIN(4, numret); +} + + +double DBaseStatusBar::GetTopOfStatusbar() const +{ + return gST_Y; // fixme: Get rid of this global later. +} + +DEFINE_ACTION_FUNCTION(DBaseStatusBar, GetTopOfStatusbar) +{ + PARAM_SELF_PROLOGUE(DBaseStatusBar); + ACTION_RETURN_FLOAT(self->GetTopOfStatusbar()); +} + //============================================================================ // // draw stuff diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 379e660ce..d92f79b6d 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -521,10 +521,11 @@ struct LevelLocals native native static void WorldDone(); native static void RemoveAllBots(bool fromlist); native void SetInterMusic(String nextmap); + native String FormatMapName(int mapnamecolor); - String TimeFormatted() + String TimeFormatted(bool totals = false) { - int sec = Thinker.Tics2Seconds(time); + int sec = Thinker.Tics2Seconds(totals? totaltime : time); return String.Format("%02d:%02d:%02d", sec / 3600, (sec % 3600) / 60, sec % 60); } } diff --git a/wadsrc/static/zscript/statusbar/doom_sbar.txt b/wadsrc/static/zscript/statusbar/doom_sbar.txt index b1671889a..25e8bb7b9 100644 --- a/wadsrc/static/zscript/statusbar/doom_sbar.txt +++ b/wadsrc/static/zscript/statusbar/doom_sbar.txt @@ -20,6 +20,12 @@ class DoomStatusBar : BaseStatusBar diparms = InventoryBarState.Create(); } + override void DrawAutomapHUD(double ticFrac) + { + // This uses the normal automap HUD but just changes the highlight color. + DoDrawAutomapHUD(Font.CR_GREY, Font.CR_UNTRANSLATED); + } + override void Draw (int state, double TicFrac) { Super.Draw (state, TicFrac); diff --git a/wadsrc/static/zscript/statusbar/hexen_sbar.txt b/wadsrc/static/zscript/statusbar/hexen_sbar.txt index f88c70070..baac12ba0 100644 --- a/wadsrc/static/zscript/statusbar/hexen_sbar.txt +++ b/wadsrc/static/zscript/statusbar/hexen_sbar.txt @@ -36,7 +36,7 @@ class HexenStatusBar : BaseStatusBar override int GetProtrusion(double scaleratio) const { - return scaleratio > 0.85? 20 : 12; // need to get past the gargoyle's wings + return scaleratio > 0.85? 28 : 12; // need to get past the gargoyle's wings } override void Tick() diff --git a/wadsrc/static/zscript/statusbar/statusbar.txt b/wadsrc/static/zscript/statusbar/statusbar.txt index 7ce351c74..1659fbc50 100644 --- a/wadsrc/static/zscript/statusbar/statusbar.txt +++ b/wadsrc/static/zscript/statusbar/statusbar.txt @@ -291,13 +291,18 @@ class BaseStatusBar native ui native double drawClip[4]; // defines a clipping rectangle (not used yet) native bool fullscreenOffsets; // current screen is displayed with fullscreen behavior. + private HUDFont mSmallFont; + native void SetSize(int height, int vwidth, int vheight); native Vector2 GetHUDScale(); native void BeginStatusBar(int resW, int resH, int relTop, bool completeborder = false, bool forceScaled = false); native void BeginHUD(int resW, int resH, double Alpha, bool forcescaled = false); - virtual void Init() {} + virtual void Init() + { + mSmallFont = HUDFont.Create("SmallFont"); + } native virtual void SetScaled(bool scale, bool force = false); native virtual void Tick (); @@ -324,7 +329,8 @@ class BaseStatusBar native ui native void DrawString(HUDFont font, String string, Vector2 pos, int flags = 0, int translation = Font.CR_UNTRANSLATED, double Alpha = 1., int wrapwidth = -1, int linespacing = 4); native void Fill(Color col, double x, double y, double w, double h, int flags = 0); native static String FormatNumber(int number, int minsize = 0, int maxsize = 0, int format = 0, String prefix = ""); - + native double, double, double, double StatusbarToRealCoords(double x, double y=0, double w=0, double h=0); + native double GetTopOfStatusBar(); //============================================================================ // @@ -673,6 +679,92 @@ class BaseStatusBar native ui } + //============================================================================ + // + // automap HUD common drawer + // This is not called directly to give a status bar the opportunity to + // change the text colors. If you want to do something different, + // override DrawAutomap directly. + // + //============================================================================ + + protected void DoDrawAutomapHUD(int crdefault, int highlight) + { + let scale = GetHUDScale(); + double textdist = 8. / scale.Y; + int height = SmallFont.GetHeight(); + String printtext; + int SCREENWIDTH = screen.GetWidth(); + + BeginHUD(320, 200, 1., false); + + // Draw timer + let y = textdist; + let width = SmallFont.StringWidth("00:00:00"); + if (am_showtime) + { + printtext = level.TimeFormatted(); + DrawString(mSmallFont, level.TimeFormatted(), (-textdist-width, y), 0, crdefault); + y += height; + } + if (am_showtotaltime) + { + DrawString(mSmallFont, level.TimeFormatted(true), (-textdist-width, y), 0, crdefault); + } + + if (!deathmatch) + { + y = textdist; + + // Draw monster count + if (am_showmonsters) + { + DrawString(mSmallFont, String.Format("%s\34%c %d/%d", Stringtable.Localize("$AM_MONSTERS"), crdefault+65, level.killed_monsters, level.total_monsters), (textdist, y), 0, highlight); + y += height; + } + + // Draw secret count + if (am_showsecrets) + { + DrawString(mSmallFont, String.Format("%s\34%c %d/%d", Stringtable.Localize("$AM_SECRETS"), crdefault+65, level.found_secrets, level.total_secrets), (textdist, y), 0, highlight); + y += height; + } + + // Draw item count + if (am_showitems) + { + DrawString(mSmallFont, String.Format("%s\34%c %d/%d", Stringtable.Localize("$AM_ITEMS"), crdefault+65, level.found_items, level.total_items), (1, y), 0, highlight); + } + } + + String mapname = level.FormatMapName(crdefault); + BrokenLines lines = SmallFont.BreakLines(mapname, SCREENWIDTH / scale.X); + int numlines = lines.Count(); + int finalwidth = SmallFont.StringWidth(lines.StringAt(numlines-1)) * scale.X; + + // calculate the top of the statusbar including any protrusion and transform it from status bar to screen space. + double tmp, hres; + [tmp, tmp, hres] = StatusbarToRealCoords(0, 0, HorizontalResolution); + int protrusion = GetProtrusion(finalwidth / hres); + [tmp, tmp, tmp, hres] = StatusbarToRealCoords(0, 0, 0, protrusion); + + + // transform the top of the status bar position from screen to HUD space (a direct transformation from status bar to HUD space does not exist.) + y = (GetTopOfStatusBar() - hres) / scale.Y - height * numlines; + + // Draw the texts centered above the status bar. + for(int i = 0; i < numlines; i++) + { + DrawString(mSmallFont, lines.StringAt(i), (0, y), DI_TEXT_ALIGN_CENTER|DI_SCREEN_HCENTER|DI_SCREEN_TOP, highlight); + y += height; + } + } + + virtual void DrawAutomapHUD(double ticFrac) + { + DoDrawAutomapHUD(Font.CR_GREY, Font.CR_YELLOW); + } + //--------------------------------------------------------------------------- // // DrawPowerups diff --git a/wadsrc/static/zscript/statusbar/strife_sbar.txt b/wadsrc/static/zscript/statusbar/strife_sbar.txt index c302eebe0..044d49a1c 100644 --- a/wadsrc/static/zscript/statusbar/strife_sbar.txt +++ b/wadsrc/static/zscript/statusbar/strife_sbar.txt @@ -76,7 +76,7 @@ class StrifeStatusBar : BaseStatusBar override int GetProtrusion(double scaleratio) const { - return 8; + return 10; } override void Draw (int state, double TicFrac) From 87479d3c2fce507dbfe7fc2fbb0b75a0783eb9d5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Mar 2017 14:28:46 +0200 Subject: [PATCH 03/15] -use the proper functions to calculate the position of the popup screen in Strife. --- wadsrc/static/zscript/statusbar/strife_sbar.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wadsrc/static/zscript/statusbar/strife_sbar.txt b/wadsrc/static/zscript/statusbar/strife_sbar.txt index 044d49a1c..78084dbc6 100644 --- a/wadsrc/static/zscript/statusbar/strife_sbar.txt +++ b/wadsrc/static/zscript/statusbar/strife_sbar.txt @@ -264,7 +264,9 @@ class StrifeStatusBar : BaseStatusBar // Pop screen (log, keys, and status) if (CurrentPop != POP_None && PopHeight < 0) { - DrawPopScreen (Scaled ? (ST_Y - 8) * screen.GetHeight() / 200 : ST_Y - 8, TicFrac); + double tmp, h; + [tmp, tmp, h] = StatusbarToRealCoords(0, 0, 8); + DrawPopScreen (GetTopOfStatusBar() - h, TicFrac); } DrawImage("INVBACK", (0, 168), DI_ITEM_OFFSETS); From 1d4ab0cc2ab87abbf2b04e4761a7fd61e3f1b8c7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Mar 2017 19:23:40 +0200 Subject: [PATCH 04/15] - implemented proper scaling for the status bar itself. This allows using the UI scale or its own value, like all other scaling values. In addition there is a choice between preserving equal pixel size or aspect ratio because the squashed non-corrected versions tend to look odd, but since proper scaling requires ununiform pixel sizes it is an option. - changed how status bar sizes are being handled. This has to recalculate all scaling and positioning factors, which can cause problems if the drawer leaves with some temporary values that do not reflect the status bar as a whole. Changed it so that the status bar stores the base values and restores them after drawing is complete. --- src/am_map.cpp | 10 +- src/am_map.h | 2 +- src/ct_chat.cpp | 18 +- src/d_main.cpp | 9 +- src/f_wipe.cpp | 1 - src/g_statusbar/sbar.h | 25 +- src/g_statusbar/sbarinfo.cpp | 45 +--- src/g_statusbar/shared_sbar.cpp | 250 +++++++----------- src/gl/scene/gl_weapon.cpp | 3 +- src/hu_scores.cpp | 3 +- src/p_user.cpp | 1 + src/polyrenderer/scene/poly_playersprite.cpp | 3 +- src/r_utility.cpp | 5 +- src/st_stuff.h | 2 - src/swrenderer/things/r_playersprite.cpp | 3 +- src/v_draw.cpp | 8 +- src/v_video.cpp | 7 - src/v_video.h | 2 - wadsrc/static/zscript/statusbar/doom_sbar.txt | 4 +- .../static/zscript/statusbar/heretic_sbar.txt | 4 +- .../static/zscript/statusbar/hexen_sbar.txt | 4 +- wadsrc/static/zscript/statusbar/statusbar.txt | 76 +++++- .../static/zscript/statusbar/strife_sbar.txt | 6 +- 23 files changed, 229 insertions(+), 262 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index f4382f0fd..721bd3650 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -790,6 +790,7 @@ static double mapystart=0; // y-value for the start of the map bitmap...used in static double mapxstart=0; //x-value for the bitmap. static bool stopped = true; +static int viewbottom; static void AM_calcMinMaxMtoF(); @@ -1062,7 +1063,7 @@ static void AM_findMinMaxBoundaries () static void AM_calcMinMaxMtoF() { double a = SCREENWIDTH / max_w; - double b = gST_Y / max_h; + double b = viewbottom / max_h; min_scale_mtof = a < b ? a : b; max_scale_mtof = SCREENHEIGHT / (2*PLAYERRADIUS); @@ -1420,7 +1421,7 @@ void AM_NewResolution() else if (scale_mtof > max_scale_mtof) AM_maxOutWindowScale(); f_w = screen->GetWidth(); - f_h = gST_Y; + f_h = viewbottom; AM_activateNewScale(); } @@ -3160,7 +3161,7 @@ void AM_drawCrosshair (const AMColor &color) // //============================================================================= -void AM_Drawer () +void AM_Drawer (int bottom) { if (!automapactive) return; @@ -3168,6 +3169,7 @@ void AM_Drawer () bool allmap = (level.flags2 & LEVEL2_ALLMAP) != 0; bool allthings = allmap && players[consoleplayer].mo->FindInventory(NAME_PowerScanner, true) != nullptr; + viewbottom = bottom; if (am_portaloverlay) { sector_t *sec; @@ -3184,7 +3186,7 @@ void AM_Drawer () // and view size adjustments. f_x = f_y = 0; f_w = screen->GetWidth (); - f_h = gST_Y; + f_h = viewbottom; f_p = screen->GetPitch (); AM_clearFB(AMColors[AMColors.Background]); diff --git a/src/am_map.h b/src/am_map.h index fd9079c1e..8bf9b08c2 100644 --- a/src/am_map.h +++ b/src/am_map.h @@ -37,7 +37,7 @@ void AM_Ticker (void); // Called by main loop, // called instead of view drawer if automap active. -void AM_Drawer (void); +void AM_Drawer (int bottom); // Called to force the automap to quit // if the level is completed while it is up. diff --git a/src/ct_chat.cpp b/src/ct_chat.cpp index c49e95f57..ac026143e 100644 --- a/src/ct_chat.cpp +++ b/src/ct_chat.cpp @@ -31,6 +31,7 @@ #include "templates.h" #include "d_net.h" #include "d_event.h" +#include "sbar.h" #define QUEUESIZE 128 #define MESSAGESIZE 128 @@ -236,19 +237,10 @@ void CT_Drawer (void) scalex = 1; } - int screen_width, screen_height, st_y; - if (active_con_scaletext() == 0) - { - screen_width = SCREENWIDTH; - screen_height = SCREENHEIGHT; - st_y = gST_Y; - } - else - { - screen_width = SCREENWIDTH / active_con_scaletext(); - screen_height = SCREENHEIGHT / active_con_scaletext(); - st_y = gST_Y / active_con_scaletext(); - } + int scale = active_con_scaletext(); + int screen_width = SCREENWIDTH / scale; + int screen_height= SCREENHEIGHT / scale; + int st_y = StatusBar->GetTopOfStatusbar() / scale; y += ((SCREENHEIGHT == viewheight && viewactive) || gamestate != GS_LEVEL) ? screen_height : st_y; diff --git a/src/d_main.cpp b/src/d_main.cpp index 22ba39cfe..2ba45fe1d 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -160,7 +160,6 @@ EXTERN_CVAR (Bool, sv_unlimited_pickup) extern int testingmode; extern bool setmodeneeded; extern int NewWidth, NewHeight, NewBits, DisplayBits; -EXTERN_CVAR (Bool, st_scale) extern bool gameisdead; extern bool demorecording; extern bool M_DemoNoPlay; // [RH] if true, then skip any demos in the loop @@ -790,13 +789,7 @@ void D_Display () screen->DrawBlendingRect(); if (automapactive) { - int saved_ST_Y = gST_Y; - if (hud_althud && viewheight == SCREENHEIGHT) - { - gST_Y = viewheight; - } - AM_Drawer (); - gST_Y = saved_ST_Y; + AM_Drawer (hud_althud? viewheight : StatusBar->GetTopOfStatusbar()); } if (!automapactive || viewactive) { diff --git a/src/f_wipe.cpp b/src/f_wipe.cpp index 95f170a85..5515cd96c 100644 --- a/src/f_wipe.cpp +++ b/src/f_wipe.cpp @@ -490,7 +490,6 @@ bool wipe_ScreenWipe (int ticks) return true; // do a piece of wipe-in - V_MarkRect(0, 0, SCREENWIDTH, SCREENHEIGHT); rc = (*wipes[(CurrentWipeType-1)*3+1])(ticks); return rc; diff --git a/src/g_statusbar/sbar.h b/src/g_statusbar/sbar.h index c27977b1b..1cb0ffb7f 100644 --- a/src/g_statusbar/sbar.h +++ b/src/g_statusbar/sbar.h @@ -357,7 +357,7 @@ public: }; DBaseStatusBar (); - void SetSize(int reltop = 32, int hres = 320, int vres = 200); + void SetSize(int reltop = 32, int hres = 320, int vres = 200, int hhres = -1, int hvres = -1); void OnDestroy() override; void AttachMessage (DHUDMessage *msg, uint32_t id=0, int layer=HUDMSGLayer_Default); @@ -373,8 +373,7 @@ public: // do not make this a DObject Serialize function because it's not used like one! void SerializeMessages(FSerializer &arc); - virtual void SetScaled(bool scale, bool force = false); - void CallSetScaled(bool scale, bool force = false); + void SetScale(); virtual void Tick (); void CallTick(); virtual void Draw (EHudState state); @@ -399,11 +398,14 @@ public: void DrawString(FFont *font, const FString &cstring, double x, double y, int flags, double Alpha, int translation, int spacing, bool monospaced, int shadowX, int shadowY); void Fill(PalEntry color, double x, double y, double w, double h, int flags = 0); - void BeginStatusBar(int resW, int resH, int relTop, bool completeborder = false, bool forceScaled = false); + void BeginStatusBar(int resW, int resH, int relTop, bool forceScaled); void BeginHUD(int resW, int resH, double Alpha, bool forceScaled = false); void ForceHUDScale(bool on) { ForcedScale = on; } // This is for SBARINFO which should not use BeginStatusBar or BeginHUD. void StatusbarToRealCoords(double &x, double &y, double &w, double &h) const; - double GetTopOfStatusbar() const; + int GetTopOfStatusbar() const + { + return SBarTop; + } //protected: void DrawPowerups (); @@ -417,7 +419,10 @@ public: void DrawCrosshair (); // Sizing info for ths status bar. - int ST_X, ST_Y; + int ST_X; + int ST_Y; + int SBarTop; + DVector2 SBarScale; int RelTop; int HorizontalResolution, VerticalResolution; bool Scaled; // This needs to go away. @@ -446,8 +451,16 @@ private: void DrawMessages (int layer, int bottom); void DrawConsistancy () const; void DrawWaiting () const; + void SetDrawSize(int reltop, int hres, int vres); TObjPtr Messages[NUM_HUDMSGLAYERS]; + + int BaseRelTop; + int BaseSBarHorizontalResolution; + int BaseSBarVerticalResolution; + int BaseHUDHorizontalResolution; + int BaseHUDVerticalResolution; + }; extern DBaseStatusBar *StatusBar; diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index a28205ae2..9fcd0c48b 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -973,7 +973,7 @@ public: DSBarInfo (DBaseStatusBar *wrapper, SBarInfo *script=NULL) : ammo1(NULL), ammo2(NULL), ammocount1(0), ammocount2(0), armor(NULL), pendingPopup(DBaseStatusBar::POP_None), currentPopup(DBaseStatusBar::POP_None), lastHud(-1), - scalingWasForced(false), lastInventoryBar(NULL), lastPopup(NULL) + lastInventoryBar(NULL), lastPopup(NULL) { this->script = script; this->wrapper = wrapper; @@ -1032,14 +1032,7 @@ public: } if(script->huds[hud]->ForceScaled()) //scale the statusbar { - if(script->huds[hud]->FullScreenOffsets()) - wrapper->ForceHUDScale(true); - else if(!wrapper->Scaled) - { - scalingWasForced = true; - wrapper->SetScaled(true, true); - setsizeneeded = true; - } + wrapper->ForceHUDScale(true); } if (CPlayer->ReadyWeapon != NULL) @@ -1067,14 +1060,8 @@ public: if(hud != lastHud) { script->huds[hud]->Tick(NULL, this, true); - // Restore scaling if need be. - if(scalingWasForced) - { - scalingWasForced = false; - wrapper->SetScaled(false); - setsizeneeded = true; - } + wrapper->ForceHUDScale(false); } if(currentPopup != DBaseStatusBar::POP_None && !script->huds[hud]->FullScreenOffsets()) @@ -1478,7 +1465,6 @@ private: int pendingPopup; int currentPopup; int lastHud; - bool scalingWasForced; SBarInfoMainBlock *lastInventoryBar; SBarInfoMainBlock *lastPopup; }; @@ -1487,30 +1473,9 @@ private: void SBarInfoMainBlock::DrawAux(const SBarInfoMainBlock *block, DSBarInfo *statusBar, int xOffset, int yOffset, double alpha) { // Popups can also be forced to scale - bool rescale = false; - if(ForceScaled()) - { - if(FullScreenOffsets()) - { - rescale = true; - statusBar->wrapper->ForceHUDScale(true); - } - else if(!statusBar->wrapper->Scaled) - { - rescale = true; - statusBar->wrapper->SetScaled(true, true); - } - } - + if(ForceScaled()) statusBar->wrapper->ForceHUDScale(true); Draw(block, statusBar, xOffset, yOffset, alpha); - - if(rescale) - { - if(FullScreenOffsets()) - statusBar->wrapper->ForceHUDScale(false); - else - statusBar->wrapper->SetScaled(false); - } + statusBar->wrapper->ForceHUDScale(false); } #include "sbarinfo_commands.cpp" diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index 78394038b..adec61bf5 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -92,8 +92,6 @@ DBaseStatusBar *StatusBar; extern int setblocks; -int gST_Y; - FTexture *CrosshairImage; static int CrosshairNum; @@ -108,11 +106,24 @@ CVAR (Flag, pf_ice, paletteflash, PF_ICE) CVAR (Flag, pf_hazard, paletteflash, PF_HAZARD) // Stretch status bar to full screen width? -CUSTOM_CVAR (Bool, st_scale, true, CVAR_ARCHIVE) +CUSTOM_CVAR (Int, st_scale, -1, CVAR_ARCHIVE) +{ + if (self < -1) + { + self = -1; + return; + } + if (StatusBar) + { + StatusBar->SetScale(); + setsizeneeded = true; + } +} +CUSTOM_CVAR(Bool, st_aspectscale, false, CVAR_ARCHIVE) { if (StatusBar) { - StatusBar->CallSetScaled (self); + StatusBar->SetScale(); setsizeneeded = true; } } @@ -339,7 +350,17 @@ DBaseStatusBar::DBaseStatusBar () defaultScale = { (double)CleanXfac, (double)CleanYfac }; } -void DBaseStatusBar::SetSize(int reltop, int hres, int vres) +void DBaseStatusBar::SetSize(int reltop, int hres, int vres, int hhres, int hvres) +{ + BaseRelTop = reltop; + BaseSBarHorizontalResolution = hres; + BaseSBarVerticalResolution = vres; + BaseHUDHorizontalResolution = hhres < 0? hres : hhres; + BaseHUDVerticalResolution = hvres < 0? vres : hvres; + SetDrawSize(reltop, hres, vres); +} + +void DBaseStatusBar::SetDrawSize(int reltop, int hres, int vres) { RelTop = reltop; HorizontalResolution = hres; @@ -348,16 +369,19 @@ void DBaseStatusBar::SetSize(int reltop, int hres, int vres) V_CalcCleanFacs(hres, vres, SCREENWIDTH, SCREENHEIGHT, &x, &y); defaultScale = { (double)x, (double)y }; - CallSetScaled(st_scale); + SetScale(); // recalculate positioning info. } + DEFINE_ACTION_FUNCTION(DBaseStatusBar, SetSize) { PARAM_SELF_PROLOGUE(DBaseStatusBar); - PARAM_INT_DEF(rt); - PARAM_INT_DEF(vw); - PARAM_INT_DEF(vh); - self->SetSize(rt, vw, vh); + PARAM_INT(rt); + PARAM_INT(vw); + PARAM_INT(vh); + PARAM_INT_DEF(hvw); + PARAM_INT_DEF(hvh); + self->SetSize(rt, vw, vh, hvw, hvh); return 0; } @@ -390,62 +414,58 @@ void DBaseStatusBar::OnDestroy () // //--------------------------------------------------------------------------- -//[BL] Added force argument to have forcescaled mean forcescaled. -// - Also, if the VerticalResolution is something other than the default (200) -// We should always obey the value of scale. -void DBaseStatusBar::SetScaled (bool scale, bool force) +void DBaseStatusBar::SetScale () { - Scaled = (RelTop != 0 || force) && ((SCREENWIDTH != 320 || HorizontalResolution != 320) && scale); - - if (!Scaled) + int w = SCREENWIDTH; + int h = SCREENHEIGHT; + if (st_scale == -1) { - ST_X = (SCREENWIDTH - HorizontalResolution) / 2; - ST_Y = SCREENHEIGHT - RelTop; - gST_Y = ST_Y; + // This is the classic fullscreen scale with aspect ratio compensation. + int sby = VerticalResolution - RelTop; + float aspect = ActiveRatio(w, h); + if (!AspectTallerThanWide(aspect)) + { + // Wider or equal than 4:3 + SBarTop = Scale(sby, h, VerticalResolution); + double width4_3 = w * 1.333 / aspect; + ST_X = int((w - width4_3) / 2); + } + else + { // 5:4 resolution + ST_X = 0; + + // this was far more obtuse before... + double height4_3 = h * aspect / 1.333; + SBarTop = int(h - height4_3 + sby * height4_3 / VerticalResolution); + } + Displacement = 0; + SBarScale.X = -1; + ST_Y = 0; + } + else + { + // Since status bars and HUDs can be designed for non 320x200 screens this needs to be factored in here. + // The global scaling factors are for resources at 320x200, so if the actual ones are higher resolution + // the resulting scaling factor needs to be reduced accordingly. + + int newscale = (st_scale > 0) ? *st_scale : *uiscale; + int realscale = clamp((320 * st_scale) / HorizontalResolution, 1, w / HorizontalResolution); // do not scale wider than the screen. + double realscaley = realscale * (st_aspectscale ? 1.2 : 1.); + + ST_X = (w - HorizontalResolution * realscale) / 2; + SBarTop = int(h - RelTop * realscaley); if (RelTop > 0) { - Displacement = double((ST_Y * VerticalResolution / SCREENHEIGHT) - (VerticalResolution - RelTop))/RelTop; + Displacement = double((SBarTop * VerticalResolution / h) - (VerticalResolution - RelTop))/RelTop/realscaley; } else { Displacement = 0; } + SBarScale.X = realscale; + SBarScale.Y = realscaley; + ST_Y = int(h - VerticalResolution * realscaley); } - else - { - ST_X = 0; - ST_Y = VerticalResolution - RelTop; - float aspect = ActiveRatio(SCREENWIDTH, SCREENHEIGHT); - if (!AspectTallerThanWide(aspect)) - { // Normal resolution - gST_Y = Scale (ST_Y, SCREENHEIGHT, VerticalResolution); - } - else - { // 5:4 resolution - gST_Y = Scale(ST_Y - VerticalResolution/2, SCREENHEIGHT*3, Scale(VerticalResolution, AspectBaseHeight(aspect), 200)) + SCREENHEIGHT/2 - + (SCREENHEIGHT - SCREENHEIGHT * AspectMultiplier(aspect) / 48) / 2; - } - Displacement = 0; - } -} - -DEFINE_ACTION_FUNCTION(DBaseStatusBar, SetScaled) -{ - PARAM_SELF_PROLOGUE(DBaseStatusBar); - PARAM_BOOL(scale); - PARAM_BOOL_DEF(force); - self->SetScaled(scale, force); - return 0; -} - -void DBaseStatusBar::CallSetScaled(bool scale, bool force) -{ - IFVIRTUAL(DBaseStatusBar, SetScaled) - { - VMValue params[] = { (DObject*)this, scale, force }; - GlobalVMStack.Call(func, params, countof(params), nullptr, 0); - } - else SetScaled(scale, force); } //--------------------------------------------------------------------------- @@ -493,23 +513,21 @@ DEFINE_ACTION_FUNCTION(DBaseStatusBar, GetHUDScale) // //--------------------------------------------------------------------------- -void DBaseStatusBar::BeginStatusBar(int resW, int resH, int relTop, bool completeborder, bool forceScaled) +void DBaseStatusBar::BeginStatusBar(int resW, int resH, int relTop, bool forceScaled) { - SetSize(relTop, resW, resH); - SetScaled(st_scale, forceScaled); - CompleteBorder = completeborder; + SetDrawSize(relTop < 0? BaseRelTop : relTop, resW < 0? BaseSBarHorizontalResolution : resW, resH < 0? BaseSBarVerticalResolution : resH); + ForcedScale = forceScaled; fullscreenOffsets = false; } DEFINE_ACTION_FUNCTION(DBaseStatusBar, BeginStatusBar) { PARAM_SELF_PROLOGUE(DBaseStatusBar); - PARAM_INT(w); - PARAM_INT(h); - PARAM_INT(r); - PARAM_BOOL_DEF(cb); PARAM_BOOL_DEF(fs); - self->BeginStatusBar(w, h, r, cb, fs); + PARAM_INT_DEF(w); + PARAM_INT_DEF(h); + PARAM_INT_DEF(r); + self->BeginStatusBar(w, h, r, fs); return 0; } //--------------------------------------------------------------------------- @@ -520,7 +538,7 @@ DEFINE_ACTION_FUNCTION(DBaseStatusBar, BeginStatusBar) void DBaseStatusBar::BeginHUD(int resW, int resH, double Alpha, bool forcescaled) { - SetSize(RelTop, resW, resH); + SetDrawSize(RelTop, resW < 0? BaseHUDHorizontalResolution : resW, resH < 0? BaseHUDVerticalResolution : resH); this->Alpha = Alpha; ForcedScale = forcescaled; CompleteBorder = false; @@ -530,10 +548,10 @@ void DBaseStatusBar::BeginHUD(int resW, int resH, double Alpha, bool forcescaled DEFINE_ACTION_FUNCTION(DBaseStatusBar, BeginHUD) { PARAM_SELF_PROLOGUE(DBaseStatusBar); - PARAM_INT(w); - PARAM_INT(h); - PARAM_FLOAT(a); + PARAM_FLOAT_DEF(a); PARAM_BOOL_DEF(fs); + PARAM_INT_DEF(w); + PARAM_INT_DEF(h); self->BeginHUD(w, h, a, fs); return 0; } @@ -775,8 +793,8 @@ void DBaseStatusBar::RefreshBackground () const int x, x2, y; float ratio = ActiveRatio (SCREENWIDTH, SCREENHEIGHT); - x = (ratio < 1.5f || !Scaled) ? ST_X : SCREENWIDTH*(48-AspectMultiplier(ratio))/(48*2); - y = x == ST_X && x > 0 ? ST_Y : gST_Y; + x = ST_X; + y = SBarTop; if(!CompleteBorder) { @@ -795,8 +813,7 @@ void DBaseStatusBar::RefreshBackground () const { if(!CompleteBorder) { - x2 = ratio < 1.5f || !Scaled ? ST_X+HorizontalResolution : - SCREENWIDTH - (SCREENWIDTH*(48-AspectMultiplier(ratio))+48*2-1)/(48*2); + x2 = SCREENWIDTH - ST_X; } else { @@ -818,13 +835,6 @@ void DBaseStatusBar::RefreshBackground () const } } -DEFINE_ACTION_FUNCTION(DBaseStatusBar, RefreshBackground) -{ - PARAM_SELF_PROLOGUE(DBaseStatusBar); - self->RefreshBackground(); - return 0; -} - //--------------------------------------------------------------------------- // // DrawCrosshair @@ -959,8 +969,6 @@ void DBaseStatusBar::Draw (EHudState state) if (state == HUD_AltHud) return; - char line[64+10]; - if (state == HUD_StatusBar) { RefreshBackground (); @@ -968,57 +976,6 @@ void DBaseStatusBar::Draw (EHudState state) if (idmypos) { // Draw current coordinates - int height = SmallFont->GetHeight(); - char labels[3] = { 'X', 'Y', 'Z' }; - int i; - - int vwidth; - int vheight; - int xpos; - int y; - - if (active_con_scaletext() == 1) - { - vwidth = SCREENWIDTH; - vheight = SCREENHEIGHT; - xpos = vwidth - 80; - y = gST_Y - height; - } - else if (active_con_scaletext() > 1) - { - vwidth = SCREENWIDTH / active_con_scaletext(); - vheight = SCREENHEIGHT / active_con_scaletext(); - xpos = vwidth - SmallFont->StringWidth("X: -00000")-6; - y = gST_Y/4 - height; - } - else - { - vwidth = SCREENWIDTH/2; - vheight = SCREENHEIGHT/2; - xpos = vwidth - SmallFont->StringWidth("X: -00000")-6; - y = gST_Y/2 - height; - } - - if (gameinfo.gametype == GAME_Strife) - { - if (active_con_scaletext() == 1) - y -= height * 4; - else if (active_con_scaletext() > 3) - y -= height; - else - y -= height * 2; - } - - DVector3 pos = CPlayer->mo->Pos(); - for (i = 2; i >= 0; y -= height, --i) - { - mysnprintf (line, countof(line), "%c: %d", labels[i], int(pos[i])); - screen->DrawText (SmallFont, CR_GREEN, xpos, y, line, - DTA_KeepRatio, true, - DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, - TAG_DONE); - V_SetBorderNeedRefresh(); - } } if (viewactive) @@ -1055,6 +1012,7 @@ void DBaseStatusBar::CallDraw(EHudState state) } else Draw(state); screen->ClearClipRect(); // make sure the scripts don't leave a valid clipping rect behind. + BeginStatusBar(BaseSBarHorizontalResolution, BaseSBarVerticalResolution, BaseRelTop, false); } @@ -1156,7 +1114,7 @@ void DBaseStatusBar::SetMugShotState(const char *stateName, bool waitTillDone, b void DBaseStatusBar::DrawBottomStuff (EHudState state) { - DrawMessages (HUDMSGLayer_UnderHUD, (state == HUD_StatusBar) ? gST_Y : SCREENHEIGHT); + DrawMessages (HUDMSGLayer_UnderHUD, (state == HUD_StatusBar) ? GetTopOfStatusbar() : SCREENHEIGHT); } //--------------------------------------------------------------------------- @@ -1169,7 +1127,7 @@ void DBaseStatusBar::DrawTopStuff (EHudState state) { if (demoplayback && demover != DEMOGAMEVERSION) { - screen->DrawText (SmallFont, CR_TAN, 0, ST_Y - 40 * CleanYfac, + screen->DrawText (SmallFont, CR_TAN, 0, GetTopOfStatusbar() - 40 * CleanYfac, "Demo was recorded with a different version\n" "of " GAMENAME ". Expect it to go out of sync.", DTA_CleanNoMove, true, TAG_DONE); @@ -1189,9 +1147,9 @@ void DBaseStatusBar::DrawTopStuff (EHudState state) if (automapactive && !viewactive) { - DrawMessages (HUDMSGLayer_OverMap, (state == HUD_StatusBar) ? gST_Y : SCREENHEIGHT); + DrawMessages (HUDMSGLayer_OverMap, (state == HUD_StatusBar) ? GetTopOfStatusbar() : SCREENHEIGHT); } - DrawMessages (HUDMSGLayer_OverHUD, (state == HUD_StatusBar) ? gST_Y : SCREENHEIGHT); + DrawMessages (HUDMSGLayer_OverHUD, (state == HUD_StatusBar) ? GetTopOfStatusbar() : SCREENHEIGHT); DrawConsistancy (); DrawWaiting (); if (ShowLog && MustDrawLog(state)) DrawLog (); @@ -1485,14 +1443,16 @@ uint32_t DBaseStatusBar::GetTranslation() const void DBaseStatusBar::StatusbarToRealCoords(double &x, double &y, double &w, double &h) const { - if (Scaled) + if (SBarScale.X == -1 || ForcedScale) { screen->VirtualToRealCoords(x, y, w, h, HorizontalResolution, VerticalResolution, true, true); } else { - x += ST_X; - y += screen->GetHeight() - VerticalResolution; + x = ST_X + x * SBarScale.X; + y = ST_Y + y * SBarScale.Y; + w *= SBarScale.X; + h *= SBarScale.Y; } } @@ -1512,15 +1472,10 @@ DEFINE_ACTION_FUNCTION(DBaseStatusBar, StatusbarToRealCoords) } -double DBaseStatusBar::GetTopOfStatusbar() const -{ - return gST_Y; // fixme: Get rid of this global later. -} - DEFINE_ACTION_FUNCTION(DBaseStatusBar, GetTopOfStatusbar) { PARAM_SELF_PROLOGUE(DBaseStatusBar); - ACTION_RETURN_FLOAT(self->GetTopOfStatusbar()); + ACTION_RETURN_INT(self->GetTopOfStatusbar()); } //============================================================================ @@ -1994,12 +1949,9 @@ CCMD (showpop) } } -DEFINE_FIELD(DBaseStatusBar, ST_X); -DEFINE_FIELD(DBaseStatusBar, ST_Y); DEFINE_FIELD(DBaseStatusBar, RelTop); DEFINE_FIELD(DBaseStatusBar, HorizontalResolution); DEFINE_FIELD(DBaseStatusBar, VerticalResolution); -DEFINE_FIELD(DBaseStatusBar, Scaled); DEFINE_FIELD(DBaseStatusBar, Centering); DEFINE_FIELD(DBaseStatusBar, FixedOrigin); DEFINE_FIELD(DBaseStatusBar, CompleteBorder); diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 5f261d9d4..c0dc250f7 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -52,7 +52,6 @@ EXTERN_CVAR (Bool, r_drawplayersprites) EXTERN_CVAR(Float, transsouls) -EXTERN_CVAR (Bool, st_scale) EXTERN_CVAR(Int, gl_fuzztype) EXTERN_CVAR (Bool, r_deathcamera) @@ -121,7 +120,7 @@ void GLSceneDrawer::DrawPSprite (player_t * player,DPSprite *psp, float sx, floa { ftexturemid -= fYAd; } - else if (!st_scale) + else { ftexturemid -= StatusBar->GetDisplacement () * fYAd; } diff --git a/src/hu_scores.cpp b/src/hu_scores.cpp index 0c001a3ba..a39901181 100644 --- a/src/hu_scores.cpp +++ b/src/hu_scores.cpp @@ -51,6 +51,7 @@ #include "d_net.h" #include "c_dispatch.h" #include "g_levellocals.h" +#include "sbar.h" // MACROS ------------------------------------------------------------------ @@ -262,7 +263,7 @@ static void HU_DoDrawScores (player_t *player, player_t *sortedplayers[MAXPLAYER lineheight = MAX(height, maxiconheight * CleanYfac); ypadding = (lineheight - height + 1) / 2; - bottom = gST_Y; + bottom = StatusBar->GetTopOfStatusbar(); y = MAX(48*CleanYfac, (bottom - MAXPLAYERS * (height + CleanYfac + 1)) / 2); HU_DrawTimeRemaining (bottom - height); diff --git a/src/p_user.cpp b/src/p_user.cpp index 694daffa1..ab9319f20 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -759,6 +759,7 @@ bool player_t::Resurrect() E_PlayerRespawned(int(this - players)); // FBehavior::StaticStartTypedScripts(SCRIPT_Respawn, mo, true); + return true; } DEFINE_ACTION_FUNCTION(_PlayerInfo, Resurrect) diff --git a/src/polyrenderer/scene/poly_playersprite.cpp b/src/polyrenderer/scene/poly_playersprite.cpp index 360af43bc..eb1ff323e 100644 --- a/src/polyrenderer/scene/poly_playersprite.cpp +++ b/src/polyrenderer/scene/poly_playersprite.cpp @@ -32,7 +32,6 @@ EXTERN_CVAR(Bool, r_drawplayersprites) EXTERN_CVAR(Bool, r_deathcamera) -EXTERN_CVAR(Bool, st_scale) EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor) EXTERN_CVAR(Bool, r_shadercolormaps) @@ -275,7 +274,7 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *pspr, AActor *owner, float if (viewpoint.camera->player && (renderTarget != screen || viewheight == renderTarget->GetHeight() || - (renderTarget->GetWidth() > (BASEXCENTER * 2) && !st_scale))) + (renderTarget->GetWidth() > (BASEXCENTER * 2)))) { // Adjust PSprite for fullscreen views AWeapon *weapon = dyn_cast(pspr->GetCaller()); if (weapon != nullptr && weapon->YAdjust != 0) diff --git a/src/r_utility.cpp b/src/r_utility.cpp index df6c1e3dd..6af399bfb 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -59,6 +59,7 @@ #include "p_local.h" #include "g_levellocals.h" #include "p_maputl.h" +#include "sbar.h" #include "math/cmath.h" @@ -262,13 +263,13 @@ void R_ExecuteSetViewSize (FRenderViewpoint &viewpoint, FViewWindow &viewwindow) setsizeneeded = false; V_SetBorderNeedRefresh(); - R_SetWindow (viewpoint, viewwindow, setblocks, SCREENWIDTH, SCREENHEIGHT, gST_Y); + R_SetWindow (viewpoint, viewwindow, setblocks, SCREENWIDTH, SCREENHEIGHT, StatusBar->GetTopOfStatusbar()); // Handle resize, e.g. smaller view windows with border and/or status bar. viewwindowx = (screen->GetWidth() - viewwidth) >> 1; // Same with base row offset. - viewwindowy = (viewwidth == screen->GetWidth()) ? 0 : (gST_Y - viewheight) >> 1; + viewwindowy = (viewwidth == screen->GetWidth()) ? 0 : (StatusBar->GetTopOfStatusbar() - viewheight) >> 1; } //========================================================================== diff --git a/src/st_stuff.h b/src/st_stuff.h index a0434f8b4..19e17a111 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -26,8 +26,6 @@ struct event_t; -extern int gST_Y; - bool ST_Responder(event_t* ev); // [RH] Base blending values (for e.g. underwater) diff --git a/src/swrenderer/things/r_playersprite.cpp b/src/swrenderer/things/r_playersprite.cpp index 4afa44d60..c56b95980 100644 --- a/src/swrenderer/things/r_playersprite.cpp +++ b/src/swrenderer/things/r_playersprite.cpp @@ -58,7 +58,6 @@ #include "swrenderer/r_renderthread.h" #include "g_levellocals.h" -EXTERN_CVAR(Bool, st_scale) EXTERN_CVAR(Bool, r_drawplayersprites) EXTERN_CVAR(Bool, r_deathcamera) EXTERN_CVAR(Bool, r_shadercolormaps) @@ -275,7 +274,7 @@ namespace swrenderer if (Thread->Viewport->viewpoint.camera->player && (viewport->RenderTarget != screen || viewheight == viewport->RenderTarget->GetHeight() || - (viewport->RenderTarget->GetWidth() > (BASEXCENTER * 2) && !st_scale))) + (viewport->RenderTarget->GetWidth() > (BASEXCENTER * 2)))) { // Adjust PSprite for fullscreen views AWeapon *weapon = dyn_cast(pspr->GetCaller()); if (weapon != nullptr && weapon->YAdjust != 0) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index b95ade5bd..97aa21ef0 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -65,6 +65,11 @@ CUSTOM_CVAR(Int, uiscale, 2, CVAR_ARCHIVE | CVAR_NOINITCALL) { + if (self < 0) + { + self = 0; + return; + } if (StatusBar != NULL) { StatusBar->CallScreenSizeChanged(); @@ -1257,10 +1262,9 @@ static void V_DrawViewBorder (void) V_DrawBorder (0, 0, SCREENWIDTH, viewwindowy); V_DrawBorder (0, viewwindowy, viewwindowx, viewheight + viewwindowy); V_DrawBorder (viewwindowx + viewwidth, viewwindowy, SCREENWIDTH, viewheight + viewwindowy); - V_DrawBorder (0, viewwindowy + viewheight, SCREENWIDTH, gST_Y); + V_DrawBorder (0, viewwindowy + viewheight, SCREENWIDTH, StatusBar->GetTopOfStatusbar()); V_DrawFrame (viewwindowx, viewwindowy, viewwidth, viewheight); - V_MarkRect (0, 0, SCREENWIDTH, gST_Y); } //========================================================================== diff --git a/src/v_video.cpp b/src/v_video.cpp index 3dea831be..07990af8b 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -197,13 +197,6 @@ bool setmodeneeded = false; int NewWidth, NewHeight, NewBits; -// -// V_MarkRect -// -void V_MarkRect (int x, int y, int width, int height) -{ -} - //========================================================================== // // DCanvas Constructor diff --git a/src/v_video.h b/src/v_video.h index 2d554dea9..81ae91c70 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -528,8 +528,6 @@ void V_Init2 (); void V_Shutdown (); -void V_MarkRect (int x, int y, int width, int height); - class FScanner; // Returns the closest color to the one desired. String // should be of the form "rr gg bb". diff --git a/wadsrc/static/zscript/statusbar/doom_sbar.txt b/wadsrc/static/zscript/statusbar/doom_sbar.txt index 25e8bb7b9..f5ac66ac2 100644 --- a/wadsrc/static/zscript/statusbar/doom_sbar.txt +++ b/wadsrc/static/zscript/statusbar/doom_sbar.txt @@ -32,12 +32,12 @@ class DoomStatusBar : BaseStatusBar if (state == HUD_StatusBar) { - BeginStatusBar(320, 200, 32); + BeginStatusBar(); DrawMainBar (TicFrac); } else if (state == HUD_Fullscreen) { - BeginHUD(320, 200, 1., false); + BeginHUD(); DrawFullScreenStuff (); } } diff --git a/wadsrc/static/zscript/statusbar/heretic_sbar.txt b/wadsrc/static/zscript/statusbar/heretic_sbar.txt index 821621d97..b6db47dcf 100644 --- a/wadsrc/static/zscript/statusbar/heretic_sbar.txt +++ b/wadsrc/static/zscript/statusbar/heretic_sbar.txt @@ -48,12 +48,12 @@ class HereticStatusBar : BaseStatusBar if (state == HUD_StatusBar) { - BeginStatusBar(320, 200, 42); + BeginStatusBar(); DrawMainBar (TicFrac); } else if (state == HUD_Fullscreen) { - BeginHUD(320, 200, 1., false); + BeginHUD(); DrawFullScreenStuff (); } } diff --git a/wadsrc/static/zscript/statusbar/hexen_sbar.txt b/wadsrc/static/zscript/statusbar/hexen_sbar.txt index baac12ba0..d1418763f 100644 --- a/wadsrc/static/zscript/statusbar/hexen_sbar.txt +++ b/wadsrc/static/zscript/statusbar/hexen_sbar.txt @@ -52,12 +52,12 @@ class HexenStatusBar : BaseStatusBar if (state == HUD_StatusBar) { - BeginStatusBar(320, 200, 38); + BeginStatusBar(); DrawMainBar (TicFrac); } else if (state == HUD_Fullscreen) { - BeginHUD(320, 200, 1., false); + BeginHUD(); DrawFullScreenStuff (); } } diff --git a/wadsrc/static/zscript/statusbar/statusbar.txt b/wadsrc/static/zscript/statusbar/statusbar.txt index 1659fbc50..dc916cad4 100644 --- a/wadsrc/static/zscript/statusbar/statusbar.txt +++ b/wadsrc/static/zscript/statusbar/statusbar.txt @@ -270,10 +270,8 @@ class BaseStatusBar native ui const POWERUPICONSIZE = 32; - native int ST_X, ST_Y; native int RelTop; native int HorizontalResolution, VerticalResolution; - native bool Scaled; native bool Centering; native bool FixedOrigin; native bool CompleteBorder; @@ -294,17 +292,16 @@ class BaseStatusBar native ui private HUDFont mSmallFont; - native void SetSize(int height, int vwidth, int vheight); + native void SetSize(int height, int vwidth, int vheight, int hwidth = -1, int hheight = -1); native Vector2 GetHUDScale(); - native void BeginStatusBar(int resW, int resH, int relTop, bool completeborder = false, bool forceScaled = false); - native void BeginHUD(int resW, int resH, double Alpha, bool forcescaled = false); + native void BeginStatusBar(bool forceScaled = false, int resW = -1, int resH = -1, int rel = -1); + native void BeginHUD(double Alpha = 1., bool forcescaled = false, int resW = -1, int resH = -1); virtual void Init() { mSmallFont = HUDFont.Create("SmallFont"); } - native virtual void SetScaled(bool scale, bool force = false); native virtual void Tick (); native virtual void Draw (int state, double TicFrac); native virtual void ScreenSizeChanged (); @@ -318,7 +315,6 @@ class BaseStatusBar native ui virtual void ShowPop (int popnum) { ShowLog = (popnum == POP_Log && !ShowLog); } virtual bool MustDrawLog(int state) { return true; } - native void RefreshBackground () const; native TextureID GetMugshot(int accuracy, int stateflags=MugShot.STANDARD, String default_face = "STF"); // These functions are kept native solely for performance reasons. They get called repeatedly and can drag down performance easily if they get too slow. @@ -330,7 +326,7 @@ class BaseStatusBar native ui native void Fill(Color col, double x, double y, double w, double h, int flags = 0); native static String FormatNumber(int number, int minsize = 0, int maxsize = 0, int format = 0, String prefix = ""); native double, double, double, double StatusbarToRealCoords(double x, double y=0, double w=0, double h=0); - native double GetTopOfStatusBar(); + native int GetTopOfStatusBar(); //============================================================================ // @@ -678,6 +674,68 @@ class BaseStatusBar native ui return it != null && it.Amount >= amount; } + //============================================================================ + // + // mypos cheat + // + //============================================================================ + + virtual void DrawMyPos() + { + /* + int height = SmallFont->GetHeight(); + char labels[3] = { 'X', 'Y', 'Z' }; + int i; + + int vwidth; + int vheight; + int xpos; + int y; + + if (active_con_scaletext() == 1) + { + vwidth = SCREENWIDTH; + vheight = SCREENHEIGHT; + xpos = vwidth - 80; + y = SBarTop - height; + } + else if (active_con_scaletext() > 1) + { + vwidth = SCREENWIDTH / active_con_scaletext(); + vheight = SCREENHEIGHT / active_con_scaletext(); + xpos = vwidth - SmallFont->StringWidth("X: -00000")-6; + y = SBarTop/4 - height; + } + else + { + vwidth = SCREENWIDTH/2; + vheight = SCREENHEIGHT/2; + xpos = vwidth - SmallFont->StringWidth("X: -00000")-6; + y = SBarTop/2 - height; + } + + if (gameinfo.gametype == GAME_Strife) + { + if (active_con_scaletext() == 1) + y -= height * 4; + else if (active_con_scaletext() > 3) + y -= height; + else + y -= height * 2; + } + + DVector3 pos = CPlayer->mo->Pos(); + for (i = 2; i >= 0; y -= height, --i) + { + mysnprintf (line, countof(line), "%c: %d", labels[i], int(pos[i])); + screen->DrawText (SmallFont, CR_GREEN, xpos, y, line, + DTA_KeepRatio, true, + DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, + TAG_DONE); + V_SetBorderNeedRefresh(); + } + */ + } //============================================================================ // @@ -696,7 +754,7 @@ class BaseStatusBar native ui String printtext; int SCREENWIDTH = screen.GetWidth(); - BeginHUD(320, 200, 1., false); + BeginHUD(); // Draw timer let y = textdist; diff --git a/wadsrc/static/zscript/statusbar/strife_sbar.txt b/wadsrc/static/zscript/statusbar/strife_sbar.txt index 78084dbc6..8a7717e99 100644 --- a/wadsrc/static/zscript/statusbar/strife_sbar.txt +++ b/wadsrc/static/zscript/statusbar/strife_sbar.txt @@ -85,14 +85,14 @@ class StrifeStatusBar : BaseStatusBar if (state == HUD_StatusBar) { - BeginStatusBar(320, 200, 32); + BeginStatusBar(); DrawMainBar (TicFrac); } else { if (state == HUD_Fullscreen) { - BeginHUD(320, 200, 1., false); + BeginHUD(); DrawFullScreenStuff (); } @@ -100,7 +100,7 @@ class StrifeStatusBar : BaseStatusBar if (CurrentPop != POP_None && PopHeight < 0) { // This uses direct low level draw commands and would otherwise require calling - // BeginStatusBar(320, 200, false, true); + // BeginStatusBar(true); DrawPopScreen (screen.GetHeight(), TicFrac); } } From 401a1e80e8acbe3d855ea1dcf5c73407e96a4b9f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Mar 2017 19:24:56 +0200 Subject: [PATCH 05/15] - fixes typo in actionspecials.h. --- src/actionspecials.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/actionspecials.h b/src/actionspecials.h index 08f989754..9a8427ebc 100644 --- a/src/actionspecials.h +++ b/src/actionspecials.h @@ -265,6 +265,6 @@ DEFINE_SPECIAL(Ceiling_Stop, 276, 1, 1, 1) DEFINE_SPECIAL(Sector_SetFloorGlow, 277, 5, 5, 5) DEFINE_SPECIAL(Sector_SetCeilingGlow, 278, 5, 5, 5) DEFINE_SPECIAL(Floor_MoveToValueAndCrush, 279, 4, 5, 5) -DEFINE_SPECIAL(Ceiling_MoveToValueAndCrush, 290, 4, 5, 5) +DEFINE_SPECIAL(Ceiling_MoveToValueAndCrush, 280, 4, 5, 5) #undef DEFINE_SPECIAL From 9d1031f0ba7ee82927ab79af8a1f0f2740b3af8c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Mar 2017 20:01:57 +0200 Subject: [PATCH 06/15] - fixed ForcedScale handling in SBARINFO. Due to the setup it would miss setting it when changing between HUDs. --- src/g_statusbar/sbar.h | 2 +- src/g_statusbar/sbarinfo.cpp | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/g_statusbar/sbar.h b/src/g_statusbar/sbar.h index 1cb0ffb7f..2f3f7b202 100644 --- a/src/g_statusbar/sbar.h +++ b/src/g_statusbar/sbar.h @@ -400,7 +400,7 @@ public: void BeginStatusBar(int resW, int resH, int relTop, bool forceScaled); void BeginHUD(int resW, int resH, double Alpha, bool forceScaled = false); - void ForceHUDScale(bool on) { ForcedScale = on; } // This is for SBARINFO which should not use BeginStatusBar or BeginHUD. + bool ForceHUDScale(bool on) { std::swap(ForcedScale, on); return on; } // This is for SBARINFO which should not use BeginStatusBar or BeginHUD. void StatusbarToRealCoords(double &x, double &y, double &w, double &h) const; int GetTopOfStatusbar() const { diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index 9fcd0c48b..2c9d962c4 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -1030,10 +1030,7 @@ public: { hud = STBAR_NONE; } - if(script->huds[hud]->ForceScaled()) //scale the statusbar - { - wrapper->ForceHUDScale(true); - } + wrapper->ForceHUDScale(script->huds[hud]->ForceScaled()); if (CPlayer->ReadyWeapon != NULL) { @@ -1061,8 +1058,8 @@ public: { script->huds[hud]->Tick(NULL, this, true); // Restore scaling if need be. - wrapper->ForceHUDScale(false); } + wrapper->ForceHUDScale(script->huds[hud]->ForceScaled()); if(currentPopup != DBaseStatusBar::POP_None && !script->huds[hud]->FullScreenOffsets()) script->huds[hud]->Draw(NULL, this, script->popups[currentPopup-1].getXDisplacement(), script->popups[currentPopup-1].getYDisplacement(), 1.); @@ -1083,6 +1080,8 @@ public: else inventoryBar->DrawAux(NULL, this, 0, 0, 1.); } + // Reset hud scale + wrapper->ForceHUDScale(false); } // Handle popups @@ -1106,8 +1105,6 @@ public: else lastPopup = NULL; - // Reset hud scale - wrapper->ForceHUDScale(false); } void _NewGame () @@ -1473,9 +1470,9 @@ private: void SBarInfoMainBlock::DrawAux(const SBarInfoMainBlock *block, DSBarInfo *statusBar, int xOffset, int yOffset, double alpha) { // Popups can also be forced to scale - if(ForceScaled()) statusBar->wrapper->ForceHUDScale(true); + bool old = statusBar->wrapper->ForceHUDScale(ForceScaled()); Draw(block, statusBar, xOffset, yOffset, alpha); - statusBar->wrapper->ForceHUDScale(false); + statusBar->wrapper->ForceHUDScale(old); } #include "sbarinfo_commands.cpp" From 356144a537577b788e28c138698cf2b3f86b9cd7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Mar 2017 20:11:58 +0200 Subject: [PATCH 07/15] - fixed: The player menu was not able to set the new name because the security check did not account for the text enter menu being present. --- src/menu/playermenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/menu/playermenu.cpp b/src/menu/playermenu.cpp index c730f2d81..fa5796a45 100644 --- a/src/menu/playermenu.cpp +++ b/src/menu/playermenu.cpp @@ -91,7 +91,7 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, PlayerNameChanged) const char *pp = s; FString command("name \""); - if (self == CurrentMenu) + if (self == CurrentMenu || self == CurrentMenu->mParentMenu) { // Escape any backslashes or quotation marks before sending the name to the console. for (auto p = pp; *p != '\0'; ++p) From d36f656caf78f6bc8a4d4c043aec7038b9efc2d7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Mar 2017 20:25:54 +0200 Subject: [PATCH 08/15] - added a callback for when damage is drained from a target. --- src/p_interaction.cpp | 6 ++++++ wadsrc/static/zscript/actor.txt | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index eb1fb46fe..431c637de 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1415,6 +1415,12 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da } } + IFVIRTUALPTR(source, AActor, OnDrain) + { + VMValue params[] = { source, target, draindamage, mod.GetIndex() }; + VMReturn ret(&draindamage); + GlobalVMStack.Call(func, params, countof(params), &ret, 1); + } if ( P_GiveBody( source, int(draindamage * damage))) { S_Sound(source, CHAN_ITEM, "*drainhealth", 1, ATTN_NORM ); diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index daac2f23d..fb883f846 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -489,6 +489,11 @@ class Actor : Thinker native return Obituary; } + virtual int OnDrain(Actor victim, int damage, Name dmgtype) + { + return damage; + } + native virtual bool OkayToSwitchTarget(Actor other); native static class GetReplacement(class cls); native static class GetReplacee(class cls); From 01b095c9115e5790457f2dc51a827f82f829eb1a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Mar 2017 21:22:05 +0200 Subject: [PATCH 09/15] - added colorization for untranslated fonts. This uses the light color of the vertices. The software rendered 2D code will ignore this infomation. - added a virtual OnRetrun method to menus. --- src/gl/renderer/gl_2ddrawer.cpp | 1 + src/gl/system/gl_swframebuffer.cpp | 6 ++++++ src/menu/menu.cpp | 6 ++++++ src/v_draw.cpp | 5 +++++ src/v_font.cpp | 13 +++++++++++-- src/v_font.h | 2 +- src/v_text.cpp | 16 ++++++++++++---- src/v_video.h | 4 ++++ src/win32/fb_d3d9.cpp | 6 ++++++ wadsrc/static/zscript/menu/menu.txt | 1 + 10 files changed, 53 insertions(+), 7 deletions(-) diff --git a/src/gl/renderer/gl_2ddrawer.cpp b/src/gl/renderer/gl_2ddrawer.cpp index 3f4f74cc5..0e08073cc 100644 --- a/src/gl/renderer/gl_2ddrawer.cpp +++ b/src/gl/renderer/gl_2ddrawer.cpp @@ -140,6 +140,7 @@ void F2DDrawer::AddTexture(FTexture *img, DrawParms &parms) color = PalEntry(light, light, light); } color.a = (uint8_t)(parms.Alpha * 255); + color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255); // scissor test doesn't use the current viewport for the coordinates, so use real screen coordinates dg.mScissor[0] = GLRenderer->ScreenToWindowX(parms.lclip); diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index acf5dc40b..3bb0fd8d8 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -2773,6 +2773,12 @@ void OpenGLSWFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms) vert = &VertexData[VertexPos]; + { + PalEntry color = color1; + color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255); + color1 = color; + } + // Fill the vertex buffer. vert[0].x = float(x0); vert[0].y = float(y0); diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 6d82bd680..be14b2f09 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -243,6 +243,12 @@ void DMenu::Close () if (CurrentMenu != nullptr) { GC::WriteBarrier(CurrentMenu); + IFVIRTUALPTR(CurrentMenu, DMenu, OnReturn) + { + VMValue params[] = { CurrentMenu }; + GlobalVMStack.Call(func, params, 1, nullptr, 0, nullptr); + } + } else { diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 97aa21ef0..c8da6ac4d 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -366,6 +366,7 @@ bool DCanvas::ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t t parms->colorOverlay = 0; parms->alphaChannel = false; parms->flipX = false; + parms->color = 0xffffffff; //parms->shadowAlpha = 0; parms->shadowColor = 0; parms->virtWidth = this->GetWidth(); @@ -542,6 +543,10 @@ bool DCanvas::ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t t parms->colorOverlay = ListGetInt(tags); break; + case DTA_Color: + parms->color = ListGetInt(tags); + break; + case DTA_FlipX: parms->flipX = ListGetInt(tags); break; diff --git a/src/v_font.cpp b/src/v_font.cpp index a1730bd04..e6aa57a50 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -756,9 +756,18 @@ void FFont::BuildTranslations (const double *luminosity, const uint8_t *identity // //========================================================================== -FRemapTable *FFont::GetColorTranslation (EColorRange range) const +FRemapTable *FFont::GetColorTranslation (EColorRange range, PalEntry *color) const { - if (ActiveColors == 0 || noTranslate) + if (noTranslate) + { + PalEntry retcolor = PalEntry(255, 255, 255, 255); + if (range >= 0 && range < NumTextColors && range != CR_UNTRANSLATED) + { + retcolor = TranslationColors[range]; + } + if (color != nullptr) *color = retcolor; + } + if (ActiveColors == 0) return NULL; else if (range >= NumTextColors) range = CR_UNTRANSLATED; diff --git a/src/v_font.h b/src/v_font.h index 6553f5855..c3d2ce561 100644 --- a/src/v_font.h +++ b/src/v_font.h @@ -80,7 +80,7 @@ public: virtual FTexture *GetChar (int code, int *const width) const; virtual int GetCharWidth (int code) const; - FRemapTable *GetColorTranslation (EColorRange range) const; + FRemapTable *GetColorTranslation (EColorRange range, PalEntry *color = nullptr) const; int GetLump() const { return Lump; } int GetSpaceWidth () const { return SpaceWidth; } int GetHeight () const { return FontHeight; } diff --git a/src/v_text.cpp b/src/v_text.cpp index 90131ed86..f068b876c 100644 --- a/src/v_text.cpp +++ b/src/v_text.cpp @@ -80,7 +80,9 @@ void DCanvas::DrawChar (FFont *font, int normalcolor, double x, double y, int ch { return; } - parms.remap = font->GetColorTranslation((EColorRange)normalcolor); + PalEntry color; + parms.remap = font->GetColorTranslation((EColorRange)normalcolor, &color); + parms.color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255); DrawTextureParms(pic, parms); } } @@ -102,7 +104,9 @@ void DCanvas::DrawChar(FFont *font, int normalcolor, double x, double y, int cha uint32_t tag = ListGetInt(args); bool res = ParseDrawTextureTags(pic, x, y, tag, args, &parms, false); if (!res) return; - parms.remap = font->GetColorTranslation((EColorRange)normalcolor); + PalEntry color; + parms.remap = font->GetColorTranslation((EColorRange)normalcolor, &color); + parms.color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255); DrawTextureParms(pic, parms); } } @@ -151,7 +155,10 @@ void DCanvas::DrawTextCommon(FFont *font, int normalcolor, double x, double y, c normalcolor = CR_UNTRANSLATED; boldcolor = normalcolor ? normalcolor - 1 : NumTextColors - 1; - range = font->GetColorTranslation((EColorRange)normalcolor); + PalEntry colorparm = parms.color; + PalEntry color; + range = font->GetColorTranslation((EColorRange)normalcolor, &color); + parms.color = PalEntry((color.a * colorparm.a) / 255, (color.r * colorparm.r) / 255, (color.g * colorparm.g) / 255, (color.b * colorparm.b) / 255); kerning = font->GetDefaultKerning(); @@ -171,7 +178,8 @@ void DCanvas::DrawTextCommon(FFont *font, int normalcolor, double x, double y, c EColorRange newcolor = V_ParseFontColor(ch, normalcolor, boldcolor); if (newcolor != CR_UNDEFINED) { - range = font->GetColorTranslation(newcolor); + range = font->GetColorTranslation(newcolor, &color); + parms.color = PalEntry((color.a * colorparm.a) / 255, (color.r * colorparm.r) / 255, (color.g * colorparm.g) / 255, (color.b * colorparm.b) / 255); } continue; } diff --git a/src/v_video.h b/src/v_video.h index 81ae91c70..e92b045b1 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -125,6 +125,9 @@ enum DTA_TextLen, // stop after this many characters, even if \0 not hit DTA_CellX, // horizontal size of character cell DTA_CellY, // vertical size of character cell + + // New additions. + DTA_Color, }; enum @@ -161,6 +164,7 @@ struct DrawParms uint32_t fillcolor; FRemapTable *remap; uint32_t colorOverlay; + PalEntry color; INTBOOL alphaChannel; INTBOOL flipX; //float shadowAlpha; diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 4fd198a1b..332e2416d 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -2942,6 +2942,12 @@ void D3DFB::DrawTextureParms (FTexture *img, DrawParms &parms) vert = &VertexData[VertexPos]; + { + PalEntry color = color1; + color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255); + color1 = color; + } + // Fill the vertex buffer. vert[0].x = float(x0); vert[0].y = float(y0); diff --git a/wadsrc/static/zscript/menu/menu.txt b/wadsrc/static/zscript/menu/menu.txt index 09f5d9cde..32b738c5c 100644 --- a/wadsrc/static/zscript/menu/menu.txt +++ b/wadsrc/static/zscript/menu/menu.txt @@ -271,6 +271,7 @@ class Menu : Object native ui version("2.4") virtual void ResetColor() {} virtual bool MouseEvent(int type, int mx, int my) { return true; } virtual void Ticker() {} + virtual void OnReturn() {} //============================================================================= // From b38934b532f90fa193c0aedb0c3db35c11d91c9b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Mar 2017 21:54:11 +0200 Subject: [PATCH 10/15] - fixed declaration of ACS getters for status bar. - fixed some uninitialized variables in font print code. --- src/v_text.cpp | 10 +++++----- wadsrc/static/zscript/statusbar/statusbar.txt | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/v_text.cpp b/src/v_text.cpp index f068b876c..454964aa3 100644 --- a/src/v_text.cpp +++ b/src/v_text.cpp @@ -80,7 +80,7 @@ void DCanvas::DrawChar (FFont *font, int normalcolor, double x, double y, int ch { return; } - PalEntry color; + PalEntry color = 0xffffffff; parms.remap = font->GetColorTranslation((EColorRange)normalcolor, &color); parms.color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255); DrawTextureParms(pic, parms); @@ -104,7 +104,7 @@ void DCanvas::DrawChar(FFont *font, int normalcolor, double x, double y, int cha uint32_t tag = ListGetInt(args); bool res = ParseDrawTextureTags(pic, x, y, tag, args, &parms, false); if (!res) return; - PalEntry color; + PalEntry color = 0xffffffff; parms.remap = font->GetColorTranslation((EColorRange)normalcolor, &color); parms.color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255); DrawTextureParms(pic, parms); @@ -156,9 +156,9 @@ void DCanvas::DrawTextCommon(FFont *font, int normalcolor, double x, double y, c boldcolor = normalcolor ? normalcolor - 1 : NumTextColors - 1; PalEntry colorparm = parms.color; - PalEntry color; + PalEntry color = 0xffffffff; range = font->GetColorTranslation((EColorRange)normalcolor, &color); - parms.color = PalEntry((color.a * colorparm.a) / 255, (color.r * colorparm.r) / 255, (color.g * colorparm.g) / 255, (color.b * colorparm.b) / 255); + parms.color = PalEntry(colorparm.a, (color.r * colorparm.r) / 255, (color.g * colorparm.g) / 255, (color.b * colorparm.b) / 255); kerning = font->GetDefaultKerning(); @@ -179,7 +179,7 @@ void DCanvas::DrawTextCommon(FFont *font, int normalcolor, double x, double y, c if (newcolor != CR_UNDEFINED) { range = font->GetColorTranslation(newcolor, &color); - parms.color = PalEntry((color.a * colorparm.a) / 255, (color.r * colorparm.r) / 255, (color.g * colorparm.g) / 255, (color.b * colorparm.b) / 255); + parms.color = PalEntry(colorparm.a, (color.r * colorparm.r) / 255, (color.g * colorparm.g) / 255, (color.b * colorparm.b) / 255); } continue; } diff --git a/wadsrc/static/zscript/statusbar/statusbar.txt b/wadsrc/static/zscript/statusbar/statusbar.txt index dc916cad4..8a7476f8f 100644 --- a/wadsrc/static/zscript/statusbar/statusbar.txt +++ b/wadsrc/static/zscript/statusbar/statusbar.txt @@ -426,10 +426,10 @@ class BaseStatusBar native ui } // These cannot be done in ZScript. - native String GetGlobalACSString(int index); - native String GetGlobalACSArrayString(int arrayno, int index); - native int GetGlobalACSValue(int index); - native int GetGlobalACSArrayValue(int arrayno, int index); + native static String GetGlobalACSString(int index); + native static String GetGlobalACSArrayString(int arrayno, int index); + native static int GetGlobalACSValue(int index); + native static int GetGlobalACSArrayValue(int arrayno, int index); //============================================================================ // From 3f9ad55432f06d055e51ad7bb1d26eb5d577188c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Mar 2017 22:18:52 +0200 Subject: [PATCH 11/15] - allow multiple expressions in 'for' iteration part. --- src/scripting/zscript/zcc-parse.lemon | 1 + src/scripting/zscript/zcc_compile.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/scripting/zscript/zcc-parse.lemon b/src/scripting/zscript/zcc-parse.lemon index aa618fa94..cf7eb4566 100644 --- a/src/scripting/zscript/zcc-parse.lemon +++ b/src/scripting/zscript/zcc-parse.lemon @@ -1859,6 +1859,7 @@ for_init(X) ::= for_bump(A). { X = A /*X-overwrites-A*/; } %type for_bump{ZCC_Statement *} for_bump(X) ::= . { X = NULL; } for_bump(X) ::= expression_statement(A). { X = A; /*X-overwrites-A*/ } +for_bump(X) ::= for_bump(A) COMMA expression_statement(B). { X = A; /*X-overwrites-A*/ AppendTreeNodeSibling(X, B); } /*----- If Statements -----*/ diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index 8dfed30e7..fe93be7c9 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -3482,7 +3482,15 @@ FxExpression *ZCCCompiler::ConvertNode(ZCC_TreeNode *ast) } else if (iter->LoopBumper != nullptr) { - return new FxForLoop(nullptr, ConvertNode(iter->LoopCondition), ConvertNode(iter->LoopBumper), ConvertNode(iter->LoopStatement), *ast); + FArgumentList bumper; + ConvertNodeList(bumper, iter->LoopBumper); + FxCompoundStatement *bumps = new FxCompoundStatement(*ast); + for (auto &ex : bumper) + { + bumps->Add(ex); + ex = nullptr; + } + return new FxForLoop(nullptr, ConvertNode(iter->LoopCondition), bumps, ConvertNode(iter->LoopStatement), *ast); } else { From 7011010ff255b7dec821cc57f1c6e9df8dc4e596 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Mar 2017 22:50:13 +0200 Subject: [PATCH 12/15] - fixed the drain callback. - changed the effect spawn prevention of the Hexen flame strike weapon and reverted the attempt to fix this in FastProjectile. This cannot be fixed in the base class, which was doing everything right. It's the flame missile that was doing undefined things by stopping its movement without clearing its missile flag. This cannot work because missiles are given some minimal forced velocity to ensure collision detection and any attempt to address this without clearing the missile flag is doomed to fail. --- src/p_interaction.cpp | 20 +++++++++++-------- wadsrc/static/zscript/hexen/clericflame.txt | 1 + .../static/zscript/shared/fastprojectile.txt | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 431c637de..b4db7cb0b 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1415,15 +1415,19 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da } } - IFVIRTUALPTR(source, AActor, OnDrain) + if (draindamage > 0) { - VMValue params[] = { source, target, draindamage, mod.GetIndex() }; - VMReturn ret(&draindamage); - GlobalVMStack.Call(func, params, countof(params), &ret, 1); - } - if ( P_GiveBody( source, int(draindamage * damage))) - { - S_Sound(source, CHAN_ITEM, "*drainhealth", 1, ATTN_NORM ); + int draindmg = int(draindamage * damage); + IFVIRTUALPTR(source, AActor, OnDrain) + { + VMValue params[] = { source, target, draindmg, mod.GetIndex() }; + VMReturn ret(&draindmg); + GlobalVMStack.Call(func, params, countof(params), &ret, 1); + } + if (P_GiveBody(source, draindmg)) + { + S_Sound(source, CHAN_ITEM, "*drainhealth", 1, ATTN_NORM); + } } } } diff --git a/wadsrc/static/zscript/hexen/clericflame.txt b/wadsrc/static/zscript/hexen/clericflame.txt index d222a07db..1978f43f1 100644 --- a/wadsrc/static/zscript/hexen/clericflame.txt +++ b/wadsrc/static/zscript/hexen/clericflame.txt @@ -274,6 +274,7 @@ class CFlameMissile : FastProjectile void A_CFlamePuff() { bInvisible = false; + bMissile = false; Vel = (0,0,0); A_PlaySound ("ClericFlameExplode", CHAN_BODY); } diff --git a/wadsrc/static/zscript/shared/fastprojectile.txt b/wadsrc/static/zscript/shared/fastprojectile.txt index 657c4680e..a0fa1a91c 100644 --- a/wadsrc/static/zscript/shared/fastprojectile.txt +++ b/wadsrc/static/zscript/shared/fastprojectile.txt @@ -156,7 +156,7 @@ class FastProjectile : Actor ExplodeMissile (NULL, NULL); return; } - if (!(frac.xy ~== (0, 0)) && ripcount <= 0) + if (changexy && ripcount <= 0) { ripcount = count >> 3; From bde73fc530fc54397c090da48ca631f9fb921516 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Mar 2017 23:13:11 +0200 Subject: [PATCH 13/15] - added automatic brightmaps. Everything in the brightmaps/auto directory will automatically be assigned to the same-named texture. --- src/gl/data/gl_data.cpp | 2 ++ src/gl/textures/gl_texture.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index 6b4edcb9d..a055523fc 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -69,6 +69,7 @@ CUSTOM_CVAR(Bool, gl_notexturefill, false, 0) void gl_CreateSections(); +void AddAutoBrightmaps(); //----------------------------------------------------------------------------- // @@ -364,6 +365,7 @@ void gl_RecalcVertexHeights(vertex_t * v) void gl_InitData() { AdjustSpriteOffsets(); + AddAutoBrightmaps(); } //========================================================================== diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index fbed6b383..63e29d240 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -665,11 +665,13 @@ void gl_ParseBrightmap(FScanner &sc, int deflump) if (bmtex != NULL) { + /* I do not think this is needed any longer if (tex->bWarped != 0) { Printf("Cannot combine warping with brightmap on texture '%s'\n", tex->Name.GetChars()); return; } + */ bmtex->bMasked = false; tex->gl_info.Brightmap = bmtex; @@ -677,6 +679,33 @@ void gl_ParseBrightmap(FScanner &sc, int deflump) tex->gl_info.bDisableFullbright = disable_fullbright; } +//========================================================================== +// +// +// +//========================================================================== + +void AddAutoBrightmaps() +{ + int num = Wads.GetNumLumps(); + for (unsigned i = 0; i < num; i++) + { + const char *name = Wads.GetLumpFullName(i); + if (strstr(name, "brightmaps/auto/") == name) + { + TArray list; + FString texname = ExtractFileBase(name, false); + TexMan.ListTextures(texname, list); + auto bmtex = TexMan.FindTexture(name, FTexture::TEX_Any, FTextureManager::TEXMAN_TryAny); + for (auto texid : list) + { + bmtex->bMasked = false; + TexMan[texid]->gl_info.Brightmap = bmtex; + } + } + } +} + //========================================================================== // // Parses a GLBoom+ detail texture definition From 1dcc017daffdc6bd3970fc16ec02cece0ed9c3fe Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Mar 2017 23:51:53 +0200 Subject: [PATCH 14/15] - reimplemented the position display, but changed its position a bit upward. - activated the RenderOverlay event, now that it can be called from the correct spot, i.e. right after the top level HUD messages are drawn. The system's status output will still be drawn on top of them. --- src/d_main.cpp | 1 - src/events.cpp | 10 +++- src/events.h | 6 +- src/g_statusbar/shared_sbar.cpp | 12 +++- wadsrc/static/zscript/events.txt | 2 +- wadsrc/static/zscript/statusbar/statusbar.txt | 57 +++++-------------- 6 files changed, 38 insertions(+), 50 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 2ba45fe1d..80a37b21e 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -900,7 +900,6 @@ void D_Display () NetUpdate (); // send out any new accumulation // normal update // draw ZScript UI stuff - //E_RenderOverlay(); C_DrawConsole (hw2d); // draw console M_Drawer (); // menu is drawn even on top of everything FStat::PrintStat (); diff --git a/src/events.cpp b/src/events.cpp index 5a40a3983..970b68da5 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -448,6 +448,12 @@ void E_Console(int player, FString name, int arg1, int arg2, int arg3, bool manu handler->ConsoleProcess(player, name, arg1, arg2, arg3, manual); } +void E_RenderOverlay(EHudState state) +{ + for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next) + handler->RenderOverlay(state); +} + bool E_CheckUiProcessors() { for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next) @@ -468,7 +474,6 @@ bool E_CheckRequireMouse() // normal event loopers (non-special, argument-less) DEFINE_EVENT_LOOPER(RenderFrame) -DEFINE_EVENT_LOOPER(RenderOverlay) DEFINE_EVENT_LOOPER(WorldLightning) DEFINE_EVENT_LOOPER(WorldTick) DEFINE_EVENT_LOOPER(UiTick) @@ -798,7 +803,7 @@ void DStaticEventHandler::RenderFrame() } } -void DStaticEventHandler::RenderOverlay() +void DStaticEventHandler::RenderOverlay(EHudState state) { IFVIRTUAL(DStaticEventHandler, RenderOverlay) { @@ -806,6 +811,7 @@ void DStaticEventHandler::RenderOverlay() if (func == DStaticEventHandler_RenderOverlay_VMPtr) return; FRenderEvent e = E_SetupRenderEvent(); + e.HudState = int(state); VMValue params[2] = { (DStaticEventHandler*)this, &e }; GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr); } diff --git a/src/events.h b/src/events.h index a2f014a32..5ef7f85aa 100755 --- a/src/events.h +++ b/src/events.h @@ -5,6 +5,7 @@ #include "serializer.h" #include "d_event.h" #include "d_gui.h" +#include "sbar.h" class DStaticEventHandler; @@ -48,7 +49,7 @@ void E_UiTick(); // called on each render frame once. void E_RenderFrame(); // called after everything's been rendered, but before console/menus -void E_RenderOverlay(); +void E_RenderOverlay(EHudState state); // this executes when a player enters the level (once). PlayerEnter+inhub = RETURN void E_PlayerEntered(int num, bool fromhub); // this executes when a player respawns. includes resurrect cheat. @@ -141,7 +142,7 @@ public: // void RenderFrame(); - void RenderOverlay(); + void RenderOverlay(EHudState state); // void PlayerEntered(int num, bool fromhub); @@ -175,6 +176,7 @@ struct FRenderEvent DAngle ViewRoll; double FracTic = 0; // 0..1 value that describes where we are inside the current gametic, render-wise. AActor* Camera = nullptr; + int HudState; }; struct FWorldEvent diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index adec61bf5..1cb3fe32c 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -61,6 +61,7 @@ #include "p_acs.h" #include "r_data/r_translate.h" #include "sbarinfo.h" +#include "events.h" #include "../version.h" @@ -975,7 +976,14 @@ void DBaseStatusBar::Draw (EHudState state) } if (idmypos) - { // Draw current coordinates + { + // Draw current coordinates + IFVIRTUAL(DBaseStatusBar, DrawMyPos) + { + VMValue params[] = { (DObject*)this }; + GlobalVMStack.Call(func, params, countof(params), nullptr, 0); + } + V_SetBorderNeedRefresh(); } if (viewactive) @@ -1150,6 +1158,8 @@ void DBaseStatusBar::DrawTopStuff (EHudState state) DrawMessages (HUDMSGLayer_OverMap, (state == HUD_StatusBar) ? GetTopOfStatusbar() : SCREENHEIGHT); } DrawMessages (HUDMSGLayer_OverHUD, (state == HUD_StatusBar) ? GetTopOfStatusbar() : SCREENHEIGHT); + E_RenderOverlay(state); + DrawConsistancy (); DrawWaiting (); if (ShowLog && MustDrawLog(state)) DrawLog (); diff --git a/wadsrc/static/zscript/events.txt b/wadsrc/static/zscript/events.txt index 0c0947f45..f3a281e0c 100755 --- a/wadsrc/static/zscript/events.txt +++ b/wadsrc/static/zscript/events.txt @@ -305,7 +305,7 @@ class StaticEventHandler : Object native play version("2.4") // //virtual native ui void RenderFrame(RenderEvent e); - //virtual native ui void RenderOverlay(RenderEvent e); + virtual native ui void RenderOverlay(RenderEvent e); // virtual native void PlayerEntered(PlayerEvent e); diff --git a/wadsrc/static/zscript/statusbar/statusbar.txt b/wadsrc/static/zscript/statusbar/statusbar.txt index 8a7476f8f..238e177bb 100644 --- a/wadsrc/static/zscript/statusbar/statusbar.txt +++ b/wadsrc/static/zscript/statusbar/statusbar.txt @@ -682,59 +682,30 @@ class BaseStatusBar native ui virtual void DrawMyPos() { - /* - int height = SmallFont->GetHeight(); - char labels[3] = { 'X', 'Y', 'Z' }; + int height = SmallFont.GetHeight(); int i; int vwidth; int vheight; int xpos; int y; + let scalevec = GetHUDScale(); + int scale = int(scalevec.X); - if (active_con_scaletext() == 1) - { - vwidth = SCREENWIDTH; - vheight = SCREENHEIGHT; - xpos = vwidth - 80; - y = SBarTop - height; - } - else if (active_con_scaletext() > 1) - { - vwidth = SCREENWIDTH / active_con_scaletext(); - vheight = SCREENHEIGHT / active_con_scaletext(); - xpos = vwidth - SmallFont->StringWidth("X: -00000")-6; - y = SBarTop/4 - height; - } - else - { - vwidth = SCREENWIDTH/2; - vheight = SCREENHEIGHT/2; - xpos = vwidth - SmallFont->StringWidth("X: -00000")-6; - y = SBarTop/2 - height; - } + vwidth = screen.GetWidth() / scale; + vheight = screen.GetHeight() / scale; + xpos = vwidth - SmallFont.StringWidth("X: -00000")-6; + y = GetTopOfStatusBar() / (3*scale) - height; - if (gameinfo.gametype == GAME_Strife) + Vector3 pos = CPlayer.mo.Pos; + + for (i = 0; i < 3; y += height, ++i) { - if (active_con_scaletext() == 1) - y -= height * 4; - else if (active_con_scaletext() > 3) - y -= height; - else - y -= height * 2; + double v = i == 0? pos.X : i == 1? pos.Y : pos.Z; + String line = String.Format("%c: %d", int("X") + i, v); + screen.DrawText (SmallFont, Font.CR_GREEN, xpos, y, line, DTA_KeepRatio, true, + DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight); } - - DVector3 pos = CPlayer->mo->Pos(); - for (i = 2; i >= 0; y -= height, --i) - { - mysnprintf (line, countof(line), "%c: %d", labels[i], int(pos[i])); - screen->DrawText (SmallFont, CR_GREEN, xpos, y, line, - DTA_KeepRatio, true, - DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, - TAG_DONE); - V_SetBorderNeedRefresh(); - } - */ } //============================================================================ From f95c29ad2825a85dd368ad2fe5b747203649d018 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 30 Mar 2017 02:16:23 +0200 Subject: [PATCH 15/15] cleaned up the scaling options. - all 5 settings affected by uiscale have been changed to have the exact same semantics: -1, if supported means special scaling, this is available for HUD and status bar, 0 means to use uiscale, any larger value is a direct scaling factor. - scaling is cut off when the factor is larger than screenwidth/320 or screenheight/200 because anything larger will definitely not fit. - a lot of code has been cleaned up and consolidated. Especially the message code had an incredible amount of redundancy. - all scaling options have been moved into a submenu. This menu is not complete, though - it still requires a special menu widget to convey the intended information without confusing the user. --- src/c_console.cpp | 98 ++++------------------- src/ct_chat.cpp | 26 ++----- src/g_shared/hudmessages.cpp | 134 ++++++++++---------------------- src/g_shared/shared_hud.cpp | 78 ++++--------------- src/g_statusbar/shared_sbar.cpp | 40 +++------- src/gameconfigfile.cpp | 22 ++++-- src/v_draw.cpp | 20 +++++ src/v_video.cpp | 11 +-- src/v_video.h | 14 ++++ src/version.h | 2 +- wadsrc/static/language.enu | 14 +++- wadsrc/static/menudef.txt | 50 ++++-------- 12 files changed, 166 insertions(+), 343 deletions(-) diff --git a/src/c_console.cpp b/src/c_console.cpp index e2ffe2ec6..0d37198f3 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -146,10 +146,9 @@ static int worklen = 0; CVAR(Float, con_notifytime, 3.f, CVAR_ARCHIVE) CVAR(Bool, con_centernotify, false, CVAR_ARCHIVE) -CUSTOM_CVAR(Int, con_scaletext, 1, CVAR_ARCHIVE) // Scale notify text at high resolutions? +CUSTOM_CVAR(Int, con_scaletext, 0, CVAR_ARCHIVE) // Scale notify text at high resolutions? { if (self < 0) self = 0; - if (self > 3) self = 3; } CUSTOM_CVAR(Int, con_scale, 0, CVAR_ARCHIVE) @@ -157,36 +156,6 @@ CUSTOM_CVAR(Int, con_scale, 0, CVAR_ARCHIVE) if (self < 0) self = 0; } -int active_con_scale() -{ - int scale = con_scale; - if (scale <= 0) - { - scale = uiscale; - if (scale == 0) - { - scale = CleanXfac - 1; - if (scale <= 0) - { - scale = 1; - } - } - } - return scale; -} - -int active_con_scaletext() -{ - switch (con_scaletext) - { - default: - case 0: return 1; - case 1: return uiscale; - case 2: return 2; - case 3: return 4; - } -} - CUSTOM_CVAR(Float, con_alpha, 0.75f, CVAR_ARCHIVE) { if (self < 0.f) self = 0.f; @@ -811,14 +780,7 @@ void FNotifyBuffer::AddString(int printlevel, FString source) return; } - if (active_con_scaletext() == 0) - { - width = DisplayWidth / CleanXfac; - } - else - { - width = DisplayWidth / active_con_scaletext(); - } + width = DisplayWidth / active_con_scaletext(); if (AddType == APPENDLINE && Text.Size() > 0 && Text[Text.Size() - 1].PrintLevel == printlevel) { @@ -1061,10 +1023,6 @@ void FNotifyBuffer::Draw() canskip = true; lineadv = SmallFont->GetHeight (); - if (active_con_scaletext() == 0) - { - lineadv *= CleanYfac; - } BorderTopRefresh = screen->GetPageCount (); @@ -1088,45 +1046,21 @@ void FNotifyBuffer::Draw() else color = PrintColors[notify.PrintLevel]; - if (active_con_scaletext() == 0) - { - if (!center) - screen->DrawText (SmallFont, color, 0, line, notify.Text, - DTA_CleanNoMove, true, DTA_Alpha, alpha, TAG_DONE); - else - screen->DrawText (SmallFont, color, (SCREENWIDTH - - SmallFont->StringWidth (notify.Text)*CleanXfac)/2, - line, notify.Text, DTA_CleanNoMove, true, - DTA_Alpha, alpha, TAG_DONE); - } - else if (active_con_scaletext() == 1) - { - if (!center) - screen->DrawText (SmallFont, color, 0, line, notify.Text, - DTA_Alpha, alpha, TAG_DONE); - else - screen->DrawText (SmallFont, color, (SCREENWIDTH - - SmallFont->StringWidth (notify.Text))/2, - line, notify.Text, - DTA_Alpha, alpha, TAG_DONE); - } + int scale = active_con_scaletext(); + if (!center) + screen->DrawText (SmallFont, color, 0, line, notify.Text, + DTA_VirtualWidth, screen->GetWidth() / scale, + DTA_VirtualHeight, screen->GetHeight() / scale, + DTA_KeepRatio, true, + DTA_Alpha, alpha, TAG_DONE); else - { - if (!center) - screen->DrawText (SmallFont, color, 0, line, notify.Text, - DTA_VirtualWidth, screen->GetWidth() / active_con_scaletext(), - DTA_VirtualHeight, screen->GetHeight() / active_con_scaletext(), - DTA_KeepRatio, true, - DTA_Alpha, alpha, TAG_DONE); - else - screen->DrawText (SmallFont, color, (screen->GetWidth() - - SmallFont->StringWidth (notify.Text) * active_con_scaletext()) / 2 / active_con_scaletext(), - line, notify.Text, - DTA_VirtualWidth, screen->GetWidth() / active_con_scaletext(), - DTA_VirtualHeight, screen->GetHeight() / active_con_scaletext(), - DTA_KeepRatio, true, - DTA_Alpha, alpha, TAG_DONE); - } + screen->DrawText (SmallFont, color, (screen->GetWidth() - + SmallFont->StringWidth (notify.Text) * scale) / 2 / scale, + line, notify.Text, + DTA_VirtualWidth, screen->GetWidth() / scale, + DTA_VirtualHeight, screen->GetHeight() / scale, + DTA_KeepRatio, true, + DTA_Alpha, alpha, TAG_DONE); line += lineadv; canskip = false; } diff --git a/src/ct_chat.cpp b/src/ct_chat.cpp index ac026143e..c632df203 100644 --- a/src/ct_chat.cpp +++ b/src/ct_chat.cpp @@ -227,16 +227,8 @@ void CT_Drawer (void) int i, x, scalex, y, promptwidth; y = (viewactive || gamestate != GS_LEVEL) ? -10 : -30; - if (active_con_scaletext() == 0) - { - scalex = CleanXfac; - y *= CleanYfac; - } - else - { - scalex = 1; - } + scalex = 1; int scale = active_con_scaletext(); int screen_width = SCREENWIDTH / scale; int screen_height= SCREENHEIGHT / scale; @@ -266,18 +258,10 @@ void CT_Drawer (void) // draw the prompt, text, and cursor ChatQueue[len] = SmallFont->GetCursor(); ChatQueue[len+1] = '\0'; - if (active_con_scaletext() < 2) - { - screen->DrawText (SmallFont, CR_GREEN, 0, y, prompt, DTA_CleanNoMove, active_con_scaletext() == 0, TAG_DONE); - screen->DrawText (SmallFont, CR_GREY, promptwidth, y, (char *)(ChatQueue + i), DTA_CleanNoMove, active_con_scaletext() == 0, TAG_DONE); - } - else - { - screen->DrawText (SmallFont, CR_GREEN, 0, y, prompt, - DTA_VirtualWidth, screen_width, DTA_VirtualHeight, screen_height, DTA_KeepRatio, true, TAG_DONE); - screen->DrawText (SmallFont, CR_GREY, promptwidth, y, (char *)(ChatQueue + i), - DTA_VirtualWidth, screen_width, DTA_VirtualHeight, screen_height, DTA_KeepRatio, true, TAG_DONE); - } + screen->DrawText (SmallFont, CR_GREEN, 0, y, prompt, + DTA_VirtualWidth, screen_width, DTA_VirtualHeight, screen_height, DTA_KeepRatio, true, TAG_DONE); + screen->DrawText (SmallFont, CR_GREY, promptwidth, y, (char *)(ChatQueue + i), + DTA_VirtualWidth, screen_width, DTA_VirtualHeight, screen_height, DTA_KeepRatio, true, TAG_DONE); ChatQueue[len] = '\0'; BorderTopRefresh = screen->GetPageCount (); diff --git a/src/g_shared/hudmessages.cpp b/src/g_shared/hudmessages.cpp index eab0e8d29..caa041d4c 100644 --- a/src/g_shared/hudmessages.cpp +++ b/src/g_shared/hudmessages.cpp @@ -42,7 +42,6 @@ #include "serializer.h" EXTERN_CVAR(Int, con_scaletext) -int active_con_scaletext(); IMPLEMENT_CLASS(DHUDMessage, false, true) @@ -269,11 +268,7 @@ void DHUDMessage::ResetText (const char *text) } else { - switch (active_con_scaletext()) - { - case 0: width = SCREENWIDTH / CleanXfac; break; - default: width = SCREENWIDTH / active_con_scaletext(); break; - } + width = SCREENWIDTH / active_con_scaletext(); } if (Lines != NULL) @@ -338,21 +333,13 @@ void DHUDMessage::Draw (int bottom, int visibility) int screen_width = SCREENWIDTH; int screen_height = SCREENHEIGHT; - if (HUDWidth == 0 && active_con_scaletext() == 0) + xscale = yscale = 1; + if (HUDWidth == 0) { - clean = true; - xscale = CleanXfac; - yscale = CleanYfac; - } - else - { - xscale = yscale = 1; - if (HUDWidth == 0) - { - screen_width /= active_con_scaletext(); - screen_height /= active_con_scaletext(); - bottom /= active_con_scaletext(); - } + int scale = active_con_scaletext(); + screen_width /= scale; + screen_height /= scale; + bottom /= scale; } if (HUDWidth == 0) @@ -453,24 +440,14 @@ void DHUDMessage::DoDraw (int linenum, int x, int y, bool clean, int hudheight) { if (hudheight == 0) { - if (active_con_scaletext() <= 1) - { - screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, - DTA_CleanNoMove, clean, - DTA_Alpha, Alpha, - DTA_RenderStyle, Style, - TAG_DONE); - } - else - { - screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, - DTA_VirtualWidth, SCREENWIDTH / active_con_scaletext(), - DTA_VirtualHeight, SCREENHEIGHT / active_con_scaletext(), - DTA_Alpha, Alpha, - DTA_RenderStyle, Style, - DTA_KeepRatio, true, - TAG_DONE); - } + int scale = active_con_scaletext(); + screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, + DTA_VirtualWidth, SCREENWIDTH / scale, + DTA_VirtualHeight, SCREENHEIGHT / scale, + DTA_Alpha, Alpha, + DTA_RenderStyle, Style, + DTA_KeepRatio, true, + TAG_DONE); } else { @@ -556,24 +533,14 @@ void DHUDMessageFadeOut::DoDraw (int linenum, int x, int y, bool clean, int hudh float trans = float(Alpha * -(Tics - FadeOutTics) / FadeOutTics); if (hudheight == 0) { - if (active_con_scaletext() <= 1) - { - screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, - DTA_CleanNoMove, clean, - DTA_Alpha, trans, - DTA_RenderStyle, Style, - TAG_DONE); - } - else - { - screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, - DTA_VirtualWidth, SCREENWIDTH / active_con_scaletext(), - DTA_VirtualHeight, SCREENHEIGHT / active_con_scaletext(), - DTA_Alpha, trans, - DTA_RenderStyle, Style, - DTA_KeepRatio, true, - TAG_DONE); - } + int scale = active_con_scaletext(); + screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, + DTA_VirtualWidth, SCREENWIDTH / scale, + DTA_VirtualHeight, SCREENHEIGHT / scale, + DTA_Alpha, trans, + DTA_RenderStyle, Style, + DTA_KeepRatio, true, + TAG_DONE); } else { @@ -656,24 +623,14 @@ void DHUDMessageFadeInOut::DoDraw (int linenum, int x, int y, bool clean, int hu float trans = float(Alpha * Tics / FadeInTics); if (hudheight == 0) { - if (active_con_scaletext() <= 1) - { - screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, - DTA_CleanNoMove, clean, - DTA_Alpha, trans, - DTA_RenderStyle, Style, - TAG_DONE); - } - else - { - screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, - DTA_VirtualWidth, SCREENWIDTH / active_con_scaletext(), - DTA_VirtualHeight, SCREENHEIGHT / active_con_scaletext(), - DTA_Alpha, trans, - DTA_RenderStyle, Style, - DTA_KeepRatio, true, - TAG_DONE); - } + int scale = active_con_scaletext(); + screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, + DTA_VirtualWidth, SCREENWIDTH / scale, + DTA_VirtualHeight, SCREENHEIGHT / scale, + DTA_Alpha, trans, + DTA_RenderStyle, Style, + DTA_KeepRatio, true, + TAG_DONE); } else { @@ -837,26 +794,15 @@ void DHUDMessageTypeOnFadeOut::DoDraw (int linenum, int x, int y, bool clean, in { if (hudheight == 0) { - if (active_con_scaletext() <= 1) - { - screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, - DTA_CleanNoMove, clean, - DTA_TextLen, LineVisible, - DTA_Alpha, Alpha, - DTA_RenderStyle, Style, - TAG_DONE); - } - else - { - screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, - DTA_VirtualWidth, SCREENWIDTH / active_con_scaletext(), - DTA_VirtualHeight, SCREENHEIGHT / active_con_scaletext(), - DTA_KeepRatio, true, - DTA_TextLen, LineVisible, - DTA_Alpha, Alpha, - DTA_RenderStyle, Style, - TAG_DONE); - } + int scale = active_con_scaletext(); + screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, + DTA_VirtualWidth, SCREENWIDTH / scale, + DTA_VirtualHeight, SCREENHEIGHT / scale, + DTA_KeepRatio, true, + DTA_TextLen, LineVisible, + DTA_Alpha, Alpha, + DTA_RenderStyle, Style, + TAG_DONE); } else { diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index ce8a4965e..19183a437 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -65,11 +65,12 @@ EXTERN_CVAR(Bool,am_follow) EXTERN_CVAR (Int, con_scaletext) EXTERN_CVAR (Bool, idmypos) EXTERN_CVAR (Int, screenblocks) +EXTERN_CVAR(Bool, hud_aspectscale) EXTERN_CVAR (Bool, am_showtime) EXTERN_CVAR (Bool, am_showtotaltime) -CVAR(Int,hud_althudscale, 4, CVAR_ARCHIVE) // Scale the hud to 640x400? +CVAR(Int,hud_althudscale, 0, CVAR_ARCHIVE) // Scale the hud to 640x400? CVAR(Bool,hud_althud, false, CVAR_ARCHIVE) // Enable/Disable the alternate HUD // These are intentionally not the same as in the automap! @@ -121,7 +122,6 @@ static int hudwidth, hudheight; // current width/height for HUD display static int statspace; DVector2 AM_GetPosition(); -int active_con_scaletext(); //--------------------------------------------------------------------------- // @@ -897,43 +897,31 @@ static void DrawCoordinates(player_t * CPlayer) pos = DVector3(apos, z); } - int vwidth, vheight; - if (active_con_scaletext() == 0) - { - vwidth = SCREENWIDTH / 2; - vheight = SCREENHEIGHT / 2; - } - else - { - vwidth = SCREENWIDTH / active_con_scaletext(); - vheight = SCREENHEIGHT / active_con_scaletext(); - } - - int xpos = vwidth - SmallFont->StringWidth("X: -00000")-6; + int xpos = hudwidth - SmallFont->StringWidth("X: -00000")-6; int ypos = 18; - screen->DrawText(SmallFont, hudcolor_titl, vwidth - 6 - SmallFont->StringWidth(level.MapName), ypos, level.MapName, + screen->DrawText(SmallFont, hudcolor_titl, hudwidth - 6 - SmallFont->StringWidth(level.MapName), ypos, level.MapName, DTA_KeepRatio, true, - DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE); + DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, TAG_DONE); - screen->DrawText(SmallFont, hudcolor_titl, vwidth - 6 - SmallFont->StringWidth(level.LevelName), ypos + h, level.LevelName, + screen->DrawText(SmallFont, hudcolor_titl, hudwidth - 6 - SmallFont->StringWidth(level.LevelName), ypos + h, level.LevelName, DTA_KeepRatio, true, - DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE); + DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, TAG_DONE); mysnprintf(coordstr, countof(coordstr), "X: %d", int(pos.X)); screen->DrawText(SmallFont, hudcolor_xyco, xpos, ypos+2*h, coordstr, DTA_KeepRatio, true, - DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE); + DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, TAG_DONE); mysnprintf(coordstr, countof(coordstr), "Y: %d", int(pos.Y)); screen->DrawText(SmallFont, hudcolor_xyco, xpos, ypos+3*h, coordstr, DTA_KeepRatio, true, - DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE); + DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, TAG_DONE); mysnprintf(coordstr, countof(coordstr), "Z: %d", int(pos.Z)); screen->DrawText(SmallFont, hudcolor_xyco, xpos, ypos+4*h, coordstr, DTA_KeepRatio, true, - DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE); + DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, TAG_DONE); } //--------------------------------------------------------------------------- @@ -1134,49 +1122,9 @@ void DrawHUD() player_t * CPlayer = StatusBar->CPlayer; players[consoleplayer].inventorytics = 0; - if (hud_althudscale && SCREENWIDTH>640) - { - hudwidth=SCREENWIDTH/2; - if (hud_althudscale == 4) - { - if (uiscale == 0) - { - hudwidth = CleanWidth; - hudheight = CleanHeight; - } - else - { - hudwidth = SCREENWIDTH / uiscale; - hudheight = SCREENHEIGHT / uiscale; - } - } - else if (hud_althudscale == 3) - { - hudwidth = SCREENWIDTH / 4; - hudheight = SCREENHEIGHT / 4; - } - else if (hud_althudscale == 2) - { - // Optionally just double the pixels to reduce scaling artifacts. - hudheight=SCREENHEIGHT/2; - } - else - { - if (AspectTallerThanWide(r_viewwindow.WidescreenRatio)) - { - hudheight = hudwidth * 30 / AspectMultiplier(r_viewwindow.WidescreenRatio); // BaseRatioSizes is inverted for this mode - } - else - { - hudheight = hudwidth * 30 / (48*48/AspectMultiplier(r_viewwindow.WidescreenRatio)); - } - } - } - else - { - hudwidth=SCREENWIDTH; - hudheight=SCREENHEIGHT; - } + int scale = GetUIScale(hud_althudscale); + hudwidth = SCREENWIDTH / scale; + hudheight = hud_aspectscale ? int(SCREENHEIGHT / (scale*1.2)) : SCREENHEIGHT / scale; if (!automapactive) { diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index 1cb3fe32c..d5330b2b5 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -87,7 +87,6 @@ EXTERN_CVAR (Int, con_scaletext) EXTERN_CVAR(Bool, vid_fps) CVAR(Int, hud_scale, 0, CVAR_ARCHIVE); -int active_con_scaletext(); DBaseStatusBar *StatusBar; @@ -107,7 +106,7 @@ CVAR (Flag, pf_ice, paletteflash, PF_ICE) CVAR (Flag, pf_hazard, paletteflash, PF_HAZARD) // Stretch status bar to full screen width? -CUSTOM_CVAR (Int, st_scale, -1, CVAR_ARCHIVE) +CUSTOM_CVAR (Int, st_scale, 0, CVAR_ARCHIVE) { if (self < -1) { @@ -120,7 +119,7 @@ CUSTOM_CVAR (Int, st_scale, -1, CVAR_ARCHIVE) setsizeneeded = true; } } -CUSTOM_CVAR(Bool, st_aspectscale, false, CVAR_ARCHIVE) +CUSTOM_CVAR(Bool, hud_aspectscale, false, CVAR_ARCHIVE) { if (StatusBar) { @@ -419,7 +418,7 @@ void DBaseStatusBar::SetScale () { int w = SCREENWIDTH; int h = SCREENHEIGHT; - if (st_scale == -1) + if (st_scale < 0 || ForcedScale) { // This is the classic fullscreen scale with aspect ratio compensation. int sby = VerticalResolution - RelTop; @@ -448,10 +447,9 @@ void DBaseStatusBar::SetScale () // Since status bars and HUDs can be designed for non 320x200 screens this needs to be factored in here. // The global scaling factors are for resources at 320x200, so if the actual ones are higher resolution // the resulting scaling factor needs to be reduced accordingly. + int realscale = clamp((320 * GetUIScale(st_scale)) / HorizontalResolution, 1, w / HorizontalResolution); - int newscale = (st_scale > 0) ? *st_scale : *uiscale; - int realscale = clamp((320 * st_scale) / HorizontalResolution, 1, w / HorizontalResolution); // do not scale wider than the screen. - double realscaley = realscale * (st_aspectscale ? 1.2 : 1.); + double realscaley = realscale * (hud_aspectscale ? 1.2 : 1.); ST_X = (w - HorizontalResolution * realscale) / 2; SBarTop = int(h - RelTop * realscaley); @@ -482,24 +480,13 @@ DVector2 DBaseStatusBar::GetHUDScale() const { return defaultScale; } - if (hud_scale > 0) // use the scale as an absolute value, but also factor in the specified resolution of the HUD - { - scale = hud_scale; - } - else if (uiscale == 0) - { - return defaultScale; - } - else - { - scale = MAX(1, uiscale); - } + scale = GetUIScale(hud_scale); // Since status bars and HUDs can be designed for non 320x200 screens this needs to be factored in here. // The global scaling factors are for resources at 320x200, so if the actual ones are higher resolution // the resulting scaling factor needs to be reduced accordingly. int realscale = MAX(1, (320 * scale) / HorizontalResolution); - return{ double(realscale), double(realscale) }; + return{ double(realscale), double(realscale * (hud_aspectscale ? 1.2 : 1.)) }; } DEFINE_ACTION_FUNCTION(DBaseStatusBar, GetHUDScale) @@ -1032,16 +1019,9 @@ void DBaseStatusBar::DrawLog () if (CPlayer->LogText.IsNotEmpty()) { // This uses the same scaling as regular HUD messages - if (active_con_scaletext() == 0) - { - hudwidth = SCREENWIDTH / CleanXfac; - hudheight = SCREENHEIGHT / CleanYfac; - } - else - { - hudwidth = SCREENWIDTH / active_con_scaletext(); - hudheight = SCREENHEIGHT / active_con_scaletext(); - } + auto scale = active_con_scaletext(); + hudwidth = SCREENWIDTH / scale; + hudheight = SCREENHEIGHT / scale; int linelen = hudwidth<640? Scale(hudwidth,9,10)-40 : 560; FBrokenLines *lines = V_BreakLines (SmallFont, linelen, CPlayer->LogText); diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index cd221958d..ffeba90f2 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -356,12 +356,7 @@ void FGameConfigFile::DoGlobalSetup () } if (last < 213) { - FBaseCVar *var = FindCVar("hud_scale", NULL); - if (var != NULL) - { - var->ResetToDefault(); - } - var = FindCVar("snd_channels", NULL); + auto var = FindCVar("snd_channels", NULL); if (var != NULL) { // old settings were default 32, minimum 8, new settings are default 128, minimum 64. @@ -369,6 +364,21 @@ void FGameConfigFile::DoGlobalSetup () if (v.Int < 64) var->ResetToDefault(); } } + if (last < 214) + { + FBaseCVar *var = FindCVar("hud_scale", NULL); + if (var != NULL) var->ResetToDefault(); + var = FindCVar("st_scale", NULL); + if (var != NULL) var->ResetToDefault(); + var = FindCVar("hud_althudscale", NULL); + if (var != NULL) var->ResetToDefault(); + var = FindCVar("con_scale", NULL); + if (var != NULL) var->ResetToDefault(); + var = FindCVar("con_scaletext", NULL); + if (var != NULL) var->ResetToDefault(); + + } + } } } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index c8da6ac4d..78b0dd7f3 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -76,6 +76,26 @@ CUSTOM_CVAR(Int, uiscale, 2, CVAR_ARCHIVE | CVAR_NOINITCALL) } } +int GetUIScale(int altval) +{ + int scaleval; + if (altval > 0) scaleval = altval; + else if (uiscale == 0) + { + // Default should try to scale to 640x480 + int vscale = screen->GetHeight() / 640; + int hscale = screen->GetWidth() / 480; + scaleval = clamp(vscale, 1, hscale); + } + else scaleval = uiscale; + + // block scales that result in something larger than the current screen. + int vmax = screen->GetHeight() / 200; + int hmax = screen->GetWidth() / 320; + int max = MAX(vmax, hmax); + return MIN(scaleval, max); +} + // [RH] Stretch values to make a 320x200 image best fit the screen // without using fractional steppings int CleanXfac, CleanYfac; diff --git a/src/v_video.cpp b/src/v_video.cpp index 07990af8b..3073e259c 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -870,13 +870,10 @@ void DFrameBuffer::DrawRateStuff () chars = mysnprintf (fpsbuff, countof(fpsbuff), "%2u ms (%3u fps)", howlong, LastCount); rate_x = Width / textScale - ConFont->StringWidth(&fpsbuff[0]); Clear (rate_x * textScale, 0, Width, ConFont->GetHeight() * textScale, GPalette.BlackIndex, 0); - if (textScale == 1) - DrawText (ConFont, CR_WHITE, rate_x, 0, (char *)&fpsbuff[0], TAG_DONE); - else - DrawText (ConFont, CR_WHITE, rate_x, 0, (char *)&fpsbuff[0], - DTA_VirtualWidth, screen->GetWidth() / textScale, - DTA_VirtualHeight, screen->GetHeight() / textScale, - DTA_KeepRatio, true, TAG_DONE); + DrawText (ConFont, CR_WHITE, rate_x, 0, (char *)&fpsbuff[0], + DTA_VirtualWidth, screen->GetWidth() / textScale, + DTA_VirtualHeight, screen->GetHeight() / textScale, + DTA_KeepRatio, true, TAG_DONE); uint32_t thisSec = ms/1000; if (LastSec < thisSec) diff --git a/src/v_video.h b/src/v_video.h index e92b045b1..d836e1a1f 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -563,7 +563,21 @@ int AspectBaseHeight(float aspect); double AspectPspriteOffset(float aspect); int AspectMultiplier(float aspect); bool AspectTallerThanWide(float aspect); +int GetUIScale(int altval); EXTERN_CVAR(Int, uiscale); +EXTERN_CVAR(Int, con_scaletext); +EXTERN_CVAR(Int, con_scale); + +inline int active_con_scaletext() +{ + return GetUIScale(con_scaletext); +} + +inline int active_con_scale() +{ + return GetUIScale(con_scale); +} + #endif // __V_VIDEO_H__ diff --git a/src/version.h b/src/version.h index a3bb6d199..b2e554633 100644 --- a/src/version.h +++ b/src/version.h @@ -66,7 +66,7 @@ const char *GetVersionString(); // Version stored in the ini's [LastRun] section. // Bump it if you made some configuration change that you want to // be able to migrate in FGameConfigFile::DoGlobalSetup(). -#define LASTRUNVERSION "213" +#define LASTRUNVERSION "214" // Protocol version used in demos. // Bump it if you change existing DEM_ commands or add new ones. diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 1a4a97148..de32e0253 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -1847,7 +1847,6 @@ HUDMNU_CROSSHAIRHEALTH = "Crosshair shows health"; HUDMNU_CROSSHAIRSCALE = "Scale crosshair"; HUDMNU_NAMETAGS = "Display nametags"; HUDMNU_NAMETAGCOLOR = "Nametag color"; -HUDMNU_SCALESTATBAR = "Stretch status bar"; HUDMNU_SCALEFULLSCREENHUD = "Stretch Fullscreen HUD"; HUDMNU_OLDOUCH = "Use old ouch mug shot formula"; HUDMNU_HEXENFLASHES = "Hexen weapon flashes"; @@ -1855,10 +1854,19 @@ HUDMNU_POISONFLASHES = "Poison damage flashes"; HUDMNU_ICEFLASHES = "Ice death flashes"; HUDMNU_HAZARDFLASHES = "Poison Buildup flashes"; +// Scaling options +SCALEMNU_TITLE = "Scaling Options"; +SCALEMNU_OVERRIDE = "Overrides for above setting"; +SCALEMNU_MESSAGES = "Messages"; +SCALEMNU_CONSOLE = "Console"; +SCALEMNU_STATBAR = "Status bar"; +SCALEMNU_HUD = "Fullscreen HUD"; +SCALEMNU_ALTHUD = "Alternative HUD"; +SCALEMNU_HUDASPECT = "HUD preserves aspect ratio"; + // AltHUD Options ALTHUDMNU_TITLE = "Alternative HUD"; ALTHUDMNU_ENABLE = "Enable alternative HUD"; -ALTHUDMNU_SCALEHUD = "Stretch alternative HUD"; ALTHUDMNU_SHOWSECRETS = "Show secret count"; ALTHUDMNU_SHOWMONSTERS = "Show monster count"; ALTHUDMNU_SHOWITEMS = "Show item count"; @@ -1977,8 +1985,6 @@ MSGMNU_TITLE = "MESSAGES"; MSGMNU_SHOWMESSAGES = "Show messages"; MSGMNU_SHOWOBITUARIES = "Show obituaries"; MSGMNU_SHOWSECRETS = "Show secret notifications"; -MSGMNU_SCALETEXT = "Scale text in high res"; -MSGMNU_SCALECONSOLE = "Scale console"; MSGMNU_MESSAGELEVEL = "Minimum message level"; MSGMNU_CENTERMESSAGES = "Center messages"; MSGMNU_MESSAGECOLORS = "Message Colors"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 545a9f31c..37b2a0175 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -828,11 +828,10 @@ OptionValue ZDoomStrife OptionMenu "HUDOptions" { Title "$HUDMNU_TITLE" + Submenu "$HUDMNU_SCALEOPT", "ScalingOptions" Submenu "$HUDMNU_ALTHUD", "AltHudOptions" Submenu "$HUDMNU_MESSAGE", "MessageOptions" StaticText " " - Slider "$HUDMNU_UISCALE", "uiscale", 0.0, 8.0, 1.0, 0 - StaticText " " Option "$HUDMNU_CROSSHAIR", "crosshair", "Crosshairs" Option "$HUDMNU_FORCECROSSHAIR", "crosshairforce", "OnOff" Option "$HUDMNU_GROWCROSSHAIR", "crosshairgrow", "OnOff" @@ -842,7 +841,6 @@ OptionMenu "HUDOptions" StaticText " " Option "$HUDMNU_NAMETAGS", "displaynametags", "DisplayTagsTypes" Option "$HUDMNU_NAMETAGCOLOR", "nametagcolor", "TextColors", "displaynametags" - Option "$HUDMNU_SCALESTATBAR", "st_scale", "OnOff" Option "$HUDMNU_OLDOUCH", "st_oldouch", "OnOff" StaticText " " Option "$HUDMNU_HEXENFLASHES", "pf_hexenweaps", "ZDoomHexen" @@ -850,7 +848,22 @@ OptionMenu "HUDOptions" Option "$HUDMNU_ICEFLASHES", "pf_ice", "ZDoomHexen" Option "$HUDMNU_HAZARDFLASHES", "pf_hazard", "ZDoomStrife" } - + +OptionMenu "ScalingOptions" +{ + Title "$SCALEMNU_TITLE" + Slider "$HUDMNU_UISCALE", "uiscale", 0.0, 8.0, 1.0, 0 + StaticText " " + // These will need a new control type. + StaticText "$SCALEMNU_OVERRIDE", 1 + Option "$SCALEMNU_MESSAGES", "con_scaletext", "OnOff" + Option "$SCALEMNU_CONSOLE", "con_scale", "OnOff" + Option "$SCALEMNU_STATBAR", "st_scale", "OnOff" + Option "$SCALEMNU_HUD", "hud_scale", "OnOff" + Option "$SCALEMNU_ALTHUD", "hud_althudscale", "OnOff" + StaticText " " + Option "$SCALEMNU_HUDASPECT", "hud_aspectscale", "OnOff" +} //------------------------------------------------------------------------------------------- // // Alternative HUD @@ -863,15 +876,6 @@ OptionValue "AMCoordinates" 1, "$OPTVAL_MAP" } -OptionValue "AltHUDScale" -{ - 0, "$OPTVAL_OFF" - 4, "$OPTVAL_ON" - 1, "$OPTVAL_SCALETO640X400" - 2, "$OPTVAL_PIXELDOUBLE" - 3, "$OPTVAL_PIXELQUADRUPLE" -} - OptionValue "AltHUDAmmo" { 0, "$OPTVAL_CURRENTWEAPON" @@ -911,7 +915,6 @@ OptionMenu "AltHUDOptions" Title "$ALTHUDMNU_TITLE" //Indent 220 Option "$ALTHUDMNU_ENABLE", "hud_althud", "OnOff" - Option "$ALTHUDMNU_SCALEHUD", "hud_althudscale", "AltHUDScale" Option "$ALTHUDMNU_SHOWSECRETS", "hud_showsecrets", "OnOff" Option "$ALTHUDMNU_SHOWMONSTERS", "hud_showmonsters", "OnOff" Option "$ALTHUDMNU_SHOWITEMS", "hud_showitems", "OnOff" @@ -1189,23 +1192,6 @@ OptionMenu ColorPickerMenu //------------------------------------------------------------------------------------------- -OptionValue ScaleValues -{ - 0, "$OPTVAL_OFF" - 1, "$OPTVAL_ON" - 2, "$OPTVAL_DOUBLE" - 3, "$OPTVAL_QUADRUPLE" -} - -OptionValue ConsoleScaleValues -{ - 1, "$OPTVAL_OFF" - 0, "$OPTVAL_ON" - 2, "$OPTVAL_DOUBLE" - 3, "$OPTVAL_TRIPLE" - 4, "$OPTVAL_QUADRUPLE" -} - OptionValue MessageLevels { 0.0, "$OPTVAL_ITEMPICKUP" @@ -1228,8 +1214,6 @@ OptionMenu MessageOptions Option "$MSGMNU_SHOWMESSAGES", "show_messages", "OnOff" Option "$MSGMNU_SHOWOBITUARIES", "show_obituaries", "OnOff" Option "$MSGMNU_SHOWSECRETS", "cl_showsecretmessage", "OnOff" - Option "$MSGMNU_SCALETEXT", "con_scaletext", "ScaleValues" - Option "$MSGMNU_SCALECONSOLE", "con_scale", "ConsoleScaleValues" Option "$MSGMNU_MESSAGELEVEL", "msg", "MessageLevels" Option "$MSGMNU_DEVELOPER", "developer", "DevMessageLevels" Option "$MSGMNU_CENTERMESSAGES", "con_centernotify", "OnOff"