fix: teleports and imgui.ini located in game folder

This commit is contained in:
Callow 2022-07-13 15:06:50 +03:00
parent 3b5b7f052e
commit cf7d6ad511
6 changed files with 28 additions and 7 deletions

View File

@ -202,6 +202,9 @@ namespace renderer
ImGui_ImplDX12_CreateDeviceObjects();
ImGui::GetIO().ImeWindowHandle = window;
static const std::string imguiPath = (util::GetCurrentPath() / "imgui.ini").string();
ImGui::GetIO().IniFilename = imguiPath.c_str();
io.SetPlatformImeDataFn = nullptr; // F**king bug take 4 hours of my life
}
@ -213,6 +216,8 @@ namespace renderer
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
static const std::string imguiPath = (util::GetCurrentPath() / "imgui.ini").string();
io.IniFilename = imguiPath.c_str();
LoadCustomFont();
SetupImGuiStyle();

View File

@ -70,6 +70,17 @@ namespace util
return std::filesystem::path(pathOut).parent_path().string();
}
static std::filesystem::path _currentPath;
void SetCurrentPath(const std::filesystem::path& current_path)
{
_currentPath = current_path;
}
std::filesystem::path GetCurrentPath()
{
return _currentPath;
}
std::optional<std::string> SelectDirectory(const char* title)
{
auto currPath = std::filesystem::current_path();

View File

@ -6,6 +6,7 @@
#include <vector>
#include <cheat-base/Logger.h>
#include <filesystem>
#include <SimpleIni.h>
@ -38,6 +39,9 @@ namespace util
std::string GetModulePath(HMODULE hModule = nullptr);
void SetCurrentPath(const std::filesystem::path& curren_path);
std::filesystem::path GetCurrentPath();
std::vector<std::string> StringSplit(const std::string& delimiter, const std::string& content);
std::string SplitWords(const std::string& value);
std::string MakeCapital(std::string value);

View File

@ -20,11 +20,13 @@ namespace cheat::feature
NF(f_DebugMode, "Debug Mode", "CustomTeleports", false), // Soon to be added
NF(f_Enabled, "Custom Teleport", "CustomTeleports", false),
NF(f_Next, "Teleport Next", "CustomTeleports", Hotkey(VK_OEM_6)),
NF(f_Previous, "Teleport Previous", "CustomTeleports", Hotkey(VK_OEM_4))
NF(f_Previous, "Teleport Previous", "CustomTeleports", Hotkey(VK_OEM_4)),
dir(util::GetCurrentPath() / "teleports")
{
f_Next.value().PressedEvent += MY_METHOD_HANDLER(CustomTeleports::OnNext);
f_Previous.value().PressedEvent += MY_METHOD_HANDLER(CustomTeleports::OnPrevious);
}
const FeatureGUIInfo& CustomTeleports::GetGUIInfo() const
{
static const FeatureGUIInfo info{ "Custom Teleports", "Teleport", true };

View File

@ -45,7 +45,7 @@ namespace cheat::feature
void DrawStatus() override;
std::vector<Teleport> Teleports;
std::filesystem::path dir = std::filesystem::current_path() / "teleports";
std::filesystem::path dir;
private:
std::set<unsigned int> checkedIndices;

View File

@ -14,17 +14,16 @@
void Run(HMODULE* phModule)
{
ResourceLoader::SetModuleHandle(*phModule);
auto cheatDir = std::filesystem::path(util::GetModulePath(*phModule));
util::SetCurrentPath(util::GetModulePath(*phModule));
// Init config
config::Initialize((cheatDir / "cfg.json").string());
config::Initialize((util::GetCurrentPath() / "cfg.json").string());
// Init logger
auto& settings = cheat::feature::Settings::GetInstance();
if (settings.f_FileLogging)
{
Logger::PrepareFileLogging((cheatDir / "logs").string());
Logger::PrepareFileLogging((util::GetCurrentPath() / "logs").string());
Logger::SetLevel(Logger::Level::Trace, Logger::LoggerType::FileLogger);
}
@ -56,5 +55,5 @@ void Run(HMODULE* phModule)
cheat::Init();
LOG_DEBUG("Config path is at %s", (cheatDir / "cfg.json").string().c_str());
LOG_DEBUG("Config path is at %s", (util::GetCurrentPath() / "cfg.json").string().c_str());
}