2023-03-25 10:56:41 -04:00
|
|
|
#ifndef CONSOLE_C_VAR_HPP
|
|
|
|
|
#define CONSOLE_C_VAR_HPP
|
2023-01-02 13:17:18 -06:00
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <common/String.hpp>
|
|
|
|
|
#include <storm/Hash.hpp>
|
2023-08-24 20:51:30 -04:00
|
|
|
#include <bc/os/File.hpp>
|
2023-01-02 13:17:18 -06:00
|
|
|
|
|
|
|
|
class CVar : public TSHashObject<CVar, HASHKEY_STRI> {
|
|
|
|
|
public:
|
|
|
|
|
// Static variables
|
|
|
|
|
static TSHashTable<CVar, HASHKEY_STRI> s_registeredCVars;
|
|
|
|
|
static bool m_needsSave;
|
|
|
|
|
|
|
|
|
|
// Static functions
|
|
|
|
|
static CVar* Lookup(const char* name);
|
|
|
|
|
static CVar* Register(const char*, const char*, uint32_t, const char*, bool (*)(CVar*, const char*, const char*, void*), uint32_t, bool, void*, bool);
|
2023-08-24 20:51:30 -04:00
|
|
|
static void Initialize(const char* filename);
|
2023-01-02 13:17:18 -06:00
|
|
|
|
|
|
|
|
// Member variables
|
|
|
|
|
uint32_t m_category = 0;
|
|
|
|
|
uint32_t m_flags = 0;
|
|
|
|
|
RCString m_stringValue;
|
|
|
|
|
float m_floatValue = 0.0;
|
|
|
|
|
int32_t m_intValue = 0;
|
|
|
|
|
int32_t m_modified = 0;
|
|
|
|
|
RCString m_defaultValue;
|
|
|
|
|
RCString m_resetValue;
|
|
|
|
|
RCString m_latchedValue;
|
|
|
|
|
RCString m_help;
|
|
|
|
|
bool (*m_callback)(CVar*, const char*, const char*, void*) = nullptr;
|
|
|
|
|
void* m_arg = nullptr;
|
|
|
|
|
|
|
|
|
|
// Member functions
|
|
|
|
|
CVar();
|
|
|
|
|
int32_t GetInt();
|
|
|
|
|
const char* GetString(void);
|
2023-08-24 20:51:30 -04:00
|
|
|
int32_t Load(const char* filename);
|
|
|
|
|
int32_t Load(HOSFILE fileHandle);
|
2023-01-02 13:17:18 -06:00
|
|
|
void InternalSet(const char*, bool, bool, bool, bool);
|
|
|
|
|
bool Set(const char*, bool, bool, bool, bool);
|
2023-08-24 22:24:47 -04:00
|
|
|
bool Reset();
|
|
|
|
|
bool Default();
|
2023-01-02 13:17:18 -06:00
|
|
|
int32_t Update();
|
|
|
|
|
};
|
|
|
|
|
|
2023-08-16 16:37:38 -04:00
|
|
|
int32_t CvarCommandHandler(const char* command, const char* arguments);
|
|
|
|
|
|
|
|
|
|
int32_t CvarListCommandHandler(const char* command, const char* arguments);
|
|
|
|
|
|
2023-01-02 13:17:18 -06:00
|
|
|
#endif
|