2022-12-22 21:23:32 +00:00
|
|
|
#pragma once
|
|
|
|
#include "command.hpp"
|
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
|
|
|
class bool_command : public command
|
|
|
|
{
|
2023-07-26 22:22:40 +02:00
|
|
|
bool m_last_enabled = false;
|
|
|
|
|
2022-12-22 21:23:32 +00:00
|
|
|
protected:
|
|
|
|
bool& m_toggle;
|
2023-03-11 00:06:09 +01:00
|
|
|
bool m_show_notify;
|
2023-07-26 22:22:40 +02:00
|
|
|
virtual void execute(const command_arguments& args, const std::shared_ptr<command_context> ctx = std::make_shared<default_command_context>()) override;
|
|
|
|
virtual std::optional<command_arguments> parse_args(const std::vector<std::string>& args, const std::shared_ptr<command_context> ctx = std::make_shared<default_command_context>()) override;
|
2023-03-01 21:27:15 +00:00
|
|
|
|
2022-12-22 21:23:32 +00:00
|
|
|
public:
|
2023-03-11 00:06:09 +01:00
|
|
|
bool_command(const std::string& name, const std::string& label, const std::string& description, bool& toggle, bool show_notify = true);
|
2023-03-01 21:27:15 +00:00
|
|
|
inline bool& is_enabled()
|
|
|
|
{
|
|
|
|
return m_toggle;
|
|
|
|
}
|
2022-12-22 21:23:32 +00:00
|
|
|
|
2024-07-13 00:26:34 +02:00
|
|
|
virtual std::optional<std::vector<std::string>> get_argument_suggestions(int arg) override
|
|
|
|
{
|
|
|
|
if (arg == 1) // First argument of all bool commands is true or false
|
|
|
|
{
|
|
|
|
return std::vector<std::string>{"true", "false"};
|
|
|
|
}
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
};
|
|
|
|
|
2023-07-26 22:22:40 +02:00
|
|
|
virtual void on_enable(){};
|
|
|
|
virtual void on_disable(){};
|
|
|
|
virtual void refresh();
|
|
|
|
|
|
|
|
virtual void enable();
|
|
|
|
virtual void disable();
|
2022-12-22 21:23:32 +00:00
|
|
|
};
|
2023-07-26 22:22:40 +02:00
|
|
|
|
|
|
|
inline std::vector<bool_command*> g_bool_commands;
|
2022-12-22 21:23:32 +00:00
|
|
|
}
|