From 3ea526055fb892541b4764bbefcb1bd1ef218215 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 4 Dec 2019 23:07:02 +0100 Subject: [PATCH] - added a generic message display, using ZDoom's code. This is mainly meant for Nam and WW2GI which have an ugly-as-hell font for these texts. --- source/build/include/baselayer.h | 2 +- source/common/console/c_console.cpp | 17 +++++++---------- source/common/gamecvars.cpp | 6 ++---- source/duke3d/src/screentext.cpp | 4 ++-- source/rr/src/screentext.cpp | 4 ++-- source/sw/src/game.cpp | 4 ++-- source/sw/src/text.cpp | 2 +- 7 files changed, 17 insertions(+), 22 deletions(-) diff --git a/source/build/include/baselayer.h b/source/build/include/baselayer.h index 4d9ac6269..555f2a2ab 100644 --- a/source/build/include/baselayer.h +++ b/source/build/include/baselayer.h @@ -234,7 +234,7 @@ struct GameInterface va_start(ap, fmt); FString f; f.VFormat(fmt, ap); - DoPrintMessage(prio, fmt); + DoPrintMessage(prio, f); } }; diff --git a/source/common/console/c_console.cpp b/source/common/console/c_console.cpp index 0b9ab28e8..b9fba6b15 100644 --- a/source/common/console/c_console.cpp +++ b/source/common/console/c_console.cpp @@ -53,6 +53,8 @@ #include "v_font.h" #include "printf.h" #include "inputstate.h" +#include "i_time.h" +#include "gamecvars.h" #define LEFTMARGIN 8 @@ -123,15 +125,13 @@ static GameAtExit *ExitCmdList; #define SCROLLDN 2 #define SCROLLNO 0 -CVAR (Bool, show_messages, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) - // Buffer for AddToConsole() static char *work = NULL; static int worklen = 0; CVAR(Float, con_notifytime, 3.f, CVAR_ARCHIVE) CVAR(Bool, con_centernotify, false, CVAR_ARCHIVE) -CUSTOM_CVAR(Int, con_scaletext, 0, CVAR_ARCHIVE) // Scale notify text at high resolutions? +CUSTOM_CVAR(Int, con_scaletext, 2, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // Scale notify text at high resolutions? { if (self < 0) self = 0; } @@ -541,7 +541,7 @@ CUSTOM_CVAR(Int, con_notifylines, NUMNOTIFIES, CVAR_GLOBALCONFIG | CVAR_ARCHIVE) } -int PrintColors[PRINTLEVELS+2] = { CR_RED, CR_GOLD, CR_GRAY, CR_GREEN, CR_GREEN, CR_GOLD }; +int PrintColors[PRINTLEVELS+2] = { CR_RED, CR_GOLD, CR_YELLOW, CR_GREEN, CR_GREEN, CR_GOLD }; static void setmsgcolor (int index, int color); @@ -775,7 +775,7 @@ void FNotifyBuffer::AddString(int printlevel, FString source) TArray lines; int width; - if ((printlevel != 128 && !show_messages) || + if (hud_messages != 2 || source.IsEmpty() || //gamestate == GS_FULLCONSOLE || //gamestate == GS_DEMOSCREEN || @@ -901,7 +901,7 @@ int PrintString (int iprintlevel, const char *outline) #endif conbuffer->AddText(printlevel, outline); - if (vidactive && screen && (iprintlevel & PRINT_NOTIFY)) + if (vidactive && (iprintlevel & PRINT_NOTIFY)) { NotifyStrings.AddString(printlevel, outline); } @@ -1074,7 +1074,7 @@ void FNotifyBuffer::Tick() if (Text[i].TimeOut != 0 && --Text[i].TimeOut <= 0) break; } - if (i > 0) + if (i < Text.Size()) { Text.Delete(0, i); } @@ -1106,9 +1106,6 @@ void FNotifyBuffer::Draw() j = notify.TimeOut; if (j > 0) { - if (!show_messages && notify.PrintLevel != 128) - continue; - double alpha = (j < NOTIFYFADETIME) ? 1. * j / NOTIFYFADETIME : 1; if (notify.PrintLevel >= PRINTLEVELS) diff --git a/source/common/gamecvars.cpp b/source/common/gamecvars.cpp index a99cf27a1..5b8f21a32 100644 --- a/source/common/gamecvars.cpp +++ b/source/common/gamecvars.cpp @@ -257,7 +257,6 @@ CVARD(Bool, hud_showmapname, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disab CVARD(Bool, hud_position, false, CVAR_ARCHIVE, "aligns the status bar to the bottom/top") CVARD(Bool, hud_bgstretch, false, CVAR_ARCHIVE|CVAR_FRONTEND_DUKELIKE, "enable/disable background image stretching in wide resolutions") CVARD(Int, hud_messagetime, 120, CVAR_ARCHIVE|CVAR_FRONTEND_DUKELIKE, "length of time to display multiplayer chat messages") -// Should be available to all games - the message handling should also be consolidated into a game independent feature. CUSTOM_CVARD(Int, hud_messages, 1, CVAR_ARCHIVE, "enable/disable showing messages") { if (self < 0 || self > 2) self = 1; @@ -266,16 +265,15 @@ CUSTOM_CVARD(Int, hud_messages, 1, CVAR_ARCHIVE, "enable/disable showing message CCMD (togglemessages) { - if (hud_messages) { - Printf (128, "%s\n", GStrings("MSGOFF")); + gi->PrintMessage(PRINT_MEDIUM, "%s\n", GStrings("MSGOFF")); hud_messages = false; } else { - Printf (128, "%s\n", GStrings("MSGON")); hud_messages = true; + gi->PrintMessage(PRINT_MEDIUM, "%s\n", GStrings("MSGON")); } } diff --git a/source/duke3d/src/screentext.cpp b/source/duke3d/src/screentext.cpp index e3cf83e13..792d70d89 100644 --- a/source/duke3d/src/screentext.cpp +++ b/source/duke3d/src/screentext.cpp @@ -1107,7 +1107,7 @@ void G_PrintGameQuotes(int32_t snum) } #endif - if (text_quote.IsNotEmpty() && ps->ftq == -32878) height = gametext_(x, y, text_quote, textsh(k), pal, texto(k), texta(k), TEXT_XCENTER).y + (1 << 16); + if (text_quote.IsNotEmpty() && ps->ftq == -32768) height = gametext_(x, y, text_quote, textsh(k), pal, texto(k), texta(k), TEXT_XCENTER).y + (1 << 16); else height = gametext_(x, y, quoteMgr.GetQuote(ps->ftq), textsh(k), pal, texto(k), texta(k), TEXT_XCENTER).y + (1<<16); } while (0); @@ -1154,7 +1154,7 @@ void P_DoQuote(int32_t q, DukePlayer_t *p) { auto qu = quoteMgr.GetQuote(q); if (p == g_player[screenpeek].ps && qu[0] != '\0') - Printf(PRINT_MEDIUM | PRINT_NOTIFY, cq ? OSDTEXT_DEFAULT "%s\n" : "%s\n", qu); + Printf((cq? PRINT_LOW : PRINT_MEDIUM) | PRINT_NOTIFY, "%s\n", qu); } diff --git a/source/rr/src/screentext.cpp b/source/rr/src/screentext.cpp index 327fcb6c4..6aea65a7b 100644 --- a/source/rr/src/screentext.cpp +++ b/source/rr/src/screentext.cpp @@ -1153,7 +1153,7 @@ void P_DoQuote(int32_t q, DukePlayer_t *p) { auto qu = quoteMgr.GetQuote(q); if (p == g_player[screenpeek].ps && qu[0] != '\0') - Printf(PRINT_NOTIFY, cq ? OSDTEXT_DEFAULT "%s\n" : "%s\n", qu); + Printf((cq ? PRINT_LOW : PRINT_MEDIUM) | PRINT_NOTIFY, "%s\n", qu); } @@ -1178,7 +1178,7 @@ void GameInterface::DoPrintMessage(int prio, const char* t) if (p->ftq == QUOTE_RESERVED || p->ftq == QUOTE_RESERVED2) return; if (p == g_player[screenpeek].ps) - Printf(PRINT_NOTIFY, cq ? OSDTEXT_DEFAULT "%s\n" : "%s\n", t); + Printf(prio|PRINT_NOTIFY, cq ? OSDTEXT_DEFAULT "%s\n" : "%s\n", t); if (hud_messages == 1) { diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index f9a0d98ad..e4a572994 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -1352,8 +1352,8 @@ InitLevel(void) if (ArgCheat) { - SWBOOL bak = hud_messages; - hud_messages = FALSE; + int bak = hud_messages; + hud_messages = 0; EveryCheatToggle(&Player[0],NULL); hud_messages = bak; GodMode = TRUE; diff --git a/source/sw/src/text.cpp b/source/sw/src/text.cpp index 842b77f7d..bdeabf16c 100644 --- a/source/sw/src/text.cpp +++ b/source/sw/src/text.cpp @@ -447,7 +447,7 @@ void PutStringInfo(PLAYERp pp, const char *string) if (!hud_messages) return; - Printf(PRINT_LOW|PRINT_NOTIFY, "%s", string); // Put it in the console too + Printf(PRINT_MEDIUM|PRINT_NOTIFY, "%s", string); // Put it in the console too if (hud_messages == 1) PutStringInfoLine(pp, string); }