Fix language selection not saving

This commit is contained in:
Grinch_ 2022-09-26 00:40:48 +06:00
parent 3cdaf619ed
commit c413c53043
12 changed files with 22 additions and 23 deletions

View File

@ -191,8 +191,6 @@ Remove = "Remove"
Favourites = "Add to favourites"
FavouritesNone = "You don't have any favourites!"
FavouritesRemove = "Remove from favourites"
FavouritesRemoveText = "Removed from favourites"
FavouritesText = "Added to favourites"
Close = "Close"
QuickSSKey = "Quick screenshot"
QuickTPKey = "Toggle quick teleport"
@ -331,7 +329,7 @@ Custom skin allows to change player skins without replacing any existing game pe
Steps to enable 'Custom Skins',
1. Download & install modloader
2. Create a folder inside 'modloader' folder with the name 'CustomSkins'
2. Create a folder inside 'modloader' folder with the name 'CustomSkinsLoader'
3. Download ped skins online ( .dff & .txd files) and put them inside.
4. Restart your game.

View File

@ -273,7 +273,7 @@ Etapas para ativar 'Skins personalizadas',
1. Baixe & instale o modloader
2. Crie uma pasta dentro da pasta 'modloader' com o nome 'CustomSkins'
2. Crie uma pasta dentro da pasta 'modloader' com o nome 'CustomSkinsLoader'
3. Baixe skins online (arquivos .dff & .txd) e coloque-os dentro.

View File

@ -205,8 +205,6 @@ Remove = "Удалить"
Favourites = "Добавить в избранное"
FavouritesNone = "У вас нет ничего в избранном!"
FavouritesRemove = "Удалить из избранного"
FavouritesRemoveText = "Удалено из избранного"
FavouritesText = "Добавлено в избранное"
Close = "Закрыть"
QuickSSKey = "Снимок экрана"
QuickTPKey = "Показать карту телепортации"

View File

@ -266,7 +266,7 @@ Pasos para activar 'Skins personalizadas',
1. Descarga e instala modloader
2. Crea una carpeta dentro de la carpeta 'modloader' con el nombre 'CustomSkins'
2. Crea una carpeta dentro de la carpeta 'modloader' con el nombre 'CustomSkinsLoader'
3. Descarga skins de peds online (archivos .dff y .txd) y ponlos adentro de la carpeta.

View File

@ -189,8 +189,6 @@ Remove = "删除"
Favourites = "添加到收藏夹"
FavouritesNone = "你没有任何收藏夹!"
FavouritesRemove = "从收藏夹中删除"
FavouritesRemoveText = "从收藏夹中删除"
FavouritesText = "添加到收藏夹"
Close = "关闭"
QuickSSKey = "快速屏幕截图"
QuickTPKey = "快速传送"

View File

@ -209,6 +209,7 @@ CheatMenuMgr::CheatMenuMgr()
ApplyStyle();
Locale::Init(FILE_NAME "/locale/", "English", "English");
Locale::SetLocaleByName(gConfig.Get("Menu.Language", ""));
Overlay::Init();
// Load menu settings

View File

@ -8,7 +8,7 @@ CustomSkinsMgr::CustomSkinsMgr()
std::string path = GAME_PATH((char*)"modloader/");
if (GetModuleHandle("modloader.asi") && std::filesystem::is_directory(path))
{
path += "CustomSkins/";
path += "CustomSkinsLoader/";
if (std::filesystem::is_directory(path))
{
for (auto& p : std::filesystem::recursive_directory_iterator(path))

View File

@ -77,6 +77,7 @@ void MenuPage::Draw()
{
if (Locale::SetLocale(selected) == Locale::eReturnCodes::SUCCESS)
{
gConfig.Set("Menu.Language", vec[selected]);
// CheatMenu::GenHeaderList();
}
else

View File

@ -103,14 +103,7 @@ size_t Locale::GetCurrentLocaleIndex()
void Locale::SetDefaultLocale()
{
for (size_t i = 0; i < m_locales.size(); ++i)
{
if (m_locales[i] == "English")
{
SetLocale(i);
return;
}
}
SetLocaleByName("English");
}
Locale::eReturnCodes Locale::SetLocale(size_t index)
@ -131,6 +124,19 @@ Locale::eReturnCodes Locale::SetLocale(size_t index)
return eReturnCodes::SUCCESS;
}
Locale::eReturnCodes Locale::SetLocaleByName(const std::string& name)
{
for (size_t i = 0; i < m_locales.size(); ++i)
{
if (m_locales[i] == name)
{
return SetLocale(i);
}
}
return eReturnCodes::NO_LOCALE_FOUND;
}
std::string Locale::GetText(std::string&& key, std::string&& defaultValue)
{
if (m_pData == nullptr)

View File

@ -58,6 +58,7 @@ public:
index is the index of the language in the GetLocaleList() list
*/
static eReturnCodes SetLocale(size_t index);
static eReturnCodes SetLocaleByName(const std::string &name);
/*
Sets the language back to default (aka English)

View File

@ -142,7 +142,6 @@ void DrawClippedList(ResourceStore& data, fArg3_t clickFunc, bool favourites, bo
{
data.m_pData->Set(std::format("Favourites.{}", contextMenu.key).c_str(), contextMenu.val);
data.m_pData->Save();
Util::SetMessage(TEXT("Menu.FavouritesText"));
}
if (!favourites && ImGui::MenuItem(TEXT("Menu.Remove")))
{
@ -165,7 +164,6 @@ void DrawClippedList(ResourceStore& data, fArg3_t clickFunc, bool favourites, bo
data.m_pData->RemoveKey("Favourites", contextMenu.key.c_str());
data.m_pData->Save();
data.UpdateSearchList(true);
Util::SetMessage(TEXT("Menu.FavouritesRemoveText"));
}
if (ImGui::MenuItem(TEXT("Menu.Close")))
@ -354,7 +352,6 @@ void DrawClippedImages(ResourceStore& data, ImVec2 imgSz, size_t imagesInRow, bo
{
data.m_pData->Set(std::format("Favourites.{}", contextMenu.key).c_str(), contextMenu.val);
data.m_pData->Save();
Util::SetMessage(TEXT("Menu.FavouritesText"));
}
if (!favourites && contextMenu.added && ImGui::MenuItem(TEXT("Menu.Remove")))
{
@ -368,7 +365,6 @@ void DrawClippedImages(ResourceStore& data, ImVec2 imgSz, size_t imagesInRow, bo
data.m_pData->RemoveKey("Favourites", contextMenu.key.c_str());
data.m_pData->Save();
data.UpdateSearchList(true, getNameFunc, verifyFunc);
Util::SetMessage(TEXT("Menu.FavouritesRemoveText"));
}
if (ImGui::MenuItem(TEXT("Menu.Close")))
{

View File

@ -10,7 +10,7 @@ PSDK_DIR = os.getenv("PLUGIN_SDK_DIR")
DX9SDK_DIR = os.getenv("DXSDK_DIR")
if (DX9SDK_DIR == nil) then
error("DXSDK_DIR environment variable not set")
-- error("DXSDK_DIR environment variable not set")
end
if (PSDK_DIR == nil) then