
* feat(Commands): Prototype command system * feat(Commands): Chat commands * refactor(Toxic): convert most options into commands * feat(Protections): block breakup kicks on other players as host * refactor(Kicks): convert most options into commands * refactor(Commands): add labels and descriptions to all commands * feat(Commands): cleanup on unload * refactor(Troll): convert most options into commands * refactor(Misc): convert most options into commands * refactor(Teleport): convert most options into commands * feat(Commands): Variadic commands and toggleable bools * feat(Hotkeys): hotkeys now use commands * fix(Chat): fix the chat window locking up when a message is sent * fix(Commands): properly handle spoofed username * fix(Spam): update filter Co-authored-by: Yimura <24669514+Yimura@users.noreply.github.com>
45 lines
911 B
C++
45 lines
911 B
C++
#include "looped_command.hpp"
|
|
#include "fiber_pool.hpp"
|
|
|
|
namespace big
|
|
{
|
|
looped_command::looped_command(const std::string& name, const std::string& label, const std::string& description, bool& toggle) :
|
|
bool_command(name, label, description, toggle)
|
|
{
|
|
g_looped_commands.push_back(this);
|
|
}
|
|
|
|
void looped_command::enable()
|
|
{
|
|
if (!m_toggle)
|
|
{
|
|
m_toggle = true;
|
|
m_last_enabled = true;
|
|
g_fiber_pool->queue_job([this] { on_enable(); });
|
|
}
|
|
}
|
|
|
|
void looped_command::disable()
|
|
{
|
|
if (m_toggle)
|
|
{
|
|
m_toggle = false;
|
|
m_last_enabled = false;
|
|
g_fiber_pool->queue_job([this] { disable(); });
|
|
}
|
|
}
|
|
|
|
void looped_command::refresh()
|
|
{
|
|
if (m_toggle && !m_last_enabled)
|
|
{
|
|
m_last_enabled = true;
|
|
g_fiber_pool->queue_job([this] { on_enable(); });
|
|
}
|
|
else if (!m_toggle && m_last_enabled)
|
|
{
|
|
m_last_enabled = false;
|
|
g_fiber_pool->queue_job([this] { on_disable(); });
|
|
}
|
|
}
|
|
} |