mirror of https://github.com/AxioDL/metaforce.git
Add ability to unregister command on the fly
This commit is contained in:
parent
2c5a662fec
commit
694bc0a888
|
@ -80,6 +80,7 @@ private:
|
||||||
public:
|
public:
|
||||||
Console(CVarManager*);
|
Console(CVarManager*);
|
||||||
void registerCommand(std::string_view name, std::string_view helpText, std::string_view usage, const std::function<void(Console*, const std::vector<std::string>&)>&& func);
|
void registerCommand(std::string_view name, std::string_view helpText, std::string_view usage, const std::function<void(Console*, const std::vector<std::string>&)>&& func);
|
||||||
|
void unregisterCommand(std::string_view name);
|
||||||
|
|
||||||
void executeString(const std::string& strToExec);
|
void executeString(const std::string& strToExec);
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,14 @@ void Console::registerCommand(std::string_view name, std::string_view helpText,
|
||||||
m_commands[lowName] = SConsoleCommand{name.data(), helpText.data(), usage.data(), std::move(func)};
|
m_commands[lowName] = SConsoleCommand{name.data(), helpText.data(), usage.data(), std::move(func)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Console::unregisterCommand(std::string_view name)
|
||||||
|
{
|
||||||
|
std::string lowName = name.data();
|
||||||
|
athena::utility::tolower(lowName);
|
||||||
|
if (m_commands.find(lowName) != m_commands.end())
|
||||||
|
m_commands.erase(m_commands.find(lowName));
|
||||||
|
}
|
||||||
|
|
||||||
void Console::executeString(const std::string& str)
|
void Console::executeString(const std::string& str)
|
||||||
{
|
{
|
||||||
if (str.empty())
|
if (str.empty())
|
||||||
|
|
Loading…
Reference in New Issue