mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-07-01 12:02:55 +08:00
Weapon Hotkeys (#1685)
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
#include "services/gta_data/gta_data_service.hpp"
|
||||
#include "views/view.hpp"
|
||||
#include "services/persist_weapons/persist_weapons.hpp"
|
||||
#include "gta/weapons.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
@ -196,7 +197,9 @@ namespace big
|
||||
selected_weapon_attachment.clear();
|
||||
}
|
||||
if (is_selected)
|
||||
{
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
@ -234,7 +237,9 @@ namespace big
|
||||
selected_weapon_attachment_hash = attachment_hash;
|
||||
}
|
||||
if (is_selected)
|
||||
{
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -304,5 +309,72 @@ namespace big
|
||||
ImGui::EndGroup();
|
||||
ImGui::PopItemWidth();
|
||||
}
|
||||
if (ImGui::CollapsingHeader("Weapon Hotkeys"))
|
||||
{
|
||||
ImGui::Checkbox("Enabled", &g.weapons.enable_weapon_hotkeys);
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::SetTooltip("This will select the next weapon in the hotkey list.\r\nThe first weapon in the list is the first weapon it will select, then the second is the one it will select after and so on.\r\nAfter the end of the list, it will wrap back to the first weapon.");
|
||||
}
|
||||
|
||||
static int selected_key = 0;
|
||||
const char* const keys[]{ "1", "2", "3", "4", "5", "6" };
|
||||
|
||||
ImGui::PushItemWidth(250);
|
||||
ImGui::Combo("Key", &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);
|
||||
auto weapon = g_gta_data_service->weapon_by_hash(weapon_hash);
|
||||
ImGui::PushItemWidth(300);
|
||||
if (ImGui::BeginCombo("Weapons", weapon.m_display_name.c_str()))
|
||||
{
|
||||
for (auto& weapon : g_gta_data_service->weapons())
|
||||
{
|
||||
if (weapon.second.m_display_name == "NULL")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bool is_selected = weapon.second.m_hash == weapon_hash;
|
||||
if (ImGui::Selectable(weapon.second.m_display_name.c_str(), is_selected, ImGuiSelectableFlags_None))
|
||||
{
|
||||
weapon_hash = weapon.second.m_hash;
|
||||
}
|
||||
if (is_selected)
|
||||
{
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
components::button("Set To Current Weapon", [&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("Remove Weapon"))
|
||||
{
|
||||
g.weapons.weapon_hotkeys[selected_key].erase(g.weapons.weapon_hotkeys[selected_key].begin() + counter);
|
||||
}
|
||||
ImGui::PopID();
|
||||
ImGui::PopItemWidth();
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::Button("Add Weapon"))
|
||||
{
|
||||
g.weapons.weapon_hotkeys[selected_key].push_back(WEAPON_UNARMED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,10 @@ namespace big
|
||||
auto ped_count = g_gta_data_service->peds().size();
|
||||
auto veh_count = g_gta_data_service->vehicles().size();
|
||||
auto wep_count = g_gta_data_service->weapons().size();
|
||||
auto wep_comp_count = g_gta_data_service->weapon_components().size();
|
||||
|
||||
components::sub_title("GTA cache stats:");
|
||||
ImGui::Text("Peds Cached: %d\nVehicles Cached: %d\nWeapons Cached: %d", ped_count, veh_count, wep_count);
|
||||
ImGui::Text("Peds Cached: %d\nVehicles Cached: %d\nWeapons Cached: %d\nWeapon Components Cached: %d", ped_count, veh_count, wep_count, wep_comp_count);
|
||||
|
||||
if (components::button("Rebuild Cache"))
|
||||
{
|
||||
|
Reference in New Issue
Block a user