#pragma once ///////////////////////////////////////////////////////////////////////////// // Internals int Stricmp(const char* s1, const char* s2); int Strnicmp(const char* s1, const char* s2, int n); char* Strdup(const char* s); void Strtrim(char* s); class GuiConfig { public: struct { int bind1 = VK_OEM_3; int bind2 = VK_INSERT; } CGameConsoleConfig; struct { int bind1 = VK_HOME; int bind2 = VK_F10; } CCompanionConfig; void Load() { std::filesystem::path path = std::filesystem::current_path() /= "gui.config"; // Get current path + gui.config nlohmann::json in; std::ifstream config_file(path, std::ios::in); // Parse config file. if (config_file.good() && config_file) // Check if it parsed. { config_file >> in; config_file.close(); if (!in.is_null()) { if (!in["config"].is_null()) { // CGameConsole CGameConsoleConfig.bind1 = in["config"]["CGameConsole"]["bind1"].get(); CGameConsoleConfig.bind2 = in["config"]["CGameConsole"]["bind2"].get(); // CCompanion CCompanionConfig.bind1 = in["config"]["CCompanion"]["bind1"].get(); CCompanionConfig.bind2 = in["config"]["CCompanion"]["bind2"].get(); } } } } void Save() { nlohmann::json out; // CGameConsole out["config"]["CGameConsole"]["bind1"] = CGameConsoleConfig.bind1; out["config"]["CGameConsole"]["bind2"] = CGameConsoleConfig.bind2; // CCompanion out["config"]["CCompanion"]["bind1"] = CCompanionConfig.bind1; out["config"]["CCompanion"]["bind2"] = CCompanionConfig.bind2; std::filesystem::path path = std::filesystem::current_path() /= "gui.config"; // Get current path + gui.config std::ofstream out_file(path, std::ios::out | std::ios::trunc); // Write config file.. out_file << out.dump(4); // Dump it into config file.. out_file.close(); // Close the file handle. }; }; extern GuiConfig g_GuiConfig;