This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
YimMenu/src/backend/bool_command.hpp
DayibBaba b90ce402a1
Some checks failed
Nightly Build / Check Recent Commit (push) Failing after 5s
Nightly Build / Build Nightly (push) Has been skipped
Nightly Build / Recreate Release (push) Has been skipped
Expand Cmd Executor (#2884)
Added additional commands to showcase suggestion system.
Added a new util file to operate on strings in a unified manner.
Changed input_text_with_hint component to allow for more flags than one.
Added more player seeking features to player_service such as get_by_name()

* Fixed out of bounds suggestion navigation

* Added suggestions to spawn_vehicle command

* Created command play_animation

* Added suggestion support for multi commands

using a semicolon allows for more commands to fire at once, and is now supported with appropriate suggestions

* Added rotation to teleport_to_location command

* Fixed stupid error & added multiple raw command auto fills

* Added sanity checks to avoid nullpointers

* Added context identifiers to player commands

* Added temporary self inclusion to player commands

Needs translation on the translations repo

* Applied rudamentary reviews

* Experimental proxy globalization

* Fixed argument sensitivity on spawn vehicle

* Scrapped 2 ideas (maybe for future)

* Added true and false suggestions to bool commands

---------

Co-authored-by: Andreas Maerten <24669514+Yimura@users.noreply.github.com>
Co-authored-by: gir489 <100792176+gir489returns@users.noreply.github.com>
2024-07-13 00:26:34 +02:00

42 lines
1.2 KiB
C++

#pragma once
#include "command.hpp"
namespace big
{
class bool_command : public command
{
bool m_last_enabled = false;
protected:
bool& m_toggle;
bool m_show_notify;
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;
public:
bool_command(const std::string& name, const std::string& label, const std::string& description, bool& toggle, bool show_notify = true);
inline bool& is_enabled()
{
return m_toggle;
}
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;
};
virtual void on_enable(){};
virtual void on_disable(){};
virtual void refresh();
virtual void enable();
virtual void disable();
};
inline std::vector<bool_command*> g_bool_commands;
}