deprecated old stuff
This commit is contained in:
parent
0f1fe917fe
commit
8eca92be62
@ -10,7 +10,7 @@
|
||||
#include "common.h"
|
||||
#include "sdk.h"
|
||||
|
||||
CatVar::CatVar(CatVar_t type, std::string name, std::string value, std::string help, ICatEnum* enum_type, std::string long_description, bool hasminmax, float maxv, float minv) {
|
||||
CatVar::CatVar(CatVar_t type, std::string name, std::string value, std::string help, CatEnum* enum_type, std::string long_description, bool hasminmax, float maxv, float minv) {
|
||||
m_Type = type;
|
||||
m_pConVar = CreateConVar(CON_PREFIX + name, value, help);
|
||||
m_EnumType = enum_type;
|
||||
@ -42,49 +42,3 @@ int CatEnum::Minimum() {
|
||||
return m_iMin;
|
||||
}
|
||||
|
||||
void CatVar::Increment(int factor) {
|
||||
if (!m_pConVar) return;
|
||||
switch (m_Type) {
|
||||
case CatVar_t::CV_SWITCH: {
|
||||
m_pConVar->SetValue(!m_pConVar->GetInt());
|
||||
} break;
|
||||
case CatVar_t::CV_INT:
|
||||
m_pConVar->SetValue(m_pConVar->GetInt() + factor * m_fStep);
|
||||
break;
|
||||
case CatVar_t::CV_FLOAT:
|
||||
m_pConVar->SetValue(m_pConVar->GetFloat() + (float)factor * m_fStep);
|
||||
break;
|
||||
case CatVar_t::CV_ENUM: {
|
||||
int cur = m_pConVar->GetInt();
|
||||
int newv = cur + 1;
|
||||
if (newv > m_EnumType->Maximum()) {
|
||||
newv = m_EnumType->Minimum();
|
||||
}
|
||||
m_pConVar->SetValue(newv);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void CatVar::Decrement(int factor) {
|
||||
if (!m_pConVar) return;
|
||||
switch (m_Type) {
|
||||
case CatVar_t::CV_SWITCH:
|
||||
m_pConVar->SetValue((int)!m_pConVar->GetInt());
|
||||
break;
|
||||
case CatVar_t::CV_INT:
|
||||
m_pConVar->SetValue(m_pConVar->GetInt() - factor * m_fStep);
|
||||
break;
|
||||
case CatVar_t::CV_FLOAT:
|
||||
m_pConVar->SetValue(m_pConVar->GetFloat() - (float)factor * m_fStep);
|
||||
break;
|
||||
case CatVar_t::CV_ENUM: {
|
||||
int cur = m_pConVar->GetInt();
|
||||
int newv = cur - 1;
|
||||
if (newv < m_EnumType->Minimum()) {
|
||||
newv = m_EnumType->Maximum() - 1;
|
||||
}
|
||||
m_pConVar->SetValue(newv);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ class ConVar;
|
||||
#include "beforecheaders.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stack>
|
||||
#include "aftercheaders.h"
|
||||
|
||||
//#define CREATE_CV(type, name, defaults, description) \
|
||||
@ -32,20 +33,12 @@ enum CatVar_t {
|
||||
CV_KEY
|
||||
};
|
||||
|
||||
class ICatEnum {
|
||||
public:
|
||||
inline virtual ~ICatEnum() {}
|
||||
virtual std::string Name(int value) = 0;
|
||||
virtual int Minimum() = 0;
|
||||
virtual int Maximum() = 0;
|
||||
};
|
||||
|
||||
class CatEnum : public ICatEnum {
|
||||
class CatEnum {
|
||||
public:
|
||||
CatEnum(std::vector<std::string> values, int min = 0);
|
||||
virtual std::string Name(int value);
|
||||
virtual int Maximum();
|
||||
virtual int Minimum();
|
||||
std::string Name(int value);
|
||||
int Maximum();
|
||||
int Minimum();
|
||||
std::vector<std::string> m_values;
|
||||
int m_iMin;
|
||||
int m_iMax;
|
||||
@ -54,37 +47,46 @@ public:
|
||||
|
||||
class CatVar {
|
||||
public:
|
||||
CatVar(CatVar_t type, std::string name, std::string value, std::string help, ICatEnum* enum_type = 0, std::string long_description = "no description", bool hasminmax = false, float max = 1.0f, float min = 0.0f);
|
||||
//inline CatVar(ConVar* var, CatVar_t type, std::string desc = "") { m_fStep = 1; m_fStep = 0.5f; m_pConVar = var; m_Type = type; SetDescription(desc); }
|
||||
//inline CatVar(ConVar* var, ICatEnum* catenum, std::string desc = "") { m_pConVar = var; m_Type = CatVar_t::CV_ENUM; m_EnumType = catenum; SetDescription(desc); }
|
||||
CatVar(CatVar_t type, std::string name, std::string value, std::string help, CatEnum* enum_type = 0, std::string long_description = "no description", bool hasminmax = false, float max = 1.0f, float min = 0.0f);
|
||||
inline CatVar_t GetType() { return m_Type; }
|
||||
inline ICatEnum* GetEnum() { return m_EnumType; }
|
||||
inline CatEnum* GetEnum() { return m_EnumType; }
|
||||
inline ConVar* GetConVar() { return m_pConVar; }
|
||||
inline void SetDescription(std::string description) { m_strDescription = description; }
|
||||
inline std::string Description() { return m_strDescription; }
|
||||
|
||||
inline explicit operator bool() const { return !!convar_parent->m_nValue; }
|
||||
inline explicit operator int() const { return convar_parent->m_nValue; }
|
||||
inline explicit operator float() const { return convar_parent->m_fValue; }
|
||||
inline void operator =(const int& value) { convar_parent->InternalSetIntValue(value); }
|
||||
inline void operator =(const float& value) { convar_parent->InternalSetFloatValue(value); }
|
||||
inline bool operator ==(const int& value) { return convar_parent->m_nValue == value; }
|
||||
inline bool operator ==(const float& value) { return convar_parent->m_fValue == value; }
|
||||
|
||||
[[deprecated]]
|
||||
inline bool GetBool() const { return m_pConVar->GetBool(); }
|
||||
[[deprecated]]
|
||||
inline int GetInt() const { return m_pConVar->GetInt(); }
|
||||
[[deprecated]]
|
||||
inline float GetFloat() const { return m_pConVar->GetFloat(); };
|
||||
inline const char* GetString() const { return m_pConVar->GetString(); }
|
||||
[[deprecated]]
|
||||
inline void SetValue(float value) { m_pConVar->SetValue(value); }
|
||||
inline void SetValue(std::string value) { m_pConVar->SetValue(value.c_str()); }
|
||||
[[deprecated]]
|
||||
inline void SetValue(int value) { m_pConVar->SetValue(value); }
|
||||
|
||||
void Increment(int factor = 1);
|
||||
void Decrement(int factor = 1);
|
||||
|
||||
inline void SetStep(float step) { m_fStep = step; }
|
||||
|
||||
bool m_bHasMinmax;
|
||||
float m_flMaxValue;
|
||||
float m_flMinValue;
|
||||
float m_fStep;
|
||||
|
||||
std::string m_strDescription;
|
||||
ICatEnum* m_EnumType;
|
||||
CatEnum* m_EnumType;
|
||||
CatVar_t m_Type;
|
||||
ConVar* m_pConVar;
|
||||
ConVar* convar_parent;
|
||||
};
|
||||
|
||||
extern std::stack<CatVar*> g_UnregisteredCatVars;
|
||||
void RegisterCatVars();
|
||||
|
||||
#endif /* CVWRAPPER_H_ */
|
||||
|
Reference in New Issue
Block a user