refactor!: Modify command argument handling and move on_ method to bool_command (#1826)

This commit is contained in:
Andreas Maerten
2023-07-26 22:22:40 +02:00
committed by GitHub
parent d590313e4e
commit 4b1fd88f6c
104 changed files with 562 additions and 381 deletions

View File

@ -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();

View File

@ -28,7 +28,7 @@ namespace big
});
ImGui::SetNextItemWidth(400);
components::input_text_with_hint("##dictionaryfilter", "Dictionary", &current_dict);
components::input_text_with_hint("##dictionaryfilter", "Dictionary", current_dict);
if (animations::has_anim_list_been_populated() && ImGui::BeginListBox("##dictionaries", ImVec2(400, 200)))
{

View File

@ -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");

View File

@ -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();

View File

@ -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()

View File

@ -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();
}