mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 14:51:40 +00:00
- since we already got lots of CVAR descriptions from the menu's content, let's use that as CVAR description if none is explicitly provided.
This also necessitated localization support for CVAR descriptions because menu content is multi-language.
This commit is contained in:
parent
bb3e100c54
commit
3a23cc69d6
4 changed files with 23 additions and 1 deletions
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue