From fa273cbb150734c795746ffe128e62870f603317 Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 5 Jan 2015 18:25:57 -0800 Subject: [PATCH] Added settings for autoloading games, added qt-specific autoplay and map loading settings. Also changed the comments in the default ini to look more clear and not invoke parsing errors --- src/citra/citra.cpp | 16 ++++++----- src/citra/config.cpp | 1 + src/citra/default_ini.h | 27 ++++++++++++++++--- src/citra_qt/CMakeLists.txt | 2 ++ src/citra_qt/config.cpp | 9 ++++++- src/citra_qt/main.cpp | 13 +++++++-- src/citra_qt/settings.cpp | 11 ++++++++ src/citra_qt/settings.h | 21 +++++++++++++++ src/core/arm/disassembler/load_symbol_map.cpp | 4 ++- src/core/settings.h | 2 ++ 10 files changed, 92 insertions(+), 14 deletions(-) create mode 100644 src/citra_qt/settings.cpp create mode 100644 src/citra_qt/settings.h diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index 69f0b35b3..952427274 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -28,17 +28,21 @@ int __cdecl main(int argc, char **argv) { logging_thread.join(); }); - if (argc < 2) { + Config config; + log_filter.ParseFilterString(Settings::values.log_filter); + + std::string boot_filename; + if (argc >= 2) { + // TODO: Better argument parsing + boot_filename = argv[1]; + } else if (!Settings::values.autoload_game_path.empty()) { + boot_filename = Settings::values.autoload_game_path; + } else { LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified"); return -1; } - Config config; - log_filter.ParseFilterString(Settings::values.log_filter); - - std::string boot_filename = argv[1]; EmuWindow_GLFW* emu_window = new EmuWindow_GLFW; - System::Init(emu_window); Loader::ResultStatus load_result = Loader::LoadFile(boot_filename); diff --git a/src/citra/config.cpp b/src/citra/config.cpp index 2bf0dff35..8aec5b95a 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -66,6 +66,7 @@ void Config::ReadValues() { // Miscellaneous Settings::values.log_filter = glfw_config->Get("Miscellaneous", "log_filter", "*:Info"); + Settings::values.autoload_game_path = glfw_config->Get("Miscellaneous", "autoload_game_path", ""); } void Config::Reload() { diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h index ebe2e9767..a8d4ba4ae 100644 --- a/src/citra/default_ini.h +++ b/src/citra/default_ini.h @@ -27,15 +27,34 @@ 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. +# The CPU core to be enabled +# 0 (default): Interpreter, 1: Old interpreter (soon to be deprecated) +cpu_core = + +# The refresh rate for the GPU +# Defaults to 30 +gpu_refresh_rate = + +# The applied frameskip amount. Must be a power of two. +# 0 (default): No frameskip, 1: x2 frameskip, 2: x4 frameskip, 3: x8 frameskip, etc. +frame_skip = + [Data Storage] +# Whether to create a virtual SD card. +# 1 (default): Yes, 0: No use_virtual_sd = + [Miscellaneous] -log_filter = *:Info ## Examples: *:Debug Kernel.SVC:Trace Service.*:Critical +# A filter which removes logs below a certain logging level. +# Examples: *:Debug Kernel.SVC:Trace Service.*:Critical +log_filter = *:Info + + +# Path for to a game file to be autoloaded by Citra. +# Leave blank for no autoloading. Overridden by path passed as a console argument. +autoload_game_path = )"; } diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index a0ba252b3..a5803354f 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -17,6 +17,7 @@ set(SRCS bootmanager.cpp hotkeys.cpp main.cpp + settings.cpp citra-qt.rc ) @@ -37,6 +38,7 @@ set(HEADERS bootmanager.h hotkeys.h main.h + settings.h version.h ) diff --git a/src/citra_qt/config.cpp b/src/citra_qt/config.cpp index 1596c08d7..19524eb5f 100644 --- a/src/citra_qt/config.cpp +++ b/src/citra_qt/config.cpp @@ -9,7 +9,8 @@ #include "core/core.h" #include "common/file_util.h" -#include "config.h" +#include "citra_qt/config.h" +#include "citra_qt/settings.h" Config::Config() { @@ -54,6 +55,9 @@ void Config::ReadValues() { qt_config->beginGroup("Miscellaneous"); Settings::values.log_filter = qt_config->value("log_filter", "*:Info").toString().toStdString(); + Settings::qt_values.autoplay_game = qt_config->value("autoplay_game", true).toBool(); + Settings::values.autoload_game_path = qt_config->value("autoload_game_path", "").toString().toStdString(); + Settings::qt_values.autoload_map_path = qt_config->value("autoload_map_path", "").toString().toStdString(); qt_config->endGroup(); } @@ -90,6 +94,9 @@ void Config::SaveValues() { qt_config->beginGroup("Miscellaneous"); qt_config->setValue("log_filter", QString::fromStdString(Settings::values.log_filter)); + qt_config->setValue("autoplay_game", Settings::qt_values.autoplay_game); + qt_config->setValue("autoload_game_path", QString::fromStdString(Settings::values.autoload_game_path)); + qt_config->setValue("autoload_map_path", QString::fromStdString(Settings::qt_values.autoload_map_path)); qt_config->endGroup(); } diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index c6671bef1..1ff36bfc9 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -41,6 +41,7 @@ #include "core/loader/loader.h" #include "core/arm/disassembler/load_symbol_map.h" #include "citra_qt/config.h" +#include "citra_qt/settings.h" #include "version.h" @@ -143,7 +144,14 @@ GMainWindow::GMainWindow() QStringList args = QApplication::arguments(); if (args.length() >= 2) { + // TODO: Better argument parsing BootGame(args[1].toStdString()); + } else if (!Settings::values.autoload_game_path.empty()) { + BootGame(Settings::values.autoload_game_path); + } + + if (!Settings::qt_values.autoload_map_path.empty()) { + LoadSymbolMap(Settings::qt_values.autoload_map_path); } } @@ -174,7 +182,9 @@ void GMainWindow::BootGame(std::string filename) render_window->GetEmuThread().start(); render_window->show(); - OnStartGame(); + + if (Settings::qt_values.autoplay_game) + OnStartGame(); } void GMainWindow::OnMenuLoadFile() @@ -259,7 +269,6 @@ void GMainWindow::closeEvent(QCloseEvent* event) settings.setValue("state", saveState()); settings.setValue("geometryRenderWindow", render_window->saveGeometry()); settings.setValue("singleWindowMode", ui.action_Single_Window_Mode->isChecked()); - settings.setValue("firstStart", false); SaveHotkeys(settings); render_window->close(); diff --git a/src/citra_qt/settings.cpp b/src/citra_qt/settings.cpp new file mode 100644 index 000000000..8c98edba4 --- /dev/null +++ b/src/citra_qt/settings.cpp @@ -0,0 +1,11 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "citra_qt/settings.h" + +namespace Settings { + +QtValues qt_values; + +} diff --git a/src/citra_qt/settings.h b/src/citra_qt/settings.h new file mode 100644 index 000000000..d117f8df2 --- /dev/null +++ b/src/citra_qt/settings.h @@ -0,0 +1,21 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include + +// These are settings that apply only to the Qt frontend. +// Hence, they shouldn't be put in Core but instead here. +namespace Settings { + +struct QtValues { + // Whether a loaded game is automatically started on load. + bool autoplay_game; + + // A map file path to automatically load on init. + std::string autoload_map_path; +} extern qt_values; + +} diff --git a/src/core/arm/disassembler/load_symbol_map.cpp b/src/core/arm/disassembler/load_symbol_map.cpp index 13d26d170..beb522dec 100644 --- a/src/core/arm/disassembler/load_symbol_map.cpp +++ b/src/core/arm/disassembler/load_symbol_map.cpp @@ -23,7 +23,9 @@ void LoadSymbolMap(std::string filename) { while (std::getline(infile, line)) { std::istringstream iss(line); if (!(iss >> address_str >> size >> function_name)) { - break; // Error parsing + Symbols::Clear(); + LOG_ERROR(Frontend, "Could not load symbol map."); + break; // Error while parsing } u32 address = std::stoul(address_str, nullptr, 16); diff --git a/src/core/settings.h b/src/core/settings.h index 4b8928847..31c8173f4 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -36,6 +36,8 @@ struct Values { // Data Storage bool use_virtual_sd; + // Misc + std::string autoload_game_path; std::string log_filter; } extern values;