diff --git a/src/c_console.cpp b/src/c_console.cpp index 32bff7e62..e717ecba8 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -80,6 +80,7 @@ CUSTOM_CVAR(Int, con_buffersize, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) } CVAR(Bool, con_consolefont, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Bool, con_midconsolefont, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) FConsoleBuffer *conbuffer; @@ -628,6 +629,12 @@ void DequeueConsoleText () EnqueuedTextTail = &EnqueuedText; } +EColorRange C_GetDefaultFontColor() +{ + // Ideally this should analyze the SmallFont and pick a matching color. + return gameinfo.gametype == GAME_Doom ? CR_RED : gameinfo.gametype == GAME_Chex ? CR_GREEN : gameinfo.gametype == GAME_Strife ? CR_GOLD : CR_GRAY; +} + void C_InitConback() { conback = TexMan.CheckForTexture ("CONBACK", ETextureType::MiscPatch); @@ -1097,8 +1104,7 @@ void FNotifyBuffer::Draw() if (color == CR_UNTRANSLATED && *con_consolefont) { - // Ideally this should analyze the SmallFont and pick a matching color. - color = gameinfo.gametype == GAME_Doom ? CR_RED : gameinfo.gametype == GAME_Chex ? CR_GREEN : gameinfo.gametype == GAME_Strife ? CR_GOLD : CR_GRAY; + color = C_GetDefaultFontColor(); } int scale = active_con_scaletext(con_consolefont); if (!center) @@ -1772,8 +1778,18 @@ void C_MidPrint (FFont *font, const char *msg) AddToConsole (-1, msg); AddToConsole (-1, bar3); + auto color = (EColorRange)PrintColors[PRINTLEVELS]; + + bool altscale = false; + if (font == nullptr) + { + altscale = con_midconsolefont; + font = altscale ? NewConsoleFont : SmallFont; + if (altscale && color == CR_UNTRANSLATED) color = C_GetDefaultFontColor(); + } + StatusBar->AttachMessage (Create(font, msg, 1.5f, 0.375f, 0, 0, - (EColorRange)PrintColors[PRINTLEVELS], con_midtime), MAKE_ID('C','N','T','R')); + color, con_midtime, altscale), MAKE_ID('C','N','T','R')); } else { @@ -1789,8 +1805,17 @@ void C_MidPrintBold (FFont *font, const char *msg) AddToConsole (-1, msg); AddToConsole (-1, bar3); + auto color = (EColorRange)PrintColors[PRINTLEVELS+1]; + bool altscale = false; + if (font == nullptr) + { + altscale = con_midconsolefont; + font = altscale ? NewConsoleFont : SmallFont; + if (altscale && color == CR_UNTRANSLATED) color = C_GetDefaultFontColor(); + } + StatusBar->AttachMessage (Create (font, msg, 1.5f, 0.375f, 0, 0, - (EColorRange)PrintColors[PRINTLEVELS+1], con_midtime), MAKE_ID('C','N','T','R')); + color, con_midtime, altscale), MAKE_ID('C','N','T','R')); } else { @@ -1801,7 +1826,7 @@ void C_MidPrintBold (FFont *font, const char *msg) DEFINE_ACTION_FUNCTION(_Console, MidPrint) { PARAM_PROLOGUE; - PARAM_POINTER_NOT_NULL(fnt, FFont); + PARAM_POINTER(fnt, FFont); PARAM_STRING(text); PARAM_BOOL(bold); diff --git a/src/c_console.h b/src/c_console.h index 9bd940390..41fcd1eb0 100644 --- a/src/c_console.h +++ b/src/c_console.h @@ -47,7 +47,10 @@ typedef enum cstate_t } constate_e; -#define PRINTLEVELS 5 +enum +{ + PRINTLEVELS = 5 +}; extern int PrintColors[PRINTLEVELS + 2]; extern constate_e ConsoleState; diff --git a/src/d_net.cpp b/src/d_net.cpp index 0d497bcbd..b1240a332 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2169,7 +2169,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player) case DEM_CENTERPRINT: s = ReadString (stream); - C_MidPrint (SmallFont, s); + C_MidPrint (nullptr, s); break; case DEM_UINFCHANGED: diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 9efabd6b1..c53bade0e 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -623,7 +623,7 @@ void FParser::SF_Tip(void) if (t_argc>0 && Script->trigger && Script->trigger->CheckLocalView()) { - C_MidPrint(SmallFont, GetFormatString(0).GetChars()); + C_MidPrint(nullptr, GetFormatString(0).GetChars()); } } @@ -643,7 +643,7 @@ void FParser::SF_TimedTip(void) { float saved = con_midtime; con_midtime = intvalue(t_argv[0])/100.0f; - C_MidPrint(SmallFont, GetFormatString(1).GetChars()); + C_MidPrint(nullptr, GetFormatString(1).GetChars()); con_midtime=saved; } } @@ -662,7 +662,7 @@ void FParser::SF_PlayerTip(void) int plnum = T_GetPlayerNum(t_argv[0]); if (plnum!=-1 && Level->Players[plnum]->mo->CheckLocalView()) { - C_MidPrint(SmallFont, GetFormatString(1).GetChars()); + C_MidPrint(nullptr, GetFormatString(1).GetChars()); } } } diff --git a/src/g_statusbar/hudmessages.cpp b/src/g_statusbar/hudmessages.cpp index 0906b6b54..82a399084 100644 --- a/src/g_statusbar/hudmessages.cpp +++ b/src/g_statusbar/hudmessages.cpp @@ -128,7 +128,7 @@ void DHUDMessageBase::CallDraw(int bottom, int visibility) //============================================================================ DHUDMessage::DHUDMessage (FFont *font, const char *text, float x, float y, int hudwidth, int hudheight, - EColorRange textColor, float holdTime) + EColorRange textColor, float holdTime, bool altscale) { if (hudwidth == 0 || hudheight == 0) { @@ -139,6 +139,7 @@ DHUDMessage::DHUDMessage (FFont *font, const char *text, float x, float y, int h // for x range [0.0, 1.0]: Positions center of box // for x range [1.0, 2.0]: Positions center of box, and centers text inside it HUDWidth = HUDHeight = 0; + AltScale = altscale; if (fabs (x) > 2.f) { CenterX = true; @@ -319,7 +320,7 @@ void DHUDMessage::ResetText (const char *text) } else { - width = SCREENWIDTH / active_con_scaletext(); + width = SCREENWIDTH / active_con_scaletext(AltScale); } Lines = V_BreakLines (Font, NoWrap ? INT_MAX : width, (uint8_t *)text); @@ -379,7 +380,7 @@ void DHUDMessage::Draw (int bottom, int visibility) xscale = yscale = 1; if (HUDWidth == 0) { - int scale = active_con_scaletext(); + int scale = active_con_scaletext(AltScale); screen_width /= scale; screen_height /= scale; bottom /= scale; @@ -483,7 +484,7 @@ void DHUDMessage::DoDraw (int linenum, int x, int y, bool clean, int hudheight) { if (hudheight == 0) { - int scale = active_con_scaletext(); + int scale = active_con_scaletext(AltScale); screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, DTA_VirtualWidth, SCREENWIDTH / scale, DTA_VirtualHeight, SCREENHEIGHT / scale, @@ -576,7 +577,7 @@ void DHUDMessageFadeOut::DoDraw (int linenum, int x, int y, bool clean, int hudh float trans = float(Alpha * -(Tics - FadeOutTics) / FadeOutTics); if (hudheight == 0) { - int scale = active_con_scaletext(); + int scale = active_con_scaletext(AltScale); screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, DTA_VirtualWidth, SCREENWIDTH / scale, DTA_VirtualHeight, SCREENHEIGHT / scale, @@ -665,7 +666,7 @@ void DHUDMessageFadeInOut::DoDraw (int linenum, int x, int y, bool clean, int hu float trans = float(Alpha * Tics / FadeInTics); if (hudheight == 0) { - int scale = active_con_scaletext(); + int scale = active_con_scaletext(AltScale); screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, DTA_VirtualWidth, SCREENWIDTH / scale, DTA_VirtualHeight, SCREENHEIGHT / scale, @@ -836,7 +837,7 @@ void DHUDMessageTypeOnFadeOut::DoDraw (int linenum, int x, int y, bool clean, in { if (hudheight == 0) { - int scale = active_con_scaletext(); + int scale = active_con_scaletext(AltScale); screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, DTA_VirtualWidth, SCREENWIDTH / scale, DTA_VirtualHeight, SCREENHEIGHT / scale, diff --git a/src/g_statusbar/sbar.h b/src/g_statusbar/sbar.h index a91452e3f..6fe11c5bc 100644 --- a/src/g_statusbar/sbar.h +++ b/src/g_statusbar/sbar.h @@ -84,7 +84,7 @@ class DHUDMessage : public DHUDMessageBase DECLARE_CLASS (DHUDMessage, DHUDMessageBase) public: DHUDMessage (FFont *font, const char *text, float x, float y, int hudwidth, int hudheight, - EColorRange textColor, float holdTime); + EColorRange textColor, float holdTime, bool altscale = false); virtual void OnDestroy () override; virtual void Serialize(FSerializer &arc); @@ -140,6 +140,7 @@ protected: int ClipX, ClipY, ClipWidth, ClipHeight, WrapWidth; // in HUD coords int ClipLeft, ClipTop, ClipRight, ClipBot; // in screen coords bool HandleAspect; + bool AltScale; EColorRange TextColor; FFont *Font; FRenderStyle Style; diff --git a/src/gamedata/a_keys.cpp b/src/gamedata/a_keys.cpp index 7260c967d..7362cb3e6 100644 --- a/src/gamedata/a_keys.cpp +++ b/src/gamedata/a_keys.cpp @@ -220,7 +220,7 @@ static void PrintMessage (const char *str) { str = GStrings(str+1); } - C_MidPrint (SmallFont, str); + C_MidPrint (nullptr, str); } } diff --git a/src/p_acs.cpp b/src/p_acs.cpp index dff6e4cb3..e5c338b00 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -705,7 +705,7 @@ protected: TObjPtr activator; line_t *activationline; bool backSide; - FFont *activefont; + FFont *activefont = nullptr; int hudwidth, hudheight; int ClipRectLeft, ClipRectTop, ClipRectWidth, ClipRectHeight; int WrapWidth; @@ -774,7 +774,7 @@ protected: private: - DLevelScript(); + DLevelScript() = default; friend class DACSThinker; }; @@ -3506,11 +3506,6 @@ void DLevelScript::Serialize(FSerializer &arc) } } -DLevelScript::DLevelScript () -{ - activefont = SmallFont; -} - void DLevelScript::Unlink () { DACSThinker *controller = Level->ACSThinker; @@ -3924,10 +3919,6 @@ void DLevelScript::DoSetFont (int fontnum) { const char *fontname = Level->Behaviors.LookupString (fontnum); activefont = V_GetFont (fontname); - if (activefont == NULL) - { - activefont = SmallFont; - } } int DLevelScript::DoSetMaster (AActor *self, AActor *master) @@ -8676,17 +8667,18 @@ scriptwait: color = CLAMPCOLOR(Stack[optstart-4]); } + FFont *font = activefont ? activefont : SmallFont; switch (type & 0xFF) { default: // normal alpha = (optstart < sp) ? ACSToFloat(Stack[optstart]) : 1.f; - msg = Create (activefont, work, x, y, hudwidth, hudheight, color, holdTime); + msg = Create (font, work, x, y, hudwidth, hudheight, color, holdTime); break; case 1: // fade out { float fadeTime = (optstart < sp) ? ACSToFloat(Stack[optstart]) : 0.5f; alpha = (optstart < sp-1) ? ACSToFloat(Stack[optstart+1]) : 1.f; - msg = Create (activefont, work, x, y, hudwidth, hudheight, color, holdTime, fadeTime); + msg = Create (font, work, x, y, hudwidth, hudheight, color, holdTime, fadeTime); } break; case 2: // type on, then fade out @@ -8694,7 +8686,7 @@ scriptwait: float typeTime = (optstart < sp) ? ACSToFloat(Stack[optstart]) : 0.05f; float fadeTime = (optstart < sp-1) ? ACSToFloat(Stack[optstart+1]) : 0.5f; alpha = (optstart < sp-2) ? ACSToFloat(Stack[optstart+2]) : 1.f; - msg = Create (activefont, work, x, y, hudwidth, hudheight, color, typeTime, holdTime, fadeTime); + msg = Create (font, work, x, y, hudwidth, hudheight, color, typeTime, holdTime, fadeTime); } break; case 3: // fade in, then fade out @@ -8702,7 +8694,7 @@ scriptwait: float inTime = (optstart < sp) ? ACSToFloat(Stack[optstart]) : 0.5f; float outTime = (optstart < sp-1) ? ACSToFloat(Stack[optstart+1]) : 0.5f; alpha = (optstart < sp-2) ? ACSToFloat(Stack[optstart + 2]) : 1.f; - msg = Create (activefont, work, x, y, hudwidth, hudheight, color, holdTime, inTime, outTime); + msg = Create (font, work, x, y, hudwidth, hudheight, color, holdTime, inTime, outTime); } break; } @@ -10286,7 +10278,6 @@ DLevelScript::DLevelScript (FLevelLocals *l, AActor *who, line_t *where, int num activator = who; activationline = where; backSide = flags & ACS_BACKSIDE; - activefont = SmallFont; hudwidth = hudheight = 0; ClipRectLeft = ClipRectTop = ClipRectWidth = ClipRectHeight = WrapWidth = 0; HandleAspect = true; diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index f37f8d9cc..24f4d68b8 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -1309,7 +1309,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Print) con_midtime = float(time); } FString formatted = strbin1(text); - C_MidPrint(font != NULL ? font : SmallFont, formatted.GetChars()); + C_MidPrint(font, formatted.GetChars()); con_midtime = saved; } return 0; @@ -1341,7 +1341,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PrintBold) con_midtime = float(time); } FString formatted = strbin1(text); - C_MidPrintBold(font != NULL ? font : SmallFont, formatted.GetChars()); + C_MidPrintBold(font, formatted.GetChars()); con_midtime = saved; return 0; } diff --git a/src/p_spec.cpp b/src/p_spec.cpp index bd4319f41..a8f62151b 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -592,12 +592,12 @@ void P_GiveSecret(FLevelLocals *Level, AActor *actor, bool printmessage, bool pl { if (printmessage) { - if (!showsecretsector || sectornum < 0) C_MidPrint(SmallFont, GStrings["SECRETMESSAGE"]); + if (!showsecretsector || sectornum < 0) C_MidPrint(nullptr, GStrings["SECRETMESSAGE"]); else { FString s = GStrings["SECRETMESSAGE"]; s.AppendFormat(" (Sector %d)", sectornum); - C_MidPrint(SmallFont, s); + C_MidPrint(nullptr, s); } } if (playsound) S_Sound (CHAN_AUTO | CHAN_UI, "misc/secret", 1, ATTN_NORM);