mirror of https://github.com/AxioDL/metaforce.git
Add ability to enable developer mode in-code
This commit is contained in:
parent
5c66ffc5df
commit
8cef2f5192
|
@ -70,6 +70,7 @@ ENABLE_BITWISE_ENUM(CVar::EFlags)
|
|||
template<typename T>
|
||||
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);
|
||||
|
|
|
@ -100,6 +100,7 @@ public:
|
|||
|
||||
|
||||
bool restartRequired() const;
|
||||
void setDeveloperMode(bool v, bool setDeserialized = false);
|
||||
private:
|
||||
bool suppressDeveloper();
|
||||
void restoreDeveloper(bool oldDeveloper);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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", "<command>", 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", "<cvar> <value>", std::bind(&CVarManager::setCVar, m_cvarMgr, std::placeholders::_1, std::placeholders::_2));
|
||||
registerCommand("getCVar", "Prints the value stored in the specified Console Variable", "<cvar>", 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<void(Console*, const std::vector<std::string> &)>&& 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", "<command>", 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", "<cvar> <value>", std::bind(&CVarManager::setCVar, m_cvarMgr, std::placeholders::_1, std::placeholders::_2));
|
||||
registerCommand("getCVar", "Prints the value stored in the specified Console Variable", "<cvar>", 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)
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue