From 1631e99eed644bb9d313bc49ef6023ac3afe1e52 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Dec 2016 23:49:36 -0500 Subject: citra-qt: Move config dialog code to its own directory --- src/citra_qt/CMakeLists.txt | 46 +- src/citra_qt/config.cpp | 318 ------------ src/citra_qt/config.h | 30 -- src/citra_qt/configuration/config.cpp | 318 ++++++++++++ src/citra_qt/configuration/config.h | 30 ++ src/citra_qt/configuration/configure.ui | 136 +++++ src/citra_qt/configuration/configure_audio.cpp | 77 +++ src/citra_qt/configuration/configure_audio.h | 30 ++ src/citra_qt/configuration/configure_audio.ui | 73 +++ src/citra_qt/configuration/configure_debug.cpp | 26 + src/citra_qt/configuration/configure_debug.h | 28 + src/citra_qt/configuration/configure_debug.ui | 102 ++++ src/citra_qt/configuration/configure_dialog.cpp | 27 + src/citra_qt/configuration/configure_dialog.h | 28 + src/citra_qt/configuration/configure_general.cpp | 37 ++ src/citra_qt/configuration/configure_general.h | 28 + src/citra_qt/configuration/configure_general.ui | 164 ++++++ src/citra_qt/configuration/configure_graphics.cpp | 115 +++++ src/citra_qt/configuration/configure_graphics.h | 28 + src/citra_qt/configuration/configure_graphics.ui | 202 ++++++++ src/citra_qt/configuration/configure_input.cpp | 205 ++++++++ src/citra_qt/configuration/configure_input.h | 69 +++ src/citra_qt/configuration/configure_input.ui | 592 ++++++++++++++++++++++ src/citra_qt/configuration/configure_system.cpp | 142 ++++++ src/citra_qt/configuration/configure_system.h | 37 ++ src/citra_qt/configuration/configure_system.ui | 255 ++++++++++ src/citra_qt/configure.ui | 136 ----- src/citra_qt/configure_audio.cpp | 77 --- src/citra_qt/configure_audio.h | 30 -- src/citra_qt/configure_audio.ui | 73 --- src/citra_qt/configure_debug.cpp | 26 - src/citra_qt/configure_debug.h | 28 - src/citra_qt/configure_debug.ui | 102 ---- src/citra_qt/configure_dialog.cpp | 27 - src/citra_qt/configure_dialog.h | 28 - src/citra_qt/configure_general.cpp | 37 -- src/citra_qt/configure_general.h | 28 - src/citra_qt/configure_general.ui | 164 ------ src/citra_qt/configure_graphics.cpp | 115 ----- src/citra_qt/configure_graphics.h | 28 - src/citra_qt/configure_graphics.ui | 202 -------- src/citra_qt/configure_input.cpp | 205 -------- src/citra_qt/configure_input.h | 69 --- src/citra_qt/configure_input.ui | 592 ---------------------- src/citra_qt/configure_system.cpp | 142 ------ src/citra_qt/configure_system.h | 37 -- src/citra_qt/configure_system.ui | 255 ---------- src/citra_qt/main.cpp | 4 +- 48 files changed, 2774 insertions(+), 2774 deletions(-) delete mode 100644 src/citra_qt/config.cpp delete mode 100644 src/citra_qt/config.h create mode 100644 src/citra_qt/configuration/config.cpp create mode 100644 src/citra_qt/configuration/config.h create mode 100644 src/citra_qt/configuration/configure.ui create mode 100644 src/citra_qt/configuration/configure_audio.cpp create mode 100644 src/citra_qt/configuration/configure_audio.h create mode 100644 src/citra_qt/configuration/configure_audio.ui create mode 100644 src/citra_qt/configuration/configure_debug.cpp create mode 100644 src/citra_qt/configuration/configure_debug.h create mode 100644 src/citra_qt/configuration/configure_debug.ui create mode 100644 src/citra_qt/configuration/configure_dialog.cpp create mode 100644 src/citra_qt/configuration/configure_dialog.h create mode 100644 src/citra_qt/configuration/configure_general.cpp create mode 100644 src/citra_qt/configuration/configure_general.h create mode 100644 src/citra_qt/configuration/configure_general.ui create mode 100644 src/citra_qt/configuration/configure_graphics.cpp create mode 100644 src/citra_qt/configuration/configure_graphics.h create mode 100644 src/citra_qt/configuration/configure_graphics.ui create mode 100644 src/citra_qt/configuration/configure_input.cpp create mode 100644 src/citra_qt/configuration/configure_input.h create mode 100644 src/citra_qt/configuration/configure_input.ui create mode 100644 src/citra_qt/configuration/configure_system.cpp create mode 100644 src/citra_qt/configuration/configure_system.h create mode 100644 src/citra_qt/configuration/configure_system.ui delete mode 100644 src/citra_qt/configure.ui delete mode 100644 src/citra_qt/configure_audio.cpp delete mode 100644 src/citra_qt/configure_audio.h delete mode 100644 src/citra_qt/configure_audio.ui delete mode 100644 src/citra_qt/configure_debug.cpp delete mode 100644 src/citra_qt/configure_debug.h delete mode 100644 src/citra_qt/configure_debug.ui delete mode 100644 src/citra_qt/configure_dialog.cpp delete mode 100644 src/citra_qt/configure_dialog.h delete mode 100644 src/citra_qt/configure_general.cpp delete mode 100644 src/citra_qt/configure_general.h delete mode 100644 src/citra_qt/configure_general.ui delete mode 100644 src/citra_qt/configure_graphics.cpp delete mode 100644 src/citra_qt/configure_graphics.h delete mode 100644 src/citra_qt/configure_graphics.ui delete mode 100644 src/citra_qt/configure_input.cpp delete mode 100644 src/citra_qt/configure_input.h delete mode 100644 src/citra_qt/configure_input.ui delete mode 100644 src/citra_qt/configure_system.cpp delete mode 100644 src/citra_qt/configure_system.h delete mode 100644 src/citra_qt/configure_system.ui diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index 2b1c59a92..3e6106f0a 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -3,7 +3,14 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules) set(SRCS - config.cpp + configuration/config.cpp + configuration/configure_audio.cpp + configuration/configure_debug.cpp + configuration/configure_dialog.cpp + configuration/configure_general.cpp + configuration/configure_graphics.cpp + configuration/configure_input.cpp + configuration/configure_system.cpp debugger/callstack.cpp debugger/disassembler.cpp debugger/graphics/graphics.cpp @@ -19,13 +26,6 @@ set(SRCS util/spinbox.cpp util/util.cpp bootmanager.cpp - configure_audio.cpp - configure_debug.cpp - configure_dialog.cpp - configure_general.cpp - configure_graphics.cpp - configure_system.cpp - configure_input.cpp game_list.cpp hotkeys.cpp main.cpp @@ -35,7 +35,14 @@ set(SRCS ) set(HEADERS - config.h + configuration/config.h + configuration/configure_audio.h + configuration/configure_debug.h + configuration/configure_dialog.h + configuration/configure_general.h + configuration/configure_graphics.h + configuration/configure_input.h + configuration/configure_system.h debugger/callstack.h debugger/disassembler.h debugger/graphics/graphics.h @@ -52,13 +59,6 @@ set(HEADERS util/spinbox.h util/util.h bootmanager.h - configure_audio.h - configure_debug.h - configure_dialog.h - configure_general.h - configure_graphics.h - configure_system.h - configure_input.h game_list.h game_list_p.h hotkeys.h @@ -67,16 +67,16 @@ set(HEADERS ) set(UIS + configuration/configure.ui + configuration/configure_audio.ui + configuration/configure_debug.ui + configuration/configure_general.ui + configuration/configure_graphics.ui + configuration/configure_input.ui + configuration/configure_system.ui debugger/callstack.ui debugger/disassembler.ui debugger/registers.ui - configure.ui - configure_audio.ui - configure_debug.ui - configure_general.ui - configure_graphics.ui - configure_system.ui - configure_input.ui hotkeys.ui main.ui ) diff --git a/src/citra_qt/config.cpp b/src/citra_qt/config.cpp deleted file mode 100644 index bf0ac7c66..000000000 --- a/src/citra_qt/config.cpp +++ /dev/null @@ -1,318 +0,0 @@ -// Copyright 2014 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include -#include "citra_qt/config.h" -#include "citra_qt/ui_settings.h" -#include "common/file_util.h" -#include "input_common/main.h" - -Config::Config() { - // TODO: Don't hardcode the path; let the frontend decide where to put the config files. - qt_config_loc = FileUtil::GetUserPath(D_CONFIG_IDX) + "qt-config.ini"; - FileUtil::CreateFullPath(qt_config_loc); - qt_config = new QSettings(QString::fromStdString(qt_config_loc), QSettings::IniFormat); - - Reload(); -} - -const std::array Config::default_buttons = { - Qt::Key_A, Qt::Key_S, Qt::Key_Z, Qt::Key_X, Qt::Key_T, Qt::Key_G, Qt::Key_F, Qt::Key_H, - Qt::Key_Q, Qt::Key_W, Qt::Key_M, Qt::Key_N, Qt::Key_1, Qt::Key_2, Qt::Key_B, -}; - -const std::array, Settings::NativeAnalog::NumAnalogs> Config::default_analogs{{ - { - Qt::Key_Up, Qt::Key_Down, Qt::Key_Left, Qt::Key_Right, Qt::Key_D, - }, - { - Qt::Key_I, Qt::Key_K, Qt::Key_J, Qt::Key_L, Qt::Key_D, - }, -}}; - -void Config::ReadValues() { - qt_config->beginGroup("Controls"); - for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { - std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); - Settings::values.buttons[i] = - qt_config - ->value(Settings::NativeButton::mapping[i], QString::fromStdString(default_param)) - .toString() - .toStdString(); - if (Settings::values.buttons[i].empty()) - Settings::values.buttons[i] = default_param; - } - - for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { - std::string default_param = InputCommon::GenerateAnalogParamFromKeys( - default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], - default_analogs[i][3], default_analogs[i][4], 0.5f); - Settings::values.analogs[i] = - qt_config - ->value(Settings::NativeAnalog::mapping[i], QString::fromStdString(default_param)) - .toString() - .toStdString(); - if (Settings::values.analogs[i].empty()) - Settings::values.analogs[i] = default_param; - } - - qt_config->endGroup(); - - qt_config->beginGroup("Core"); - Settings::values.use_cpu_jit = qt_config->value("use_cpu_jit", true).toBool(); - qt_config->endGroup(); - - qt_config->beginGroup("Renderer"); - Settings::values.use_hw_renderer = qt_config->value("use_hw_renderer", true).toBool(); - Settings::values.use_shader_jit = qt_config->value("use_shader_jit", true).toBool(); - Settings::values.resolution_factor = qt_config->value("resolution_factor", 1.0).toFloat(); - Settings::values.use_vsync = qt_config->value("use_vsync", false).toBool(); - Settings::values.toggle_framelimit = qt_config->value("toggle_framelimit", true).toBool(); - - Settings::values.bg_red = qt_config->value("bg_red", 1.0).toFloat(); - Settings::values.bg_green = qt_config->value("bg_green", 1.0).toFloat(); - Settings::values.bg_blue = qt_config->value("bg_blue", 1.0).toFloat(); - qt_config->endGroup(); - - qt_config->beginGroup("Layout"); - Settings::values.layout_option = - static_cast(qt_config->value("layout_option").toInt()); - Settings::values.swap_screen = qt_config->value("swap_screen", false).toBool(); - Settings::values.custom_layout = qt_config->value("custom_layout", false).toBool(); - Settings::values.custom_top_left = qt_config->value("custom_top_left", 0).toInt(); - Settings::values.custom_top_top = qt_config->value("custom_top_top", 0).toInt(); - Settings::values.custom_top_right = qt_config->value("custom_top_right", 400).toInt(); - Settings::values.custom_top_bottom = qt_config->value("custom_top_bottom", 240).toInt(); - Settings::values.custom_bottom_left = qt_config->value("custom_bottom_left", 40).toInt(); - Settings::values.custom_bottom_top = qt_config->value("custom_bottom_top", 240).toInt(); - Settings::values.custom_bottom_right = qt_config->value("custom_bottom_right", 360).toInt(); - Settings::values.custom_bottom_bottom = qt_config->value("custom_bottom_bottom", 480).toInt(); - qt_config->endGroup(); - - qt_config->beginGroup("Audio"); - Settings::values.sink_id = qt_config->value("output_engine", "auto").toString().toStdString(); - Settings::values.enable_audio_stretching = - qt_config->value("enable_audio_stretching", true).toBool(); - Settings::values.audio_device_id = - qt_config->value("output_device", "auto").toString().toStdString(); - qt_config->endGroup(); - - using namespace Service::CAM; - qt_config->beginGroup("Camera"); - Settings::values.camera_name[OuterRightCamera] = - qt_config->value("camera_outer_right_name", "blank").toString().toStdString(); - Settings::values.camera_config[OuterRightCamera] = - qt_config->value("camera_outer_right_config", "").toString().toStdString(); - Settings::values.camera_name[InnerCamera] = - qt_config->value("camera_inner_name", "blank").toString().toStdString(); - Settings::values.camera_config[InnerCamera] = - qt_config->value("camera_inner_config", "").toString().toStdString(); - Settings::values.camera_name[OuterLeftCamera] = - qt_config->value("camera_outer_left_name", "blank").toString().toStdString(); - Settings::values.camera_config[OuterLeftCamera] = - qt_config->value("camera_outer_left_config", "").toString().toStdString(); - 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("System"); - Settings::values.is_new_3ds = qt_config->value("is_new_3ds", false).toBool(); - Settings::values.region_value = - qt_config->value("region_value", Settings::REGION_VALUE_AUTO_SELECT).toInt(); - qt_config->endGroup(); - - qt_config->beginGroup("Miscellaneous"); - Settings::values.log_filter = qt_config->value("log_filter", "*:Info").toString().toStdString(); - qt_config->endGroup(); - - qt_config->beginGroup("Debugging"); - Settings::values.use_gdbstub = qt_config->value("use_gdbstub", false).toBool(); - Settings::values.gdbstub_port = qt_config->value("gdbstub_port", 24689).toInt(); - qt_config->endGroup(); - - qt_config->beginGroup("UI"); - - qt_config->beginGroup("UILayout"); - UISettings::values.geometry = qt_config->value("geometry").toByteArray(); - UISettings::values.state = qt_config->value("state").toByteArray(); - UISettings::values.renderwindow_geometry = - qt_config->value("geometryRenderWindow").toByteArray(); - UISettings::values.gamelist_header_state = - qt_config->value("gameListHeaderState").toByteArray(); - UISettings::values.microprofile_geometry = - qt_config->value("microProfileDialogGeometry").toByteArray(); - UISettings::values.microprofile_visible = - qt_config->value("microProfileDialogVisible", false).toBool(); - qt_config->endGroup(); - - qt_config->beginGroup("Paths"); - UISettings::values.roms_path = qt_config->value("romsPath").toString(); - UISettings::values.symbols_path = qt_config->value("symbolsPath").toString(); - UISettings::values.gamedir = qt_config->value("gameListRootDir", ".").toString(); - UISettings::values.gamedir_deepscan = qt_config->value("gameListDeepScan", false).toBool(); - UISettings::values.recent_files = qt_config->value("recentFiles").toStringList(); - qt_config->endGroup(); - - qt_config->beginGroup("Shortcuts"); - QStringList groups = qt_config->childGroups(); - for (auto group : groups) { - qt_config->beginGroup(group); - - QStringList hotkeys = qt_config->childGroups(); - for (auto hotkey : hotkeys) { - qt_config->beginGroup(hotkey); - UISettings::values.shortcuts.emplace_back(UISettings::Shortcut( - group + "/" + hotkey, - UISettings::ContextualShortcut(qt_config->value("KeySeq").toString(), - qt_config->value("Context").toInt()))); - qt_config->endGroup(); - } - - qt_config->endGroup(); - } - qt_config->endGroup(); - - UISettings::values.single_window_mode = qt_config->value("singleWindowMode", true).toBool(); - UISettings::values.display_titlebar = qt_config->value("displayTitleBars", true).toBool(); - UISettings::values.show_status_bar = qt_config->value("showStatusBar", true).toBool(); - UISettings::values.confirm_before_closing = qt_config->value("confirmClose", true).toBool(); - UISettings::values.first_start = qt_config->value("firstStart", true).toBool(); - - qt_config->endGroup(); -} - -void Config::SaveValues() { - qt_config->beginGroup("Controls"); - for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { - qt_config->setValue(QString::fromStdString(Settings::NativeButton::mapping[i]), - QString::fromStdString(Settings::values.buttons[i])); - } - for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { - qt_config->setValue(QString::fromStdString(Settings::NativeAnalog::mapping[i]), - QString::fromStdString(Settings::values.analogs[i])); - } - qt_config->endGroup(); - - qt_config->beginGroup("Core"); - qt_config->setValue("use_cpu_jit", Settings::values.use_cpu_jit); - qt_config->endGroup(); - - qt_config->beginGroup("Renderer"); - qt_config->setValue("use_hw_renderer", Settings::values.use_hw_renderer); - qt_config->setValue("use_shader_jit", Settings::values.use_shader_jit); - qt_config->setValue("resolution_factor", (double)Settings::values.resolution_factor); - qt_config->setValue("use_vsync", Settings::values.use_vsync); - qt_config->setValue("toggle_framelimit", Settings::values.toggle_framelimit); - - // Cast to double because Qt's written float values are not human-readable - qt_config->setValue("bg_red", (double)Settings::values.bg_red); - qt_config->setValue("bg_green", (double)Settings::values.bg_green); - qt_config->setValue("bg_blue", (double)Settings::values.bg_blue); - qt_config->endGroup(); - - qt_config->beginGroup("Layout"); - qt_config->setValue("layout_option", static_cast(Settings::values.layout_option)); - qt_config->setValue("swap_screen", Settings::values.swap_screen); - qt_config->setValue("custom_layout", Settings::values.custom_layout); - qt_config->setValue("custom_top_left", Settings::values.custom_top_left); - qt_config->setValue("custom_top_top", Settings::values.custom_top_top); - qt_config->setValue("custom_top_right", Settings::values.custom_top_right); - qt_config->setValue("custom_top_bottom", Settings::values.custom_top_bottom); - qt_config->setValue("custom_bottom_left", Settings::values.custom_bottom_left); - qt_config->setValue("custom_bottom_top", Settings::values.custom_bottom_top); - qt_config->setValue("custom_bottom_right", Settings::values.custom_bottom_right); - qt_config->setValue("custom_bottom_bottom", Settings::values.custom_bottom_bottom); - qt_config->endGroup(); - - qt_config->beginGroup("Audio"); - qt_config->setValue("output_engine", QString::fromStdString(Settings::values.sink_id)); - qt_config->setValue("enable_audio_stretching", Settings::values.enable_audio_stretching); - qt_config->setValue("output_device", QString::fromStdString(Settings::values.audio_device_id)); - qt_config->endGroup(); - - using namespace Service::CAM; - qt_config->beginGroup("Camera"); - qt_config->setValue("camera_outer_right_name", - QString::fromStdString(Settings::values.camera_name[OuterRightCamera])); - qt_config->setValue("camera_outer_right_config", - QString::fromStdString(Settings::values.camera_config[OuterRightCamera])); - qt_config->setValue("camera_inner_name", - QString::fromStdString(Settings::values.camera_name[InnerCamera])); - qt_config->setValue("camera_inner_config", - QString::fromStdString(Settings::values.camera_config[InnerCamera])); - qt_config->setValue("camera_outer_left_name", - QString::fromStdString(Settings::values.camera_name[OuterLeftCamera])); - qt_config->setValue("camera_outer_left_config", - QString::fromStdString(Settings::values.camera_config[OuterLeftCamera])); - 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("System"); - qt_config->setValue("is_new_3ds", Settings::values.is_new_3ds); - qt_config->setValue("region_value", Settings::values.region_value); - qt_config->endGroup(); - - qt_config->beginGroup("Miscellaneous"); - qt_config->setValue("log_filter", QString::fromStdString(Settings::values.log_filter)); - qt_config->endGroup(); - - qt_config->beginGroup("Debugging"); - qt_config->setValue("use_gdbstub", Settings::values.use_gdbstub); - qt_config->setValue("gdbstub_port", Settings::values.gdbstub_port); - qt_config->endGroup(); - - qt_config->beginGroup("UI"); - - qt_config->beginGroup("UILayout"); - qt_config->setValue("geometry", UISettings::values.geometry); - qt_config->setValue("state", UISettings::values.state); - qt_config->setValue("geometryRenderWindow", UISettings::values.renderwindow_geometry); - qt_config->setValue("gameListHeaderState", UISettings::values.gamelist_header_state); - qt_config->setValue("microProfileDialogGeometry", UISettings::values.microprofile_geometry); - qt_config->setValue("microProfileDialogVisible", UISettings::values.microprofile_visible); - qt_config->endGroup(); - - qt_config->beginGroup("Paths"); - qt_config->setValue("romsPath", UISettings::values.roms_path); - qt_config->setValue("symbolsPath", UISettings::values.symbols_path); - qt_config->setValue("gameListRootDir", UISettings::values.gamedir); - qt_config->setValue("gameListDeepScan", UISettings::values.gamedir_deepscan); - qt_config->setValue("recentFiles", UISettings::values.recent_files); - qt_config->endGroup(); - - qt_config->beginGroup("Shortcuts"); - for (auto shortcut : UISettings::values.shortcuts) { - qt_config->setValue(shortcut.first + "/KeySeq", shortcut.second.first); - qt_config->setValue(shortcut.first + "/Context", shortcut.second.second); - } - qt_config->endGroup(); - - qt_config->setValue("singleWindowMode", UISettings::values.single_window_mode); - qt_config->setValue("displayTitleBars", UISettings::values.display_titlebar); - qt_config->setValue("showStatusBar", UISettings::values.show_status_bar); - qt_config->setValue("confirmClose", UISettings::values.confirm_before_closing); - qt_config->setValue("firstStart", UISettings::values.first_start); - - qt_config->endGroup(); -} - -void Config::Reload() { - ReadValues(); - Settings::Apply(); -} - -void Config::Save() { - SaveValues(); -} - -Config::~Config() { - Save(); - - delete qt_config; -} diff --git a/src/citra_qt/config.h b/src/citra_qt/config.h deleted file mode 100644 index cbf745ea2..000000000 --- a/src/citra_qt/config.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include -#include -#include -#include "core/settings.h" - -class QSettings; - -class Config { - QSettings* qt_config; - std::string qt_config_loc; - - void ReadValues(); - void SaveValues(); - -public: - Config(); - ~Config(); - - void Reload(); - void Save(); - - static const std::array default_buttons; - static const std::array, Settings::NativeAnalog::NumAnalogs> default_analogs; -}; diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp new file mode 100644 index 000000000..0b9b73f9e --- /dev/null +++ b/src/citra_qt/configuration/config.cpp @@ -0,0 +1,318 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include +#include "citra_qt/configuration/config.h" +#include "citra_qt/ui_settings.h" +#include "common/file_util.h" +#include "input_common/main.h" + +Config::Config() { + // TODO: Don't hardcode the path; let the frontend decide where to put the config files. + qt_config_loc = FileUtil::GetUserPath(D_CONFIG_IDX) + "qt-config.ini"; + FileUtil::CreateFullPath(qt_config_loc); + qt_config = new QSettings(QString::fromStdString(qt_config_loc), QSettings::IniFormat); + + Reload(); +} + +const std::array Config::default_buttons = { + Qt::Key_A, Qt::Key_S, Qt::Key_Z, Qt::Key_X, Qt::Key_T, Qt::Key_G, Qt::Key_F, Qt::Key_H, + Qt::Key_Q, Qt::Key_W, Qt::Key_M, Qt::Key_N, Qt::Key_1, Qt::Key_2, Qt::Key_B, +}; + +const std::array, Settings::NativeAnalog::NumAnalogs> Config::default_analogs{{ + { + Qt::Key_Up, Qt::Key_Down, Qt::Key_Left, Qt::Key_Right, Qt::Key_D, + }, + { + Qt::Key_I, Qt::Key_K, Qt::Key_J, Qt::Key_L, Qt::Key_D, + }, +}}; + +void Config::ReadValues() { + qt_config->beginGroup("Controls"); + for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { + std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); + Settings::values.buttons[i] = + qt_config + ->value(Settings::NativeButton::mapping[i], QString::fromStdString(default_param)) + .toString() + .toStdString(); + if (Settings::values.buttons[i].empty()) + Settings::values.buttons[i] = default_param; + } + + for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { + std::string default_param = InputCommon::GenerateAnalogParamFromKeys( + default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], + default_analogs[i][3], default_analogs[i][4], 0.5f); + Settings::values.analogs[i] = + qt_config + ->value(Settings::NativeAnalog::mapping[i], QString::fromStdString(default_param)) + .toString() + .toStdString(); + if (Settings::values.analogs[i].empty()) + Settings::values.analogs[i] = default_param; + } + + qt_config->endGroup(); + + qt_config->beginGroup("Core"); + Settings::values.use_cpu_jit = qt_config->value("use_cpu_jit", true).toBool(); + qt_config->endGroup(); + + qt_config->beginGroup("Renderer"); + Settings::values.use_hw_renderer = qt_config->value("use_hw_renderer", true).toBool(); + Settings::values.use_shader_jit = qt_config->value("use_shader_jit", true).toBool(); + Settings::values.resolution_factor = qt_config->value("resolution_factor", 1.0).toFloat(); + Settings::values.use_vsync = qt_config->value("use_vsync", false).toBool(); + Settings::values.toggle_framelimit = qt_config->value("toggle_framelimit", true).toBool(); + + Settings::values.bg_red = qt_config->value("bg_red", 1.0).toFloat(); + Settings::values.bg_green = qt_config->value("bg_green", 1.0).toFloat(); + Settings::values.bg_blue = qt_config->value("bg_blue", 1.0).toFloat(); + qt_config->endGroup(); + + qt_config->beginGroup("Layout"); + Settings::values.layout_option = + static_cast(qt_config->value("layout_option").toInt()); + Settings::values.swap_screen = qt_config->value("swap_screen", false).toBool(); + Settings::values.custom_layout = qt_config->value("custom_layout", false).toBool(); + Settings::values.custom_top_left = qt_config->value("custom_top_left", 0).toInt(); + Settings::values.custom_top_top = qt_config->value("custom_top_top", 0).toInt(); + Settings::values.custom_top_right = qt_config->value("custom_top_right", 400).toInt(); + Settings::values.custom_top_bottom = qt_config->value("custom_top_bottom", 240).toInt(); + Settings::values.custom_bottom_left = qt_config->value("custom_bottom_left", 40).toInt(); + Settings::values.custom_bottom_top = qt_config->value("custom_bottom_top", 240).toInt(); + Settings::values.custom_bottom_right = qt_config->value("custom_bottom_right", 360).toInt(); + Settings::values.custom_bottom_bottom = qt_config->value("custom_bottom_bottom", 480).toInt(); + qt_config->endGroup(); + + qt_config->beginGroup("Audio"); + Settings::values.sink_id = qt_config->value("output_engine", "auto").toString().toStdString(); + Settings::values.enable_audio_stretching = + qt_config->value("enable_audio_stretching", true).toBool(); + Settings::values.audio_device_id = + qt_config->value("output_device", "auto").toString().toStdString(); + qt_config->endGroup(); + + using namespace Service::CAM; + qt_config->beginGroup("Camera"); + Settings::values.camera_name[OuterRightCamera] = + qt_config->value("camera_outer_right_name", "blank").toString().toStdString(); + Settings::values.camera_config[OuterRightCamera] = + qt_config->value("camera_outer_right_config", "").toString().toStdString(); + Settings::values.camera_name[InnerCamera] = + qt_config->value("camera_inner_name", "blank").toString().toStdString(); + Settings::values.camera_config[InnerCamera] = + qt_config->value("camera_inner_config", "").toString().toStdString(); + Settings::values.camera_name[OuterLeftCamera] = + qt_config->value("camera_outer_left_name", "blank").toString().toStdString(); + Settings::values.camera_config[OuterLeftCamera] = + qt_config->value("camera_outer_left_config", "").toString().toStdString(); + 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("System"); + Settings::values.is_new_3ds = qt_config->value("is_new_3ds", false).toBool(); + Settings::values.region_value = + qt_config->value("region_value", Settings::REGION_VALUE_AUTO_SELECT).toInt(); + qt_config->endGroup(); + + qt_config->beginGroup("Miscellaneous"); + Settings::values.log_filter = qt_config->value("log_filter", "*:Info").toString().toStdString(); + qt_config->endGroup(); + + qt_config->beginGroup("Debugging"); + Settings::values.use_gdbstub = qt_config->value("use_gdbstub", false).toBool(); + Settings::values.gdbstub_port = qt_config->value("gdbstub_port", 24689).toInt(); + qt_config->endGroup(); + + qt_config->beginGroup("UI"); + + qt_config->beginGroup("UILayout"); + UISettings::values.geometry = qt_config->value("geometry").toByteArray(); + UISettings::values.state = qt_config->value("state").toByteArray(); + UISettings::values.renderwindow_geometry = + qt_config->value("geometryRenderWindow").toByteArray(); + UISettings::values.gamelist_header_state = + qt_config->value("gameListHeaderState").toByteArray(); + UISettings::values.microprofile_geometry = + qt_config->value("microProfileDialogGeometry").toByteArray(); + UISettings::values.microprofile_visible = + qt_config->value("microProfileDialogVisible", false).toBool(); + qt_config->endGroup(); + + qt_config->beginGroup("Paths"); + UISettings::values.roms_path = qt_config->value("romsPath").toString(); + UISettings::values.symbols_path = qt_config->value("symbolsPath").toString(); + UISettings::values.gamedir = qt_config->value("gameListRootDir", ".").toString(); + UISettings::values.gamedir_deepscan = qt_config->value("gameListDeepScan", false).toBool(); + UISettings::values.recent_files = qt_config->value("recentFiles").toStringList(); + qt_config->endGroup(); + + qt_config->beginGroup("Shortcuts"); + QStringList groups = qt_config->childGroups(); + for (auto group : groups) { + qt_config->beginGroup(group); + + QStringList hotkeys = qt_config->childGroups(); + for (auto hotkey : hotkeys) { + qt_config->beginGroup(hotkey); + UISettings::values.shortcuts.emplace_back(UISettings::Shortcut( + group + "/" + hotkey, + UISettings::ContextualShortcut(qt_config->value("KeySeq").toString(), + qt_config->value("Context").toInt()))); + qt_config->endGroup(); + } + + qt_config->endGroup(); + } + qt_config->endGroup(); + + UISettings::values.single_window_mode = qt_config->value("singleWindowMode", true).toBool(); + UISettings::values.display_titlebar = qt_config->value("displayTitleBars", true).toBool(); + UISettings::values.show_status_bar = qt_config->value("showStatusBar", true).toBool(); + UISettings::values.confirm_before_closing = qt_config->value("confirmClose", true).toBool(); + UISettings::values.first_start = qt_config->value("firstStart", true).toBool(); + + qt_config->endGroup(); +} + +void Config::SaveValues() { + qt_config->beginGroup("Controls"); + for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { + qt_config->setValue(QString::fromStdString(Settings::NativeButton::mapping[i]), + QString::fromStdString(Settings::values.buttons[i])); + } + for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { + qt_config->setValue(QString::fromStdString(Settings::NativeAnalog::mapping[i]), + QString::fromStdString(Settings::values.analogs[i])); + } + qt_config->endGroup(); + + qt_config->beginGroup("Core"); + qt_config->setValue("use_cpu_jit", Settings::values.use_cpu_jit); + qt_config->endGroup(); + + qt_config->beginGroup("Renderer"); + qt_config->setValue("use_hw_renderer", Settings::values.use_hw_renderer); + qt_config->setValue("use_shader_jit", Settings::values.use_shader_jit); + qt_config->setValue("resolution_factor", (double)Settings::values.resolution_factor); + qt_config->setValue("use_vsync", Settings::values.use_vsync); + qt_config->setValue("toggle_framelimit", Settings::values.toggle_framelimit); + + // Cast to double because Qt's written float values are not human-readable + qt_config->setValue("bg_red", (double)Settings::values.bg_red); + qt_config->setValue("bg_green", (double)Settings::values.bg_green); + qt_config->setValue("bg_blue", (double)Settings::values.bg_blue); + qt_config->endGroup(); + + qt_config->beginGroup("Layout"); + qt_config->setValue("layout_option", static_cast(Settings::values.layout_option)); + qt_config->setValue("swap_screen", Settings::values.swap_screen); + qt_config->setValue("custom_layout", Settings::values.custom_layout); + qt_config->setValue("custom_top_left", Settings::values.custom_top_left); + qt_config->setValue("custom_top_top", Settings::values.custom_top_top); + qt_config->setValue("custom_top_right", Settings::values.custom_top_right); + qt_config->setValue("custom_top_bottom", Settings::values.custom_top_bottom); + qt_config->setValue("custom_bottom_left", Settings::values.custom_bottom_left); + qt_config->setValue("custom_bottom_top", Settings::values.custom_bottom_top); + qt_config->setValue("custom_bottom_right", Settings::values.custom_bottom_right); + qt_config->setValue("custom_bottom_bottom", Settings::values.custom_bottom_bottom); + qt_config->endGroup(); + + qt_config->beginGroup("Audio"); + qt_config->setValue("output_engine", QString::fromStdString(Settings::values.sink_id)); + qt_config->setValue("enable_audio_stretching", Settings::values.enable_audio_stretching); + qt_config->setValue("output_device", QString::fromStdString(Settings::values.audio_device_id)); + qt_config->endGroup(); + + using namespace Service::CAM; + qt_config->beginGroup("Camera"); + qt_config->setValue("camera_outer_right_name", + QString::fromStdString(Settings::values.camera_name[OuterRightCamera])); + qt_config->setValue("camera_outer_right_config", + QString::fromStdString(Settings::values.camera_config[OuterRightCamera])); + qt_config->setValue("camera_inner_name", + QString::fromStdString(Settings::values.camera_name[InnerCamera])); + qt_config->setValue("camera_inner_config", + QString::fromStdString(Settings::values.camera_config[InnerCamera])); + qt_config->setValue("camera_outer_left_name", + QString::fromStdString(Settings::values.camera_name[OuterLeftCamera])); + qt_config->setValue("camera_outer_left_config", + QString::fromStdString(Settings::values.camera_config[OuterLeftCamera])); + 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("System"); + qt_config->setValue("is_new_3ds", Settings::values.is_new_3ds); + qt_config->setValue("region_value", Settings::values.region_value); + qt_config->endGroup(); + + qt_config->beginGroup("Miscellaneous"); + qt_config->setValue("log_filter", QString::fromStdString(Settings::values.log_filter)); + qt_config->endGroup(); + + qt_config->beginGroup("Debugging"); + qt_config->setValue("use_gdbstub", Settings::values.use_gdbstub); + qt_config->setValue("gdbstub_port", Settings::values.gdbstub_port); + qt_config->endGroup(); + + qt_config->beginGroup("UI"); + + qt_config->beginGroup("UILayout"); + qt_config->setValue("geometry", UISettings::values.geometry); + qt_config->setValue("state", UISettings::values.state); + qt_config->setValue("geometryRenderWindow", UISettings::values.renderwindow_geometry); + qt_config->setValue("gameListHeaderState", UISettings::values.gamelist_header_state); + qt_config->setValue("microProfileDialogGeometry", UISettings::values.microprofile_geometry); + qt_config->setValue("microProfileDialogVisible", UISettings::values.microprofile_visible); + qt_config->endGroup(); + + qt_config->beginGroup("Paths"); + qt_config->setValue("romsPath", UISettings::values.roms_path); + qt_config->setValue("symbolsPath", UISettings::values.symbols_path); + qt_config->setValue("gameListRootDir", UISettings::values.gamedir); + qt_config->setValue("gameListDeepScan", UISettings::values.gamedir_deepscan); + qt_config->setValue("recentFiles", UISettings::values.recent_files); + qt_config->endGroup(); + + qt_config->beginGroup("Shortcuts"); + for (auto shortcut : UISettings::values.shortcuts) { + qt_config->setValue(shortcut.first + "/KeySeq", shortcut.second.first); + qt_config->setValue(shortcut.first + "/Context", shortcut.second.second); + } + qt_config->endGroup(); + + qt_config->setValue("singleWindowMode", UISettings::values.single_window_mode); + qt_config->setValue("displayTitleBars", UISettings::values.display_titlebar); + qt_config->setValue("showStatusBar", UISettings::values.show_status_bar); + qt_config->setValue("confirmClose", UISettings::values.confirm_before_closing); + qt_config->setValue("firstStart", UISettings::values.first_start); + + qt_config->endGroup(); +} + +void Config::Reload() { + ReadValues(); + Settings::Apply(); +} + +void Config::Save() { + SaveValues(); +} + +Config::~Config() { + Save(); + + delete qt_config; +} diff --git a/src/citra_qt/configuration/config.h b/src/citra_qt/configuration/config.h new file mode 100644 index 000000000..cbf745ea2 --- /dev/null +++ b/src/citra_qt/configuration/config.h @@ -0,0 +1,30 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include +#include +#include "core/settings.h" + +class QSettings; + +class Config { + QSettings* qt_config; + std::string qt_config_loc; + + void ReadValues(); + void SaveValues(); + +public: + Config(); + ~Config(); + + void Reload(); + void Save(); + + static const std::array default_buttons; + static const std::array, Settings::NativeAnalog::NumAnalogs> default_analogs; +}; diff --git a/src/citra_qt/configuration/configure.ui b/src/citra_qt/configuration/configure.ui new file mode 100644 index 000000000..85e206e42 --- /dev/null +++ b/src/citra_qt/configuration/configure.ui @@ -0,0 +1,136 @@ + + + ConfigureDialog + + + + 0 + 0 + 441 + 501 + + + + Citra Configuration + + + + + + 0 + + + + General + + + + + System + + + + + Input + + + + + Graphics + + + + + Audio + + + + + Debug + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + ConfigureGeneral + QWidget +
configuration/configure_general.h
+ 1 +
+ + ConfigureSystem + QWidget +
configuration/configure_system.h
+ 1 +
+ + ConfigureAudio + QWidget +
configuration/configure_audio.h
+ 1 +
+ + ConfigureDebug + QWidget +
configuration/configure_debug.h
+ 1 +
+ + ConfigureInput + QWidget +
configuration/configure_input.h
+ 1 +
+ + ConfigureGraphics + QWidget +
configuration/configure_graphics.h
+ 1 +
+
+ + + + buttonBox + accepted() + ConfigureDialog + accept() + + + 220 + 380 + + + 220 + 200 + + + + + buttonBox + rejected() + ConfigureDialog + reject() + + + 220 + 380 + + + 220 + 200 + + + + +
diff --git a/src/citra_qt/configuration/configure_audio.cpp b/src/citra_qt/configuration/configure_audio.cpp new file mode 100644 index 000000000..3fd1d127a --- /dev/null +++ b/src/citra_qt/configuration/configure_audio.cpp @@ -0,0 +1,77 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include +#include "audio_core/audio_core.h" +#include "audio_core/sink.h" +#include "audio_core/sink_details.h" +#include "citra_qt/configuration/configure_audio.h" +#include "core/settings.h" +#include "ui_configure_audio.h" + +ConfigureAudio::ConfigureAudio(QWidget* parent) + : QWidget(parent), ui(std::make_unique()) { + ui->setupUi(this); + + ui->output_sink_combo_box->clear(); + ui->output_sink_combo_box->addItem("auto"); + for (const auto& sink_detail : AudioCore::g_sink_details) { + ui->output_sink_combo_box->addItem(sink_detail.id); + } + + this->setConfiguration(); + connect(ui->output_sink_combo_box, SIGNAL(currentIndexChanged(int)), this, + SLOT(updateAudioDevices(int))); +} + +ConfigureAudio::~ConfigureAudio() {} + +void ConfigureAudio::setConfiguration() { + int new_sink_index = 0; + for (int index = 0; index < ui->output_sink_combo_box->count(); index++) { + if (ui->output_sink_combo_box->itemText(index).toStdString() == Settings::values.sink_id) { + new_sink_index = index; + break; + } + } + ui->output_sink_combo_box->setCurrentIndex(new_sink_index); + + ui->toggle_audio_stretching->setChecked(Settings::values.enable_audio_stretching); + + // The device list cannot be pre-populated (nor listed) until the output sink is known. + updateAudioDevices(new_sink_index); + + int new_device_index = -1; + for (int index = 0; index < ui->audio_device_combo_box->count(); index++) { + if (ui->audio_device_combo_box->itemText(index).toStdString() == + Settings::values.audio_device_id) { + new_device_index = index; + break; + } + } + ui->audio_device_combo_box->setCurrentIndex(new_device_index); +} + +void ConfigureAudio::applyConfiguration() { + Settings::values.sink_id = + ui->output_sink_combo_box->itemText(ui->output_sink_combo_box->currentIndex()) + .toStdString(); + Settings::values.enable_audio_stretching = ui->toggle_audio_stretching->isChecked(); + Settings::values.audio_device_id = + ui->audio_device_combo_box->itemText(ui->audio_device_combo_box->currentIndex()) + .toStdString(); + Settings::Apply(); +} + +void ConfigureAudio::updateAudioDevices(int sink_index) { + ui->audio_device_combo_box->clear(); + ui->audio_device_combo_box->addItem("auto"); + + std::string sink_id = ui->output_sink_combo_box->itemText(sink_index).toStdString(); + std::vector device_list = + AudioCore::GetSinkDetails(sink_id).factory()->GetDeviceList(); + for (const auto& device : device_list) { + ui->audio_device_combo_box->addItem(device.c_str()); + } +} diff --git a/src/citra_qt/configuration/configure_audio.h b/src/citra_qt/configuration/configure_audio.h new file mode 100644 index 000000000..8190e694f --- /dev/null +++ b/src/citra_qt/configuration/configure_audio.h @@ -0,0 +1,30 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include + +namespace Ui { +class ConfigureAudio; +} + +class ConfigureAudio : public QWidget { + Q_OBJECT + +public: + explicit ConfigureAudio(QWidget* parent = nullptr); + ~ConfigureAudio(); + + void applyConfiguration(); + +public slots: + void updateAudioDevices(int sink_index); + +private: + void setConfiguration(); + + std::unique_ptr ui; +}; diff --git a/src/citra_qt/configuration/configure_audio.ui b/src/citra_qt/configuration/configure_audio.ui new file mode 100644 index 000000000..dd870eb61 --- /dev/null +++ b/src/citra_qt/configuration/configure_audio.ui @@ -0,0 +1,73 @@ + + + + ConfigureAudio + + + + + + Audio + + + + + + + + Output Engine: + + + + + + + + + + + + + Enable audio stretching + + + This post-processing effect adjusts audio speed to match emulation speed and helps prevent audio stutter. This however increases audio latency. + + + + + + + + + Audio Device: + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/src/citra_qt/configuration/configure_debug.cpp b/src/citra_qt/configuration/configure_debug.cpp new file mode 100644 index 000000000..263f73f38 --- /dev/null +++ b/src/citra_qt/configuration/configure_debug.cpp @@ -0,0 +1,26 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "citra_qt/configuration/configure_debug.h" +#include "core/settings.h" +#include "ui_configure_debug.h" + +ConfigureDebug::ConfigureDebug(QWidget* parent) : QWidget(parent), ui(new Ui::ConfigureDebug) { + ui->setupUi(this); + this->setConfiguration(); +} + +ConfigureDebug::~ConfigureDebug() {} + +void ConfigureDebug::setConfiguration() { + ui->toggle_gdbstub->setChecked(Settings::values.use_gdbstub); + ui->gdbport_spinbox->setEnabled(Settings::values.use_gdbstub); + ui->gdbport_spinbox->setValue(Settings::values.gdbstub_port); +} + +void ConfigureDebug::applyConfiguration() { + Settings::values.use_gdbstub = ui->toggle_gdbstub->isChecked(); + Settings::values.gdbstub_port = ui->gdbport_spinbox->value(); + Settings::Apply(); +} diff --git a/src/citra_qt/configuration/configure_debug.h b/src/citra_qt/configuration/configure_debug.h new file mode 100644 index 000000000..d167eb996 --- /dev/null +++ b/src/citra_qt/configuration/configure_debug.h @@ -0,0 +1,28 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include + +namespace Ui { +class ConfigureDebug; +} + +class ConfigureDebug : public QWidget { + Q_OBJECT + +public: + explicit ConfigureDebug(QWidget* parent = nullptr); + ~ConfigureDebug(); + + void applyConfiguration(); + +private: + void setConfiguration(); + +private: + std::unique_ptr ui; +}; diff --git a/src/citra_qt/configuration/configure_debug.ui b/src/citra_qt/configuration/configure_debug.ui new file mode 100644 index 000000000..bbbb0e3f4 --- /dev/null +++ b/src/citra_qt/configuration/configure_debug.ui @@ -0,0 +1,102 @@ + + + ConfigureDebug + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + + + GDB + + + + + + + + Enable GDB Stub + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Port: + + + + + + + 65536 + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + toggle_gdbstub + toggled(bool) + gdbport_spinbox + setEnabled(bool) + + + 84 + 157 + + + 342 + 158 + + + + + diff --git a/src/citra_qt/configuration/configure_dialog.cpp b/src/citra_qt/configuration/configure_dialog.cpp new file mode 100644 index 000000000..dfc8c03a7 --- /dev/null +++ b/src/citra_qt/configuration/configure_dialog.cpp @@ -0,0 +1,27 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "citra_qt/configuration/config.h" +#include "citra_qt/configuration/configure_dialog.h" +#include "core/settings.h" +#include "ui_configure.h" + +ConfigureDialog::ConfigureDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ConfigureDialog) { + ui->setupUi(this); + this->setConfiguration(); +} + +ConfigureDialog::~ConfigureDialog() {} + +void ConfigureDialog::setConfiguration() {} + +void ConfigureDialog::applyConfiguration() { + ui->generalTab->applyConfiguration(); + ui->systemTab->applyConfiguration(); + ui->inputTab->applyConfiguration(); + ui->graphicsTab->applyConfiguration(); + ui->audioTab->applyConfiguration(); + ui->debugTab->applyConfiguration(); + Settings::Apply(); +} diff --git a/src/citra_qt/configuration/configure_dialog.h b/src/citra_qt/configuration/configure_dialog.h new file mode 100644 index 000000000..21fa1f501 --- /dev/null +++ b/src/citra_qt/configuration/configure_dialog.h @@ -0,0 +1,28 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include + +namespace Ui { +class ConfigureDialog; +} + +class ConfigureDialog : public QDialog { + Q_OBJECT + +public: + explicit ConfigureDialog(QWidget* parent); + ~ConfigureDialog(); + + void applyConfiguration(); + +private: + void setConfiguration(); + +private: + std::unique_ptr ui; +}; diff --git a/src/citra_qt/configuration/configure_general.cpp b/src/citra_qt/configuration/configure_general.cpp new file mode 100644 index 000000000..a21176c34 --- /dev/null +++ b/src/citra_qt/configuration/configure_general.cpp @@ -0,0 +1,37 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "citra_qt/configuration/configure_general.h" +#include "citra_qt/ui_settings.h" +#include "core/core.h" +#include "core/settings.h" +#include "ui_configure_general.h" + +ConfigureGeneral::ConfigureGeneral(QWidget* parent) + : QWidget(parent), ui(new Ui::ConfigureGeneral) { + + ui->setupUi(this); + this->setConfiguration(); + + ui->toggle_cpu_jit->setEnabled(!Core::System::GetInstance().IsPoweredOn()); +} + +ConfigureGeneral::~ConfigureGeneral() {} + +void ConfigureGeneral::setConfiguration() { + ui->toggle_deepscan->setChecked(UISettings::values.gamedir_deepscan); + ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing); + ui->toggle_cpu_jit->setChecked(Settings::values.use_cpu_jit); + + // The first item is "auto-select" with actual value -1, so plus one here will do the trick + ui->region_combobox->setCurrentIndex(Settings::values.region_value + 1); +} + +void ConfigureGeneral::applyConfiguration() { + UISettings::values.gamedir_deepscan = ui->toggle_deepscan->isChecked(); + UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); + Settings::values.region_value = ui->region_combobox->currentIndex() - 1; + Settings::values.use_cpu_jit = ui->toggle_cpu_jit->isChecked(); + Settings::Apply(); +} diff --git a/src/citra_qt/configuration/configure_general.h b/src/citra_qt/configuration/configure_general.h new file mode 100644 index 000000000..447552d8c --- /dev/null +++ b/src/citra_qt/configuration/configure_general.h @@ -0,0 +1,28 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include + +namespace Ui { +class ConfigureGeneral; +} + +class ConfigureGeneral : public QWidget { + Q_OBJECT + +public: + explicit ConfigureGeneral(QWidget* parent = nullptr); + ~ConfigureGeneral(); + + void applyConfiguration(); + +private: + void setConfiguration(); + +private: + std::unique_ptr ui; +}; diff --git a/src/citra_qt/configuration/configure_general.ui b/src/citra_qt/configuration/configure_general.ui new file mode 100644 index 000000000..c739605a4 --- /dev/null +++ b/src/citra_qt/configuration/configure_general.ui @@ -0,0 +1,164 @@ + + + ConfigureGeneral + + + + 0 + 0 + 300 + 377 + + + + Form + + + + + + + + General + + + + + + + + Search sub-directories for games + + + + + + + Confirm exit while emulation is running + + + + + + + + + + + + Performance + + + + + + + + Enable CPU JIT + + + + + + + + + + + + Emulation + + + + + + + + + + Region: + + + + + + + + Auto-select + + + + + JPN + + + + + USA + + + + + EUR + + + + + AUS + + + + + CHN + + + + + KOR + + + + + TWN + + + + + + + + + + + + + + + Hotkeys + + + + + + + + + + + + + + + + + + + GHotkeysDialog + QWidget +
hotkeys.h
+ 1 +
+
+ + +
diff --git a/src/citra_qt/configuration/configure_graphics.cpp b/src/citra_qt/configuration/configure_graphics.cpp new file mode 100644 index 000000000..b5a5ab1e1 --- /dev/null +++ b/src/citra_qt/configuration/configure_graphics.cpp @@ -0,0 +1,115 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "citra_qt/configuration/configure_graphics.h" +#include "core/core.h" +#include "core/settings.h" +#include "ui_configure_graphics.h" + +ConfigureGraphics::ConfigureGraphics(QWidget* parent) + : QWidget(parent), ui(new Ui::ConfigureGraphics) { + + ui->setupUi(this); + this->setConfiguration(); + + ui->toggle_vsync->setEnabled(!Core::System::GetInstance().IsPoweredOn()); + + ui->layoutBox->setEnabled(!Settings::values.custom_layout); +} + +ConfigureGraphics::~ConfigureGraphics() {} + +enum class Resolution : int { + Auto, + Scale1x, + Scale2x, + Scale3x, + Scale4x, + Scale5x, + Scale6x, + Scale7x, + Scale8x, + Scale9x, + Scale10x, +}; + +float ToResolutionFactor(Resolution option) { + switch (option) { + case Resolution::Auto: + return 0.f; + case Resolution::Scale1x: + return 1.f; + case Resolution::Scale2x: + return 2.f; + case Resolution::Scale3x: + return 3.f; + case Resolution::Scale4x: + return 4.f; + case Resolution::Scale5x: + return 5.f; + case Resolution::Scale6x: + return 6.f; + case Resolution::Scale7x: + return 7.f; + case Resolution::Scale8x: + return 8.f; + case Resolution::Scale9x: + return 9.f; + case Resolution::Scale10x: + return 10.f; + } + return 0.f; +} + +Resolution FromResolutionFactor(float factor) { + if (factor == 0.f) { + return Resolution::Auto; + } else if (factor == 1.f) { + return Resolution::Scale1x; + } else if (factor == 2.f) { + return Resolution::Scale2x; + } else if (factor == 3.f) { + return Resolution::Scale3x; + } else if (factor == 4.f) { + return Resolution::Scale4x; + } else if (factor == 5.f) { + return Resolution::Scale5x; + } else if (factor == 6.f) { + return Resolution::Scale6x; + } else if (factor == 7.f) { + return Resolution::Scale7x; + } else if (factor == 8.f) { + return Resolution::Scale8x; + } else if (factor == 9.f) { + return Resolution::Scale9x; + } else if (factor == 10.f) { + return Resolution::Scale10x; + } + return Resolution::Auto; +} + +void ConfigureGraphics::setConfiguration() { + ui->toggle_hw_renderer->setChecked(Settings::values.use_hw_renderer); + ui->resolution_factor_combobox->setEnabled(Settings::values.use_hw_renderer); + ui->toggle_shader_jit->setChecked(Settings::values.use_shader_jit); + ui->resolution_factor_combobox->setCurrentIndex( + static_cast(FromResolutionFactor(Settings::values.resolution_factor))); + ui->toggle_vsync->setChecked(Settings::values.use_vsync); + ui->toggle_framelimit->setChecked(Settings::values.toggle_framelimit); + ui->layout_combobox->setCurrentIndex(static_cast(Settings::values.layout_option)); + ui->swap_screen->setChecked(Settings::values.swap_screen); +} + +void ConfigureGraphics::applyConfiguration() { + Settings::values.use_hw_renderer = ui->toggle_hw_renderer->isChecked(); + Settings::values.use_shader_jit = ui->toggle_shader_jit->isChecked(); + Settings::values.resolution_factor = + ToResolutionFactor(static_cast(ui->resolution_factor_combobox->currentIndex())); + Settings::values.use_vsync = ui->toggle_vsync->isChecked(); + Settings::values.toggle_framelimit = ui->toggle_framelimit->isChecked(); + Settings::values.layout_option = + static_cast(ui->layout_combobox->currentIndex()); + Settings::values.swap_screen = ui->swap_screen->isChecked(); + Settings::Apply(); +} diff --git a/src/citra_qt/configuration/configure_graphics.h b/src/citra_qt/configuration/configure_graphics.h new file mode 100644 index 000000000..5497a55f7 --- /dev/null +++ b/src/citra_qt/configuration/configure_graphics.h @@ -0,0 +1,28 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include + +namespace Ui { +class ConfigureGraphics; +} + +class ConfigureGraphics : public QWidget { + Q_OBJECT + +public: + explicit ConfigureGraphics(QWidget* parent = nullptr); + ~ConfigureGraphics(); + + void applyConfiguration(); + +private: + void setConfiguration(); + +private: + std::unique_ptr ui; +}; diff --git a/src/citra_qt/configuration/configure_graphics.ui b/src/citra_qt/configuration/configure_graphics.ui new file mode 100644 index 000000000..228f2a869 --- /dev/null +++ b/src/citra_qt/configuration/configure_graphics.ui @@ -0,0 +1,202 @@ + + + ConfigureGraphics + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + + + Graphics + + + + + + Enable hardware renderer + + + + + + + Enable shader JIT + + + + + + + Enable V-Sync + + + + + + + Limit framerate + + + + + + + + + Internal Resolution: + + + + + + + + Auto (Window Size) + + + + + Native (400x240) + + + + + 2x Native (800x480) + + + + + 3x Native (1200x720) + + + + + 4x Native (1600x960) + + + + + 5x Native (2000x1200) + + + + + 6x Native (2400x1440) + + + + + 7x Native (2800x1680) + + + + + 8x Native (3200x1920) + + + + + 9x Native (3600x2160) + + + + + 10x Native (4000x2400) + + + + + + + + + + + + + + + Layout + + + + + + + + + + Screen Layout: + + + + + + + + Default + + + + + Single Screen + + + + + Large Screen + + + + + + + + + + Swap Screens + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + toggle_hw_renderer + toggled(bool) + resolution_factor_combobox + setEnabled(bool) + + + diff --git a/src/citra_qt/configuration/configure_input.cpp b/src/citra_qt/configuration/configure_input.cpp new file mode 100644 index 000000000..daac9b63a --- /dev/null +++ b/src/citra_qt/configuration/configure_input.cpp @@ -0,0 +1,205 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include +#include +#include +#include +#include "citra_qt/configuration/config.h" +#include "citra_qt/configuration/configure_input.h" +#include "common/param_package.h" +#include "input_common/main.h" + +const std::array + ConfigureInput::analog_sub_buttons{{ + "up", "down", "left", "right", "modifier", + }}; + +static QString getKeyName(int key_code) { + switch (key_code) { + case Qt::Key_Shift: + return QObject::tr("Shift"); + case Qt::Key_Control: + return QObject::tr("Ctrl"); + case Qt::Key_Alt: + return QObject::tr("Alt"); + case Qt::Key_Meta: + return ""; + default: + return QKeySequence(key_code).toString(); + } +} + +static void SetButtonKey(int key, Common::ParamPackage& button_param) { + button_param = Common::ParamPackage{InputCommon::GenerateKeyboardParam(key)}; +} + +static void SetAnalogKey(int key, Common::ParamPackage& analog_param, + const std::string& button_name) { + if (analog_param.Get("engine", "") != "analog_from_button") { + analog_param = { + {"engine", "analog_from_button"}, {"modifier_scale", "0.5"}, + }; + } + analog_param.Set(button_name, InputCommon::GenerateKeyboardParam(key)); +} + +ConfigureInput::ConfigureInput(QWidget* parent) + : QWidget(parent), ui(std::make_unique()), + timer(std::make_unique()) { + + ui->setupUi(this); + setFocusPolicy(Qt::ClickFocus); + + button_map = { + ui->buttonA, ui->buttonB, ui->buttonX, ui->buttonY, ui->buttonDpadUp, + ui->buttonDpadDown, ui->buttonDpadLeft, ui->buttonDpadRight, ui->buttonL, ui->buttonR, + ui->buttonStart, ui->buttonSelect, ui->buttonZL, ui->buttonZR, ui->buttonHome, + }; + + analog_map = {{ + { + ui->buttonCircleUp, ui->buttonCircleDown, ui->buttonCircleLeft, ui->buttonCircleRight, + ui->buttonCircleMod, + }, + { + ui->buttonCStickUp, ui->buttonCStickDown, ui->buttonCStickLeft, ui->buttonCStickRight, + nullptr, + }, + }}; + + for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) { + if (button_map[button_id]) + connect(button_map[button_id], &QPushButton::released, [=]() { + handleClick(button_map[button_id], + [=](int key) { SetButtonKey(key, buttons_param[button_id]); }); + }); + } + + for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) { + for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) { + if (analog_map[analog_id][sub_button_id] != nullptr) { + connect(analog_map[analog_id][sub_button_id], &QPushButton::released, [=]() { + handleClick(analog_map[analog_id][sub_button_id], [=](int key) { + SetAnalogKey(key, analogs_param[analog_id], + analog_sub_buttons[sub_button_id]); + }); + }); + } + } + } + + connect(ui->buttonRestoreDefaults, &QPushButton::released, [this]() { restoreDefaults(); }); + + timer->setSingleShot(true); + connect(timer.get(), &QTimer::timeout, [this]() { + releaseKeyboard(); + releaseMouse(); + key_setter = boost::none; + updateButtonLabels(); + }); + + this->loadConfiguration(); + + // TODO(wwylele): enable these when the input emulation for them is implemented + ui->buttonZL->setEnabled(false); + ui->buttonZR->setEnabled(false); + ui->buttonHome->setEnabled(false); + ui->buttonCStickUp->setEnabled(false); + ui->buttonCStickDown->setEnabled(false); + ui->buttonCStickLeft->setEnabled(false); + ui->buttonCStickRight->setEnabled(false); +} + +void ConfigureInput::applyConfiguration() { + std::transform(buttons_param.begin(), buttons_param.end(), Settings::values.buttons.begin(), + [](const Common::ParamPackage& param) { return param.Serialize(); }); + std::transform(analogs_param.begin(), analogs_param.end(), Settings::values.analogs.begin(), + [](const Common::ParamPackage& param) { return param.Serialize(); }); + + Settings::Apply(); +} + +void ConfigureInput::loadConfiguration() { + std::transform(Settings::values.buttons.begin(), Settings::values.buttons.end(), + buttons_param.begin(), + [](const std::string& str) { return Common::ParamPackage(str); }); + std::transform(Settings::values.analogs.begin(), Settings::values.analogs.end(), + analogs_param.begin(), + [](const std::string& str) { return Common::ParamPackage(str); }); + updateButtonLabels(); +} + +void ConfigureInput::restoreDefaults() { + for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) { + SetButtonKey(Config::default_buttons[button_id], buttons_param[button_id]); + } + + for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) { + for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) { + SetAnalogKey(Config::default_analogs[analog_id][sub_button_id], + analogs_param[analog_id], analog_sub_buttons[sub_button_id]); + } + } + updateButtonLabels(); + applyConfiguration(); +} + +void ConfigureInput::updateButtonLabels() { + QString non_keyboard(tr("[non-keyboard]")); + + auto KeyToText = [&non_keyboard](const Common::ParamPackage& param) { + if (param.Get("engine", "") != "keyboard") { + return non_keyboard; + } else { + return getKeyName(param.Get("code", 0)); + } + }; + + for (int button = 0; button < Settings::NativeButton::NumButtons; button++) { + button_map[button]->setText(KeyToText(buttons_param[button])); + } + + for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) { + if (analogs_param[analog_id].Get("engine", "") != "analog_from_button") { + for (QPushButton* button : analog_map[analog_id]) { + if (button) + button->setText(non_keyboard); + } + } else { + for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) { + Common::ParamPackage param( + analogs_param[analog_id].Get(analog_sub_buttons[sub_button_id], "")); + if (analog_map[analog_id][sub_button_id]) + analog_map[analog_id][sub_button_id]->setText(KeyToText(param)); + } + } + } +} + +void ConfigureInput::handleClick(QPushButton* button, std::function new_key_setter) { + button->setText(tr("[press key]")); + button->setFocus(); + + key_setter = new_key_setter; + + grabKeyboard(); + grabMouse(); + timer->start(5000); // Cancel after 5 seconds +} + +void ConfigureInput::keyPressEvent(QKeyEvent* event) { + releaseKeyboard(); + releaseMouse(); + + if (!key_setter || !event) + return; + + if (event->key() != Qt::Key_Escape) + (*key_setter)(event->key()); + + updateButtonLabels(); + key_setter = boost::none; + timer->stop(); +} diff --git a/src/citra_qt/configuration/configure_input.h b/src/citra_qt/configuration/configure_input.h new file mode 100644 index 000000000..c950fbcb4 --- /dev/null +++ b/src/citra_qt/configuration/configure_input.h @@ -0,0 +1,69 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include "common/param_package.h" +#include "core/settings.h" +#include "ui_configure_input.h" + +class QPushButton; +class QString; +class QTimer; + +namespace Ui { +class ConfigureInput; +} + +class ConfigureInput : public QWidget { + Q_OBJECT + +public: + explicit ConfigureInput(QWidget* parent = nullptr); + + /// Save all button configurations to settings file + void applyConfiguration(); + +private: + std::unique_ptr ui; + + std::unique_ptr timer; + + /// This will be the the setting function when an input is awaiting configuration. + boost::optional> key_setter; + + std::array buttons_param; + std::array analogs_param; + + static constexpr int ANALOG_SUB_BUTTONS_NUM = 5; + + /// Each button input is represented by a QPushButton. + std::array button_map; + + /// Each analog input is represented by five QPushButtons which represents up, down, left, right + /// and modifier + std::array, Settings::NativeAnalog::NumAnalogs> + analog_map; + + static const std::array analog_sub_buttons; + + /// Load configuration settings. + void loadConfiguration(); + /// Restore all buttons to their default values. + void restoreDefaults(); + /// Update UI to reflect current configuration. + void updateButtonLabels(); + + /// Called when the button was pressed. + void handleClick(QPushButton* button, std::function new_key_setter); + /// Handle key press events. + void keyPressEvent(QKeyEvent* event) override; +}; diff --git a/src/citra_qt/configuration/configure_input.ui b/src/citra_qt/configuration/configure_input.ui new file mode 100644 index 000000000..2760787e5 --- /dev/null +++ b/src/citra_qt/configuration/configure_input.ui @@ -0,0 +1,592 @@ + + + ConfigureInput + + + + 0 + 0 + 370 + 534 + + + + ConfigureInput + + + + + + + + Face Buttons + + + false + + + false + + + + + + + + A: + + + + + + + + + + + + + + + + + + B: + + + + + + + + + + + + + + + + + + X: + + + + + + + + + + + + + + + + + + Y: + + + + + + + + + + + + + + + + + + + Directional Pad + + + false + + + false + + + + + + + + Up: + + + + + + + + + + + + + + + + + + Down: + + + + + + + + + + + + + + + + + + Left: + + + + + + + + + + + + + + + + + + Right: + + + + + + + + + + + + + + + + + + + Shoulder Buttons + + + false + + + false + + + + + + + + L: + + + + + + + + + + + + + + + + + + R: + + + + + + + + + + + + + + + + + + ZL: + + + + + + + + + + + + + + + + + + ZR: + + + + + + + + + + + + + + + + + + + Circle Pad + + + false + + + false + + + + + + + + Left: + + + + + + + + + + + + + + + + + + Right: + + + + + + + + + + + + + + + + + + Up: + + + + + + + + + + + + + + + + + + Down: + + + + + + + + + + + + + + + + + + + C-Stick + + + false + + + false + + + + + + + + Left: + + + + + + + + + + + + + + + + + + Right: + + + + + + + + + + + + + + + + + + Up: + + + + + + + + + + + + + + + + + + Down: + + + + + + + + + + + + + + + + + + + Misc. + + + false + + + false + + + + + + + + Start: + + + + + + + + + + + + + + + + + + Select: + + + + + + + + + + + + + + + + + + Home: + + + + + + + + + + + + + + + + + + Circle Mod: + + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 0 + 0 + + + + Qt::LeftToRight + + + Restore Defaults + + + + + + + + + + diff --git a/src/citra_qt/configuration/configure_system.cpp b/src/citra_qt/configuration/configure_system.cpp new file mode 100644 index 000000000..a3a9015a4 --- /dev/null +++ b/src/citra_qt/configuration/configure_system.cpp @@ -0,0 +1,142 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "citra_qt/configuration/configure_system.h" +#include "citra_qt/ui_settings.h" +#include "core/core.h" +#include "core/hle/service/cfg/cfg.h" +#include "core/hle/service/fs/archive.h" +#include "ui_configure_system.h" + +static const std::array days_in_month = {{ + 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, +}}; + +ConfigureSystem::ConfigureSystem(QWidget* parent) : QWidget(parent), ui(new Ui::ConfigureSystem) { + ui->setupUi(this); + connect(ui->combo_birthmonth, SIGNAL(currentIndexChanged(int)), + SLOT(updateBirthdayComboBox(int))); + + this->setConfiguration(); +} + +ConfigureSystem::~ConfigureSystem() {} + +void ConfigureSystem::setConfiguration() { + enabled = !Core::System::GetInstance().IsPoweredOn(); + + if (!enabled) { + ReadSystemSettings(); + ui->group_system_settings->setEnabled(false); + } else { + // This tab is enabled only when game is not running (i.e. all service are not initialized). + // Temporarily register archive types and load the config savegame file to memory. + Service::FS::RegisterArchiveTypes(); + ResultCode result = Service::CFG::LoadConfigNANDSaveFile(); + Service::FS::UnregisterArchiveTypes(); + + if (result.IsError()) { + ui->label_disable_info->setText(tr("Failed to load system settings data.")); + ui->group_system_settings->setEnabled(false); + enabled = false; + return; + } + + ReadSystemSettings(); + ui->label_disable_info->hide(); + } +} + +void ConfigureSystem::ReadSystemSettings() { + // set username + username = Service::CFG::GetUsername(); + // TODO(wwylele): Use this when we move to Qt 5.5 + // ui->edit_username->setText(QString::fromStdU16String(username)); + ui->edit_username->setText( + QString::fromUtf16(reinterpret_cast(username.data()))); + + // set birthday + std::tie(birthmonth, birthday) = Service::CFG::GetBirthday(); + ui->combo_birthmonth->setCurrentIndex(birthmonth - 1); + updateBirthdayComboBox( + birthmonth - + 1); // explicitly update it because the signal from setCurrentIndex is not reliable + ui->combo_birthday->setCurrentIndex(birthday - 1); + + // set system language + language_index = Service::CFG::GetSystemLanguage(); + ui->combo_language->setCurrentIndex(language_index); + + // set sound output mode + sound_index = Service::CFG::GetSoundOutputMode(); + ui->combo_sound->setCurrentIndex(sound_index); +} + +void ConfigureSystem::applyConfiguration() { + if (!enabled) + return; + + bool modified = false; + + // apply username + // TODO(wwylele): Use this when we move to Qt 5.5 + // std::u16string new_username = ui->edit_username->text().toStdU16String(); + std::u16string new_username( + reinterpret_cast(ui->edit_username->text().utf16())); + if (new_username != username) { + Service::CFG::SetUsername(new_username); + modified = true; + } + + // apply birthday + int new_birthmonth = ui->combo_birthmonth->currentIndex() + 1; + int new_birthday = ui->combo_birthday->currentIndex() + 1; + if (birthmonth != new_birthmonth || birthday != new_birthday) { + Service::CFG::SetBirthday(new_birthmonth, new_birthday); + modified = true; + } + + // apply language + int new_language = ui->combo_language->currentIndex(); + if (language_index != new_language) { + Service::CFG::SetSystemLanguage(static_cast(new_language)); + modified = true; + } + + // apply sound + int new_sound = ui->combo_sound->currentIndex(); + if (sound_index != new_sound) { + Service::CFG::SetSoundOutputMode(static_cast(new_sound)); + modified = true; + } + + // update the config savegame if any item is modified. + if (modified) + Service::CFG::UpdateConfigNANDSavegame(); +} + +void ConfigureSystem::updateBirthdayComboBox(int birthmonth_index) { + if (birthmonth_index < 0 || birthmonth_index >= 12) + return; + + // store current day selection + int birthday_index = ui->combo_birthday->currentIndex(); + + // get number of days in the new selected month + int days = days_in_month[birthmonth_index]; + + // if the selected day is out of range, + // reset it to 1st + if (birthday_index < 0 || birthday_index >= days) + birthday_index = 0; + + // update the day combo box + ui->combo_birthday->clear(); + for (int i = 1; i <= days; ++i) { + ui->combo_birthday->addItem(QString::number(i)); + } + + // restore the day selection + ui->combo_birthday->setCurrentIndex(birthday_index); +} diff --git a/src/citra_qt/configuration/configure_system.h b/src/citra_qt/configuration/configure_system.h new file mode 100644 index 000000000..db0ead13c --- /dev/null +++ b/src/citra_qt/configuration/configure_system.h @@ -0,0 +1,37 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include + +namespace Ui { +class ConfigureSystem; +} + +class ConfigureSystem : public QWidget { + Q_OBJECT + +public: + explicit ConfigureSystem(QWidget* parent = nullptr); + ~ConfigureSystem(); + + void applyConfiguration(); + void setConfiguration(); + +public slots: + void updateBirthdayComboBox(int birthmonth_index); + +private: + void ReadSystemSettings(); + + std::unique_ptr ui; + bool enabled; + + std::u16string username; + int birthmonth, birthday; + int language_index; + int sound_index; +}; diff --git a/src/citra_qt/configuration/configure_system.ui b/src/citra_qt/configuration/configure_system.ui new file mode 100644 index 000000000..cc54fa37f --- /dev/null +++ b/src/citra_qt/configuration/configure_system.ui @@ -0,0 +1,255 @@ + + + ConfigureSystem + + + + 0 + 0 + 360 + 377 + + + + Form + + + + + + + + System Settings + + + + + + Username + + + + + + + + 0 + 0 + + + + 10 + + + + + + + Birthday + + + + + + + + + + January + + + + + February + + + + + March + + + + + April + + + + + May + + + + + June + + + + + July + + + + + August + + + + + September + + + + + October + + + + + November + + + + + December + + + + + + + + + + + + + Language + + + + + + + Note: this can be overridden when region setting is auto-select + + + + Japanese (日本語) + + + + + English + + + + + French (français) + + + + + German (Deutsch) + + + + + Italian (italiano) + + + + + Spanish (español) + + + + + Simplified Chinese (简体中文) + + + + + Korean (한국어) + + + + + Dutch (Nederlands) + + + + + Portuguese (português) + + + + + Russian (Русский) + + + + + Traditional Chinese (正體中文) + + + + + + + + Sound output mode + + + + + + + + Mono + + + + + Stereo + + + + + Surround + + + + + + + + + + + System settings are available only when game is not running. + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + diff --git a/src/citra_qt/configure.ui b/src/citra_qt/configure.ui deleted file mode 100644 index 28b4a3b90..000000000 --- a/src/citra_qt/configure.ui +++ /dev/null @@ -1,136 +0,0 @@ - - - ConfigureDialog - - - - 0 - 0 - 441 - 501 - - - - Citra Configuration - - - - - - 0 - - - - General - - - - - System - - - - - Input - - - - - Graphics - - - - - Audio - - - - - Debug - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - ConfigureGeneral - QWidget -
configure_general.h
- 1 -
- - ConfigureSystem - QWidget -
configure_system.h
- 1 -
- - ConfigureAudio - QWidget -
configure_audio.h
- 1 -
- - ConfigureDebug - QWidget -
configure_debug.h
- 1 -
- - ConfigureInput - QWidget -
configure_input.h
- 1 -
- - ConfigureGraphics - QWidget -
configure_graphics.h
- 1 -
-
- - - - buttonBox - accepted() - ConfigureDialog - accept() - - - 220 - 380 - - - 220 - 200 - - - - - buttonBox - rejected() - ConfigureDialog - reject() - - - 220 - 380 - - - 220 - 200 - - - - -
diff --git a/src/citra_qt/configure_audio.cpp b/src/citra_qt/configure_audio.cpp deleted file mode 100644 index 3ddcf9232..000000000 --- a/src/citra_qt/configure_audio.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2016 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include -#include "audio_core/audio_core.h" -#include "audio_core/sink.h" -#include "audio_core/sink_details.h" -#include "citra_qt/configure_audio.h" -#include "core/settings.h" -#include "ui_configure_audio.h" - -ConfigureAudio::ConfigureAudio(QWidget* parent) - : QWidget(parent), ui(std::make_unique()) { - ui->setupUi(this); - - ui->output_sink_combo_box->clear(); - ui->output_sink_combo_box->addItem("auto"); - for (const auto& sink_detail : AudioCore::g_sink_details) { - ui->output_sink_combo_box->addItem(sink_detail.id); - } - - this->setConfiguration(); - connect(ui->output_sink_combo_box, SIGNAL(currentIndexChanged(int)), this, - SLOT(updateAudioDevices(int))); -} - -ConfigureAudio::~ConfigureAudio() {} - -void ConfigureAudio::setConfiguration() { - int new_sink_index = 0; - for (int index = 0; index < ui->output_sink_combo_box->count(); index++) { - if (ui->output_sink_combo_box->itemText(index).toStdString() == Settings::values.sink_id) { - new_sink_index = index; - break; - } - } - ui->output_sink_combo_box->setCurrentIndex(new_sink_index); - - ui->toggle_audio_stretching->setChecked(Settings::values.enable_audio_stretching); - - // The device list cannot be pre-populated (nor listed) until the output sink is known. - updateAudioDevices(new_sink_index); - - int new_device_index = -1; - for (int index = 0; index < ui->audio_device_combo_box->count(); index++) { - if (ui->audio_device_combo_box->itemText(index).toStdString() == - Settings::values.audio_device_id) { - new_device_index = index; - break; - } - } - ui->audio_device_combo_box->setCurrentIndex(new_device_index); -} - -void ConfigureAudio::applyConfiguration() { - Settings::values.sink_id = - ui->output_sink_combo_box->itemText(ui->output_sink_combo_box->currentIndex()) - .toStdString(); - Settings::values.enable_audio_stretching = ui->toggle_audio_stretching->isChecked(); - Settings::values.audio_device_id = - ui->audio_device_combo_box->itemText(ui->audio_device_combo_box->currentIndex()) - .toStdString(); - Settings::Apply(); -} - -void ConfigureAudio::updateAudioDevices(int sink_index) { - ui->audio_device_combo_box->clear(); - ui->audio_device_combo_box->addItem("auto"); - - std::string sink_id = ui->output_sink_combo_box->itemText(sink_index).toStdString(); - std::vector device_list = - AudioCore::GetSinkDetails(sink_id).factory()->GetDeviceList(); - for (const auto& device : device_list) { - ui->audio_device_combo_box->addItem(device.c_str()); - } -} diff --git a/src/citra_qt/configure_audio.h b/src/citra_qt/configure_audio.h deleted file mode 100644 index 8190e694f..000000000 --- a/src/citra_qt/configure_audio.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include -#include - -namespace Ui { -class ConfigureAudio; -} - -class ConfigureAudio : public QWidget { - Q_OBJECT - -public: - explicit ConfigureAudio(QWidget* parent = nullptr); - ~ConfigureAudio(); - - void applyConfiguration(); - -public slots: - void updateAudioDevices(int sink_index); - -private: - void setConfiguration(); - - std::unique_ptr ui; -}; diff --git a/src/citra_qt/configure_audio.ui b/src/citra_qt/configure_audio.ui deleted file mode 100644 index dd870eb61..000000000 --- a/src/citra_qt/configure_audio.ui +++ /dev/null @@ -1,73 +0,0 @@ - - - - ConfigureAudio - - - - - - Audio - - - - - - - - Output Engine: - - - - - - - - - - - - - Enable audio stretching - - - This post-processing effect adjusts audio speed to match emulation speed and helps prevent audio stutter. This however increases audio latency. - - - - - - - - - Audio Device: - - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - diff --git a/src/citra_qt/configure_debug.cpp b/src/citra_qt/configure_debug.cpp deleted file mode 100644 index dcc398eee..000000000 --- a/src/citra_qt/configure_debug.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "citra_qt/configure_debug.h" -#include "core/settings.h" -#include "ui_configure_debug.h" - -ConfigureDebug::ConfigureDebug(QWidget* parent) : QWidget(parent), ui(new Ui::ConfigureDebug) { - ui->setupUi(this); - this->setConfiguration(); -} - -ConfigureDebug::~ConfigureDebug() {} - -void ConfigureDebug::setConfiguration() { - ui->toggle_gdbstub->setChecked(Settings::values.use_gdbstub); - ui->gdbport_spinbox->setEnabled(Settings::values.use_gdbstub); - ui->gdbport_spinbox->setValue(Settings::values.gdbstub_port); -} - -void ConfigureDebug::applyConfiguration() { - Settings::values.use_gdbstub = ui->toggle_gdbstub->isChecked(); - Settings::values.gdbstub_port = ui->gdbport_spinbox->value(); - Settings::Apply(); -} diff --git a/src/citra_qt/configure_debug.h b/src/citra_qt/configure_debug.h deleted file mode 100644 index d167eb996..000000000 --- a/src/citra_qt/configure_debug.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include -#include - -namespace Ui { -class ConfigureDebug; -} - -class ConfigureDebug : public QWidget { - Q_OBJECT - -public: - explicit ConfigureDebug(QWidget* parent = nullptr); - ~ConfigureDebug(); - - void applyConfiguration(); - -private: - void setConfiguration(); - -private: - std::unique_ptr ui; -}; diff --git a/src/citra_qt/configure_debug.ui b/src/citra_qt/configure_debug.ui deleted file mode 100644 index bbbb0e3f4..000000000 --- a/src/citra_qt/configure_debug.ui +++ /dev/null @@ -1,102 +0,0 @@ - - - ConfigureDebug - - - - 0 - 0 - 400 - 300 - - - - Form - - - - - - - - GDB - - - - - - - - Enable GDB Stub - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Port: - - - - - - - 65536 - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - toggle_gdbstub - toggled(bool) - gdbport_spinbox - setEnabled(bool) - - - 84 - 157 - - - 342 - 158 - - - - - diff --git a/src/citra_qt/configure_dialog.cpp b/src/citra_qt/configure_dialog.cpp deleted file mode 100644 index 525a7cc4e..000000000 --- a/src/citra_qt/configure_dialog.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "citra_qt/config.h" -#include "citra_qt/configure_dialog.h" -#include "core/settings.h" -#include "ui_configure.h" - -ConfigureDialog::ConfigureDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ConfigureDialog) { - ui->setupUi(this); - this->setConfiguration(); -} - -ConfigureDialog::~ConfigureDialog() {} - -void ConfigureDialog::setConfiguration() {} - -void ConfigureDialog::applyConfiguration() { - ui->generalTab->applyConfiguration(); - ui->systemTab->applyConfiguration(); - ui->inputTab->applyConfiguration(); - ui->graphicsTab->applyConfiguration(); - ui->audioTab->applyConfiguration(); - ui->debugTab->applyConfiguration(); - Settings::Apply(); -} diff --git a/src/citra_qt/configure_dialog.h b/src/citra_qt/configure_dialog.h deleted file mode 100644 index 21fa1f501..000000000 --- a/src/citra_qt/configure_dialog.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include -#include - -namespace Ui { -class ConfigureDialog; -} - -class ConfigureDialog : public QDialog { - Q_OBJECT - -public: - explicit ConfigureDialog(QWidget* parent); - ~ConfigureDialog(); - - void applyConfiguration(); - -private: - void setConfiguration(); - -private: - std::unique_ptr ui; -}; diff --git a/src/citra_qt/configure_general.cpp b/src/citra_qt/configure_general.cpp deleted file mode 100644 index ac90a6df4..000000000 --- a/src/citra_qt/configure_general.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2016 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "citra_qt/configure_general.h" -#include "citra_qt/ui_settings.h" -#include "core/core.h" -#include "core/settings.h" -#include "ui_configure_general.h" - -ConfigureGeneral::ConfigureGeneral(QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureGeneral) { - - ui->setupUi(this); - this->setConfiguration(); - - ui->toggle_cpu_jit->setEnabled(!Core::System::GetInstance().IsPoweredOn()); -} - -ConfigureGeneral::~ConfigureGeneral() {} - -void ConfigureGeneral::setConfiguration() { - ui->toggle_deepscan->setChecked(UISettings::values.gamedir_deepscan); - ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing); - ui->toggle_cpu_jit->setChecked(Settings::values.use_cpu_jit); - - // The first item is "auto-select" with actual value -1, so plus one here will do the trick - ui->region_combobox->setCurrentIndex(Settings::values.region_value + 1); -} - -void ConfigureGeneral::applyConfiguration() { - UISettings::values.gamedir_deepscan = ui->toggle_deepscan->isChecked(); - UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); - Settings::values.region_value = ui->region_combobox->currentIndex() - 1; - Settings::values.use_cpu_jit = ui->toggle_cpu_jit->isChecked(); - Settings::Apply(); -} diff --git a/src/citra_qt/configure_general.h b/src/citra_qt/configure_general.h deleted file mode 100644 index 447552d8c..000000000 --- a/src/citra_qt/configure_general.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include -#include - -namespace Ui { -class ConfigureGeneral; -} - -class ConfigureGeneral : public QWidget { - Q_OBJECT - -public: - explicit ConfigureGeneral(QWidget* parent = nullptr); - ~ConfigureGeneral(); - - void applyConfiguration(); - -private: - void setConfiguration(); - -private: - std::unique_ptr ui; -}; diff --git a/src/citra_qt/configure_general.ui b/src/citra_qt/configure_general.ui deleted file mode 100644 index c739605a4..000000000 --- a/src/citra_qt/configure_general.ui +++ /dev/null @@ -1,164 +0,0 @@ - - - ConfigureGeneral - - - - 0 - 0 - 300 - 377 - - - - Form - - - - - - - - General - - - - - - - - Search sub-directories for games - - - - - - - Confirm exit while emulation is running - - - - - - - - - - - - Performance - - - - - - - - Enable CPU JIT - - - - - - - - - - - - Emulation - - - - - - - - - - Region: - - - - - - - - Auto-select - - - - - JPN - - - - - USA - - - - - EUR - - - - - AUS - - - - - CHN - - - - - KOR - - - - - TWN - - - - - - - - - - - - - - - Hotkeys - - - - - - - - - - - - - - - - - - - GHotkeysDialog - QWidget -
hotkeys.h
- 1 -
-
- - -
diff --git a/src/citra_qt/configure_graphics.cpp b/src/citra_qt/configure_graphics.cpp deleted file mode 100644 index 4c0bd4246..000000000 --- a/src/citra_qt/configure_graphics.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2016 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "citra_qt/configure_graphics.h" -#include "core/core.h" -#include "core/settings.h" -#include "ui_configure_graphics.h" - -ConfigureGraphics::ConfigureGraphics(QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureGraphics) { - - ui->setupUi(this); - this->setConfiguration(); - - ui->toggle_vsync->setEnabled(!Core::System::GetInstance().IsPoweredOn()); - - ui->layoutBox->setEnabled(!Settings::values.custom_layout); -} - -ConfigureGraphics::~ConfigureGraphics() {} - -enum class Resolution : int { - Auto, - Scale1x, - Scale2x, - Scale3x, - Scale4x, - Scale5x, - Scale6x, - Scale7x, - Scale8x, - Scale9x, - Scale10x, -}; - -float ToResolutionFactor(Resolution option) { - switch (option) { - case Resolution::Auto: - return 0.f; - case Resolution::Scale1x: - return 1.f; - case Resolution::Scale2x: - return 2.f; - case Resolution::Scale3x: - return 3.f; - case Resolution::Scale4x: - return 4.f; - case Resolution::Scale5x: - return 5.f; - case Resolution::Scale6x: - return 6.f; - case Resolution::Scale7x: - return 7.f; - case Resolution::Scale8x: - return 8.f; - case Resolution::Scale9x: - return 9.f; - case Resolution::Scale10x: - return 10.f; - } - return 0.f; -} - -Resolution FromResolutionFactor(float factor) { - if (factor == 0.f) { - return Resolution::Auto; - } else if (factor == 1.f) { - return Resolution::Scale1x; - } else if (factor == 2.f) { - return Resolution::Scale2x; - } else if (factor == 3.f) { - return Resolution::Scale3x; - } else if (factor == 4.f) { - return Resolution::Scale4x; - } else if (factor == 5.f) { - return Resolution::Scale5x; - } else if (factor == 6.f) { - return Resolution::Scale6x; - } else if (factor == 7.f) { - return Resolution::Scale7x; - } else if (factor == 8.f) { - return Resolution::Scale8x; - } else if (factor == 9.f) { - return Resolution::Scale9x; - } else if (factor == 10.f) { - return Resolution::Scale10x; - } - return Resolution::Auto; -} - -void ConfigureGraphics::setConfiguration() { - ui->toggle_hw_renderer->setChecked(Settings::values.use_hw_renderer); - ui->resolution_factor_combobox->setEnabled(Settings::values.use_hw_renderer); - ui->toggle_shader_jit->setChecked(Settings::values.use_shader_jit); - ui->resolution_factor_combobox->setCurrentIndex( - static_cast(FromResolutionFactor(Settings::values.resolution_factor))); - ui->toggle_vsync->setChecked(Settings::values.use_vsync); - ui->toggle_framelimit->setChecked(Settings::values.toggle_framelimit); - ui->layout_combobox->setCurrentIndex(static_cast(Settings::values.layout_option)); - ui->swap_screen->setChecked(Settings::values.swap_screen); -} - -void ConfigureGraphics::applyConfiguration() { - Settings::values.use_hw_renderer = ui->toggle_hw_renderer->isChecked(); - Settings::values.use_shader_jit = ui->toggle_shader_jit->isChecked(); - Settings::values.resolution_factor = - ToResolutionFactor(static_cast(ui->resolution_factor_combobox->currentIndex())); - Settings::values.use_vsync = ui->toggle_vsync->isChecked(); - Settings::values.toggle_framelimit = ui->toggle_framelimit->isChecked(); - Settings::values.layout_option = - static_cast(ui->layout_combobox->currentIndex()); - Settings::values.swap_screen = ui->swap_screen->isChecked(); - Settings::Apply(); -} diff --git a/src/citra_qt/configure_graphics.h b/src/citra_qt/configure_graphics.h deleted file mode 100644 index 5497a55f7..000000000 --- a/src/citra_qt/configure_graphics.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include -#include - -namespace Ui { -class ConfigureGraphics; -} - -class ConfigureGraphics : public QWidget { - Q_OBJECT - -public: - explicit ConfigureGraphics(QWidget* parent = nullptr); - ~ConfigureGraphics(); - - void applyConfiguration(); - -private: - void setConfiguration(); - -private: - std::unique_ptr ui; -}; diff --git a/src/citra_qt/configure_graphics.ui b/src/citra_qt/configure_graphics.ui deleted file mode 100644 index 228f2a869..000000000 --- a/src/citra_qt/configure_graphics.ui +++ /dev/null @@ -1,202 +0,0 @@ - - - ConfigureGraphics - - - - 0 - 0 - 400 - 300 - - - - Form - - - - - - - - Graphics - - - - - - Enable hardware renderer - - - - - - - Enable shader JIT - - - - - - - Enable V-Sync - - - - - - - Limit framerate - - - - - - - - - Internal Resolution: - - - - - - - - Auto (Window Size) - - - - - Native (400x240) - - - - - 2x Native (800x480) - - - - - 3x Native (1200x720) - - - - - 4x Native (1600x960) - - - - - 5x Native (2000x1200) - - - - - 6x Native (2400x1440) - - - - - 7x Native (2800x1680) - - - - - 8x Native (3200x1920) - - - - - 9x Native (3600x2160) - - - - - 10x Native (4000x2400) - - - - - - - - - - - - - - - Layout - - - - - - - - - - Screen Layout: - - - - - - - - Default - - - - - Single Screen - - - - - Large Screen - - - - - - - - - - Swap Screens - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - toggle_hw_renderer - toggled(bool) - resolution_factor_combobox - setEnabled(bool) - - - diff --git a/src/citra_qt/configure_input.cpp b/src/citra_qt/configure_input.cpp deleted file mode 100644 index b59713e2c..000000000 --- a/src/citra_qt/configure_input.cpp +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright 2016 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include -#include -#include -#include -#include "citra_qt/config.h" -#include "citra_qt/configure_input.h" -#include "common/param_package.h" -#include "input_common/main.h" - -const std::array - ConfigureInput::analog_sub_buttons{{ - "up", "down", "left", "right", "modifier", - }}; - -static QString getKeyName(int key_code) { - switch (key_code) { - case Qt::Key_Shift: - return QObject::tr("Shift"); - case Qt::Key_Control: - return QObject::tr("Ctrl"); - case Qt::Key_Alt: - return QObject::tr("Alt"); - case Qt::Key_Meta: - return ""; - default: - return QKeySequence(key_code).toString(); - } -} - -static void SetButtonKey(int key, Common::ParamPackage& button_param) { - button_param = Common::ParamPackage{InputCommon::GenerateKeyboardParam(key)}; -} - -static void SetAnalogKey(int key, Common::ParamPackage& analog_param, - const std::string& button_name) { - if (analog_param.Get("engine", "") != "analog_from_button") { - analog_param = { - {"engine", "analog_from_button"}, {"modifier_scale", "0.5"}, - }; - } - analog_param.Set(button_name, InputCommon::GenerateKeyboardParam(key)); -} - -ConfigureInput::ConfigureInput(QWidget* parent) - : QWidget(parent), ui(std::make_unique()), - timer(std::make_unique()) { - - ui->setupUi(this); - setFocusPolicy(Qt::ClickFocus); - - button_map = { - ui->buttonA, ui->buttonB, ui->buttonX, ui->buttonY, ui->buttonDpadUp, - ui->buttonDpadDown, ui->buttonDpadLeft, ui->buttonDpadRight, ui->buttonL, ui->buttonR, - ui->buttonStart, ui->buttonSelect, ui->buttonZL, ui->buttonZR, ui->buttonHome, - }; - - analog_map = {{ - { - ui->buttonCircleUp, ui->buttonCircleDown, ui->buttonCircleLeft, ui->buttonCircleRight, - ui->buttonCircleMod, - }, - { - ui->buttonCStickUp, ui->buttonCStickDown, ui->buttonCStickLeft, ui->buttonCStickRight, - nullptr, - }, - }}; - - for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) { - if (button_map[button_id]) - connect(button_map[button_id], &QPushButton::released, [=]() { - handleClick(button_map[button_id], - [=](int key) { SetButtonKey(key, buttons_param[button_id]); }); - }); - } - - for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) { - for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) { - if (analog_map[analog_id][sub_button_id] != nullptr) { - connect(analog_map[analog_id][sub_button_id], &QPushButton::released, [=]() { - handleClick(analog_map[analog_id][sub_button_id], [=](int key) { - SetAnalogKey(key, analogs_param[analog_id], - analog_sub_buttons[sub_button_id]); - }); - }); - } - } - } - - connect(ui->buttonRestoreDefaults, &QPushButton::released, [this]() { restoreDefaults(); }); - - timer->setSingleShot(true); - connect(timer.get(), &QTimer::timeout, [this]() { - releaseKeyboard(); - releaseMouse(); - key_setter = boost::none; - updateButtonLabels(); - }); - - this->loadConfiguration(); - - // TODO(wwylele): enable these when the input emulation for them is implemented - ui->buttonZL->setEnabled(false); - ui->buttonZR->setEnabled(false); - ui->buttonHome->setEnabled(false); - ui->buttonCStickUp->setEnabled(false); - ui->buttonCStickDown->setEnabled(false); - ui->buttonCStickLeft->setEnabled(false); - ui->buttonCStickRight->setEnabled(false); -} - -void ConfigureInput::applyConfiguration() { - std::transform(buttons_param.begin(), buttons_param.end(), Settings::values.buttons.begin(), - [](const Common::ParamPackage& param) { return param.Serialize(); }); - std::transform(analogs_param.begin(), analogs_param.end(), Settings::values.analogs.begin(), - [](const Common::ParamPackage& param) { return param.Serialize(); }); - - Settings::Apply(); -} - -void ConfigureInput::loadConfiguration() { - std::transform(Settings::values.buttons.begin(), Settings::values.buttons.end(), - buttons_param.begin(), - [](const std::string& str) { return Common::ParamPackage(str); }); - std::transform(Settings::values.analogs.begin(), Settings::values.analogs.end(), - analogs_param.begin(), - [](const std::string& str) { return Common::ParamPackage(str); }); - updateButtonLabels(); -} - -void ConfigureInput::restoreDefaults() { - for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) { - SetButtonKey(Config::default_buttons[button_id], buttons_param[button_id]); - } - - for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) { - for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) { - SetAnalogKey(Config::default_analogs[analog_id][sub_button_id], - analogs_param[analog_id], analog_sub_buttons[sub_button_id]); - } - } - updateButtonLabels(); - applyConfiguration(); -} - -void ConfigureInput::updateButtonLabels() { - QString non_keyboard(tr("[non-keyboard]")); - - auto KeyToText = [&non_keyboard](const Common::ParamPackage& param) { - if (param.Get("engine", "") != "keyboard") { - return non_keyboard; - } else { - return getKeyName(param.Get("code", 0)); - } - }; - - for (int button = 0; button < Settings::NativeButton::NumButtons; button++) { - button_map[button]->setText(KeyToText(buttons_param[button])); - } - - for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) { - if (analogs_param[analog_id].Get("engine", "") != "analog_from_button") { - for (QPushButton* button : analog_map[analog_id]) { - if (button) - button->setText(non_keyboard); - } - } else { - for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) { - Common::ParamPackage param( - analogs_param[analog_id].Get(analog_sub_buttons[sub_button_id], "")); - if (analog_map[analog_id][sub_button_id]) - analog_map[analog_id][sub_button_id]->setText(KeyToText(param)); - } - } - } -} - -void ConfigureInput::handleClick(QPushButton* button, std::function new_key_setter) { - button->setText(tr("[press key]")); - button->setFocus(); - - key_setter = new_key_setter; - - grabKeyboard(); - grabMouse(); - timer->start(5000); // Cancel after 5 seconds -} - -void ConfigureInput::keyPressEvent(QKeyEvent* event) { - releaseKeyboard(); - releaseMouse(); - - if (!key_setter || !event) - return; - - if (event->key() != Qt::Key_Escape) - (*key_setter)(event->key()); - - updateButtonLabels(); - key_setter = boost::none; - timer->stop(); -} diff --git a/src/citra_qt/configure_input.h b/src/citra_qt/configure_input.h deleted file mode 100644 index c950fbcb4..000000000 --- a/src/citra_qt/configure_input.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2016 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include "common/param_package.h" -#include "core/settings.h" -#include "ui_configure_input.h" - -class QPushButton; -class QString; -class QTimer; - -namespace Ui { -class ConfigureInput; -} - -class ConfigureInput : public QWidget { - Q_OBJECT - -public: - explicit ConfigureInput(QWidget* parent = nullptr); - - /// Save all button configurations to settings file - void applyConfiguration(); - -private: - std::unique_ptr ui; - - std::unique_ptr timer; - - /// This will be the the setting function when an input is awaiting configuration. - boost::optional> key_setter; - - std::array buttons_param; - std::array analogs_param; - - static constexpr int ANALOG_SUB_BUTTONS_NUM = 5; - - /// Each button input is represented by a QPushButton. - std::array button_map; - - /// Each analog input is represented by five QPushButtons which represents up, down, left, right - /// and modifier - std::array, Settings::NativeAnalog::NumAnalogs> - analog_map; - - static const std::array analog_sub_buttons; - - /// Load configuration settings. - void loadConfiguration(); - /// Restore all buttons to their default values. - void restoreDefaults(); - /// Update UI to reflect current configuration. - void updateButtonLabels(); - - /// Called when the button was pressed. - void handleClick(QPushButton* button, std::function new_key_setter); - /// Handle key press events. - void keyPressEvent(QKeyEvent* event) override; -}; diff --git a/src/citra_qt/configure_input.ui b/src/citra_qt/configure_input.ui deleted file mode 100644 index 2760787e5..000000000 --- a/src/citra_qt/configure_input.ui +++ /dev/null @@ -1,592 +0,0 @@ - - - ConfigureInput - - - - 0 - 0 - 370 - 534 - - - - ConfigureInput - - - - - - - - Face Buttons - - - false - - - false - - - - - - - - A: - - - - - - - - - - - - - - - - - - B: - - - - - - - - - - - - - - - - - - X: - - - - - - - - - - - - - - - - - - Y: - - - - - - - - - - - - - - - - - - - Directional Pad - - - false - - - false - - - - - - - - Up: - - - - - - - - - - - - - - - - - - Down: - - - - - - - - - - - - - - - - - - Left: - - - - - - - - - - - - - - - - - - Right: - - - - - - - - - - - - - - - - - - - Shoulder Buttons - - - false - - - false - - - - - - - - L: - - - - - - - - - - - - - - - - - - R: - - - - - - - - - - - - - - - - - - ZL: - - - - - - - - - - - - - - - - - - ZR: - - - - - - - - - - - - - - - - - - - Circle Pad - - - false - - - false - - - - - - - - Left: - - - - - - - - - - - - - - - - - - Right: - - - - - - - - - - - - - - - - - - Up: - - - - - - - - - - - - - - - - - - Down: - - - - - - - - - - - - - - - - - - - C-Stick - - - false - - - false - - - - - - - - Left: - - - - - - - - - - - - - - - - - - Right: - - - - - - - - - - - - - - - - - - Up: - - - - - - - - - - - - - - - - - - Down: - - - - - - - - - - - - - - - - - - - Misc. - - - false - - - false - - - - - - - - Start: - - - - - - - - - - - - - - - - - - Select: - - - - - - - - - - - - - - - - - - Home: - - - - - - - - - - - - - - - - - - Circle Mod: - - - - - - - - - - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 0 - 0 - - - - Qt::LeftToRight - - - Restore Defaults - - - - - - - - - - diff --git a/src/citra_qt/configure_system.cpp b/src/citra_qt/configure_system.cpp deleted file mode 100644 index 040185e82..000000000 --- a/src/citra_qt/configure_system.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright 2016 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "citra_qt/configure_system.h" -#include "citra_qt/ui_settings.h" -#include "core/core.h" -#include "core/hle/service/cfg/cfg.h" -#include "core/hle/service/fs/archive.h" -#include "ui_configure_system.h" - -static const std::array days_in_month = {{ - 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, -}}; - -ConfigureSystem::ConfigureSystem(QWidget* parent) : QWidget(parent), ui(new Ui::ConfigureSystem) { - ui->setupUi(this); - connect(ui->combo_birthmonth, SIGNAL(currentIndexChanged(int)), - SLOT(updateBirthdayComboBox(int))); - - this->setConfiguration(); -} - -ConfigureSystem::~ConfigureSystem() {} - -void ConfigureSystem::setConfiguration() { - enabled = !Core::System::GetInstance().IsPoweredOn(); - - if (!enabled) { - ReadSystemSettings(); - ui->group_system_settings->setEnabled(false); - } else { - // This tab is enabled only when game is not running (i.e. all service are not initialized). - // Temporarily register archive types and load the config savegame file to memory. - Service::FS::RegisterArchiveTypes(); - ResultCode result = Service::CFG::LoadConfigNANDSaveFile(); - Service::FS::UnregisterArchiveTypes(); - - if (result.IsError()) { - ui->label_disable_info->setText(tr("Failed to load system settings data.")); - ui->group_system_settings->setEnabled(false); - enabled = false; - return; - } - - ReadSystemSettings(); - ui->label_disable_info->hide(); - } -} - -void ConfigureSystem::ReadSystemSettings() { - // set username - username = Service::CFG::GetUsername(); - // TODO(wwylele): Use this when we move to Qt 5.5 - // ui->edit_username->setText(QString::fromStdU16String(username)); - ui->edit_username->setText( - QString::fromUtf16(reinterpret_cast(username.data()))); - - // set birthday - std::tie(birthmonth, birthday) = Service::CFG::GetBirthday(); - ui->combo_birthmonth->setCurrentIndex(birthmonth - 1); - updateBirthdayComboBox( - birthmonth - - 1); // explicitly update it because the signal from setCurrentIndex is not reliable - ui->combo_birthday->setCurrentIndex(birthday - 1); - - // set system language - language_index = Service::CFG::GetSystemLanguage(); - ui->combo_language->setCurrentIndex(language_index); - - // set sound output mode - sound_index = Service::CFG::GetSoundOutputMode(); - ui->combo_sound->setCurrentIndex(sound_index); -} - -void ConfigureSystem::applyConfiguration() { - if (!enabled) - return; - - bool modified = false; - - // apply username - // TODO(wwylele): Use this when we move to Qt 5.5 - // std::u16string new_username = ui->edit_username->text().toStdU16String(); - std::u16string new_username( - reinterpret_cast(ui->edit_username->text().utf16())); - if (new_username != username) { - Service::CFG::SetUsername(new_username); - modified = true; - } - - // apply birthday - int new_birthmonth = ui->combo_birthmonth->currentIndex() + 1; - int new_birthday = ui->combo_birthday->currentIndex() + 1; - if (birthmonth != new_birthmonth || birthday != new_birthday) { - Service::CFG::SetBirthday(new_birthmonth, new_birthday); - modified = true; - } - - // apply language - int new_language = ui->combo_language->currentIndex(); - if (language_index != new_language) { - Service::CFG::SetSystemLanguage(static_cast(new_language)); - modified = true; - } - - // apply sound - int new_sound = ui->combo_sound->currentIndex(); - if (sound_index != new_sound) { - Service::CFG::SetSoundOutputMode(static_cast(new_sound)); - modified = true; - } - - // update the config savegame if any item is modified. - if (modified) - Service::CFG::UpdateConfigNANDSavegame(); -} - -void ConfigureSystem::updateBirthdayComboBox(int birthmonth_index) { - if (birthmonth_index < 0 || birthmonth_index >= 12) - return; - - // store current day selection - int birthday_index = ui->combo_birthday->currentIndex(); - - // get number of days in the new selected month - int days = days_in_month[birthmonth_index]; - - // if the selected day is out of range, - // reset it to 1st - if (birthday_index < 0 || birthday_index >= days) - birthday_index = 0; - - // update the day combo box - ui->combo_birthday->clear(); - for (int i = 1; i <= days; ++i) { - ui->combo_birthday->addItem(QString::number(i)); - } - - // restore the day selection - ui->combo_birthday->setCurrentIndex(birthday_index); -} diff --git a/src/citra_qt/configure_system.h b/src/citra_qt/configure_system.h deleted file mode 100644 index db0ead13c..000000000 --- a/src/citra_qt/configure_system.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2016 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include -#include - -namespace Ui { -class ConfigureSystem; -} - -class ConfigureSystem : public QWidget { - Q_OBJECT - -public: - explicit ConfigureSystem(QWidget* parent = nullptr); - ~ConfigureSystem(); - - void applyConfiguration(); - void setConfiguration(); - -public slots: - void updateBirthdayComboBox(int birthmonth_index); - -private: - void ReadSystemSettings(); - - std::unique_ptr ui; - bool enabled; - - std::u16string username; - int birthmonth, birthday; - int language_index; - int sound_index; -}; diff --git a/src/citra_qt/configure_system.ui b/src/citra_qt/configure_system.ui deleted file mode 100644 index cc54fa37f..000000000 --- a/src/citra_qt/configure_system.ui +++ /dev/null @@ -1,255 +0,0 @@ - - - ConfigureSystem - - - - 0 - 0 - 360 - 377 - - - - Form - - - - - - - - System Settings - - - - - - Username - - - - - - - - 0 - 0 - - - - 10 - - - - - - - Birthday - - - - - - - - - - January - - - - - February - - - - - March - - - - - April - - - - - May - - - - - June - - - - - July - - - - - August - - - - - September - - - - - October - - - - - November - - - - - December - - - - - - - - - - - - - Language - - - - - - - Note: this can be overridden when region setting is auto-select - - - - Japanese (日本語) - - - - - English - - - - - French (français) - - - - - German (Deutsch) - - - - - Italian (italiano) - - - - - Spanish (español) - - - - - Simplified Chinese (简体中文) - - - - - Korean (한국어) - - - - - Dutch (Nederlands) - - - - - Portuguese (português) - - - - - Russian (Русский) - - - - - Traditional Chinese (正體中文) - - - - - - - - Sound output mode - - - - - - - - Mono - - - - - Stereo - - - - - Surround - - - - - - - - - - - System settings are available only when game is not running. - - - true - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 2723a0217..73b4dd34f 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -14,8 +14,8 @@ #include #include #include "citra_qt/bootmanager.h" -#include "citra_qt/config.h" -#include "citra_qt/configure_dialog.h" +#include "citra_qt/configuration/config.h" +#include "citra_qt/configuration/configure_dialog.h" #include "citra_qt/debugger/callstack.h" #include "citra_qt/debugger/disassembler.h" #include "citra_qt/debugger/graphics/graphics.h" -- cgit v1.2.3