mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-07-01 03:53:03 +08:00
refactor!: Modify command argument handling and move on_
method to bool_command (#1826)
This commit is contained in:
@ -20,7 +20,7 @@ namespace big
|
||||
|
||||
if (ImGui::Begin("cmd_executor", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoMouseInputs))
|
||||
{
|
||||
static char command_buffer[255];
|
||||
static std::string command_buffer;
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, {10.f, 15.f});
|
||||
components::sub_title("CMD_EXECUTOR_TITLE"_T);
|
||||
|
||||
@ -28,13 +28,14 @@ namespace big
|
||||
ImGui::SetKeyboardFocusHere(0);
|
||||
|
||||
ImGui::SetNextItemWidth((screen_x * 0.5f) - 30.f);
|
||||
components::input_text_with_hint("", "CMD_EXECUTOR_TYPE_CMD"_T, command_buffer, sizeof(command_buffer), ImGuiInputTextFlags_EnterReturnsTrue, [] {
|
||||
if (components::input_text_with_hint("", "CMD_EXECUTOR_TYPE_CMD"_T, command_buffer, ImGuiInputTextFlags_EnterReturnsTrue))
|
||||
{
|
||||
if (command::process(command_buffer, std::make_shared<default_command_context>(), true))
|
||||
{
|
||||
g.cmd_executor.enabled = false;
|
||||
command_buffer[0] = 0;
|
||||
command_buffer = {};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
components::small_text("CMD_EXECUTOR_MULTIPLE_CMDS"_T);
|
||||
ImGui::Spacing();
|
||||
|
@ -28,7 +28,7 @@ namespace big
|
||||
});
|
||||
|
||||
ImGui::SetNextItemWidth(400);
|
||||
components::input_text_with_hint("##dictionaryfilter", "Dictionary", ¤t_dict);
|
||||
components::input_text_with_hint("##dictionaryfilter", "Dictionary", current_dict);
|
||||
|
||||
if (animations::has_anim_list_been_populated() && ImGui::BeginListBox("##dictionaries", ImVec2(400, 200)))
|
||||
{
|
||||
|
@ -70,8 +70,8 @@ namespace big
|
||||
}
|
||||
|
||||
ImGui::PushItemWidth(300);
|
||||
components::input_text_with_hint("Category", "Category", &category);
|
||||
components::input_text_with_hint("Location name", "New location", &new_location_name);
|
||||
components::input_text_with_hint("Category", "Category", category);
|
||||
components::input_text_with_hint("Location name", "New location", new_location_name);
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
components::button("Save current location", [] {
|
||||
@ -140,7 +140,7 @@ namespace big
|
||||
components::small_text("Double click to teleport\nShift click to delete");
|
||||
|
||||
ImGui::Spacing();
|
||||
components::input_text_with_hint("##filter", "Search", &filter);
|
||||
components::input_text_with_hint("##filter", "Search", filter);
|
||||
|
||||
ImGui::BeginGroup();
|
||||
components::small_text("Categories");
|
||||
|
@ -296,7 +296,7 @@ namespace big
|
||||
ImGui::SameLine();
|
||||
ImGui::BeginGroup();
|
||||
static std::string input_file_name;
|
||||
components::input_text_with_hint("Weapon Loadout Filename", "Loadout Name", &input_file_name);
|
||||
components::input_text_with_hint("Weapon Loadout Filename", "Loadout Name", input_file_name);
|
||||
components::button("Save Loadout", [] {
|
||||
persist_weapons::save_weapons(input_file_name);
|
||||
input_file_name.clear();
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include "backend/bool_command.hpp"
|
||||
#include "backend/float_command.hpp"
|
||||
#include "gta_util.hpp"
|
||||
#include "gui.hpp"
|
||||
#include "pointers.hpp"
|
||||
@ -313,31 +315,18 @@ namespace big
|
||||
}
|
||||
}
|
||||
|
||||
bool_command use_animations("vehcontroluseanims", "Use animations", "Will use animations for several vehicle operations such as:\ntoggling lights, opening/closing doors and entering seats",
|
||||
g.window.vehicle_control.operation_animation);
|
||||
bool_command render_veh_dist("vehcontrolrendervehdist", "Render distance on vehicle", "Will display the distance on the controlled vehicle",
|
||||
g.window.vehicle_control.render_distance_on_veh);
|
||||
float_command max_summon_dist("vehcontrolmaxsummondist", "Max summon distance", "At what range the vehicle will drive towards the summoned location as oposed to being teleported",
|
||||
g.window.vehicle_control.max_summon_range, 10.f, 250.f);
|
||||
|
||||
void render_settings_tab()
|
||||
{
|
||||
ImGui::Checkbox("Use animations", &g.window.vehicle_control.operation_animation);
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text("Will use animations for several vehicle operations such as:\ntoggling lights, opening/closing doors and entering seats");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Render distance on vehicle", &g.window.vehicle_control.render_distance_on_veh);
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text("Will display the distance on the controlled vehicle");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
ImGui::SliderFloat("Max summon distance", &g.window.vehicle_control.max_summon_range, 10.f, 250.f);
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text("At what range the vehicle will drive towards the summoned location as oposed to being teleported");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
components::command_checkbox<"vehcontroluseanims">();
|
||||
components::command_checkbox<"vehcontrolrendervehdist">();
|
||||
components::command_float_slider<"vehcontrolmaxsummondist">();
|
||||
}
|
||||
|
||||
void view::vehicle_control()
|
||||
|
@ -113,8 +113,8 @@ namespace big
|
||||
|
||||
ImGui::PushItemWidth(250);
|
||||
|
||||
components::input_text_with_hint("##name", "Name", &new_template.m_name);
|
||||
components::input_text_with_hint("##pedmodel", "Ped model", &new_template.m_ped_model);
|
||||
components::input_text_with_hint("##name", "Name", new_template.m_name);
|
||||
components::input_text_with_hint("##pedmodel", "Ped model", new_template.m_ped_model);
|
||||
|
||||
auto ped_found = std::find_if(g_gta_data_service->peds().begin(), g_gta_data_service->peds().end(), [=](const auto& pair) {
|
||||
return pair.second.m_name == new_template.m_ped_model;
|
||||
@ -140,7 +140,7 @@ namespace big
|
||||
}
|
||||
}
|
||||
|
||||
components::input_text_with_hint("##vehmodel", "Vehicle model", &new_template.m_vehicle_model);
|
||||
components::input_text_with_hint("##vehmodel", "Vehicle model", new_template.m_vehicle_model);
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Leave empty to spawn on foot");
|
||||
|
||||
@ -168,7 +168,7 @@ namespace big
|
||||
}
|
||||
}
|
||||
|
||||
components::input_text_with_hint("##weapmodel", "Weapon model", &new_template.m_weapon_model);
|
||||
components::input_text_with_hint("##weapmodel", "Weapon model", new_template.m_weapon_model);
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Leave empty to spawn unarmed, beware that a player can only attain 3 melee attackers at a time");
|
||||
|
||||
@ -325,7 +325,7 @@ namespace big
|
||||
ImGui::PopItemWidth();
|
||||
ImGui::EndGroup();
|
||||
|
||||
components::input_text_with_hint("##new_template.m_description", "Description", &new_template.m_description);
|
||||
components::input_text_with_hint("##new_template.m_description", "Description", new_template.m_description);
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
Reference in New Issue
Block a user