Make weapon tints translatable
This commit is contained in:
parent
59aea8bb1e
commit
560e8f2a55
@ -1,50 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace big
|
||||
{
|
||||
constexpr const static auto default_tints = std::to_array({
|
||||
"Black tint",
|
||||
"Green tint",
|
||||
"Gold tint",
|
||||
"Pink tint",
|
||||
"Army tint",
|
||||
"LSPD tint",
|
||||
"Orange tint",
|
||||
"Platinum tint"
|
||||
});
|
||||
|
||||
constexpr const static auto mk2_tints = std::to_array({
|
||||
"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"
|
||||
});
|
||||
}
|
@ -1,11 +1,32 @@
|
||||
#include "core/data/weapon_tints.hpp"
|
||||
#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();
|
||||
@ -15,6 +36,31 @@ namespace big
|
||||
static int selected_tint = 0;
|
||||
static char search_weapon[64];
|
||||
|
||||
static std::vector<std::string> default_tints;
|
||||
static std::vector<std::string> 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"))
|
||||
{
|
||||
@ -57,7 +103,8 @@ namespace big
|
||||
selected_weapon = weapon_name;
|
||||
selected_weapon_hash = weapon_hash;
|
||||
selected_attachment = "SELECT"_T.data();
|
||||
selected_attachment_hash = {};
|
||||
selected_attachment_hash = 0;
|
||||
selected_tint = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -119,25 +166,50 @@ namespace big
|
||||
WEAPON::REMOVE_WEAPON_COMPONENT_FROM_PED(self::ped, selected_weapon_hash, selected_attachment_hash);
|
||||
});
|
||||
|
||||
if (selected_weapon.ends_with("Mk II"))
|
||||
if ((!default_tints.empty() && !mk2_tints.empty()) && selected_weapon_hash != NULL)
|
||||
{
|
||||
ImGui::Combo("VIEW_WEAPON_TINTS"_T.data(), &selected_tint, mk2_tints.data(), mk2_tints.size());
|
||||
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
|
||||
{
|
||||
ImGui::Combo("VIEW_WEAPON_TINTS"_T.data(), &selected_tint, default_tints.data(), default_tints.size());
|
||||
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();
|
||||
|
||||
static std::string selected_loadout = g.persist_weapons.weapon_loadout_file;
|
||||
ImGui::BeginGroup();
|
||||
ImGui::Text("VIEW_WEAPON_PERSIST_WEAPONS_SAVED_LOADOUTS"_T.data());
|
||||
if (ImGui::BeginListBox("##saved_loadouts", ImVec2(200, 200)))
|
||||
@ -154,7 +226,6 @@ namespace big
|
||||
ImGui::EndGroup();
|
||||
ImGui::SameLine();
|
||||
ImGui::BeginGroup();
|
||||
static std::string input_file_name;
|
||||
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, [] {
|
||||
@ -169,12 +240,14 @@ namespace big
|
||||
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::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();
|
||||
@ -183,18 +256,14 @@ namespace big
|
||||
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::Combo("VIEW_WEAPON_WEAPON_HOTKEYS_KEY"_T.data(), &selected_key, keys, IM_ARRAYSIZE(keys));
|
||||
|
||||
if (!g.weapons.weapon_hotkeys[selected_key].empty())
|
||||
{
|
||||
int counter{};
|
||||
int counter = 0;
|
||||
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::PushID(counter);
|
||||
if (ImGui::BeginCombo("GUI_TAB_WEAPONS"_T.data(), weapon.m_display_name.c_str()))
|
||||
{
|
||||
std::map<std::string, weapon_item> sorted_map;
|
||||
@ -202,12 +271,12 @@ namespace big
|
||||
{
|
||||
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))
|
||||
{
|
||||
|
Reference in New Issue
Block a user