From 700304bf4641f7c3aedb31ac19f3612ffa02eff7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Sep 2020 09:35:06 +0200 Subject: [PATCH] - update of console code. Backports con_pulsetext and toggle messages for CVARs from Raze. --- src/common/console/c_bind.cpp | 2 +- src/common/console/c_bind.h | 1 - src/common/console/c_console.h | 2 ++ src/common/console/c_cvars.cpp | 7 ++++++- src/common/console/c_cvars.h | 9 ++++++++- src/common/console/c_dispatch.cpp | 2 +- src/common/console/c_dispatch.h | 2 +- src/common/console/keydef.h | 3 +++ src/console/c_cmds.cpp | 7 ++++++- src/console/c_console.cpp | 16 ++++++++++++++++ 10 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/common/console/c_bind.cpp b/src/common/console/c_bind.cpp index c5a540645..1aad2d255 100644 --- a/src/common/console/c_bind.cpp +++ b/src/common/console/c_bind.cpp @@ -739,7 +739,7 @@ void C_SetDefaultKeys(const char* baseconfig) // // //============================================================================= -CVAR(Int, cl_defaultconfiguration, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Int, cl_defaultconfiguration, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) void C_BindDefaults() diff --git a/src/common/console/c_bind.h b/src/common/console/c_bind.h index 76c911a65..ada3cb84e 100644 --- a/src/common/console/c_bind.h +++ b/src/common/console/c_bind.h @@ -87,7 +87,6 @@ public: extern FKeyBindings Bindings; extern FKeyBindings DoubleBindings; extern FKeyBindings AutomapBindings; -extern FKeyBindings MenuBindings; bool C_DoKey (event_t *ev, FKeyBindings *binds, FKeyBindings *doublebinds); diff --git a/src/common/console/c_console.h b/src/common/console/c_console.h index e88ef0aa6..5ea3f8f34 100644 --- a/src/common/console/c_console.h +++ b/src/common/console/c_console.h @@ -57,6 +57,7 @@ extern constate_e ConsoleState; void C_InitConsole (int width, int height, bool ingame); void C_DeinitConsole (); void C_InitConback(); +void C_ClearMessages(); // Adjust the console for a new screen mode void C_NewModeAdjust (void); @@ -83,6 +84,7 @@ bool C_Responder (event_t *ev); void C_AddTabCommand (const char *name); void C_RemoveTabCommand (const char *name); void C_ClearTabCommands(); // Removes all tab commands +void C_SetNotifyFontScale(double scale); extern const char *console_bar; diff --git a/src/common/console/c_cvars.cpp b/src/common/console/c_cvars.cpp index fe951d65c..111bad99c 100644 --- a/src/common/console/c_cvars.cpp +++ b/src/common/console/c_cvars.cpp @@ -1519,7 +1519,12 @@ CCMD (toggle) val = var->GetGenericRep (CVAR_Bool); val.Bool = !val.Bool; var->SetGenericRep (val, CVAR_Bool); - Printf ("\"%s\" = \"%s\"\n", var->GetName(), + auto msg = var->GetToggleMessage(val.Bool); + if (msg.IsNotEmpty()) + { + Printf(PRINT_NOTIFY, "%s\n", msg.GetChars()); + } + else Printf ("\"%s\" = \"%s\"\n", var->GetName(), val.Bool ? "true" : "false"); } } diff --git a/src/common/console/c_cvars.h b/src/common/console/c_cvars.h index 6218cb956..567475c70 100644 --- a/src/common/console/c_cvars.h +++ b/src/common/console/c_cvars.h @@ -176,6 +176,13 @@ public: static void ListVars (const char *filter, bool plain); const FString &GetDescription() const { return Description; }; + const FString& GetToggleMessage(int which) { return ToggleMessages[which]; } + void SetToggleMessages(const char* on, const char* off) + { + ToggleMessages[0] = off; + ToggleMessages[1] = on; + } + protected: virtual void DoSet (UCVarValue value, ECVarType type) = 0; @@ -192,13 +199,13 @@ protected: FString VarName; FString SafeValue; FString Description; + FString ToggleMessages[2]; uint32_t Flags; bool inCallback = false; private: FBaseCVar (const FBaseCVar &var) = delete; FBaseCVar (const char *name, uint32_t flags); - void (*m_Callback)(FBaseCVar &); FBaseCVar *m_Next; diff --git a/src/common/console/c_dispatch.cpp b/src/common/console/c_dispatch.cpp index 38ef90831..cc050fea5 100644 --- a/src/common/console/c_dispatch.cpp +++ b/src/common/console/c_dispatch.cpp @@ -1123,7 +1123,7 @@ int C_RegisterFunction(const char* pszName, const char* pszDesc, int (*func)(CCm { if (args.argc() > 0) args.operator[](0); CCmdFuncParm param = { args.argc() - 1, nname.GetChars(), (const char**)args._argv + 1, args.cmd }; - if (func(¶m) != CCMD_OK) + if (func(¶m) != CCMD_OK && pszDesc) { Printf("%s\n", pszDesc); } diff --git a/src/common/console/c_dispatch.h b/src/common/console/c_dispatch.h index b381b6884..57d681c49 100644 --- a/src/common/console/c_dispatch.h +++ b/src/common/console/c_dispatch.h @@ -59,7 +59,7 @@ extern bool ParsingKeyConf, UnsafeExecutionContext; extern FString StoredWarp; // [RH] +warp at the command line -extern bool CheckCheatmode (bool printmsg = true); +extern bool CheckCheatmode (bool printmsg = true, bool sponly = false); FExecList *C_ParseCmdLineParams(FExecList *exec); diff --git a/src/common/console/keydef.h b/src/common/console/keydef.h index d85adefac..2cbdf621b 100644 --- a/src/common/console/keydef.h +++ b/src/common/console/keydef.h @@ -53,6 +53,9 @@ enum EKeyCodes KEY_PGUP = 0xc9, // DIK_PRIOR KEY_PGDN = 0xd1, // DIK_NEXT + KEY_VOLUMEDOWN = 0xAE, // DIK_VOLUMEDOWN + KEY_VOLUMEUP = 0xB0, // DIK_VOLUMEUP + KEY_FIRSTMOUSEBUTTON = 0x100, KEY_MOUSE1 = 0x100, KEY_MOUSE2 = 0x101, diff --git a/src/console/c_cmds.cpp b/src/console/c_cmds.cpp index 6f36599de..503336b82 100644 --- a/src/console/c_cmds.cpp +++ b/src/console/c_cmds.cpp @@ -87,8 +87,13 @@ CCMD (toggleconsole) C_ToggleConsole(); } -bool CheckCheatmode (bool printmsg) +bool CheckCheatmode (bool printmsg, bool sponly) { + if (sponly && netgame) + { + if (printmsg) Printf("Not in a singleplayer game.\n"); + return true; + } if ((G_SkillProperty(SKILLP_DisableCheats) || netgame || deathmatch) && (!sv_cheats)) { if (printmsg) Printf ("sv_cheats must be true to enable this command.\n"); diff --git a/src/console/c_console.cpp b/src/console/c_console.cpp index ad4fb0820..28b679eeb 100644 --- a/src/console/c_console.cpp +++ b/src/console/c_console.cpp @@ -114,6 +114,12 @@ int ConBottom, ConScroll, RowAdjust; uint64_t CursorTicker; constate_e ConsoleState = c_up; +double NotifyFontScale = 1; + +void C_SetNotifyFontScale(double scale) +{ + NotifyFontScale = scale; +} static int TopLine, InsertLine; @@ -145,6 +151,7 @@ CUSTOM_CVAR(Int, con_scaletext, 0, CVAR_ARCHIVE) // Scale notify text at high r { if (self < 0) self = 0; } +CVAR(Bool, con_pulsetext, false, CVAR_ARCHIVE) CUSTOM_CVAR(Int, con_scale, 0, CVAR_ARCHIVE) { @@ -931,6 +938,11 @@ int PrintString (int iprintlevel, const char *outline) return 0; // Don't waste time on calculating this if nothing at all was printed... } +void C_ClearMessages() +{ + NotifyStrings.Clear(); +} + int VPrintf (int printlevel, const char *format, va_list parms) { FString outline; @@ -1107,6 +1119,10 @@ void FNotifyBuffer::Draw() continue; double alpha = (j < NOTIFYFADETIME) ? 1. * j / NOTIFYFADETIME : 1; + if (con_pulsetext) + { + alpha *= 0.7 + 0.3 * sin(I_msTime() / 100.); + } if (notify.PrintLevel >= PRINTLEVELS) color = CR_UNTRANSLATED;