mirror of
https://github.com/pineappleEA/pineapple-src.git
synced 2024-11-25 00:28:27 -05:00
early-access version 3986
This commit is contained in:
parent
95b61b00a8
commit
2a27dd5f8c
@ -1,7 +1,7 @@
|
||||
yuzu emulator early access
|
||||
=============
|
||||
|
||||
This is the source code for early-access 3985.
|
||||
This is the source code for early-access 3986.
|
||||
|
||||
## Legal Notice
|
||||
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
||||
#include "common/string_util.h"
|
||||
|
||||
namespace FS = Common::FS;
|
||||
|
||||
Config::Config(const ConfigType config_type)
|
||||
@ -56,16 +58,43 @@ void Config::Initialize(const std::optional<std::string> config_path) {
|
||||
}
|
||||
|
||||
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!");
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
void Config::SetUpIni() {
|
||||
config = std::make_unique<CSimpleIniA>();
|
||||
config->SetUnicode(true);
|
||||
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 {
|
||||
@ -908,15 +937,19 @@ void Config::EndArray() {
|
||||
// You can't end a config array before starting one
|
||||
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
|
||||
if (key_stack.size() == 1 && array_stack.back().name.empty()) {
|
||||
// Edge-case where the first array created doesn't have a name
|
||||
config->SetValue(GetSection().c_str(), std::string("size").c_str(),
|
||||
ToString(array_stack.back().size).c_str());
|
||||
config->SetValue(GetSection().c_str(), std::string("size").c_str(), ToString(size).c_str());
|
||||
} else {
|
||||
const auto key = GetFullKey(std::string("size"), true);
|
||||
config->SetValue(GetSection().c_str(), key.c_str(),
|
||||
ToString(array_stack.back().size).c_str());
|
||||
config->SetValue(GetSection().c_str(), key.c_str(), ToString(size).c_str());
|
||||
}
|
||||
|
||||
array_stack.pop_back();
|
||||
|
Loading…
Reference in New Issue
Block a user