early-access version 3986

This commit is contained in:
pineappleEA 2023-11-21 23:34:31 +01:00
parent 95b61b00a8
commit 2a27dd5f8c
2 changed files with 40 additions and 7 deletions

View File

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 3985. This is the source code for early-access 3986.
## Legal Notice ## Legal Notice

View File

@ -16,6 +16,8 @@
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>
#include "common/string_util.h"
namespace FS = Common::FS; namespace FS = Common::FS;
Config::Config(const ConfigType config_type) Config::Config(const ConfigType config_type)
@ -56,16 +58,43 @@ void Config::Initialize(const std::optional<std::string> config_path) {
} }
void Config::WriteToIni() const { void Config::WriteToIni() const {
if (const SI_Error rc = config->SaveFile(config_loc.c_str(), false); rc < 0) { FILE* fp = nullptr;
#ifdef _WIN32
fp = _wfopen(Common::UTF8ToUTF16W(config_loc).data(), L"wb");
#else
fp = fopen(config_loc.c_str(), "wb");
#endif
CSimpleIniA::FileWriter writer(fp);
const SI_Error rc = config->Save(writer, false);
if (rc < 0) {
LOG_ERROR(Frontend, "Config file could not be saved!"); LOG_ERROR(Frontend, "Config file could not be saved!");
} }
fclose(fp);
} }
void Config::SetUpIni() { void Config::SetUpIni() {
config = std::make_unique<CSimpleIniA>(); config = std::make_unique<CSimpleIniA>();
config->SetUnicode(true); config->SetUnicode(true);
config->SetSpaces(false); config->SetSpaces(false);
config->LoadFile(config_loc.c_str());
FILE* fp = nullptr;
#ifdef _WIN32
_wfopen_s(&fp, Common::UTF8ToUTF16W(config_loc).data(), L"rb, ccs=UTF-8");
if (fp == nullptr) {
fp = _wfopen(Common::UTF8ToUTF16W(config_loc).data(), L"wb, ccs=UTF-8");
}
#else
fp = fopen(config_loc.c_str(), "rb");
if (fp == nullptr) {
fp = fopen(config_loc.c_str(), "wb");
}
#endif
if (SI_Error rc = config->LoadFile(fp); rc < 0) {
LOG_ERROR(Frontend, "Config file could not be loaded!");
}
fclose(fp);
} }
bool Config::IsCustomConfig() const { bool Config::IsCustomConfig() const {
@ -908,15 +937,19 @@ void Config::EndArray() {
// You can't end a config array before starting one // You can't end a config array before starting one
ASSERT(!array_stack.empty()); ASSERT(!array_stack.empty());
// Set the array size to 0 if the array is ended without changing the index
int size = 0;
if (array_stack.back().index != 0) {
size = array_stack.back().size;
}
// Write out the size to config // Write out the size to config
if (key_stack.size() == 1 && array_stack.back().name.empty()) { if (key_stack.size() == 1 && array_stack.back().name.empty()) {
// Edge-case where the first array created doesn't have a name // Edge-case where the first array created doesn't have a name
config->SetValue(GetSection().c_str(), std::string("size").c_str(), config->SetValue(GetSection().c_str(), std::string("size").c_str(), ToString(size).c_str());
ToString(array_stack.back().size).c_str());
} else { } else {
const auto key = GetFullKey(std::string("size"), true); const auto key = GetFullKey(std::string("size"), true);
config->SetValue(GetSection().c_str(), key.c_str(), config->SetValue(GetSection().c_str(), key.c_str(), ToString(size).c_str());
ToString(array_stack.back().size).c_str());
} }
array_stack.pop_back(); array_stack.pop_back();