2022-02-28 23:04:56 +01:00
|
|
|
#pragma once
|
|
|
|
#include "imgui.h"
|
2022-12-22 21:23:32 +00:00
|
|
|
#include "backend/command.hpp"
|
|
|
|
#include "backend/looped_command.hpp"
|
|
|
|
#include "backend/player_command.hpp"
|
2022-02-28 23:04:56 +01:00
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
2022-05-04 19:16:40 +02:00
|
|
|
struct navigation_struct;
|
|
|
|
enum class tabs;
|
|
|
|
|
2022-02-28 23:04:56 +01:00
|
|
|
class components
|
|
|
|
{
|
|
|
|
static void custom_text(const std::string_view, ImFont*);
|
|
|
|
public:
|
|
|
|
static bool nav_button(const std::string_view);
|
|
|
|
static bool button(const std::string_view);
|
2022-08-10 08:42:34 +08:00
|
|
|
static void icon(const std::string_view);
|
2022-02-28 23:04:56 +01:00
|
|
|
static void small_text(const std::string_view);
|
|
|
|
static void sub_title(const std::string_view);
|
|
|
|
static void title(const std::string_view);
|
|
|
|
static void button(const std::string_view, std::function<void()>);
|
2022-05-04 19:16:40 +02:00
|
|
|
static void nav_item(std::pair<tabs, navigation_struct>&, int);
|
2022-03-14 23:31:30 +01:00
|
|
|
|
|
|
|
static void input_text_with_hint(const std::string_view label, const std::string_view hint, char* buf, size_t buf_size, ImGuiInputTextFlags_ flag = ImGuiInputTextFlags_None, std::function<void()> cb = nullptr);
|
|
|
|
|
|
|
|
static bool selectable(const std::string_view, bool);
|
|
|
|
static bool selectable(const std::string_view, bool, ImGuiSelectableFlags);
|
|
|
|
static void selectable(const std::string_view, bool, std::function<void()>);
|
|
|
|
static void selectable(const std::string_view, bool, ImGuiSelectableFlags, std::function<void()>);
|
2022-11-12 18:35:28 +00:00
|
|
|
|
|
|
|
static bool script_patch_checkbox(const std::string_view text, bool* option, const std::string_view tooltip = "");
|
2022-12-22 21:23:32 +00:00
|
|
|
|
|
|
|
template<size_t N>
|
|
|
|
struct template_str
|
|
|
|
{
|
|
|
|
constexpr template_str(const char(&str)[N])
|
|
|
|
{
|
|
|
|
std::copy_n(str, N, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
char value[N];
|
|
|
|
};
|
|
|
|
|
|
|
|
template<template_str cmd_str>
|
|
|
|
static void command_button(const std::vector<std::uint64_t> args = {}, std::optional<const std::string_view> label_override = std::nullopt)
|
|
|
|
{
|
|
|
|
static command* command = command::get(rage::consteval_joaat(cmd_str.value));
|
|
|
|
if (ImGui::Button(label_override.value_or(command->get_label()).data()))
|
|
|
|
command->call(args);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<template_str cmd_str>
|
|
|
|
static void player_command_button(player_ptr player = g_player_service->get_selected(), const std::vector<std::uint64_t> args = {}, std::optional<const std::string_view> label_override = std::nullopt)
|
|
|
|
{
|
|
|
|
static player_command* command = (player_command*)command::get(rage::consteval_joaat(cmd_str.value));
|
|
|
|
if (ImGui::Button(label_override.value_or(command->get_label()).data()))
|
|
|
|
command->call(player, args);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<template_str cmd_str>
|
|
|
|
static void command_checkbox(std::optional<const std::string_view> label_override = std::nullopt)
|
|
|
|
{
|
|
|
|
static bool_command* command = (bool_command*)command::get(rage::consteval_joaat(cmd_str.value));
|
|
|
|
if (ImGui::Checkbox(label_override.value_or(command->get_label()).data(), &command->is_enabled()))
|
|
|
|
command->refresh();
|
|
|
|
}
|
2022-02-28 23:04:56 +01:00
|
|
|
};
|
2022-05-04 19:16:40 +02:00
|
|
|
}
|