mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-06-17 14:57:27 +08:00
fix(commands): fix crashes on invalid commands (#1081)
This commit is contained in:
parent
d8e4d2b8cd
commit
b452415d9d
@ -35,6 +35,9 @@ namespace big
|
||||
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 (command == nullptr)
|
||||
return ImGui::Text("INVALID COMMAND");
|
||||
|
||||
if (ImGui::Button(label_override.value_or(command->get_label()).data()))
|
||||
command->call(args);
|
||||
if (ImGui::IsItemHovered())
|
||||
@ -45,6 +48,9 @@ namespace big
|
||||
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 (command == nullptr)
|
||||
return ImGui::Text("INVALID COMMAND");
|
||||
|
||||
if (ImGui::Button(label_override.value_or(command->get_label()).data()))
|
||||
command->call(player, args);
|
||||
if (ImGui::IsItemHovered())
|
||||
@ -55,6 +61,9 @@ namespace big
|
||||
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 (command == nullptr)
|
||||
return ImGui::Text("INVALID COMMAND");
|
||||
|
||||
if (ImGui::Checkbox(label_override.value_or(command->get_label()).data(), &command->is_enabled()))
|
||||
command->refresh();
|
||||
if (ImGui::IsItemHovered())
|
||||
|
Loading…
x
Reference in New Issue
Block a user