|
|
@ -20,6 +20,8 @@ limitations under the License.
|
|
|
|
#include <string>
|
|
|
|
#include <string>
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include <spdlog/spdlog.h>
|
|
|
|
#include <spdlog/spdlog.h>
|
|
|
|
|
|
|
|
#include <locale>
|
|
|
|
|
|
|
|
#include <codecvt>
|
|
|
|
|
|
|
|
|
|
|
|
namespace Settings {
|
|
|
|
namespace Settings {
|
|
|
|
|
|
|
|
|
|
|
@ -62,10 +64,10 @@ inline bool checkIsUwp(const std::wstring& launch_path)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void Parse(std::string arg1)
|
|
|
|
inline void Parse(std::wstring arg1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!arg1.ends_with(".json")) {
|
|
|
|
if (!arg1.ends_with(L".json")) {
|
|
|
|
arg1 += ".json";
|
|
|
|
arg1 += L".json";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
std::filesystem::path path(arg1);
|
|
|
|
std::filesystem::path path(arg1);
|
|
|
|
if (path.has_extension() && !std::filesystem::exists(path)) {
|
|
|
|
if (path.has_extension() && !std::filesystem::exists(path)) {
|
|
|
@ -82,7 +84,7 @@ inline void Parse(std::string arg1)
|
|
|
|
std::ifstream json_file;
|
|
|
|
std::ifstream json_file;
|
|
|
|
json_file.open(path);
|
|
|
|
json_file.open(path);
|
|
|
|
if (!json_file.is_open()) {
|
|
|
|
if (!json_file.is_open()) {
|
|
|
|
spdlog::error("Couldn't open settings file {}", path.string());
|
|
|
|
spdlog::error(L"Couldn't open settings file {}", path.wstring());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const auto json = nlohmann::json::parse(json_file);
|
|
|
|
const auto json = nlohmann::json::parse(json_file);
|
|
|
@ -111,10 +113,8 @@ inline void Parse(std::string arg1)
|
|
|
|
std::string meh;
|
|
|
|
std::string meh;
|
|
|
|
safeParseValue(object, key, meh);
|
|
|
|
safeParseValue(object, key, meh);
|
|
|
|
if (!meh.empty()) {
|
|
|
|
if (!meh.empty()) {
|
|
|
|
value.clear();
|
|
|
|
// This assumes that char is utf8 and wchar_t is utf16, which is guaranteed on Windows.
|
|
|
|
std::ranges::transform(meh, std::back_inserter(value), [](const auto& ch) {
|
|
|
|
value = std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>().from_bytes(meh);
|
|
|
|
return static_cast<wchar_t>(ch);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -146,7 +146,7 @@ inline void Parse(std::string arg1)
|
|
|
|
|
|
|
|
|
|
|
|
json_file.close();
|
|
|
|
json_file.close();
|
|
|
|
|
|
|
|
|
|
|
|
spdlog::debug("Read config file \"{}\"", path.string());
|
|
|
|
spdlog::debug(L"Read config file \"{}\"", path.wstring());
|
|
|
|
|
|
|
|
|
|
|
|
if (launch.launch) {
|
|
|
|
if (launch.launch) {
|
|
|
|
launch.isUWP = checkIsUwp(launch.launchPath);
|
|
|
|
launch.isUWP = checkIsUwp(launch.launchPath);
|
|
|
|