-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Poggu
committed
Mar 20, 2024
1 parent
3753190
commit b6604ea
Showing
5 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "config.h" | ||
#include <nlohmann/json.hpp> | ||
#include <fstream> | ||
#include <tier0/dbg.h> | ||
|
||
using json = nlohmann::json; | ||
|
||
void PluginConfig::LoadConfig() | ||
{ | ||
std::ifstream file(m_path); | ||
|
||
if (!file.is_open()) | ||
return; | ||
|
||
try | ||
{ | ||
json j; | ||
j << file; | ||
file.close(); | ||
|
||
m_bWelcomeSeen = j["WelcomeSeen"]; | ||
} | ||
catch (const std::exception& e) | ||
{ | ||
ConMsg("Exception: %s", e.what()); | ||
} | ||
} | ||
void PluginConfig::SaveConfig() | ||
{ | ||
std::ofstream file(m_path); | ||
|
||
if (!file.is_open()) | ||
return; | ||
|
||
json j = { | ||
{"WelcomeSeen", m_bWelcomeSeen} | ||
}; | ||
|
||
file << j.dump(2); | ||
file.close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <filesystem> | ||
|
||
class PluginConfig | ||
{ | ||
public: | ||
void LoadConfig(); | ||
void SaveConfig(); | ||
void SetPath(std::filesystem::path&& path) { m_path = path; } | ||
public: | ||
bool m_bWelcomeSeen = false; | ||
private: | ||
std::filesystem::path m_path; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters