Merge branch 'development' into cmake/warn_virtual
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> # Conflicts: # Code/Legacy/CryCommon/IConsole.h # Code/Legacy/CrySystem/LocalizedStringManager.h # Code/Legacy/CrySystem/XConsole.h # Code/Legacy/CrySystem/XConsoleVariable.h # Code/Legacy/CrySystem/XML/XmlUtils.cpp # cmake/Platform/Common/Clang/Configurations_clang.cmake
This commit is contained in:
@@ -6,86 +6,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYSYSTEM_XCONSOLEVARIABLE_H
|
||||
#define CRYINCLUDE_CRYSYSTEM_XCONSOLEVARIABLE_H
|
||||
#pragma once
|
||||
|
||||
#include <IConsole.h>
|
||||
#include <ISystem.h>
|
||||
#include "BitFiddling.h"
|
||||
#include "SFunctor.h"
|
||||
#include <AzCore/std/function/function_template.h>
|
||||
|
||||
class CXConsole;
|
||||
using stack_string = AZStd::fixed_string<512>;
|
||||
|
||||
inline int64 TextToInt64(const char* s, int64 nCurrent, bool bBitfield)
|
||||
{
|
||||
int64 nValue = 0;
|
||||
if (s)
|
||||
{
|
||||
char* e;
|
||||
if (bBitfield)
|
||||
{
|
||||
// Bit manipulation.
|
||||
if (*s == '^')
|
||||
// Bit number
|
||||
#if defined(_MSC_VER)
|
||||
{
|
||||
nValue = 1LL << _strtoi64(++s, &e, 10);
|
||||
}
|
||||
#else
|
||||
{
|
||||
nValue = 1LL << strtoll(++s, &e, 10);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
// Full number
|
||||
#if defined(_MSC_VER)
|
||||
{
|
||||
nValue = _strtoi64(s, &e, 10);
|
||||
}
|
||||
#else
|
||||
{
|
||||
nValue = strtoll(s, &e, 10);
|
||||
}
|
||||
#endif
|
||||
// Check letter codes.
|
||||
for (; (*e >= 'a' && *e <= 'z') || (*e >= 'A' && *e <= 'Z'); e++)
|
||||
{
|
||||
nValue |= AlphaBit64(*e);
|
||||
}
|
||||
|
||||
if (*e == '+')
|
||||
{
|
||||
nValue = nCurrent | nValue;
|
||||
}
|
||||
else if (*e == '-')
|
||||
{
|
||||
nValue = nCurrent & ~nValue;
|
||||
}
|
||||
else if (*e == '^')
|
||||
{
|
||||
nValue = nCurrent ^ nValue;
|
||||
}
|
||||
}
|
||||
else
|
||||
#if defined(_MSC_VER)
|
||||
{
|
||||
nValue = _strtoi64(s, &e, 10);
|
||||
}
|
||||
#else
|
||||
{
|
||||
nValue = strtoll(s, &e, 10);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return nValue;
|
||||
}
|
||||
|
||||
inline int TextToInt(const char* s, int nCurrent, bool bBitfield)
|
||||
{
|
||||
return (int)TextToInt64(s, nCurrent, bBitfield);
|
||||
}
|
||||
|
||||
class CXConsoleVariableBase
|
||||
: public ICVar
|
||||
@@ -107,7 +34,7 @@ public:
|
||||
void Release() override;
|
||||
void ForceSet(const char* s) override;
|
||||
void SetOnChangeCallback(ConsoleVarFunc pChangeFunc) override;
|
||||
uint64 AddOnChangeFunctor(const SFunctor& pChangeFunctor) override;
|
||||
virtual uint64 AddOnChangeFunctor(const SFunctor& pChangeFunctor) override;
|
||||
ConsoleVarFunc GetOnChangeCallback() const override;
|
||||
|
||||
bool ShouldReset() const { return (m_nFlags & VF_RESETTABLE) != 0; }
|
||||
@@ -133,14 +60,7 @@ public:
|
||||
m_pDataProbeString = new char[ strlen(pDataProbeString) + 1 ];
|
||||
azstrcpy(m_pDataProbeString, strlen(pDataProbeString) + 1, pDataProbeString);
|
||||
}
|
||||
const char* GetDataProbeString() const override
|
||||
{
|
||||
if (gEnv->IsDedicated() && m_pDataProbeString)
|
||||
{
|
||||
return m_pDataProbeString;
|
||||
}
|
||||
return GetOwnDataProbeString();
|
||||
}
|
||||
const char* GetDataProbeString() const override;
|
||||
|
||||
protected: // ------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -157,7 +77,7 @@ protected: // ------------------------------------------------------------------
|
||||
char* m_pDataProbeString; // value client is required to have for data probes
|
||||
int m_nFlags; // e.g. VF_CHEAT, ...
|
||||
|
||||
using ChangeFunctorContainer = std::vector<std::pair<int, SFunctor> >;
|
||||
typedef std::vector<std::pair<int, AZStd::function<void ()>> > ChangeFunctorContainer;
|
||||
ChangeFunctorContainer m_changeFunctors;
|
||||
ConsoleVarFunc m_pChangeFunc; // Callback function that is called when this variable changes.
|
||||
CXConsole* m_pConsole; // used for the callback OnBeforeVarChange()
|
||||
@@ -193,59 +113,11 @@ public:
|
||||
{
|
||||
Set(m_sDefault.c_str());
|
||||
}
|
||||
void Set(const char* s) override
|
||||
{
|
||||
if (!s)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((m_sValue == s) && (m_nFlags & VF_ALWAYSONCHANGE) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_pConsole->OnBeforeVarChange(this, s))
|
||||
{
|
||||
m_nFlags |= VF_MODIFIED;
|
||||
{
|
||||
m_sValue = s;
|
||||
}
|
||||
|
||||
CallOnChangeFunctions();
|
||||
|
||||
m_pConsole->OnAfterVarChange(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Set(float f) override
|
||||
{
|
||||
stack_string s = stack_string::format("%g", f);
|
||||
|
||||
if ((m_sValue == s.c_str()) && (m_nFlags & VF_ALWAYSONCHANGE) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_nFlags |= VF_MODIFIED;
|
||||
Set(s.c_str());
|
||||
}
|
||||
|
||||
void Set(int i) override
|
||||
{
|
||||
stack_string s = stack_string::format("%d", i);
|
||||
|
||||
if ((m_sValue == s.c_str()) && (m_nFlags & VF_ALWAYSONCHANGE) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_nFlags |= VF_MODIFIED;
|
||||
Set(s.c_str());
|
||||
}
|
||||
void Set(const char* s) override;
|
||||
void Set(float f) override;
|
||||
void Set(int i) override;
|
||||
int GetType() override { return CVAR_STRING; }
|
||||
|
||||
void GetMemoryUsage(class ICrySizer* pSizer) const override { pSizer->AddObject(this, sizeof(*this)); }
|
||||
private: // --------------------------------------------------------------------------------------------
|
||||
AZStd::string m_sValue;
|
||||
AZStd::string m_sDefault; //!<
|
||||
@@ -267,122 +139,21 @@ public:
|
||||
|
||||
// interface ICVar --------------------------------------------------------------------------------------
|
||||
|
||||
virtual int GetIVal() const { return m_iValue; }
|
||||
virtual int64 GetI64Val() const { return m_iValue; }
|
||||
virtual float GetFVal() const { return (float)GetIVal(); }
|
||||
virtual const char* GetString() const
|
||||
{
|
||||
static char szReturnString[256];
|
||||
|
||||
sprintf_s(szReturnString, "%d", GetIVal());
|
||||
return szReturnString;
|
||||
}
|
||||
int GetIVal() const override { return m_iValue; }
|
||||
int64 GetI64Val() const override { return m_iValue; }
|
||||
float GetFVal() const override { return (float)GetIVal(); }
|
||||
const char* GetString() const override;
|
||||
void ResetImpl() override { Set(m_iDefault); }
|
||||
virtual void Set(const char* s)
|
||||
{
|
||||
int nValue = TextToInt(s, m_iValue, (m_nFlags & VF_BITFIELD) != 0);
|
||||
|
||||
Set(nValue);
|
||||
}
|
||||
virtual void Set(float f)
|
||||
{
|
||||
Set((int)f);
|
||||
}
|
||||
virtual void Set(int i)
|
||||
{
|
||||
if (i == m_iValue && (m_nFlags & VF_ALWAYSONCHANGE) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
stack_string s = stack_string::format("%d", i);
|
||||
|
||||
if (m_pConsole->OnBeforeVarChange(this, s.c_str()))
|
||||
{
|
||||
m_nFlags |= VF_MODIFIED;
|
||||
m_iValue = i;
|
||||
|
||||
CallOnChangeFunctions();
|
||||
|
||||
m_pConsole->OnAfterVarChange(this);
|
||||
}
|
||||
}
|
||||
virtual int GetType() { return CVAR_INT; }
|
||||
|
||||
virtual void GetMemoryUsage(class ICrySizer* pSizer) const { pSizer->AddObject(this, sizeof(*this)); }
|
||||
void Set(const char* s) override;
|
||||
void Set(float f) override;
|
||||
void Set(int i) override;
|
||||
int GetType() override { return CVAR_INT; }
|
||||
protected: // --------------------------------------------------------------------------------------------
|
||||
|
||||
int m_iValue;
|
||||
int m_iDefault; //!<
|
||||
};
|
||||
|
||||
|
||||
class CXConsoleVariableInt64
|
||||
: public CXConsoleVariableBase
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
CXConsoleVariableInt64(CXConsole* pConsole, const char* sName, const int64 iDefault, int nFlags, const char* help)
|
||||
: CXConsoleVariableBase(pConsole, sName, nFlags, help)
|
||||
, m_iValue(iDefault)
|
||||
, m_iDefault(iDefault)
|
||||
{
|
||||
}
|
||||
|
||||
// interface ICVar --------------------------------------------------------------------------------------
|
||||
|
||||
virtual int GetIVal() const { return (int)m_iValue; }
|
||||
virtual int64 GetI64Val() const { return m_iValue; }
|
||||
virtual float GetFVal() const { return (float)GetIVal(); }
|
||||
virtual const char* GetString() const
|
||||
{
|
||||
static char szReturnString[256];
|
||||
sprintf_s(szReturnString, "%lld", GetI64Val());
|
||||
return szReturnString;
|
||||
}
|
||||
void ResetImpl() override { Set(m_iDefault); }
|
||||
virtual void Set(const char* s)
|
||||
{
|
||||
int64 nValue = TextToInt64(s, m_iValue, (m_nFlags & VF_BITFIELD) != 0);
|
||||
|
||||
Set(nValue);
|
||||
}
|
||||
virtual void Set(float f)
|
||||
{
|
||||
Set((int)f);
|
||||
}
|
||||
virtual void Set(int i)
|
||||
{
|
||||
Set((int64)i);
|
||||
}
|
||||
virtual void Set(int64 i)
|
||||
{
|
||||
if (i == m_iValue && (m_nFlags & VF_ALWAYSONCHANGE) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
stack_string s = stack_string::format("%lld", i);
|
||||
|
||||
if (m_pConsole->OnBeforeVarChange(this, s.c_str()))
|
||||
{
|
||||
m_nFlags |= VF_MODIFIED;
|
||||
m_iValue = i;
|
||||
|
||||
CallOnChangeFunctions();
|
||||
|
||||
m_pConsole->OnAfterVarChange(this);
|
||||
}
|
||||
}
|
||||
virtual int GetType() { return CVAR_INT; }
|
||||
|
||||
virtual void GetMemoryUsage(class ICrySizer* pSizer) const { pSizer->AddObject(this, sizeof(*this)); }
|
||||
protected: // --------------------------------------------------------------------------------------------
|
||||
|
||||
int64 m_iValue;
|
||||
int64 m_iDefault; //!<
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class CXConsoleVariableFloat
|
||||
: public CXConsoleVariableBase
|
||||
@@ -401,78 +172,13 @@ public:
|
||||
virtual int GetIVal() const { return (int)m_fValue; }
|
||||
virtual int64 GetI64Val() const { return (int64)m_fValue; }
|
||||
virtual float GetFVal() const { return m_fValue; }
|
||||
virtual const char* GetString() const
|
||||
{
|
||||
static char szReturnString[256];
|
||||
|
||||
sprintf_s(szReturnString, "%g", m_fValue); // %g -> "2.01", %f -> "2.01000"
|
||||
return szReturnString;
|
||||
}
|
||||
void ResetImpl() override { Set(m_fDefault); }
|
||||
virtual void Set(const char* s)
|
||||
{
|
||||
float fValue = 0;
|
||||
if (s)
|
||||
{
|
||||
fValue = (float)atof(s);
|
||||
}
|
||||
|
||||
if (fValue == m_fValue && (m_nFlags & VF_ALWAYSONCHANGE) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_pConsole->OnBeforeVarChange(this, s))
|
||||
{
|
||||
m_nFlags |= VF_MODIFIED;
|
||||
m_fValue = fValue;
|
||||
|
||||
CallOnChangeFunctions();
|
||||
|
||||
m_pConsole->OnAfterVarChange(this);
|
||||
}
|
||||
}
|
||||
virtual void Set(float f)
|
||||
{
|
||||
if (f == m_fValue && (m_nFlags & VF_ALWAYSONCHANGE) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
stack_string s = stack_string::format("%g", f);
|
||||
|
||||
if (m_pConsole->OnBeforeVarChange(this, s.c_str()))
|
||||
{
|
||||
m_nFlags |= VF_MODIFIED;
|
||||
m_fValue = f;
|
||||
|
||||
CallOnChangeFunctions();
|
||||
|
||||
m_pConsole->OnAfterVarChange(this);
|
||||
}
|
||||
}
|
||||
virtual void Set(int i)
|
||||
{
|
||||
if ((float)i == m_fValue && (m_nFlags & VF_ALWAYSONCHANGE) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char sTemp[128];
|
||||
sprintf_s(sTemp, "%d", i);
|
||||
|
||||
if (m_pConsole->OnBeforeVarChange(this, sTemp))
|
||||
{
|
||||
m_nFlags |= VF_MODIFIED;
|
||||
m_fValue = (float)i;
|
||||
CallOnChangeFunctions();
|
||||
m_pConsole->OnAfterVarChange(this);
|
||||
}
|
||||
}
|
||||
virtual const char* GetString() const;
|
||||
virtual void ResetImpl() { Set(m_fDefault); }
|
||||
virtual void Set(const char* s);
|
||||
virtual void Set(float f);
|
||||
virtual void Set(int i);
|
||||
virtual int GetType() { return CVAR_FLOAT; }
|
||||
|
||||
virtual void GetMemoryUsage(class ICrySizer* pSizer) const { pSizer->AddObject(this, sizeof(*this)); }
|
||||
|
||||
protected:
|
||||
|
||||
const char* GetOwnDataProbeString() const override
|
||||
@@ -509,186 +215,19 @@ public:
|
||||
virtual int GetIVal() const { return m_iValue; }
|
||||
virtual int64 GetI64Val() const { return m_iValue; }
|
||||
virtual float GetFVal() const { return (float)m_iValue; }
|
||||
virtual const char* GetString() const
|
||||
{
|
||||
static char szReturnString[256];
|
||||
|
||||
sprintf_s(szReturnString, "%d", m_iValue);
|
||||
return szReturnString;
|
||||
}
|
||||
void ResetImpl() override { Set(m_iDefault); }
|
||||
virtual void Set(const char* s)
|
||||
{
|
||||
int nValue = TextToInt(s, m_iValue, (m_nFlags & VF_BITFIELD) != 0);
|
||||
if (nValue == m_iValue && (m_nFlags & VF_ALWAYSONCHANGE) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_pConsole->OnBeforeVarChange(this, s))
|
||||
{
|
||||
m_nFlags |= VF_MODIFIED;
|
||||
m_iValue = nValue;
|
||||
|
||||
CallOnChangeFunctions();
|
||||
m_pConsole->OnAfterVarChange(this);
|
||||
}
|
||||
}
|
||||
virtual void Set(float f)
|
||||
{
|
||||
if ((int)f == m_iValue && (m_nFlags & VF_ALWAYSONCHANGE) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char sTemp[128];
|
||||
sprintf_s(sTemp, "%g", f);
|
||||
|
||||
if (m_pConsole->OnBeforeVarChange(this, sTemp))
|
||||
{
|
||||
m_nFlags |= VF_MODIFIED;
|
||||
m_iValue = (int)f;
|
||||
CallOnChangeFunctions();
|
||||
m_pConsole->OnAfterVarChange(this);
|
||||
}
|
||||
}
|
||||
virtual void Set(int i)
|
||||
{
|
||||
if (i == m_iValue && (m_nFlags & VF_ALWAYSONCHANGE) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char sTemp[128];
|
||||
sprintf_s(sTemp, "%d", i);
|
||||
|
||||
if (m_pConsole->OnBeforeVarChange(this, sTemp))
|
||||
{
|
||||
m_nFlags |= VF_MODIFIED;
|
||||
m_iValue = i;
|
||||
CallOnChangeFunctions();
|
||||
m_pConsole->OnAfterVarChange(this);
|
||||
}
|
||||
}
|
||||
virtual const char* GetString() const;
|
||||
virtual void ResetImpl() { Set(m_iDefault); }
|
||||
virtual void Set(const char* s);
|
||||
virtual void Set(float f);
|
||||
virtual void Set(int i);
|
||||
virtual int GetType() { return CVAR_INT; }
|
||||
|
||||
virtual void GetMemoryUsage(class ICrySizer* pSizer) const { pSizer->AddObject(this, sizeof(*this)); }
|
||||
private: // --------------------------------------------------------------------------------------------
|
||||
|
||||
int& m_iValue;
|
||||
int m_iDefault; //!<
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class CXConsoleVariableFloatRef
|
||||
: public CXConsoleVariableBase
|
||||
{
|
||||
public:
|
||||
//! constructor
|
||||
//!\param pVar must not be 0
|
||||
CXConsoleVariableFloatRef(CXConsole* pConsole, const char* sName, float* pVar, int nFlags, const char* help)
|
||||
: CXConsoleVariableBase(pConsole, sName, nFlags, help)
|
||||
, m_fValue(*pVar)
|
||||
, m_fDefault(*pVar)
|
||||
{
|
||||
assert(pVar);
|
||||
}
|
||||
|
||||
// interface ICVar --------------------------------------------------------------------------------------
|
||||
|
||||
virtual int GetIVal() const { return (int)m_fValue; }
|
||||
virtual int64 GetI64Val() const { return (int64)m_fValue; }
|
||||
virtual float GetFVal() const { return m_fValue; }
|
||||
virtual const char* GetString() const
|
||||
{
|
||||
static char szReturnString[256];
|
||||
|
||||
sprintf_s(szReturnString, "%g", m_fValue);
|
||||
return szReturnString;
|
||||
}
|
||||
void ResetImpl() override { Set(m_fDefault); }
|
||||
virtual void Set(const char* s)
|
||||
{
|
||||
float fValue = 0;
|
||||
if (s)
|
||||
{
|
||||
fValue = (float)atof(s);
|
||||
}
|
||||
if (fValue == m_fValue && (m_nFlags & VF_ALWAYSONCHANGE) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_pConsole->OnBeforeVarChange(this, s))
|
||||
{
|
||||
m_nFlags |= VF_MODIFIED;
|
||||
m_fValue = fValue;
|
||||
|
||||
CallOnChangeFunctions();
|
||||
m_pConsole->OnAfterVarChange(this);
|
||||
}
|
||||
}
|
||||
virtual void Set(float f)
|
||||
{
|
||||
if (f == m_fValue && (m_nFlags & VF_ALWAYSONCHANGE) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char sTemp[128];
|
||||
sprintf_s(sTemp, "%g", f);
|
||||
|
||||
if (m_pConsole->OnBeforeVarChange(this, sTemp))
|
||||
{
|
||||
m_nFlags |= VF_MODIFIED;
|
||||
m_fValue = f;
|
||||
CallOnChangeFunctions();
|
||||
m_pConsole->OnAfterVarChange(this);
|
||||
}
|
||||
}
|
||||
virtual void Set(int i)
|
||||
{
|
||||
if ((float)i == m_fValue && (m_nFlags & VF_ALWAYSONCHANGE) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char sTemp[128];
|
||||
sprintf_s(sTemp, "%d", i);
|
||||
|
||||
if (m_pConsole->OnBeforeVarChange(this, sTemp))
|
||||
{
|
||||
m_nFlags |= VF_MODIFIED;
|
||||
m_fValue = (float)i;
|
||||
CallOnChangeFunctions();
|
||||
m_pConsole->OnAfterVarChange(this);
|
||||
}
|
||||
}
|
||||
virtual int GetType() { return CVAR_FLOAT; }
|
||||
|
||||
virtual void GetMemoryUsage(class ICrySizer* pSizer) const { pSizer->AddObject(this, sizeof(*this)); }
|
||||
|
||||
protected:
|
||||
|
||||
const char* GetOwnDataProbeString() const override
|
||||
{
|
||||
static char szReturnString[8];
|
||||
|
||||
sprintf_s(szReturnString, "%.1g", m_fValue);
|
||||
return szReturnString;
|
||||
}
|
||||
|
||||
private: // --------------------------------------------------------------------------------------------
|
||||
|
||||
float& m_fValue;
|
||||
float m_fDefault; //!<
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CXConsoleVariableStringRef
|
||||
: public CXConsoleVariableBase
|
||||
{
|
||||
@@ -714,26 +253,8 @@ public:
|
||||
{
|
||||
return m_sValue.c_str();
|
||||
}
|
||||
void ResetImpl() override { Set(m_sDefault.c_str()); }
|
||||
virtual void Set(const char* s)
|
||||
{
|
||||
if ((m_sValue == s) && (m_nFlags & VF_ALWAYSONCHANGE) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_pConsole->OnBeforeVarChange(this, s))
|
||||
{
|
||||
m_nFlags |= VF_MODIFIED;
|
||||
{
|
||||
m_sValue = s;
|
||||
m_userPtr = m_sValue.c_str();
|
||||
}
|
||||
|
||||
CallOnChangeFunctions();
|
||||
m_pConsole->OnAfterVarChange(this);
|
||||
}
|
||||
}
|
||||
virtual void ResetImpl() { Set(m_sDefault.c_str()); }
|
||||
virtual void Set(const char* s);
|
||||
virtual void Set(float f)
|
||||
{
|
||||
stack_string s = stack_string::format("%g", f);
|
||||
@@ -746,7 +267,6 @@ public:
|
||||
}
|
||||
virtual int GetType() { return CVAR_STRING; }
|
||||
|
||||
virtual void GetMemoryUsage(class ICrySizer* pSizer) const { pSizer->AddObject(this, sizeof(*this)); }
|
||||
private: // --------------------------------------------------------------------------------------------
|
||||
|
||||
AZStd::string m_sValue;
|
||||
@@ -754,84 +274,44 @@ private: // --------------------------------------------------------------------
|
||||
const char*& m_userPtr; //!<
|
||||
};
|
||||
|
||||
|
||||
|
||||
// works like CXConsoleVariableInt but when changing it sets other console variables
|
||||
// getting the value returns the last value it was set to - if that is still what was applied
|
||||
// to the cvars can be tested with GetRealIVal()
|
||||
class CXConsoleVariableCVarGroup
|
||||
: public CXConsoleVariableInt
|
||||
, public ILoadConfigurationEntrySink
|
||||
class CXConsoleVariableFloatRef
|
||||
: public CXConsoleVariableBase
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
CXConsoleVariableCVarGroup(CXConsole* pConsole, const char* sName, const char* szFileName, int nFlags);
|
||||
|
||||
// destructor
|
||||
~CXConsoleVariableCVarGroup();
|
||||
|
||||
// Returns:
|
||||
// part of the help string - useful to log out detailed description without additional help text
|
||||
AZStd::string GetDetailedInfo() const;
|
||||
|
||||
// interface ICVar -----------------------------------------------------------------------------------
|
||||
|
||||
const char* GetHelp() override;
|
||||
|
||||
int GetRealIVal() const override;
|
||||
|
||||
virtual void DebugLog(const int iExpectedValue, const ICVar::EConsoleLogMode mode) const;
|
||||
|
||||
void Set(int i) override;
|
||||
|
||||
// ConsoleVarFunc ------------------------------------------------------------------------------------
|
||||
|
||||
static void OnCVarChangeFunc(ICVar* pVar);
|
||||
|
||||
// interface ILoadConfigurationEntrySink -------------------------------------------------------------
|
||||
|
||||
void OnLoadConfigurationEntry(const char* szKey, const char* szValue, const char* szGroup) override;
|
||||
void OnLoadConfigurationEntry_End() override;
|
||||
|
||||
void GetMemoryUsage(class ICrySizer* pSizer) const override
|
||||
//! constructor
|
||||
//!\param pVar must not be 0
|
||||
CXConsoleVariableFloatRef(CXConsole* pConsole, const char* sName, float* pVar, int nFlags, const char* help)
|
||||
: CXConsoleVariableBase(pConsole, sName, nFlags, help)
|
||||
, m_fValue(*pVar)
|
||||
, m_fDefault(*pVar)
|
||||
{
|
||||
pSizer->AddObject(this, sizeof(*this));
|
||||
pSizer->AddObject(m_sDefaultValue);
|
||||
pSizer->AddObject(m_CVarGroupStates);
|
||||
assert(pVar);
|
||||
}
|
||||
|
||||
// interface ICVar --------------------------------------------------------------------------------------
|
||||
|
||||
virtual int GetIVal() const { return (int)m_fValue; }
|
||||
virtual int64 GetI64Val() const { return (int64)m_fValue; }
|
||||
virtual float GetFVal() const { return m_fValue; }
|
||||
virtual const char* GetString() const;
|
||||
virtual void ResetImpl() { Set(m_fDefault); }
|
||||
virtual void Set(const char* s);
|
||||
virtual void Set(float f);
|
||||
virtual void Set(int i);
|
||||
virtual int GetType() { return CVAR_FLOAT; }
|
||||
|
||||
protected:
|
||||
|
||||
virtual const char *GetOwnDataProbeString() const
|
||||
{
|
||||
static char szReturnString[8];
|
||||
|
||||
sprintf_s(szReturnString, "%.1g", m_fValue);
|
||||
return szReturnString;
|
||||
}
|
||||
|
||||
private: // --------------------------------------------------------------------------------------------
|
||||
|
||||
struct SCVarGroup
|
||||
{
|
||||
std::map<AZStd::string, AZStd::string> m_KeyValuePair; // e.g. m_KeyValuePair["r_fullscreen"]="0"
|
||||
void GetMemoryUsage(class ICrySizer* pSizer) const
|
||||
{
|
||||
pSizer->AddObject(m_KeyValuePair);
|
||||
}
|
||||
};
|
||||
|
||||
SCVarGroup m_CVarGroupDefault;
|
||||
typedef std::map<int, SCVarGroup*> TCVarGroupStateMap;
|
||||
TCVarGroupStateMap m_CVarGroupStates;
|
||||
AZStd::string m_sDefaultValue; // used by OnLoadConfigurationEntry_End()
|
||||
|
||||
void ApplyCVars(const SCVarGroup& rGroup, const SCVarGroup* pExclude = nullptr);
|
||||
|
||||
// Arguments:
|
||||
// sKey - must exist, at least in default
|
||||
// pSpec - can be 0
|
||||
AZStd::string GetValueSpec(const AZStd::string& sKey, const int* pSpec = nullptr) const;
|
||||
|
||||
// should only be used by TestCVars()
|
||||
// Returns:
|
||||
// true=all console variables match the state (excluding default state), false otherwise
|
||||
bool TestCVars(const SCVarGroup& rGroup, const ICVar::EConsoleLogMode mode, const SCVarGroup* pExclude = nullptr) const;
|
||||
|
||||
// Arguments:
|
||||
// pGroup - can be 0 to test if the default state is set
|
||||
// Returns:
|
||||
// true=all console variables match the state (including default state), false otherwise
|
||||
bool TestCVars(const SCVarGroup* pGroup, const ICVar::EConsoleLogMode mode = ICVar::eCLM_Off) const;
|
||||
float& m_fValue;
|
||||
float m_fDefault; //!<
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_CRYSYSTEM_XCONSOLEVARIABLE_H
|
||||
|
||||
Reference in New Issue
Block a user