mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-23 16:00:09 +00:00
Removed redundancy in frontend configs by creating a core config file
This commit is contained in:
parent
2432f317e4
commit
411745c0b0
@ -7,7 +7,6 @@ set(SRCS
|
||||
set(HEADERS
|
||||
emu_window/emu_window_glfw.h
|
||||
config.h
|
||||
default_ini.h
|
||||
resource.h
|
||||
)
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include "core/settings.h"
|
||||
#include "core/system.h"
|
||||
#include "core/config.h"
|
||||
#include "core/core.h"
|
||||
#include "core/loader/loader.h"
|
||||
|
||||
@ -33,7 +34,8 @@ int __cdecl main(int argc, char **argv) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Config config;
|
||||
Citra::Config frontend_config;
|
||||
Core::Config core_config;
|
||||
log_filter.ParseFilterString(Settings::values.log_filter);
|
||||
|
||||
std::string boot_filename = argv[1];
|
||||
|
@ -4,12 +4,33 @@
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include "citra/default_ini.h"
|
||||
#include "citra/config.h"
|
||||
#include "common/file_util.h"
|
||||
#include "core/settings.h"
|
||||
#include "core/core.h"
|
||||
|
||||
#include "config.h"
|
||||
namespace Citra {
|
||||
|
||||
static const char* default_config_file = R"(
|
||||
[Controls]
|
||||
pad_start =
|
||||
pad_select =
|
||||
pad_home =
|
||||
pad_dup =
|
||||
pad_ddown =
|
||||
pad_dleft =
|
||||
pad_dright =
|
||||
pad_a =
|
||||
pad_b =
|
||||
pad_x =
|
||||
pad_y =
|
||||
pad_r =
|
||||
pad_l =
|
||||
pad_sup =
|
||||
pad_sdown =
|
||||
pad_sleft =
|
||||
pad_sright =
|
||||
)";
|
||||
|
||||
Config::Config() {
|
||||
// TODO: Don't hardcode the path; let the frontend decide where to put the config files.
|
||||
@ -55,24 +76,15 @@ void Config::ReadValues() {
|
||||
Settings::values.pad_sdown_key = glfw_config->GetInteger("Controls", "pad_sdown", GLFW_KEY_DOWN);
|
||||
Settings::values.pad_sleft_key = glfw_config->GetInteger("Controls", "pad_sleft", GLFW_KEY_LEFT);
|
||||
Settings::values.pad_sright_key = glfw_config->GetInteger("Controls", "pad_sright", GLFW_KEY_RIGHT);
|
||||
|
||||
// Core
|
||||
Settings::values.cpu_core = glfw_config->GetInteger("Core", "cpu_core", Core::CPU_Interpreter);
|
||||
Settings::values.gpu_refresh_rate = glfw_config->GetInteger("Core", "gpu_refresh_rate", 30);
|
||||
Settings::values.frame_skip = glfw_config->GetInteger("Core", "frame_skip", 0);
|
||||
|
||||
// Data Storage
|
||||
Settings::values.use_virtual_sd = glfw_config->GetBoolean("Data Storage", "use_virtual_sd", true);
|
||||
|
||||
// Miscellaneous
|
||||
Settings::values.log_filter = glfw_config->Get("Miscellaneous", "log_filter", "*:Info");
|
||||
}
|
||||
|
||||
void Config::Reload() {
|
||||
LoadINI(glfw_config, glfw_config_loc.c_str(), DefaultINI::glfw_config_file);
|
||||
LoadINI(glfw_config, glfw_config_loc.c_str(), default_config_file);
|
||||
ReadValues();
|
||||
}
|
||||
|
||||
Config::~Config() {
|
||||
delete glfw_config;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace Citra {
|
||||
|
||||
class Config {
|
||||
INIReader* glfw_config;
|
||||
std::string glfw_config_loc;
|
||||
@ -22,3 +24,5 @@ public:
|
||||
|
||||
void Reload();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,41 +0,0 @@
|
||||
// Copyright 2014 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace DefaultINI {
|
||||
|
||||
const char* glfw_config_file = R"(
|
||||
[Controls]
|
||||
pad_start =
|
||||
pad_select =
|
||||
pad_home =
|
||||
pad_dup =
|
||||
pad_ddown =
|
||||
pad_dleft =
|
||||
pad_dright =
|
||||
pad_a =
|
||||
pad_b =
|
||||
pad_x =
|
||||
pad_y =
|
||||
pad_r =
|
||||
pad_l =
|
||||
pad_sup =
|
||||
pad_sdown =
|
||||
pad_sleft =
|
||||
pad_sright =
|
||||
|
||||
[Core]
|
||||
cpu_core = ## 0: Interpreter (default), 1: OldInterpreter (may work better, soon to be deprecated)
|
||||
gpu_refresh_rate = ## 30 (default)
|
||||
frame_skip = ## 0: No frameskip (default), 1 : 2x frameskip, 2 : 4x frameskip, etc.
|
||||
|
||||
[Data Storage]
|
||||
use_virtual_sd =
|
||||
|
||||
[Miscellaneous]
|
||||
log_filter = *:Info ## Examples: *:Debug Kernel.SVC:Trace Service.*:Critical
|
||||
)";
|
||||
|
||||
}
|
@ -59,7 +59,7 @@ endif()
|
||||
|
||||
add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS})
|
||||
target_link_libraries(citra-qt core common video_core qhexedit)
|
||||
target_link_libraries(citra-qt ${OPENGL_gl_LIBRARY} ${CITRA_QT_LIBS})
|
||||
target_link_libraries(citra-qt inih ${OPENGL_gl_LIBRARY} ${CITRA_QT_LIBS})
|
||||
|
||||
if (UNIX)
|
||||
target_link_libraries(citra-qt -pthread)
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
namespace Citra_Qt {
|
||||
|
||||
Config::Config() {
|
||||
|
||||
// TODO: Don't hardcode the path; let the frontend decide where to put the config files.
|
||||
@ -41,20 +43,6 @@ void Config::ReadValues() {
|
||||
Settings::values.pad_sleft_key = qt_config->value("pad_sleft", Qt::Key_Left).toInt();
|
||||
Settings::values.pad_sright_key = qt_config->value("pad_sright", Qt::Key_Right).toInt();
|
||||
qt_config->endGroup();
|
||||
|
||||
qt_config->beginGroup("Core");
|
||||
Settings::values.cpu_core = qt_config->value("cpu_core", Core::CPU_Interpreter).toInt();
|
||||
Settings::values.gpu_refresh_rate = qt_config->value("gpu_refresh_rate", 30).toInt();
|
||||
Settings::values.frame_skip = qt_config->value("frame_skip", 0).toInt();
|
||||
qt_config->endGroup();
|
||||
|
||||
qt_config->beginGroup("Data Storage");
|
||||
Settings::values.use_virtual_sd = qt_config->value("use_virtual_sd", true).toBool();
|
||||
qt_config->endGroup();
|
||||
|
||||
qt_config->beginGroup("Miscellaneous");
|
||||
Settings::values.log_filter = qt_config->value("log_filter", "*:Info").toString().toStdString();
|
||||
qt_config->endGroup();
|
||||
}
|
||||
|
||||
void Config::SaveValues() {
|
||||
@ -77,20 +65,6 @@ void Config::SaveValues() {
|
||||
qt_config->setValue("pad_sleft", Settings::values.pad_sleft_key);
|
||||
qt_config->setValue("pad_sright", Settings::values.pad_sright_key);
|
||||
qt_config->endGroup();
|
||||
|
||||
qt_config->beginGroup("Core");
|
||||
qt_config->setValue("cpu_core", Settings::values.cpu_core);
|
||||
qt_config->setValue("gpu_refresh_rate", Settings::values.gpu_refresh_rate);
|
||||
qt_config->setValue("frame_skip", Settings::values.frame_skip);
|
||||
qt_config->endGroup();
|
||||
|
||||
qt_config->beginGroup("Data Storage");
|
||||
qt_config->setValue("use_virtual_sd", Settings::values.use_virtual_sd);
|
||||
qt_config->endGroup();
|
||||
|
||||
qt_config->beginGroup("Miscellaneous");
|
||||
qt_config->setValue("log_filter", QString::fromStdString(Settings::values.log_filter));
|
||||
qt_config->endGroup();
|
||||
}
|
||||
|
||||
void Config::Reload() {
|
||||
@ -106,3 +80,5 @@ Config::~Config() {
|
||||
|
||||
delete qt_config;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace Citra_Qt {
|
||||
|
||||
class Config {
|
||||
QSettings* qt_config;
|
||||
std::string qt_config_loc;
|
||||
@ -21,3 +23,5 @@ public:
|
||||
void Reload();
|
||||
void Save();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
#include "core/settings.h"
|
||||
#include "core/system.h"
|
||||
#include "core/config.h"
|
||||
#include "core/core.h"
|
||||
#include "core/loader/loader.h"
|
||||
#include "core/arm/disassembler/load_symbol_map.h"
|
||||
@ -48,7 +49,8 @@ GMainWindow::GMainWindow()
|
||||
{
|
||||
Pica::g_debug_context = Pica::DebugContext::Construct();
|
||||
|
||||
Config config;
|
||||
Citra_Qt::Config frontend_config;
|
||||
Core::Config core_config;
|
||||
|
||||
ui.setupUi(this);
|
||||
statusBar()->hide();
|
||||
|
@ -76,6 +76,7 @@ set(SRCS
|
||||
loader/loader.cpp
|
||||
loader/ncch.cpp
|
||||
loader/3dsx.cpp
|
||||
config.cpp
|
||||
core.cpp
|
||||
core_timing.cpp
|
||||
mem_map.cpp
|
||||
@ -170,6 +171,7 @@ set(HEADERS
|
||||
loader/loader.h
|
||||
loader/ncch.h
|
||||
loader/3dsx.h
|
||||
config.h
|
||||
core.h
|
||||
core_timing.h
|
||||
mem_map.h
|
||||
|
74
src/core/config.cpp
Normal file
74
src/core/config.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
// Copyright 2014 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include "common/file_util.h"
|
||||
#include "core/settings.h"
|
||||
#include "core/config.h"
|
||||
#include "core/core.h"
|
||||
|
||||
namespace Core {
|
||||
|
||||
static const char* default_config_file = R"(
|
||||
[Core]
|
||||
cpu_core = ;; 0: Interpreter (default), 1: OldInterpreter (may work better, soon to be deprecated)
|
||||
gpu_refresh_rate = ;; 30 (default)
|
||||
frame_skip = ;; 0: No frameskip (default), 1 : 2x frameskip, 2 : 4x frameskip, etc.
|
||||
|
||||
[Data Storage]
|
||||
use_virtual_sd =
|
||||
|
||||
[Miscellaneous]
|
||||
log_filter = *:Info ;; Examples: *:Debug Kernel.SVC:Trace Service.*:Critical
|
||||
)";
|
||||
|
||||
Config::Config() {
|
||||
// TODO: Don't hardcode the path; let the frontend decide where to put the config files.
|
||||
core_config_loc = FileUtil::GetUserPath(D_CONFIG_IDX) + "core-config.ini";
|
||||
core_config = new INIReader(core_config_loc);
|
||||
|
||||
Reload();
|
||||
}
|
||||
|
||||
bool Config::LoadINI(INIReader* config, const char* location, const std::string& default_contents, bool retry) {
|
||||
if (config->ParseError() < 0) {
|
||||
if (retry) {
|
||||
LOG_WARNING(Config, "Failed to load %s. Creating file from defaults...", location);
|
||||
FileUtil::CreateFullPath(location);
|
||||
FileUtil::WriteStringToFile(true, default_contents, location);
|
||||
*config = INIReader(location); // Reopen file
|
||||
|
||||
return LoadINI(config, location, default_contents, false);
|
||||
}
|
||||
LOG_ERROR(Config, "Failed.");
|
||||
return false;
|
||||
}
|
||||
LOG_INFO(Config, "Successfully loaded %s", location);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Config::ReadValues() {
|
||||
// Core
|
||||
Settings::values.cpu_core = core_config->GetInteger("Core", "cpu_core", Core::CPU_Interpreter);
|
||||
Settings::values.gpu_refresh_rate = core_config->GetInteger("Core", "gpu_refresh_rate", 30);
|
||||
Settings::values.frame_skip = core_config->GetInteger("Core", "frame_skip", 0);
|
||||
|
||||
// Data Storage
|
||||
Settings::values.use_virtual_sd = core_config->GetBoolean("Data Storage", "use_virtual_sd", true);
|
||||
|
||||
// Miscellaneous
|
||||
Settings::values.log_filter = core_config->Get("Miscellaneous", "log_filter", "*:Info");
|
||||
}
|
||||
|
||||
void Config::Reload() {
|
||||
LoadINI(core_config, core_config_loc.c_str(), default_config_file);
|
||||
ReadValues();
|
||||
}
|
||||
|
||||
Config::~Config() {
|
||||
delete core_config;
|
||||
}
|
||||
|
||||
}
|
28
src/core/config.h
Normal file
28
src/core/config.h
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright 2014 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <inih/cpp/INIReader.h>
|
||||
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace Core {
|
||||
|
||||
class Config {
|
||||
INIReader* core_config;
|
||||
std::string core_config_loc;
|
||||
|
||||
bool LoadINI(INIReader* config, const char* location, const std::string& default_contents="", bool retry=true);
|
||||
void ReadValues();
|
||||
public:
|
||||
Config();
|
||||
~Config();
|
||||
|
||||
void Reload();
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user