From 0d26223bfe7ddac8c9c613caa6dcdebe35733483 Mon Sep 17 00:00:00 2001 From: Arthur <121949966+ShinyWasabi@users.noreply.github.com> Date: Sun, 1 Sep 2024 22:43:01 +0300 Subject: [PATCH] Move Collapsing Headers in Weapons to Separate Tab (#3627) --- docs/lua/commands.md | 5 +- docs/lua/commands_dump.txt | 1 + docs/lua/tabs.md | 3 +- src/backend/commands/self/reset_weapons.cpp | 21 ++ src/core/scr_globals.hpp | 2 + src/script_function.hpp | 1 + src/services/gui/gui_service.hpp | 10 +- src/views/self/view_ammunation.cpp | 314 ++++++++++++++++++++ src/views/self/view_weapons.cpp | 284 +++--------------- src/views/view.hpp | 1 + 10 files changed, 389 insertions(+), 253 deletions(-) create mode 100644 src/backend/commands/self/reset_weapons.cpp create mode 100644 src/views/self/view_ammunation.cpp diff --git a/docs/lua/commands.md b/docs/lua/commands.md index f255a43e..eba8f58d 100644 --- a/docs/lua/commands.md +++ b/docs/lua/commands.md @@ -11,7 +11,7 @@ command.call_player(somePlayerIndex, "spawn", {joaat("adder")}) For a complete list of available command functions, please refer to the command table documentation. -## Command Count: 209 +## Command Count: 210 ### breakup BREAKUP_KICK_DESC @@ -849,3 +849,6 @@ Arg Count: 0 Toggles the command executor window Arg Count: 0 +### resetweaps + Resets your weapon loadout to default. +Arg Count: 0 \ No newline at end of file diff --git a/docs/lua/commands_dump.txt b/docs/lua/commands_dump.txt index 10cee13c..48b1caf3 100644 --- a/docs/lua/commands_dump.txt +++ b/docs/lua/commands_dump.txt @@ -207,3 +207,4 @@ [20:46:19.5971135][INFO/command.cpp:48] Command | player_db_auto_update_states | Auto Update Player Online States | Toggling this feature will automatically update the player online states every 5minutes. | 0 [20:46:19.5971390][INFO/command.cpp:48] Command | vehiclecontrol | Vehicle controller | Enables/Disables the vehicle controller. | 0 [20:46:19.5972044][INFO/command.cpp:48] Command | cmdexecutor | Toggle Command Executor | Toggles the command executor window | 0 +[20:46:19.5972044][INFO/command.cpp:48] Command | resetweaps | Reset Weapons | Resets your weapon loadout to default. | 0 diff --git a/docs/lua/tabs.md b/docs/lua/tabs.md index 52e56f33..1ef619d0 100644 --- a/docs/lua/tabs.md +++ b/docs/lua/tabs.md @@ -13,10 +13,11 @@ end) For a complete list of available gui functions, please refer to the tab class documentation and the gui table documentation. -## Tab Count: 49 +## Tab Count: 50 ### `GUI_TAB_SELF` ### `GUI_TAB_WEAPONS` +### `GUI_TAB_WEAPONS_AMMUNATION` ### `GUI_TAB_TELEPORT` ### `GUI_TAB_CUSTOM_TELEPORT` ### `GUI_TAB_MOBILE` diff --git a/src/backend/commands/self/reset_weapons.cpp b/src/backend/commands/self/reset_weapons.cpp new file mode 100644 index 00000000..9532654b --- /dev/null +++ b/src/backend/commands/self/reset_weapons.cpp @@ -0,0 +1,21 @@ +#include "backend/command.hpp" +#include "script_function.hpp" + +namespace big +{ + class reset_weapons : command + { + using command::command; + + virtual void execute(const command_arguments&, const std::shared_ptr ctx) + { + if (*g_pointers->m_gta.m_is_session_started && scripts::is_running("freemode"_J)) + { + *scr_globals::should_reset_fm_weapons.as() = TRUE; + scr_functions::give_owned_freemode_weapons.call(); + } + } + }; + + reset_weapons g_reset_weapons("resetweaps", "RESET_WEAPONS", "RESET_WEAPONS_DESC", 0); +} \ No newline at end of file diff --git a/src/core/scr_globals.hpp b/src/core/scr_globals.hpp index 1ac5bdaa..f5d16489 100644 --- a/src/core/scr_globals.hpp +++ b/src/core/scr_globals.hpp @@ -56,6 +56,8 @@ namespace big::scr_globals static inline const script_global gun_van(1949748); // return -29.532f, 6435.136f, 31.162f; static inline const script_global disable_phone(20913); + + static inline const script_global should_reset_fm_weapons(1578026); } namespace big::scr_locals diff --git a/src/script_function.hpp b/src/script_function.hpp index d96a8227..70202352 100644 --- a/src/script_function.hpp +++ b/src/script_function.hpp @@ -73,6 +73,7 @@ namespace big { inline script_function set_as_ceo("SAC", "freemode"_J, "2D 04 1D 00 00 5D"); inline script_function set_freemode_session_active("SFSA", "freemode"_J, "2D 00 02 00 00 75 5D ? ? ? 50"); + inline script_function give_owned_freemode_weapons("GOFM", "freemode"_J, "2D 00 02 00 00 62 ? ? ? 72 57 ? ? 76"); inline script_function save_to_datafile("STD", "fm_race_creator"_J, "2D 01 03 00 00 71 2C"); inline script_function load_from_datafile("LFD", "fm_race_creator"_J, "2D 03 0C 00 00 71 2C"); inline script_function reset_session_data("RSD", "main_persistent"_J, "2D 02 7D 00 00"); diff --git a/src/services/gui/gui_service.hpp b/src/services/gui/gui_service.hpp index fcda8078..43419076 100644 --- a/src/services/gui/gui_service.hpp +++ b/src/services/gui/gui_service.hpp @@ -10,6 +10,7 @@ namespace big SELF, WEAPONS, + WEAPONS_AMMUNATION, TELEPORT, CUSTOM_TELEPORT, MOBILE, @@ -91,7 +92,14 @@ namespace big TAB_DECL(SELF), view::self, { - {TAB_DECL(WEAPONS), view::weapons}}, + { + TAB_DECL(WEAPONS), + view::weapons, + { + {TAB_DECL(WEAPONS_AMMUNATION), view::ammunation}}, + }, + }, + }, {TAB_DECL(MOBILE), view::mobile}}, {TAB_DECL(TELEPORT), view::teleport, { diff --git a/src/views/self/view_ammunation.cpp b/src/views/self/view_ammunation.cpp new file mode 100644 index 00000000..aa3f8304 --- /dev/null +++ b/src/views/self/view_ammunation.cpp @@ -0,0 +1,314 @@ +#include "gta/weapons.hpp" +#include "services/gta_data/gta_data_service.hpp" +#include "services/persist_weapons/persist_weapons.hpp" +#include "views/view.hpp" +#include "script_mgr.hpp" + +namespace big +{ + bool is_weapon_mk2(Hash weapon) + { + switch (weapon) + { + case "WEAPON_PISTOL_MK2"_J: + case "WEAPON_SMG_MK2"_J: + case "WEAPON_ASSAULTRIFLE_MK2"_J: + case "WEAPON_CARBINERIFLE_MK2"_J: + case "WEAPON_COMBATMG_MK2"_J: + case "WEAPON_HEAVYSNIPER_MK2"_J: + case "WEAPON_PUMPSHOTGUN_MK2"_J: + case "WEAPON_SPECIALCARBINE_MK2"_J: + case "WEAPON_SNSPISTOL_MK2"_J: + case "WEAPON_MARKSMANRIFLE_MK2"_J: + case "WEAPON_REVOLVER_MK2"_J: + case "WEAPON_BULLPUPRIFLE_MK2"_J: + return true; + } + return false; + } + + void view::ammunation() + { + static std::string selected_weapon = "SELECT"_T.data(); + static std::string selected_attachment = "SELECT"_T.data(); + static Hash selected_weapon_hash = 0; + static Hash selected_attachment_hash = 0; + static int selected_tint = 0; + static char search_weapon[64]; + + static std::vector default_tints; + static std::vector mk2_tints; + if (default_tints.empty() && g_script_mgr.can_tick()) + { + g_fiber_pool->queue_job([] { + for (int i = 0; i <= 7; i++) + { + std::string gxt = std::string("WM_TINT") + std::to_string(i); + std::string tint = HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(gxt.c_str()); + default_tints.push_back(tint); + } + }); + } + if (mk2_tints.empty() && g_script_mgr.can_tick()) + { + g_fiber_pool->queue_job([] { + for (int i = 0; i <= 31; i++) + { + std::string gxt = std::string("WCT_TINT_") + std::to_string(i); + std::string tint = HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(gxt.c_str()); + mk2_tints.push_back(tint); + } + }); + } + + ImGui::BeginCombo("GUI_TAB_WEAPONS"_T.data(), selected_weapon.c_str()); + if (ImGui::IsItemActive() && !ImGui::IsPopupOpen("##weapons_popup")) + { + ImGui::OpenPopup("##weapons_popup"); + memset(search_weapon, 0, sizeof(search_weapon)); + } + if (ImGui::BeginPopup("##weapons_popup", ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove)) + { + std::map sorted_map; + for (const auto& [_, weapon] : g_gta_data_service.weapons()) + { + sorted_map.emplace(weapon.m_display_name, weapon); + } + + ImGui::Text("SEARCH"_T.data()); + ImGui::SameLine(); + ImGui::SetNextItemWidth(250.f); + components::input_text("##search_weapon", search_weapon, sizeof(search_weapon)); + + std::string search_lower = search_weapon; + std::transform(search_lower.begin(), search_lower.end(), search_lower.begin(), ::tolower); + + bool found_match = false; + for (const auto& weapon : sorted_map) + { + auto weapon_name = weapon.second.m_display_name; + auto weapon_hash = weapon.second.m_hash; + + if (weapon_name == "NULL" || weapon_hash == NULL) + continue; + + std::string weapon_lower = weapon_name; + std::transform(weapon_lower.begin(), weapon_lower.end(), weapon_lower.begin(), ::tolower); + + if (weapon_lower.find(search_lower) != std::string::npos) + { + found_match = true; + if (ImGui::Selectable(weapon_name.c_str())) + { + selected_weapon = weapon_name; + selected_weapon_hash = weapon_hash; + selected_attachment = "SELECT"_T.data(); + selected_attachment_hash = 0; + selected_tint = 0; + } + } + } + if (!found_match) + ImGui::Text("NO_WEAPON_IN_REGISTRY"_T.data()); + ImGui::EndPopup(); + } + components::button("VIEW_WEAPON_GIVE_WEAPON"_T, [] { + WEAPON::GIVE_WEAPON_TO_PED(self::ped, selected_weapon_hash, 9999, false, true); + }); + ImGui::SameLine(); + components::button("VIEW_WEAPON_REMOVE_WEAPON"_T, [] { + WEAPON::REMOVE_WEAPON_FROM_PED(self::ped, selected_weapon_hash); + }); + + if (ImGui::BeginCombo("VIEW_WEAPON_ATTACHMENTS"_T.data(), selected_attachment.c_str())) + { + weapon_item weapon = g_gta_data_service.weapon_by_hash(selected_weapon_hash); + if (!weapon.m_attachments.empty()) + { + for (std::string attachment : weapon.m_attachments) + { + weapon_component attachment_component = g_gta_data_service.weapon_component_by_name(attachment); + std::string attachment_name = attachment_component.m_display_name; + Hash attachment_hash = attachment_component.m_hash; + + if (attachment_name == "NULL" || attachment_hash == NULL) + continue; + + bool is_selected = attachment_hash == selected_attachment_hash; + ImGui::PushID(attachment_hash); + if (ImGui::Selectable(attachment_name.c_str(), is_selected, ImGuiSelectableFlags_None)) + { + selected_attachment = attachment_name; + selected_attachment_hash = attachment_hash; + } + if (ImGui::IsItemHovered() && attachment_component.m_display_desc != "NULL") + { + ImGui::SetTooltip(attachment_component.m_display_desc.c_str()); + } + if (is_selected) + { + ImGui::SetItemDefaultFocus(); + } + ImGui::PopID(); + } + } + else + { + ImGui::Text("NO_WEAPON_ATTACHMENT_IN_REGISTRY"_T.data()); + } + ImGui::EndCombo(); + } + components::button("VIEW_WEAPON_ADD_TO_WEAPON"_T, [] { + WEAPON::GIVE_WEAPON_COMPONENT_TO_PED(self::ped, selected_weapon_hash, selected_attachment_hash); + }); + ImGui::SameLine(); + components::button("VIEW_WEAPON_REMOVE_TO_WEAPON"_T, [] { + WEAPON::REMOVE_WEAPON_COMPONENT_FROM_PED(self::ped, selected_weapon_hash, selected_attachment_hash); + }); + + if ((!default_tints.empty() && !mk2_tints.empty()) && selected_weapon_hash != NULL) + { + if (is_weapon_mk2(selected_weapon_hash)) + { + if (ImGui::BeginCombo("VIEW_WEAPON_TINTS"_T.data(), mk2_tints[selected_tint].data())) + { + for (int index = 0; index < mk2_tints.size(); index++) + { + if (ImGui::Selectable(mk2_tints[index].c_str())) + { + selected_tint = index; + } + } + ImGui::EndCombo(); + } + } + else + { + if (ImGui::BeginCombo("VIEW_WEAPON_TINTS"_T.data(), default_tints[selected_tint].data())) + { + for (int index = 0; index < default_tints.size(); index++) + { + if (ImGui::Selectable(default_tints[index].c_str())) + { + selected_tint = index; + } + } + ImGui::EndCombo(); + } + } + components::button("APPLY"_T, [] { + WEAPON::SET_PED_WEAPON_TINT_INDEX(self::ped, selected_weapon_hash, selected_tint); + }); + } + + ImGui::SeparatorText("VIEW_WEAPON_PERSIST_WEAPONS"_T.data()); + + static std::string selected_loadout = g.persist_weapons.weapon_loadout_file; + static std::string input_file_name; + + ImGui::PushID(1); + ImGui::Checkbox("ENABLED"_T.data(), &g.persist_weapons.enabled); + ImGui::PopID(); + + ImGui::BeginGroup(); + ImGui::Text("VIEW_WEAPON_PERSIST_WEAPONS_SAVED_LOADOUTS"_T.data()); + if (ImGui::BeginListBox("##saved_loadouts", ImVec2(200, 200))) + { + for (std::string filename : persist_weapons::list_weapon_loadouts()) + { + if (components::selectable(filename, filename == selected_loadout)) + { + selected_loadout = filename; + } + } + ImGui::EndListBox(); + } + ImGui::EndGroup(); + ImGui::SameLine(); + ImGui::BeginGroup(); + ImGui::Text("VIEW_WEAPON_PERSIST_WEAPONS_WEAPON_LOADOUT_FILENAME"_T.data()); + components::input_text_with_hint("##loadout_filename", "VIEW_WEAPON_PERSIST_WEAPONS_LOADOUT_NAME"_T, input_file_name); + components::button("VIEW_WEAPON_PERSIST_WEAPONS_SAVE"_T, [] { + persist_weapons::save_weapons(input_file_name); + input_file_name.clear(); + }); + ImGui::SameLine(); + components::button("VIEW_WEAPON_PERSIST_WEAPONS_LOAD"_T, [] { + persist_weapons::give_player_loadout(selected_loadout); + }); + ImGui::SameLine(); + components::button("VIEW_WEAPON_PERSIST_WEAPONS_SET_LOADOUT"_T, [] { + persist_weapons::set_weapon_loadout(selected_loadout); + }); + ImGui::Text(std::format("{}: {}:", "VIEW_WEAPON_PERSIST_WEAPONS_CURRENT_LOADOUT"_T, g.persist_weapons.weapon_loadout_file).data()); + ImGui::EndGroup(); + + ImGui::SeparatorText("VIEW_WEAPON_WEAPON_HOTKEYS"_T.data()); + + static int selected_key = 0; + const char* const keys[]{"1", "2", "3", "4", "5", "6"}; + + ImGui::PushID(2); + ImGui::Checkbox("ENABLED"_T.data(), &g.weapons.enable_weapon_hotkeys); + ImGui::PopID(); + if (ImGui::IsItemHovered()) + { + ImGui::SetTooltip("VIEW_WEAPON_WEAPON_HOTKEYS_TOOLTIP"_T.data()); + } + + ImGui::Combo("VIEW_WEAPON_WEAPON_HOTKEYS_KEY"_T.data(), &selected_key, keys, IM_ARRAYSIZE(keys)); + if (!g.weapons.weapon_hotkeys[selected_key].empty()) + { + int counter = 0; + for (auto& weapon_hash : g.weapons.weapon_hotkeys[selected_key]) + { + weapon_item weapon = g_gta_data_service.weapon_by_hash(weapon_hash); + ImGui::PushID(counter); + if (ImGui::BeginCombo("GUI_TAB_WEAPONS"_T.data(), weapon.m_display_name.c_str())) + { + std::map sorted_map; + for (const auto& [_, weapon_iter] : g_gta_data_service.weapons()) + { + sorted_map.emplace(weapon_iter.m_display_name, weapon_iter); + } + + for (const auto& [_, weapon_iter] : g_gta_data_service.weapons()) + { + if (weapon_iter.m_display_name == "NULL") + continue; + + bool is_selected = weapon_iter.m_hash == weapon_hash; + if (ImGui::Selectable(weapon_iter.m_display_name.c_str(), is_selected, ImGuiSelectableFlags_None)) + { + weapon_hash = weapon_iter.m_hash; + } + if (is_selected) + { + ImGui::SetItemDefaultFocus(); + } + } + ImGui::EndCombo(); + } + ImGui::SameLine(); + components::button("VIEW_WEAPON_WEAPON_HOTKEYS_SET_TO_CURRENT_WEAPON"_T, [&weapon_hash] { + WEAPON::GET_CURRENT_PED_WEAPON(self::ped, &weapon_hash, NULL); + if (weapon_hash == NULL) + { + WEAPON::GET_CURRENT_PED_VEHICLE_WEAPON(self::ped, &weapon_hash); + } + }); + ImGui::SameLine(); + if (ImGui::Button("VIEW_WEAPON_REMOVE_WEAPON"_T.data())) + { + g.weapons.weapon_hotkeys[selected_key].erase(g.weapons.weapon_hotkeys[selected_key].begin() + counter); + } + ImGui::PopID(); + counter++; + } + } + if (ImGui::Button("VIEW_WEAPON_WEAPON_ADD_WEAPON"_T.data())) + { + g.weapons.weapon_hotkeys[selected_key].push_back(WEAPON_UNARMED); + } + } +} \ No newline at end of file diff --git a/src/views/self/view_weapons.cpp b/src/views/self/view_weapons.cpp index 6853c390..d4e06771 100644 --- a/src/views/self/view_weapons.cpp +++ b/src/views/self/view_weapons.cpp @@ -1,12 +1,9 @@ #include "core/data/bullet_impact_types.hpp" #include "core/data/special_ammo_types.hpp" #include "gta/joaat.hpp" -#include "gta/weapons.hpp" -#include "imgui_internal.h" -#include "natives.hpp" #include "services/gta_data/gta_data_service.hpp" -#include "services/persist_weapons/persist_weapons.hpp" #include "views/view.hpp" +#include "imgui_internal.h" namespace big { @@ -107,24 +104,28 @@ namespace big { WEAPON::GIVE_DELAYED_WEAPON_TO_PED(self::ped, weapon.m_hash, 9999, false); } - - constexpr auto parachute_hash = "GADGET_PARACHUTE"_J; - WEAPON::GIVE_DELAYED_WEAPON_TO_PED(self::ped, parachute_hash, 0, true); + WEAPON::GIVE_DELAYED_WEAPON_TO_PED(self::ped, "GADGET_PARACHUTE"_J, 0, true); }); ImGui::SameLine(); - components::button("REMOVE_CUR_WEAPON"_T, [] { - Hash weaponHash; - WEAPON::GET_CURRENT_PED_WEAPON(self::ped, &weaponHash, 1); - if (weaponHash != "WEAPON_UNARMED"_J) + components::button("REMOVE_ALL_WEAPONS"_T, [] { + for (const auto& [_, weapon] : g_gta_data_service.weapons()) { - WEAPON::REMOVE_WEAPON_FROM_PED(self::ped, weaponHash); + if (weapon.m_hash != "WEAPON_UNARMED"_J) + WEAPON::REMOVE_WEAPON_FROM_PED(self::ped, weapon.m_hash); } }); + components::button("REMOVE_CUR_WEAPON"_T, [] { + Hash weapon_hash; + WEAPON::GET_CURRENT_PED_WEAPON(self::ped, &weapon_hash, 1); + if (weapon_hash != "WEAPON_UNARMED"_J) + WEAPON::REMOVE_WEAPON_FROM_PED(self::ped, weapon_hash); + }); + ImGui::SameLine(); + components::command_button<"resetweaps">(); components::command_checkbox<"incrdamage">(); ImGui::InputFloat("VIEW_WEAPON_DAMAGE"_T.data(), &g.weapons.increased_damage, .1, 10, "%.1f"); - components::command_checkbox<"flyingaxe">(); components::command_checkbox<"modifyexplosionradius">(); @@ -162,16 +163,7 @@ namespace big ImGui::Checkbox("VIEW_WEAPON_LAUNCH_ON_RELEASE"_T.data(), &g.weapons.gravity_gun.launch_on_release); break; case CustomWeapon::VEHICLE_GUN: - // this some ugly ass looking code - static char vehicle_gun[12]; - std::memcpy(vehicle_gun, g.weapons.vehicle_gun_model.c_str(), 12); - if (ImGui::InputTextWithHint("SHOOTING_MODEL"_T.data(), "NAME_VEHICLE_MODEL"_T.data(), vehicle_gun, sizeof(vehicle_gun))) - { - g.weapons.vehicle_gun_model = vehicle_gun; - } - if (ImGui::IsItemActive()) - g.self.hud.typing = TYPING_TICKS; - + components::input_text_with_hint("SHOOTING_MODEL"_T, "NAME_VEHICLE_MODEL"_T, g.weapons.vehicle_gun_model); break; case CustomWeapon::PAINT_GUN: ImGui::Checkbox("RAINBOW_PAINT"_T.data(), &g.weapons.paintgun.rainbow); @@ -197,33 +189,42 @@ namespace big ImGui::SameLine(); components::command_checkbox<"aimonlyatthreats">(); + ImGui::BeginGroup(); ImGui::CheckboxFlags("PLAYERS"_T.data(), &g.weapons.aimbot.only_on_ped_type, (int64_t)ePedTypeFlag::PED_TYPE_NETWORK_PLAYER); - ImGui::SameLine(); ImGui::CheckboxFlags("PED_TYPE_CIVMALE"_T.data(), &g.weapons.aimbot.only_on_ped_type, (int64_t)ePedTypeFlag::PED_TYPE_CIVMALE); - ImGui::SameLine(); ImGui::CheckboxFlags("PED_TYPE_CIVFEMALE"_T.data(), &g.weapons.aimbot.only_on_ped_type, (int64_t)ePedTypeFlag::PED_TYPE_CIVFEMALE); + ImGui::EndGroup(); + ImGui::SameLine(); + + ImGui::BeginGroup(); ImGui::CheckboxFlags("PED_TYPE_DEALER"_T.data(), &g.weapons.aimbot.only_on_ped_type, (int64_t)ePedTypeFlag::PED_TYPE_DEALER); - ImGui::SameLine(); ImGui::CheckboxFlags("PED_TYPE_PROSTITUTE"_T.data(), &g.weapons.aimbot.only_on_ped_type, (int64_t)ePedTypeFlag::PED_TYPE_PROSTITUTE); - ImGui::SameLine(); ImGui::CheckboxFlags("PED_TYPE_BUM"_T.data(), &g.weapons.aimbot.only_on_ped_type, (int64_t)ePedTypeFlag::PED_TYPE_BUM); + ImGui::EndGroup(); + ImGui::SameLine(); + + ImGui::BeginGroup(); ImGui::CheckboxFlags("PED_TYPE_MEDIC"_T.data(), &g.weapons.aimbot.only_on_ped_type, (int64_t)ePedTypeFlag::PED_TYPE_MEDIC); - ImGui::SameLine(); ImGui::CheckboxFlags("PED_TYPE_FIREMAN"_T.data(), &g.weapons.aimbot.only_on_ped_type, (int64_t)ePedTypeFlag::PED_TYPE_FIREMAN); - ImGui::SameLine(); ImGui::CheckboxFlags("PED_TYPE_ARMY"_T.data(), &g.weapons.aimbot.only_on_ped_type, (int64_t)ePedTypeFlag::PED_TYPE_ARMY); + ImGui::EndGroup(); - ImGui::CheckboxFlags("POLICE"_T.data(), &g.weapons.aimbot.only_on_ped_type, (int64_t)ePedTypeFlag::PED_TYPE_COP); ImGui::SameLine(); - ImGui::CheckboxFlags("PED_TYPE_SWAT"_T.data(), &g.weapons.aimbot.only_on_ped_type, (int64_t)ePedTypeFlag::PED_TYPE_SWAT); + ImGui::BeginGroup(); ImGui::CheckboxFlags("GUI_TAB_MISSIONS"_T.data(), &g.weapons.aimbot.only_on_ped_type, (int64_t)ePedTypeFlag::PED_TYPE_MISSION); - ImGui::SameLine(); ImGui::CheckboxFlags("PED_TYPE_ANIMAL"_T.data(), &g.weapons.aimbot.only_on_ped_type, (int64_t)ePedTypeFlag::PED_TYPE_ANIMAL); - ImGui::SameLine(); ImGui::CheckboxFlags("PED_TYPE_SPECIAL"_T.data(), &g.weapons.aimbot.only_on_ped_type, (int64_t)ePedTypeFlag::PED_TYPE_SPECIAL); + ImGui::EndGroup(); + + ImGui::SameLine(); + + ImGui::BeginGroup(); + ImGui::CheckboxFlags("POLICE"_T.data(), &g.weapons.aimbot.only_on_ped_type, (int64_t)ePedTypeFlag::PED_TYPE_COP); + ImGui::CheckboxFlags("PED_TYPE_SWAT"_T.data(), &g.weapons.aimbot.only_on_ped_type, (int64_t)ePedTypeFlag::PED_TYPE_SWAT); + ImGui::EndGroup(); ImGui::PushItemWidth(350); ImGui::SliderFloat("VIEW_WEAPON_AIM_FOV"_T.data(), &g.weapons.aimbot.fov, 1.f, 360.f, "%.0f"); @@ -236,222 +237,5 @@ namespace big ImGui::Checkbox("BACKEND_LOOPED_WEAPONS_USE_MAX_RANGE"_T.data(), &g.weapons.aimbot.use_weapon_range); ImGui::PopItemWidth(); } - - ImGui::PushID("ammunation_view"); - if (ImGui::CollapsingHeader("VIEW_WEAPON_AMMUNATION"_T.data())) - { - static Hash selected_weapon_hash, selected_weapon_attachment_hash{}; - static std::string selected_weapon, selected_weapon_attachment; - ImGui::PushItemWidth(300); - if (ImGui::BeginCombo("GUI_TAB_WEAPONS"_T.data(), selected_weapon.c_str())) - { - std::map sorted_map; - for (const auto& [_, weapon] : g_gta_data_service.weapons()) - { - sorted_map.emplace(weapon.m_display_name, weapon); - } - for (const auto& weapon : sorted_map) - { - bool is_selected = weapon.second.m_hash == selected_weapon_hash; - if (weapon.second.m_display_name != "NULL" && ImGui::Selectable(weapon.second.m_display_name.c_str(), is_selected, ImGuiSelectableFlags_None)) - { - selected_weapon = weapon.second.m_display_name; - selected_weapon_hash = weapon.second.m_hash; - selected_weapon_attachment_hash = {}; - selected_weapon_attachment.clear(); - } - if (is_selected) - { - ImGui::SetItemDefaultFocus(); - } - } - ImGui::EndCombo(); - } - ImGui::PopItemWidth(); - ImGui::SameLine(); - components::button("VIEW_WEAPON_GIVE_WEAPON"_T, [] { - WEAPON::GIVE_WEAPON_TO_PED(self::ped, selected_weapon_hash, 9999, false, true); - }); - ImGui::SameLine(); - components::button("VIEW_WEAPON_REMOVE_WEAPON"_T, [] { - WEAPON::REMOVE_WEAPON_FROM_PED(self::ped, selected_weapon_hash); - }); - - ImGui::PushItemWidth(250); - if (ImGui::BeginCombo("VIEW_WEAPON_ATTACHMENTS"_T.data(), selected_weapon_attachment.c_str())) - { - weapon_item weapon = g_gta_data_service.weapon_by_hash(selected_weapon_hash); - if (!weapon.m_attachments.empty()) - { - for (std::string attachment : weapon.m_attachments) - { - weapon_component attachment_component = g_gta_data_service.weapon_component_by_name(attachment); - std::string attachment_name = attachment_component.m_display_name; - Hash attachment_hash = attachment_component.m_hash; - if (attachment_hash == NULL) - { - continue; - } - ImGui::PushID(attachment_hash); - bool is_selected = attachment_hash == selected_weapon_attachment_hash; - if (ImGui::Selectable(attachment_name.c_str(), is_selected, ImGuiSelectableFlags_None)) - { - selected_weapon_attachment = attachment_name; - selected_weapon_attachment_hash = attachment_hash; - } - if (ImGui::IsItemHovered() && !attachment_component.m_display_desc.empty()) - ImGui::SetTooltip(attachment_component.m_display_desc.c_str()); - if (is_selected) - { - ImGui::SetItemDefaultFocus(); - } - ImGui::PopID(); - } - } - - ImGui::EndCombo(); - } - ImGui::SameLine(); - components::button("VIEW_WEAPON_ADD_TO_WEAPON"_T, [] { - WEAPON::GIVE_WEAPON_COMPONENT_TO_PED(self::ped, selected_weapon_hash, selected_weapon_attachment_hash); - }); - ImGui::SameLine(); - components::button("VIEW_WEAPON_REMOVE_TO_WEAPON"_T, [] { - WEAPON::REMOVE_WEAPON_COMPONENT_FROM_PED(self::ped, selected_weapon_hash, selected_weapon_attachment_hash); - }); - ImGui::PopItemWidth(); - - static const char* default_tints[]{"Black tint", "Green tint", "Gold tint", "Pink tint", "Army tint", "LSPD tint", "Orange tint", "Platinum tint"}; - static const char* mk2_tints[]{"Classic Black", "Classic Grey", "Classic Two - Tone", "Classic White", "Classic Beige", "Classic Green", "Classic Blue", "Classic Earth", "Classic Brown & Black", "Red Contrast", "Blue Contrast", "Yellow Contrast", "Orange Contrast", "Bold Pink", "Bold Purple & Yellow", "Bold Orange", "Bold Green & Purple", "Bold Red Features", "Bold Green Features", "Bold Cyan Features", "Bold Yellow Features", "Bold Red & White", "Bold Blue & White", "Metallic Gold", "Metallic Platinum", "Metallic Grey & Lilac", "Metallic Purple & Lime", "Metallic Red", "Metallic Green", "Metallic Blue", "Metallic White & Aqua", "Metallic Red & Yellow"}; - static int tint; - - if (selected_weapon.ends_with("Mk II")) - { - ImGui::Combo("VIEW_WEAPON_TINTS"_T.data(), &tint, mk2_tints, IM_ARRAYSIZE(mk2_tints)); - } - else - { - ImGui::Combo("VIEW_WEAPON_TINTS"_T.data(), &tint, default_tints, IM_ARRAYSIZE(default_tints)); - } - ImGui::SameLine(); - components::button("APPLY"_T, [] { - WEAPON::SET_PED_WEAPON_TINT_INDEX(self::ped, selected_weapon_hash, tint); - }); - } - ImGui::PopID(); - if (ImGui::CollapsingHeader("VIEW_WEAPON_PERSIST_WEAPONS"_T.data())) - { - ImGui::PushID(1); - ImGui::Checkbox("ENABLED"_T.data(), &g.persist_weapons.enabled); - ImGui::PopID(); - - static std::string selected_loadout = g.persist_weapons.weapon_loadout_file; - ImGui::PushItemWidth(250); - if (ImGui::BeginListBox("VIEW_WEAPON_PERSIST_WEAPONS_SAVED_LOADOUTS"_T.data(), ImVec2(200, 200))) - { - for (std::string filename : persist_weapons::list_weapon_loadouts()) - { - if (components::selectable(filename, filename == selected_loadout)) - { - selected_loadout = filename; - } - } - ImGui::EndListBox(); - } - ImGui::SameLine(); - ImGui::BeginGroup(); - static std::string input_file_name; - components::input_text_with_hint("VIEW_WEAPON_PERSIST_WEAPONS_WEAPON_LOADOUT_FILENAME"_T, "VIEW_WEAPON_PERSIST_WEAPONS_LOADOUT_NAME"_T, input_file_name); - components::button("VIEW_WEAPON_PERSIST_WEAPONS_SAVE"_T, [] { - persist_weapons::save_weapons(input_file_name); - input_file_name.clear(); - }); - ImGui::SameLine(); - components::button("VIEW_WEAPON_PERSIST_WEAPONS_LOAD"_T, [] { - persist_weapons::give_player_loadout(selected_loadout); - }); - ImGui::SameLine(); - components::button("VIEW_WEAPON_PERSIST_WEAPONS_SET_LOADOUT"_T, [] { - persist_weapons::set_weapon_loadout(selected_loadout); - }); - ImGui::Text(std::format("{}: {}:", "VIEW_WEAPON_PERSIST_WEAPONS_CURRENT_LOADOUT"_T, g.persist_weapons.weapon_loadout_file) - .data()); - ImGui::EndGroup(); - ImGui::PopItemWidth(); - } - if (ImGui::CollapsingHeader("VIEW_WEAPON_WEAPON_HOTKEYS"_T.data())) - { - ImGui::PushID(2); - ImGui::Checkbox("ENABLED"_T.data(), &g.weapons.enable_weapon_hotkeys); - ImGui::PopID(); - if (ImGui::IsItemHovered()) - { - ImGui::SetTooltip("VIEW_WEAPON_WEAPON_HOTKEYS_TOOLTIP"_T.data()); - } - - static int selected_key = 0; - const char* const keys[]{"1", "2", "3", "4", "5", "6"}; - - ImGui::PushItemWidth(250); - ImGui::Combo("VIEW_WEAPON_WEAPON_HOTKEYS_KEY"_T.data(), &selected_key, keys, IM_ARRAYSIZE(keys)); - ImGui::PopItemWidth(); - - if (!g.weapons.weapon_hotkeys[selected_key].empty()) - { - int counter{}; - for (auto& weapon_hash : g.weapons.weapon_hotkeys[selected_key]) - { - ImGui::PushID(counter); - weapon_item weapon = g_gta_data_service.weapon_by_hash(weapon_hash); - ImGui::PushItemWidth(300); - if (ImGui::BeginCombo("GUI_TAB_WEAPONS"_T.data(), weapon.m_display_name.c_str())) - { - std::map sorted_map; - for (const auto& [_, weapon_iter] : g_gta_data_service.weapons()) - { - sorted_map.emplace(weapon_iter.m_display_name, weapon_iter); - } - for (const auto& [_, weapon_iter] : g_gta_data_service.weapons()) - { - if (weapon_iter.m_display_name == "NULL") - { - continue; - } - bool is_selected = weapon_iter.m_hash == weapon_hash; - if (ImGui::Selectable(weapon_iter.m_display_name.c_str(), is_selected, ImGuiSelectableFlags_None)) - { - weapon_hash = weapon_iter.m_hash; - } - if (is_selected) - { - ImGui::SetItemDefaultFocus(); - } - } - ImGui::EndCombo(); - } - ImGui::SameLine(); - components::button("VIEW_WEAPON_WEAPON_HOTKEYS_SET_TO_CURRENT_WEAPON"_T, [&weapon_hash] { - WEAPON::GET_CURRENT_PED_WEAPON(self::ped, &weapon_hash, NULL); - if (weapon_hash == NULL) - { - WEAPON::GET_CURRENT_PED_VEHICLE_WEAPON(self::ped, &weapon_hash); - } - }); - ImGui::SameLine(); - if (ImGui::Button("VIEW_WEAPON_REMOVE_WEAPON"_T.data())) - { - g.weapons.weapon_hotkeys[selected_key].erase(g.weapons.weapon_hotkeys[selected_key].begin() + counter); - } - ImGui::PopID(); - ImGui::PopItemWidth(); - counter++; - } - } - - if (ImGui::Button("VIEW_WEAPON_WEAPON_ADD_WEAPON"_T.data())) - { - g.weapons.weapon_hotkeys[selected_key].push_back(WEAPON_UNARMED); - } - } } } diff --git a/src/views/view.hpp b/src/views/view.hpp index bf441cfd..0ae9e572 100644 --- a/src/views/view.hpp +++ b/src/views/view.hpp @@ -67,6 +67,7 @@ namespace big static void view_player(); static void players(); static void weapons(); + static void ammunation(); static void context_menu(); static void gta_data(); static void creator();