summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/citra_qt/CMakeLists.txt3
-rw-r--r--src/citra_qt/configure.ui11
-rw-r--r--src/citra_qt/configure_dialog.cpp9
-rw-r--r--src/citra_qt/configure_dialog.h3
-rw-r--r--src/citra_qt/configure_system.cpp136
-rw-r--r--src/citra_qt/configure_system.h38
-rw-r--r--src/citra_qt/configure_system.ui252
-rw-r--r--src/citra_qt/main.cpp2
8 files changed, 450 insertions, 4 deletions
diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt
index 43a766053..017b43871 100644
--- a/src/citra_qt/CMakeLists.txt
+++ b/src/citra_qt/CMakeLists.txt
@@ -22,6 +22,7 @@ set(SRCS
22 configure_debug.cpp 22 configure_debug.cpp
23 configure_dialog.cpp 23 configure_dialog.cpp
24 configure_general.cpp 24 configure_general.cpp
25 configure_system.cpp
25 game_list.cpp 26 game_list.cpp
26 hotkeys.cpp 27 hotkeys.cpp
27 main.cpp 28 main.cpp
@@ -52,6 +53,7 @@ set(HEADERS
52 configure_debug.h 53 configure_debug.h
53 configure_dialog.h 54 configure_dialog.h
54 configure_general.h 55 configure_general.h
56 configure_system.h
55 game_list.h 57 game_list.h
56 game_list_p.h 58 game_list_p.h
57 hotkeys.h 59 hotkeys.h
@@ -69,6 +71,7 @@ set(UIS
69 configure_audio.ui 71 configure_audio.ui
70 configure_debug.ui 72 configure_debug.ui
71 configure_general.ui 73 configure_general.ui
74 configure_system.ui
72 hotkeys.ui 75 hotkeys.ui
73 main.ui 76 main.ui
74 ) 77 )
diff --git a/src/citra_qt/configure.ui b/src/citra_qt/configure.ui
index e1624bbef..4a9c52650 100644
--- a/src/citra_qt/configure.ui
+++ b/src/citra_qt/configure.ui
@@ -24,6 +24,11 @@
24 <string>General</string> 24 <string>General</string>
25 </attribute> 25 </attribute>
26 </widget> 26 </widget>
27 <widget class="ConfigureSystem" name="systemTab">
28 <attribute name="title">
29 <string>System</string>
30 </attribute>
31 </widget>
27 <widget class="QWidget" name="inputTab"> 32 <widget class="QWidget" name="inputTab">
28 <attribute name="title"> 33 <attribute name="title">
29 <string>Input</string> 34 <string>Input</string>
@@ -58,6 +63,12 @@
58 <container>1</container> 63 <container>1</container>
59 </customwidget> 64 </customwidget>
60 <customwidget> 65 <customwidget>
66 <class>ConfigureSystem</class>
67 <extends>QWidget</extends>
68 <header>configure_system.h</header>
69 <container>1</container>
70 </customwidget>
71 <customwidget>
61 <class>ConfigureAudio</class> 72 <class>ConfigureAudio</class>
62 <extends>QWidget</extends> 73 <extends>QWidget</extends>
63 <header>configure_audio.h</header> 74 <header>configure_audio.h</header>
diff --git a/src/citra_qt/configure_dialog.cpp b/src/citra_qt/configure_dialog.cpp
index 2f0317fe0..77c266d01 100644
--- a/src/citra_qt/configure_dialog.cpp
+++ b/src/citra_qt/configure_dialog.cpp
@@ -9,9 +9,10 @@
9 9
10#include "core/settings.h" 10#include "core/settings.h"
11 11
12ConfigureDialog::ConfigureDialog(QWidget *parent) : 12ConfigureDialog::ConfigureDialog(QWidget *parent, bool running) :
13 QDialog(parent), 13 QDialog(parent),
14 ui(new Ui::ConfigureDialog) 14 ui(new Ui::ConfigureDialog),
15 emulation_running(running)
15{ 16{
16 ui->setupUi(this); 17 ui->setupUi(this);
17 this->setConfiguration(); 18 this->setConfiguration();
@@ -21,10 +22,14 @@ ConfigureDialog::~ConfigureDialog() {
21} 22}
22 23
23void ConfigureDialog::setConfiguration() { 24void ConfigureDialog::setConfiguration() {
25 // System tab needs set manually
26 // depending on whether emulation is running
27 ui->systemTab->setConfiguration(emulation_running);
24} 28}
25 29
26void ConfigureDialog::applyConfiguration() { 30void ConfigureDialog::applyConfiguration() {
27 ui->generalTab->applyConfiguration(); 31 ui->generalTab->applyConfiguration();
32 ui->systemTab->applyConfiguration();
28 ui->audioTab->applyConfiguration(); 33 ui->audioTab->applyConfiguration();
29 ui->debugTab->applyConfiguration(); 34 ui->debugTab->applyConfiguration();
30} 35}
diff --git a/src/citra_qt/configure_dialog.h b/src/citra_qt/configure_dialog.h
index 89020eeb4..305b33bdf 100644
--- a/src/citra_qt/configure_dialog.h
+++ b/src/citra_qt/configure_dialog.h
@@ -16,7 +16,7 @@ class ConfigureDialog : public QDialog
16 Q_OBJECT 16 Q_OBJECT
17 17
18public: 18public:
19 explicit ConfigureDialog(QWidget *parent = nullptr); 19 explicit ConfigureDialog(QWidget *parent, bool emulation_running);
20 ~ConfigureDialog(); 20 ~ConfigureDialog();
21 21
22 void applyConfiguration(); 22 void applyConfiguration();
@@ -26,4 +26,5 @@ private:
26 26
27private: 27private:
28 std::unique_ptr<Ui::ConfigureDialog> ui; 28 std::unique_ptr<Ui::ConfigureDialog> ui;
29 bool emulation_running;
29}; 30};
diff --git a/src/citra_qt/configure_system.cpp b/src/citra_qt/configure_system.cpp
new file mode 100644
index 000000000..4f0d4dbfe
--- /dev/null
+++ b/src/citra_qt/configure_system.cpp
@@ -0,0 +1,136 @@
1// Copyright 2016 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "citra_qt/configure_system.h"
6#include "citra_qt/ui_settings.h"
7#include "ui_configure_system.h"
8
9#include "core/hle/service/fs/archive.h"
10#include "core/hle/service/cfg/cfg.h"
11
12static const std::array<int, 12> days_in_month = {{
13 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
14}};
15
16ConfigureSystem::ConfigureSystem(QWidget *parent) :
17 QWidget(parent),
18 ui(new Ui::ConfigureSystem) {
19 ui->setupUi(this);
20
21 connect(ui->combo_birthmonth, SIGNAL(currentIndexChanged(int)), SLOT(updateBirthdayComboBox(int)));
22}
23
24ConfigureSystem::~ConfigureSystem() {
25}
26
27void ConfigureSystem::setConfiguration(bool emulation_running) {
28 enabled = !emulation_running;
29
30 if (!enabled) {
31 ReadSystemSettings();
32 ui->group_system_settings->setEnabled(false);
33 } else {
34 // This tab is enabled only when game is not running (i.e. all service are not initialized).
35 // Temporarily register archive types and load the config savegame file to memory.
36 Service::FS::RegisterArchiveTypes();
37 ResultCode result = Service::CFG::LoadConfigNANDSaveFile();
38 Service::FS::UnregisterArchiveTypes();
39
40 if (result.IsError()) {
41 ui->label_disable_info->setText(tr("Failed to load system settings data."));
42 ui->group_system_settings->setEnabled(false);
43 enabled = false;
44 return;
45 }
46
47 ReadSystemSettings();
48 ui->label_disable_info->hide();
49 }
50}
51
52void ConfigureSystem::ReadSystemSettings() {
53 // set username
54 username = Service::CFG::GetUsername();
55 // ui->edit_username->setText(QString::fromStdU16String(username)); // TODO(wwylele): Use this when we move to Qt 5.5
56 ui->edit_username->setText(QString::fromUtf16(reinterpret_cast<const ushort*>(username.data())));
57
58 // set birthday
59 std::tie(birthmonth, birthday) = Service::CFG::GetBirthday();
60 ui->combo_birthmonth->setCurrentIndex(birthmonth - 1);
61 ui->combo_birthday->setCurrentIndex(birthday - 1);
62
63 // set system language
64 language_index = Service::CFG::GetSystemLanguage();
65 ui->combo_language->setCurrentIndex(language_index);
66
67 // set sound output mode
68 sound_index = Service::CFG::GetSoundOutputMode();
69 ui->combo_sound->setCurrentIndex(sound_index);
70}
71
72void ConfigureSystem::applyConfiguration() {
73 if (!enabled)
74 return;
75
76 bool modified = false;
77
78 // apply username
79 // std::u16string new_username = ui->edit_username->text().toStdU16String(); // TODO(wwylele): Use this when we move to Qt 5.5
80 std::u16string new_username(reinterpret_cast<const char16_t*>(ui->edit_username->text().utf16()));
81 if (new_username != username) {
82 Service::CFG::SetUsername(new_username);
83 modified = true;
84 }
85
86 // apply birthday
87 int new_birthmonth = ui->combo_birthmonth->currentIndex() + 1;
88 int new_birthday = ui->combo_birthday->currentIndex() + 1;
89 if (birthmonth != new_birthmonth || birthday != new_birthday) {
90 Service::CFG::SetBirthday(new_birthmonth, new_birthday);
91 modified = true;
92 }
93
94 // apply language
95 int new_language = ui->combo_language->currentIndex();
96 if (language_index != new_language) {
97 Service::CFG::SetSystemLanguage(static_cast<Service::CFG::SystemLanguage>(new_language));
98 modified = true;
99 }
100
101 // apply sound
102 int new_sound = ui->combo_sound->currentIndex();
103 if (sound_index != new_sound) {
104 Service::CFG::SetSoundOutputMode(static_cast<Service::CFG::SoundOutputMode>(new_sound));
105 modified = true;
106 }
107
108 // update the config savegame if any item is modified.
109 if (modified)
110 Service::CFG::UpdateConfigNANDSavegame();
111}
112
113void ConfigureSystem::updateBirthdayComboBox(int birthmonth_index) {
114 if (birthmonth_index < 0 || birthmonth_index >= 12)
115 return;
116
117 // store current day selection
118 int birthday_index = ui->combo_birthday->currentIndex();
119
120 // get number of days in the new selected month
121 int days = days_in_month[birthmonth_index];
122
123 // if the selected day is out of range,
124 // reset it to 1st
125 if (birthday_index < 0 || birthday_index >= days)
126 birthday_index = 0;
127
128 // update the day combo box
129 ui->combo_birthday->clear();
130 for (int i = 1; i <= days; ++i) {
131 ui->combo_birthday->addItem(QString::number(i));
132 }
133
134 // restore the day selection
135 ui->combo_birthday->setCurrentIndex(birthday_index);
136}
diff --git a/src/citra_qt/configure_system.h b/src/citra_qt/configure_system.h
new file mode 100644
index 000000000..1f5577070
--- /dev/null
+++ b/src/citra_qt/configure_system.h
@@ -0,0 +1,38 @@
1// Copyright 2016 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <memory>
8#include <QWidget>
9
10namespace Ui {
11class ConfigureSystem;
12}
13
14class ConfigureSystem : public QWidget
15{
16 Q_OBJECT
17
18public:
19 explicit ConfigureSystem(QWidget *parent = nullptr);
20 ~ConfigureSystem();
21
22 void applyConfiguration();
23 void setConfiguration(bool emulation_running);
24
25public slots:
26 void updateBirthdayComboBox(int birthmonth_index);
27
28private:
29 void ReadSystemSettings();
30
31 std::unique_ptr<Ui::ConfigureSystem> ui;
32 bool enabled;
33
34 std::u16string username;
35 int birthmonth, birthday;
36 int language_index;
37 int sound_index;
38};
diff --git a/src/citra_qt/configure_system.ui b/src/citra_qt/configure_system.ui
new file mode 100644
index 000000000..6a906b61b
--- /dev/null
+++ b/src/citra_qt/configure_system.ui
@@ -0,0 +1,252 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<ui version="4.0">
3 <class>ConfigureSystem</class>
4 <widget class="QWidget" name="ConfigureSystem">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>360</width>
10 <height>377</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Form</string>
15 </property>
16 <layout class="QHBoxLayout" name="horizontalLayout">
17 <item>
18 <layout class="QVBoxLayout" name="verticalLayout">
19 <item>
20 <widget class="QGroupBox" name="group_system_settings">
21 <property name="title">
22 <string>System Settings</string>
23 </property>
24 <layout class="QGridLayout" name="gridLayout">
25 <item row="0" column="0">
26 <widget class="QLabel" name="label_username">
27 <property name="text">
28 <string>Username</string>
29 </property>
30 </widget>
31 </item>
32 <item row="0" column="1">
33 <widget class="QLineEdit" name="edit_username">
34 <property name="sizePolicy">
35 <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
36 <horstretch>0</horstretch>
37 <verstretch>0</verstretch>
38 </sizepolicy>
39 </property>
40 <property name="maxLength">
41 <number>10</number>
42 </property>
43 </widget>
44 </item>
45 <item row="1" column="0">
46 <widget class="QLabel" name="label_birthday">
47 <property name="text">
48 <string>Birthday</string>
49 </property>
50 </widget>
51 </item>
52 <item row="1" column="1">
53 <layout class="QHBoxLayout" name="horizontalLayout_birthday2">
54 <item>
55 <widget class="QComboBox" name="combo_birthmonth">
56 <item>
57 <property name="text">
58 <string>January</string>
59 </property>
60 </item>
61 <item>
62 <property name="text">
63 <string>February</string>
64 </property>
65 </item>
66 <item>
67 <property name="text">
68 <string>March</string>
69 </property>
70 </item>
71 <item>
72 <property name="text">
73 <string>April</string>
74 </property>
75 </item>
76 <item>
77 <property name="text">
78 <string>May</string>
79 </property>
80 </item>
81 <item>
82 <property name="text">
83 <string>June</string>
84 </property>
85 </item>
86 <item>
87 <property name="text">
88 <string>July</string>
89 </property>
90 </item>
91 <item>
92 <property name="text">
93 <string>August</string>
94 </property>
95 </item>
96 <item>
97 <property name="text">
98 <string>September</string>
99 </property>
100 </item>
101 <item>
102 <property name="text">
103 <string>October</string>
104 </property>
105 </item>
106 <item>
107 <property name="text">
108 <string>November</string>
109 </property>
110 </item>
111 <item>
112 <property name="text">
113 <string>December</string>
114 </property>
115 </item>
116 </widget>
117 </item>
118 <item>
119 <widget class="QComboBox" name="combo_birthday"/>
120 </item>
121 </layout>
122 </item>
123 <item row="2" column="0">
124 <widget class="QLabel" name="label_language">
125 <property name="text">
126 <string>Language</string>
127 </property>
128 </widget>
129 </item>
130 <item row="2" column="1">
131 <widget class="QComboBox" name="combo_language">
132 <item>
133 <property name="text">
134 <string>Japanese (日本語)</string>
135 </property>
136 </item>
137 <item>
138 <property name="text">
139 <string>English</string>
140 </property>
141 </item>
142 <item>
143 <property name="text">
144 <string>French (français)</string>
145 </property>
146 </item>
147 <item>
148 <property name="text">
149 <string>German (Deutsch)</string>
150 </property>
151 </item>
152 <item>
153 <property name="text">
154 <string>Italian (italiano)</string>
155 </property>
156 </item>
157 <item>
158 <property name="text">
159 <string>Spanish (español)</string>
160 </property>
161 </item>
162 <item>
163 <property name="text">
164 <string>Simplified Chinese (简体中文)</string>
165 </property>
166 </item>
167 <item>
168 <property name="text">
169 <string>Korean (한국어)</string>
170 </property>
171 </item>
172 <item>
173 <property name="text">
174 <string>Dutch (Nederlands)</string>
175 </property>
176 </item>
177 <item>
178 <property name="text">
179 <string>Portuguese (português)</string>
180 </property>
181 </item>
182 <item>
183 <property name="text">
184 <string>Russian (Русский)</string>
185 </property>
186 </item>
187 <item>
188 <property name="text">
189 <string>Traditional Chinese (正體中文)</string>
190 </property>
191 </item>
192 </widget>
193 </item>
194 <item row="3" column="0">
195 <widget class="QLabel" name="label_sound">
196 <property name="text">
197 <string>Sound output mode</string>
198 </property>
199 </widget>
200 </item>
201 <item row="3" column="1">
202 <widget class="QComboBox" name="combo_sound">
203 <item>
204 <property name="text">
205 <string>Mono</string>
206 </property>
207 </item>
208 <item>
209 <property name="text">
210 <string>Stereo</string>
211 </property>
212 </item>
213 <item>
214 <property name="text">
215 <string>Surround</string>
216 </property>
217 </item>
218 </widget>
219 </item>
220 </layout>
221 </widget>
222 </item>
223 <item>
224 <widget class="QLabel" name="label_disable_info">
225 <property name="text">
226 <string>System settings are available only when game is not running.</string>
227 </property>
228 <property name="wordWrap">
229 <bool>true</bool>
230 </property>
231 </widget>
232 </item>
233 <item>
234 <spacer name="verticalSpacer">
235 <property name="orientation">
236 <enum>Qt::Vertical</enum>
237 </property>
238 <property name="sizeHint" stdset="0">
239 <size>
240 <width>20</width>
241 <height>40</height>
242 </size>
243 </property>
244 </spacer>
245 </item>
246 </layout>
247 </item>
248 </layout>
249 </widget>
250 <resources/>
251 <connections/>
252</ui>
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index 0ed1ffa5a..6fe5d7a3f 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -508,7 +508,7 @@ void GMainWindow::ToggleWindowMode() {
508} 508}
509 509
510void GMainWindow::OnConfigure() { 510void GMainWindow::OnConfigure() {
511 ConfigureDialog configureDialog(this); 511 ConfigureDialog configureDialog(this, emulation_running);
512 auto result = configureDialog.exec(); 512 auto result = configureDialog.exec();
513 if (result == QDialog::Accepted) 513 if (result == QDialog::Accepted)
514 { 514 {