From bcbb4d64180ce04144c9358ea1a47a08925cb4b7 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Tue, 3 Jan 2023 01:55:46 +0600 Subject: [PATCH] Fix bugs #83 --- resource/common/locale/English.toml | 3 +- src/cheatmenu.cpp | 17 ++++++++---- src/custom/customskins_sa.cpp | 43 +++++++++++++++-------------- 3 files changed, 36 insertions(+), 27 deletions(-) diff --git a/resource/common/locale/English.toml b/resource/common/locale/English.toml index e705c51..7c0b45d 100644 --- a/resource/common/locale/English.toml +++ b/resource/common/locale/English.toml @@ -338,7 +338,8 @@ Steps to enable 'Custom Skins', Limitations: 1. Your .dff & .txd file names must not exceed 8 characters. -2. Do not rename them while the game is running +2. Do NOT rename them while the game is running +3. Do NOT name your files to existing ped names Doing so will crash your game.""" CycleJump = "Higher cycle jumps" diff --git a/src/cheatmenu.cpp b/src/cheatmenu.cpp index b71ac7d..f123808 100644 --- a/src/cheatmenu.cpp +++ b/src/cheatmenu.cpp @@ -206,12 +206,6 @@ CheatMenuMgr::CheatMenuMgr() return; } - if (!D3dHook::Init(fArgNoneWrapper(CheatMenu.Draw))) - { - return; - } - - ApplyStyle(); Locale::Init(FILE_NAME "/locale/", "English", "English"); Locale::SetLocaleByName(gConfig.Get("Menu.Language", "")); Overlay::Init(); @@ -225,6 +219,17 @@ CheatMenuMgr::CheatMenuMgr() srand(CTimer::m_snTimeInMilliseconds); }; + // Doesn't work with ThirteenAG's windowed mode while inside initRwEvent + Events::initGameEvent += [this]() + { + if (!D3dHook::Init(fArgNoneWrapper(CheatMenu.Draw))) + { + return; + } + + ApplyStyle(); + }; + Events::processScriptsEvent += [this]() { if (!FrontEndMenuManager.m_bMenuActive) diff --git a/src/custom/customskins_sa.cpp b/src/custom/customskins_sa.cpp index 2871a14..f2baa08 100644 --- a/src/custom/customskins_sa.cpp +++ b/src/custom/customskins_sa.cpp @@ -5,35 +5,38 @@ CustomSkinsMgr& CustomSkins = CustomSkinsMgr::Get(); CustomSkinsMgr::CustomSkinsMgr() { - std::string path = GAME_PATH((char*)"modloader/"); - if (GetModuleHandle("modloader.asi") && std::filesystem::is_directory(path)) + Events::initRwEvent += [this]() { - path += "CustomSkinsLoader/"; - if (std::filesystem::is_directory(path)) + std::string path = GAME_PATH((char*)"modloader/"); + if (GetModuleHandle("modloader.asi") && std::filesystem::is_directory(path)) { - for (auto& p : std::filesystem::recursive_directory_iterator(path)) + path += "CustomSkinsLoader/"; + if (std::filesystem::is_directory(path)) { - if (p.path().extension() == ".dff") + for (auto& p : std::filesystem::recursive_directory_iterator(path)) { - std::string file_name = p.path().stem().string(); + if (p.path().extension() == ".dff") + { + std::string file_name = p.path().stem().string(); - if (file_name.size() < 9) - { - m_List.push_back(file_name); - } - else - { - Log::Print("Custom Skin longer than 8 characters {}", file_name); + if (file_name.size() < 9) + { + m_List.push_back(file_name); + } + else + { + Log::Print("Custom Skin longer than 8 characters {}", file_name); + } } } } + else + { + std::filesystem::create_directory(path); + } + m_bInit = true; } - else - { - std::filesystem::create_directory(path); - } - m_bInit = true; - } + }; } void CustomSkinsMgr::SetSkin(const std::string& name)