diff --git a/hecl/include/hecl/CVar.hpp b/hecl/include/hecl/CVar.hpp index 32a832342..9e9d5558b 100755 --- a/hecl/include/hecl/CVar.hpp +++ b/hecl/include/hecl/CVar.hpp @@ -70,6 +70,7 @@ ENABLE_BITWISE_ENUM(CVar::EFlags) template class TCVar : public CVar { + friend class CVarManager; protected: T& m_value; T m_defaultValue; @@ -98,6 +99,7 @@ public: class Vec3fCVar : public CVar { + friend class CVarManager; atVec3f& m_value; atVec3f m_defaultValue; bool _fromString(std::string_view v); @@ -116,6 +118,7 @@ public: class Vec3dCVar : public CVar { + friend class CVarManager; atVec3d& m_value; atVec3d m_defaultValue; bool _fromString(std::string_view v); @@ -133,6 +136,7 @@ public: class Vec4fCVar : public CVar { + friend class CVarManager; atVec4f& m_value; atVec4f m_defaultValue; bool _fromString(std::string_view v); @@ -151,6 +155,7 @@ public: class Vec4dCVar : public CVar { + friend class CVarManager; atVec4d& m_value; atVec4d m_defaultValue; bool _fromString(std::string_view v); @@ -168,6 +173,7 @@ public: class StringCVar : public CVar { + friend class CVarManager; std::string& m_value; std::string m_defaultValue; bool _fromString(std::string_view v); diff --git a/hecl/include/hecl/CVarManager.hpp b/hecl/include/hecl/CVarManager.hpp index ab20acf94..2f49df89c 100755 --- a/hecl/include/hecl/CVarManager.hpp +++ b/hecl/include/hecl/CVarManager.hpp @@ -100,6 +100,7 @@ public: bool restartRequired() const; + void setDeveloperMode(bool v, bool setDeserialized = false); private: bool suppressDeveloper(); void restoreDeveloper(bool oldDeveloper); diff --git a/hecl/include/hecl/Console.hpp b/hecl/include/hecl/Console.hpp index f4c23d755..4ecd485cc 100644 --- a/hecl/include/hecl/Console.hpp +++ b/hecl/include/hecl/Console.hpp @@ -87,7 +87,6 @@ public: void report(Level level, const char *fmt, va_list list); void report(Level level, const char* fmt, ...); - void init(); void proc(); void draw(boo::IGraphicsCommandQueue* gfxQ); void handleCharCode(unsigned long chr, boo::EModifierKey mod, bool repeat); diff --git a/hecl/lib/CVarManager.cpp b/hecl/lib/CVarManager.cpp index 28cd98ba5..b87ef2a37 100755 --- a/hecl/lib/CVarManager.cpp +++ b/hecl/lib/CVarManager.cpp @@ -205,6 +205,16 @@ bool CVarManager::restartRequired() const return false; } +void CVarManager::setDeveloperMode(bool v, bool setDeserialized) +{ + com_developer->unlock(); + com_developer->m_value = v; + if (setDeserialized) + com_developer->m_wasDeserialized = true; + com_developer->lock(); + com_developer->setModified(); +} + bool CVarManager::suppressDeveloper() { bool oldDeveloper = m_developerMode; diff --git a/hecl/lib/Console.cpp b/hecl/lib/Console.cpp index 422b16c4c..ad1137c7e 100644 --- a/hecl/lib/Console.cpp +++ b/hecl/lib/Console.cpp @@ -11,6 +11,16 @@ Console::Console(CVarManager* cvarMgr) , m_overwrite(false) , m_cursorAtEnd(false) { + m_instance = this; + registerCommand("help", "Prints information about a given function", "", std::bind(&Console::help, this, std::placeholders::_1, std::placeholders::_2)); + registerCommand("listCommands", "Prints a list of all available Commands", "", std::bind(&Console::listCommands, this, std::placeholders::_1, std::placeholders::_2)); + registerCommand("listCVars", "Lists all available CVars", "", std::bind(&CVarManager::list, m_cvarMgr, std::placeholders::_1, std::placeholders::_2)); + registerCommand("setCVar", "Sets a given Console Variable to the specified value", " ", std::bind(&CVarManager::setCVar, m_cvarMgr, std::placeholders::_1, std::placeholders::_2)); + registerCommand("getCVar", "Prints the value stored in the specified Console Variable", "", std::bind(&CVarManager::getCVar, m_cvarMgr, std::placeholders::_1, std::placeholders::_2)); + m_cvarMgr->findOrMakeCVar("con_speed", "Speed at which the console opens and closes, calculated as pixels per second", m_conSpeed, + hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive); + m_cvarMgr->findOrMakeCVar("con_height", "Maximum absolute height of the console, height is calculated from the top of the window, expects values ranged from [0.f,1.f]", m_conHeight, + hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive); } void Console::registerCommand(std::string_view name, std::string_view helpText, std::string_view usage, const std::function &)>&& func) @@ -103,20 +113,6 @@ void Console::report(Level level, const char* fmt, ...) va_end(ap); } -void Console::init() -{ - m_instance = this; - registerCommand("help", "Prints information about a given function", "", std::bind(&Console::help, this, std::placeholders::_1, std::placeholders::_2)); - registerCommand("listCommands", "Prints a list of all available Commands", "", std::bind(&Console::listCommands, this, std::placeholders::_1, std::placeholders::_2)); - registerCommand("listCVars", "Lists all available CVars", "", std::bind(&CVarManager::list, m_cvarMgr, std::placeholders::_1, std::placeholders::_2)); - registerCommand("setCVar", "Sets a given Console Variable to the specified value", " ", std::bind(&CVarManager::setCVar, m_cvarMgr, std::placeholders::_1, std::placeholders::_2)); - registerCommand("getCVar", "Prints the value stored in the specified Console Variable", "", std::bind(&CVarManager::getCVar, m_cvarMgr, std::placeholders::_1, std::placeholders::_2)); - m_cvarMgr->findOrMakeCVar("con_speed", "Speed at which the console opens and closes, calculated as pixels per second", m_conSpeed, - hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive); - m_cvarMgr->findOrMakeCVar("con_height", "Maximum absolute height of the console, height is calculated from the top of the window, expects values ranged from [0.f,1.f]", m_conHeight, - hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive); -} - void Console::proc() { if (m_state == State::Opened) diff --git a/hecl/test/main.cpp b/hecl/test/main.cpp index 563639a0b..49f2dd387 100644 --- a/hecl/test/main.cpp +++ b/hecl/test/main.cpp @@ -62,14 +62,13 @@ struct HECLApplicationCallback : boo::IApplicationCallback m_cvarManager(m_fileStoreMgr), m_console(&m_cvarManager) { + m_console.registerCommand("quit"sv, "Quits application"sv, "", std::bind(&HECLApplicationCallback::quit, this, std::placeholders::_1, std::placeholders::_2)); } virtual ~HECLApplicationCallback(); int appMain(boo::IApplication* app) { - m_console.init(); - m_console.registerCommand("quit"sv, "Quits application"sv, "", std::bind(&HECLApplicationCallback::quit, this, std::placeholders::_1, std::placeholders::_2)); hecl::VerbosityLevel = 2; /* Setup boo window */