8 changed files with 450 additions and 4 deletions
-
3src/citra_qt/CMakeLists.txt
-
11src/citra_qt/configure.ui
-
9src/citra_qt/configure_dialog.cpp
-
3src/citra_qt/configure_dialog.h
-
136src/citra_qt/configure_system.cpp
-
38src/citra_qt/configure_system.h
-
252src/citra_qt/configure_system.ui
-
2src/citra_qt/main.cpp
@ -0,0 +1,136 @@ |
|||||
|
// 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 "ui_configure_system.h"
|
||||
|
|
||||
|
#include "core/hle/service/fs/archive.h"
|
||||
|
#include "core/hle/service/cfg/cfg.h"
|
||||
|
|
||||
|
static const std::array<int, 12> 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))); |
||||
|
} |
||||
|
|
||||
|
ConfigureSystem::~ConfigureSystem() { |
||||
|
} |
||||
|
|
||||
|
void ConfigureSystem::setConfiguration(bool emulation_running) { |
||||
|
enabled = !emulation_running; |
||||
|
|
||||
|
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(); |
||||
|
// ui->edit_username->setText(QString::fromStdU16String(username)); // TODO(wwylele): Use this when we move to Qt 5.5
|
||||
|
ui->edit_username->setText(QString::fromUtf16(reinterpret_cast<const ushort*>(username.data()))); |
||||
|
|
||||
|
// set birthday
|
||||
|
std::tie(birthmonth, birthday) = Service::CFG::GetBirthday(); |
||||
|
ui->combo_birthmonth->setCurrentIndex(birthmonth - 1); |
||||
|
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
|
||||
|
// std::u16string new_username = ui->edit_username->text().toStdU16String(); // TODO(wwylele): Use this when we move to Qt 5.5
|
||||
|
std::u16string new_username(reinterpret_cast<const char16_t*>(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<Service::CFG::SystemLanguage>(new_language)); |
||||
|
modified = true; |
||||
|
} |
||||
|
|
||||
|
// apply sound
|
||||
|
int new_sound = ui->combo_sound->currentIndex(); |
||||
|
if (sound_index != new_sound) { |
||||
|
Service::CFG::SetSoundOutputMode(static_cast<Service::CFG::SoundOutputMode>(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); |
||||
|
} |
||||
@ -0,0 +1,38 @@ |
|||||
|
// Copyright 2016 Citra Emulator Project |
||||
|
// Licensed under GPLv2 or any later version |
||||
|
// Refer to the license.txt file included. |
||||
|
|
||||
|
#pragma once |
||||
|
|
||||
|
#include <memory> |
||||
|
#include <QWidget> |
||||
|
|
||||
|
namespace Ui { |
||||
|
class ConfigureSystem; |
||||
|
} |
||||
|
|
||||
|
class ConfigureSystem : public QWidget |
||||
|
{ |
||||
|
Q_OBJECT |
||||
|
|
||||
|
public: |
||||
|
explicit ConfigureSystem(QWidget *parent = nullptr); |
||||
|
~ConfigureSystem(); |
||||
|
|
||||
|
void applyConfiguration(); |
||||
|
void setConfiguration(bool emulation_running); |
||||
|
|
||||
|
public slots: |
||||
|
void updateBirthdayComboBox(int birthmonth_index); |
||||
|
|
||||
|
private: |
||||
|
void ReadSystemSettings(); |
||||
|
|
||||
|
std::unique_ptr<Ui::ConfigureSystem> ui; |
||||
|
bool enabled; |
||||
|
|
||||
|
std::u16string username; |
||||
|
int birthmonth, birthday; |
||||
|
int language_index; |
||||
|
int sound_index; |
||||
|
}; |
||||
@ -0,0 +1,252 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<ui version="4.0"> |
||||
|
<class>ConfigureSystem</class> |
||||
|
<widget class="QWidget" name="ConfigureSystem"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>0</x> |
||||
|
<y>0</y> |
||||
|
<width>360</width> |
||||
|
<height>377</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="windowTitle"> |
||||
|
<string>Form</string> |
||||
|
</property> |
||||
|
<layout class="QHBoxLayout" name="horizontalLayout"> |
||||
|
<item> |
||||
|
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
|
<item> |
||||
|
<widget class="QGroupBox" name="group_system_settings"> |
||||
|
<property name="title"> |
||||
|
<string>System Settings</string> |
||||
|
</property> |
||||
|
<layout class="QGridLayout" name="gridLayout"> |
||||
|
<item row="0" column="0"> |
||||
|
<widget class="QLabel" name="label_username"> |
||||
|
<property name="text"> |
||||
|
<string>Username</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="0" column="1"> |
||||
|
<widget class="QLineEdit" name="edit_username"> |
||||
|
<property name="sizePolicy"> |
||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> |
||||
|
<horstretch>0</horstretch> |
||||
|
<verstretch>0</verstretch> |
||||
|
</sizepolicy> |
||||
|
</property> |
||||
|
<property name="maxLength"> |
||||
|
<number>10</number> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="1" column="0"> |
||||
|
<widget class="QLabel" name="label_birthday"> |
||||
|
<property name="text"> |
||||
|
<string>Birthday</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="1" column="1"> |
||||
|
<layout class="QHBoxLayout" name="horizontalLayout_birthday2"> |
||||
|
<item> |
||||
|
<widget class="QComboBox" name="combo_birthmonth"> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>January</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>February</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>March</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>April</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>May</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>June</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>July</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>August</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>September</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>October</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>November</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>December</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QComboBox" name="combo_birthday"/> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</item> |
||||
|
<item row="2" column="0"> |
||||
|
<widget class="QLabel" name="label_language"> |
||||
|
<property name="text"> |
||||
|
<string>Language</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="2" column="1"> |
||||
|
<widget class="QComboBox" name="combo_language"> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>Japanese (日本語)</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>English</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>French (français)</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>German (Deutsch)</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>Italian (italiano)</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>Spanish (español)</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>Simplified Chinese (简体中文)</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>Korean (한국어)</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>Dutch (Nederlands)</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>Portuguese (português)</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>Russian (Русский)</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>Traditional Chinese (正體中文)</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="3" column="0"> |
||||
|
<widget class="QLabel" name="label_sound"> |
||||
|
<property name="text"> |
||||
|
<string>Sound output mode</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="3" column="1"> |
||||
|
<widget class="QComboBox" name="combo_sound"> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>Mono</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>Stereo</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>Surround</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
</widget> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QLabel" name="label_disable_info"> |
||||
|
<property name="text"> |
||||
|
<string>System settings are available only when game is not running.</string> |
||||
|
</property> |
||||
|
<property name="wordWrap"> |
||||
|
<bool>true</bool> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<spacer name="verticalSpacer"> |
||||
|
<property name="orientation"> |
||||
|
<enum>Qt::Vertical</enum> |
||||
|
</property> |
||||
|
<property name="sizeHint" stdset="0"> |
||||
|
<size> |
||||
|
<width>20</width> |
||||
|
<height>40</height> |
||||
|
</size> |
||||
|
</property> |
||||
|
</spacer> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</widget> |
||||
|
<resources/> |
||||
|
<connections/> |
||||
|
</ui> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue