diff --git a/src/common/console/c_cvars.h b/src/common/console/c_cvars.h index d1b0e65068..2fc08df7c4 100644 --- a/src/common/console/c_cvars.h +++ b/src/common/console/c_cvars.h @@ -143,6 +143,10 @@ public: void SetArchiveBit () { Flags |= CVAR_ARCHIVE; } void MarkUnsafe(); void MarkSafe() { Flags &= ~CVAR_UNSAFECONTEXT; } + void AddDescription(const FString& label) + { + if (Description.IsEmpty()) Description = label; + } int ToInt() { diff --git a/src/common/console/c_dispatch.cpp b/src/common/console/c_dispatch.cpp index 6b4680e359..38ef90831d 100644 --- a/src/common/console/c_dispatch.cpp +++ b/src/common/console/c_dispatch.cpp @@ -50,6 +50,7 @@ #include "c_cvars.h" #include "c_buttons.h" #include "findfile.h" +#include "gstrings.h" // MACROS ------------------------------------------------------------------ @@ -300,7 +301,7 @@ void C_DoCommand (const char *cmd, int keynum) } else { // Get the variable's value - if (var->GetDescription().Len()) Printf("%s\n", var->GetDescription().GetChars()); + if (var->GetDescription().Len()) Printf("%s\n", GStrings.localize(var->GetDescription())); Printf ("\"%s\" is \"%s\"\n", var->GetName(), var->GetHumanString()); } } diff --git a/src/menu/optionmenu.cpp b/src/menu/optionmenu.cpp index ebe27800ba..0635ee5803 100644 --- a/src/menu/optionmenu.cpp +++ b/src/menu/optionmenu.cpp @@ -34,6 +34,7 @@ #include "v_video.h" #include "menu/menu.h" +#include "vm.h" //============================================================================= @@ -52,3 +53,16 @@ DMenuItemBase *DOptionMenuDescriptor::GetItem(FName name) return NULL; } +void SetCVarDescription(FBaseCVar* cvar, const FString* label) +{ + cvar->AddDescription(*label); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_OptionMenuItemOption, SetCVarDescription, SetCVarDescription) +{ + PARAM_PROLOGUE; + PARAM_POINTER(cv, FBaseCVar); + PARAM_STRING(label); + SetCVarDescription(cv, &label); + return 0; +} \ No newline at end of file diff --git a/wadsrc/static/zscript/ui/menu/optionmenuitems.zs b/wadsrc/static/zscript/ui/menu/optionmenuitems.zs index 0b5d4a86bc..d36ef3f741 100644 --- a/wadsrc/static/zscript/ui/menu/optionmenuitems.zs +++ b/wadsrc/static/zscript/ui/menu/optionmenuitems.zs @@ -360,10 +360,13 @@ class OptionMenuItemOption : OptionMenuItemOptionBase { CVar mCVar; + private static native void SetCVarDescription(CVar cv, String label); + OptionMenuItemOption Init(String label, Name command, Name values, CVar graycheck = null, int center = 0) { Super.Init(label, command, values, graycheck, center); mCVar = CVar.FindCVar(mAction); + if (mCVar) SetCVarDescription(mCVar, label); return self; }