r5sdk/r5dev/include/gui_utility.h
PixieCore 7bb4fd6313
Merge indev into master. (#44)
* Added separate function to resolve relative addresses in address.h

* Added new patterns to the print function.

* Updated IsFlagSet hooks.

* Cleaned up code to properly mask off Dev and Cheat flags.
* Added separate define from _DEBUG so you can define it in release builds for people without C++ Debug Restributeables.

* Removed un-used define in hooks.h

* Fixed potential crashes in r5net and added debug prints.

* Potential crashes were when in certain post functions the returned status wasn't 200.

* Changed map-select drop down menu, now it displays 'Map Name + Season' instead of file-name. (#41)

* Host Server shows normal map names

* Changed a few stuff...

* redid some stuff that isn't crucial

* Update CCompanion.cpp

* Update CCompanion.cpp

* Updated mapname displaying.

* Moved "ServerMap" as a static object into CCompanion::HostServerSection().

Co-authored-by: IcePixelx <41352111+PixieCore@users.noreply.github.com>

* prevent squirrel compiler errors from killing game process (#43)

* Read description for all changes.

* Added ability to register custom ConVar.
* Added 2 custom ConVars to open the CGameConsole and CCompanion Windows.
* Changed ResolveRelativeAddress.
* Added Config System for the Gui.
* Added ImGui::Hotkey.
* Added the ability to change 2 hotkeys for opening the window for CGameConsole and CCompanion.
* Changed pattern for Squirrel_CompilerError to use a String.
* Added IMemAlloc::AllocWrapper to patterns.h

* Changes in description.

* Added icon to launcher.exe
* Launcher.exe gets remnamed to Run R5 Reloaded.exe in launcher release compilation configuration.
* Extended argument buffer for starting the game in launcher.exe.
* Added exception printing if in the custom ConVars an invalid value gets passed.

* Wrong return.

* Added shortcut with launch params.

* Fixed prints.

Co-authored-by: Marcii0 <58266292+Marcii0@users.noreply.github.com>
Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
2021-08-19 15:26:44 +02:00

75 lines
2.2 KiB
C++

#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<int>();
CGameConsoleConfig.bind2 = in["config"]["CGameConsole"]["bind2"].get<int>();
// CCompanion
CCompanionConfig.bind1 = in["config"]["CCompanion"]["bind1"].get<int>();
CCompanionConfig.bind2 = in["config"]["CCompanion"]["bind2"].get<int>();
}
}
}
}
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;