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" Favourites = "Add to favourites"
FavouritesNone = "You don't have any favourites!" FavouritesNone = "You don't have any favourites!"
FavouritesRemove = "Remove from favourites" FavouritesRemove = "Remove from favourites"
FavouritesRemoveText = "Removed from favourites"
FavouritesText = "Added to favourites"
Close = "Close" Close = "Close"
QuickSSKey = "Quick screenshot" QuickSSKey = "Quick screenshot"
QuickTPKey = "Toggle quick teleport" 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', Steps to enable 'Custom Skins',
1. Download & install modloader 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. 3. Download ped skins online ( .dff & .txd files) and put them inside.
4. Restart your game. 4. Restart your game.

View File

@ -273,7 +273,7 @@ Etapas para ativar 'Skins personalizadas',
1. Baixe & instale o modloader 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. 3. Baixe skins online (arquivos .dff & .txd) e coloque-os dentro.

View File

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

View File

@ -266,7 +266,7 @@ Pasos para activar 'Skins personalizadas',
1. Descarga e instala modloader 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. 3. Descarga skins de peds online (archivos .dff y .txd) y ponlos adentro de la carpeta.

View File

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

View File

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

View File

@ -8,7 +8,7 @@ CustomSkinsMgr::CustomSkinsMgr()
std::string path = GAME_PATH((char*)"modloader/"); std::string path = GAME_PATH((char*)"modloader/");
if (GetModuleHandle("modloader.asi") && std::filesystem::is_directory(path)) if (GetModuleHandle("modloader.asi") && std::filesystem::is_directory(path))
{ {
path += "CustomSkins/"; path += "CustomSkinsLoader/";
if (std::filesystem::is_directory(path)) if (std::filesystem::is_directory(path))
{ {
for (auto& p : std::filesystem::recursive_directory_iterator(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) if (Locale::SetLocale(selected) == Locale::eReturnCodes::SUCCESS)
{ {
gConfig.Set("Menu.Language", vec[selected]);
// CheatMenu::GenHeaderList(); // CheatMenu::GenHeaderList();
} }
else else

View File

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

View File

@ -58,6 +58,7 @@ public:
index is the index of the language in the GetLocaleList() list index is the index of the language in the GetLocaleList() list
*/ */
static eReturnCodes SetLocale(size_t index); static eReturnCodes SetLocale(size_t index);
static eReturnCodes SetLocaleByName(const std::string &name);
/* /*
Sets the language back to default (aka English) 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->Set(std::format("Favourites.{}", contextMenu.key).c_str(), contextMenu.val);
data.m_pData->Save(); data.m_pData->Save();
Util::SetMessage(TEXT("Menu.FavouritesText"));
} }
if (!favourites && ImGui::MenuItem(TEXT("Menu.Remove"))) 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->RemoveKey("Favourites", contextMenu.key.c_str());
data.m_pData->Save(); data.m_pData->Save();
data.UpdateSearchList(true); data.UpdateSearchList(true);
Util::SetMessage(TEXT("Menu.FavouritesRemoveText"));
} }
if (ImGui::MenuItem(TEXT("Menu.Close"))) 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->Set(std::format("Favourites.{}", contextMenu.key).c_str(), contextMenu.val);
data.m_pData->Save(); data.m_pData->Save();
Util::SetMessage(TEXT("Menu.FavouritesText"));
} }
if (!favourites && contextMenu.added && ImGui::MenuItem(TEXT("Menu.Remove"))) 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->RemoveKey("Favourites", contextMenu.key.c_str());
data.m_pData->Save(); data.m_pData->Save();
data.UpdateSearchList(true, getNameFunc, verifyFunc); data.UpdateSearchList(true, getNameFunc, verifyFunc);
Util::SetMessage(TEXT("Menu.FavouritesRemoveText"));
} }
if (ImGui::MenuItem(TEXT("Menu.Close"))) 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") DX9SDK_DIR = os.getenv("DXSDK_DIR")
if (DX9SDK_DIR == nil) then if (DX9SDK_DIR == nil) then
error("DXSDK_DIR environment variable not set") -- error("DXSDK_DIR environment variable not set")
end end
if (PSDK_DIR == nil) then if (PSDK_DIR == nil) then