- update of console code.

Backports con_pulsetext and toggle messages for CVARs from Raze.
This commit is contained in:
Christoph Oelckers 2020-09-27 09:35:06 +02:00
commit 700304bf46
10 changed files with 44 additions and 7 deletions

View file

@ -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()

View file

@ -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);

View file

@ -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;

View file

@ -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");
}
}

View file

@ -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;

View file

@ -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(&param) != CCMD_OK)
if (func(&param) != CCMD_OK && pszDesc)
{
Printf("%s\n", pszDesc);
}

View file

@ -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);

View file

@ -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,