Return key name instead of unknown
This commit is contained in:
parent
52dad9acd8
commit
d73836ce81
@ -619,9 +619,9 @@
|
||||
"MoveWhenFiring": "Move when firing",
|
||||
"RapidFire": "Rapid fire",
|
||||
"SelectGang": "Select gang",
|
||||
"Weapon1": "Weap 1",
|
||||
"Weapon2": "Weap 2",
|
||||
"Weapon3": "Weap 3",
|
||||
"Weapon1": "Weapon 1",
|
||||
"Weapon2": "Weapon 2",
|
||||
"Weapon3": "Weapon 3",
|
||||
"WeaponTweaksText": "Weapon tweaks apply globally\nto every ped weapon type"
|
||||
},
|
||||
"Window": {
|
||||
|
11
src/locale.h
11
src/locale.h
@ -56,11 +56,12 @@ public:
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
#ifdef _GTA_
|
||||
// Wanted to do this in the macro TEXT/ TEXT_S
|
||||
// But VS Code complains about it so..
|
||||
defaultValue += "##" + key;
|
||||
#endif
|
||||
// Return keyname if no default value is provided
|
||||
if (defaultValue == "")
|
||||
{
|
||||
defaultValue = "#" + key;
|
||||
}
|
||||
|
||||
std::string rtn = m_pJson->GetValueStr(key, defaultValue);
|
||||
|
||||
if (rtn == defaultValue)
|
||||
|
@ -76,8 +76,8 @@
|
||||
#include "fontmgr.h"
|
||||
#include "locale.h"
|
||||
|
||||
#define TEXT(x) Locale::GetText(x, "Unknown").c_str()
|
||||
#define TEXT_S(x) Locale::GetText(x,"Unknown")
|
||||
#define TEXT(x) Locale::GetText(x).c_str()
|
||||
#define TEXT_S(x) Locale::GetText(x)
|
||||
|
||||
using namespace plugin;
|
||||
|
||||
|
@ -99,7 +99,7 @@ bool Ui::RoundedImageButton(ImTextureID user_texture_id, ImVec2& size, const cha
|
||||
return ImGui::IsItemClicked(0);
|
||||
}
|
||||
|
||||
bool Ui::ListBox(const char* label, std::vector<std::string>& all_items, int& selected)
|
||||
bool Ui::ListBox(const char* label, const std::vector<std::string>& all_items, int& selected)
|
||||
{
|
||||
bool rtn = false;
|
||||
if (ImGui::BeginCombo(label, all_items[selected].c_str()))
|
||||
@ -120,7 +120,7 @@ bool Ui::ListBox(const char* label, std::vector<std::string>& all_items, int& se
|
||||
return rtn;
|
||||
}
|
||||
|
||||
bool Ui::ListBoxStr(const char* label, std::vector<std::string>& all_items, std::string& selected)
|
||||
bool Ui::ListBoxStr(const char* label, const std::vector<std::string>& all_items, std::string& selected)
|
||||
{
|
||||
bool rtn = false;
|
||||
if (ImGui::BeginCombo(label, selected.c_str()))
|
||||
@ -139,7 +139,7 @@ bool Ui::ListBoxStr(const char* label, std::vector<std::string>& all_items, std:
|
||||
return rtn;
|
||||
}
|
||||
|
||||
bool Ui::ListBoxCustomNames(const char* label, std::vector<std::string>& all_items, std::string& selected, const char* customNames[], size_t length)
|
||||
bool Ui::ListBoxCustomNames(const char* label, std::string& selected, const char* customNames[], size_t length)
|
||||
{
|
||||
bool rtn = false;
|
||||
std::string display_selected = (selected == "All") ? selected : customNames[std::stoi(selected)];
|
||||
@ -558,7 +558,7 @@ void Ui::DrawImages(ResourceStore &store, std::function<void(std::string&)> onLe
|
||||
ImGui::PushItemWidth((ImGui::GetWindowContentRegionWidth() - style.ItemSpacing.x)/2);
|
||||
if (customNames)
|
||||
{
|
||||
ListBoxCustomNames("##Categories", store.m_Categories, store.m_Selected, customNames, length);
|
||||
ListBoxCustomNames("##Categories", store.m_Selected, customNames, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
6
src/ui.h
6
src/ui.h
@ -75,9 +75,9 @@ public:
|
||||
|
||||
static ImVec2 GetSize(short count = 1, bool spacing = true);
|
||||
|
||||
static bool ListBox(const char* label, std::vector<std::string>& all_items, int& selected);
|
||||
static bool ListBoxStr(const char* label, std::vector<std::string>& all_items, std::string& selected);
|
||||
static bool ListBoxCustomNames(const char* label, std::vector<std::string>& all_items, std::string& selected, const char* custom_names[] = nullptr, size_t length = 0);
|
||||
static bool ListBox(const char* label, const std::vector<std::string>& all_items, int& selected);
|
||||
static bool ListBoxStr(const char* label, const std::vector<std::string>& all_items, std::string& selected);
|
||||
static bool ListBoxCustomNames(const char* label, std::string& selected, const char* custom_names[] = nullptr, size_t length = 0);
|
||||
|
||||
static void RadioButtonAddress(const char* label, std::vector<NamedMemory>& named_mem);
|
||||
static void RadioButtonAddressEx(const char* label, int addr, std::vector<NamedValue>& named_val);
|
||||
|
@ -367,15 +367,8 @@ void Weapon::ShowPage()
|
||||
{
|
||||
ImGui::Spacing();
|
||||
Ui::ListBox(TEXT("Weapon.SelectGang"), m_GangList, m_nSelectedGang);
|
||||
|
||||
ImGui::Columns(3, 0, false);
|
||||
ImGui::RadioButton(TEXT("Weapon.Weapon1"), &m_nSelectedWeapon, 0);
|
||||
ImGui::NextColumn();
|
||||
ImGui::RadioButton(TEXT("Weapon.Weapon2"), &m_nSelectedWeapon, 1);
|
||||
ImGui::NextColumn();
|
||||
ImGui::RadioButton(TEXT("Weapon.Weapon3"), &m_nSelectedWeapon, 2);
|
||||
ImGui::Columns(1);
|
||||
|
||||
std::vector<std::string> vec = {TEXT("Weapon.Weapon1"), TEXT("Weapon.Weapon2"), TEXT("Weapon.Weapon3")};
|
||||
Ui::ListBox(TEXT("Ped.SelectWeapon"), vec, m_nSelectedWeapon);
|
||||
ImGui::Spacing();
|
||||
ImGui::Text(TEXT("Weapon.CurrentWeapon"),
|
||||
m_WeaponData.m_pJson->m_Data[std::to_string(m_nGangWeaponList[m_nSelectedGang][m_nSelectedWeapon])].get<
|
||||
|
Loading…
Reference in New Issue
Block a user