summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar David2018-08-04 01:02:55 +1000
committerGravatar bunnei2018-08-03 11:02:55 -0400
commitc1d54f4aeaada515f88b633b8cf0901ee4cb6853 (patch)
treee320222f18419b07c22617f06980bc0b767e3db7 /src
parentMerge pull request #895 from lioncash/sink (diff)
downloadyuzu-c1d54f4aeaada515f88b633b8cf0901ee4cb6853.tar.gz
yuzu-c1d54f4aeaada515f88b633b8cf0901ee4cb6853.tar.xz
yuzu-c1d54f4aeaada515f88b633b8cf0901ee4cb6853.zip
Added ability to change username & language code in the settings ui. Added IProfile::Get and SET::GetLanguageCode for libnx tests (#851)
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/acc/acc.cpp30
-rw-r--r--src/core/hle/service/am/am.cpp3
-rw-r--r--src/core/hle/service/set/set.cpp15
-rw-r--r--src/core/hle/service/set/set.h2
-rw-r--r--src/core/settings.h2
-rw-r--r--src/yuzu/configuration/config.cpp4
-rw-r--r--src/yuzu/configuration/configure_system.cpp8
-rw-r--r--src/yuzu/configuration/configure_system.ui29
-rw-r--r--src/yuzu_cmd/default_ini.h10
9 files changed, 95 insertions, 8 deletions
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp
index 0b158e015..6d15b46ed 100644
--- a/src/core/hle/service/acc/acc.cpp
+++ b/src/core/hle/service/acc/acc.cpp
@@ -10,6 +10,7 @@
10#include "core/hle/service/acc/acc_su.h" 10#include "core/hle/service/acc/acc_su.h"
11#include "core/hle/service/acc/acc_u0.h" 11#include "core/hle/service/acc/acc_u0.h"
12#include "core/hle/service/acc/acc_u1.h" 12#include "core/hle/service/acc/acc_u1.h"
13#include "core/settings.h"
13 14
14namespace Service::Account { 15namespace Service::Account {
15 16
@@ -31,13 +32,14 @@ struct ProfileBase {
31}; 32};
32static_assert(sizeof(ProfileBase) == 0x38, "ProfileBase structure has incorrect size"); 33static_assert(sizeof(ProfileBase) == 0x38, "ProfileBase structure has incorrect size");
33 34
35// TODO(ogniK): Generate a real user id based on username, md5(username) maybe?
34static constexpr u128 DEFAULT_USER_ID{1ull, 0ull}; 36static constexpr u128 DEFAULT_USER_ID{1ull, 0ull};
35 37
36class IProfile final : public ServiceFramework<IProfile> { 38class IProfile final : public ServiceFramework<IProfile> {
37public: 39public:
38 explicit IProfile(u128 user_id) : ServiceFramework("IProfile"), user_id(user_id) { 40 explicit IProfile(u128 user_id) : ServiceFramework("IProfile"), user_id(user_id) {
39 static const FunctionInfo functions[] = { 41 static const FunctionInfo functions[] = {
40 {0, nullptr, "Get"}, 42 {0, &IProfile::Get, "Get"},
41 {1, &IProfile::GetBase, "GetBase"}, 43 {1, &IProfile::GetBase, "GetBase"},
42 {10, nullptr, "GetImageSize"}, 44 {10, nullptr, "GetImageSize"},
43 {11, nullptr, "LoadImage"}, 45 {11, nullptr, "LoadImage"},
@@ -46,14 +48,36 @@ public:
46 } 48 }
47 49
48private: 50private:
51 void Get(Kernel::HLERequestContext& ctx) {
52 LOG_WARNING(Service_ACC, "(STUBBED) called");
53 ProfileBase profile_base{};
54 profile_base.user_id = user_id;
55 if (Settings::values.username.size() > profile_base.username.size()) {
56 std::copy_n(Settings::values.username.begin(), profile_base.username.size(),
57 profile_base.username.begin());
58 } else {
59 std::copy(Settings::values.username.begin(), Settings::values.username.end(),
60 profile_base.username.begin());
61 }
62
63 IPC::ResponseBuilder rb{ctx, 16};
64 rb.Push(RESULT_SUCCESS);
65 rb.PushRaw(profile_base);
66 }
67
49 void GetBase(Kernel::HLERequestContext& ctx) { 68 void GetBase(Kernel::HLERequestContext& ctx) {
50 LOG_WARNING(Service_ACC, "(STUBBED) called"); 69 LOG_WARNING(Service_ACC, "(STUBBED) called");
51 70
52 // TODO(Subv): Retrieve this information from somewhere. 71 // TODO(Subv): Retrieve this information from somewhere.
53 ProfileBase profile_base{}; 72 ProfileBase profile_base{};
54 profile_base.user_id = user_id; 73 profile_base.user_id = user_id;
55 profile_base.username = {'y', 'u', 'z', 'u'}; 74 if (Settings::values.username.size() > profile_base.username.size()) {
56 75 std::copy_n(Settings::values.username.begin(), profile_base.username.size(),
76 profile_base.username.begin());
77 } else {
78 std::copy(Settings::values.username.begin(), Settings::values.username.end(),
79 profile_base.username.begin());
80 }
57 IPC::ResponseBuilder rb{ctx, 16}; 81 IPC::ResponseBuilder rb{ctx, 16};
58 rb.Push(RESULT_SUCCESS); 82 rb.Push(RESULT_SUCCESS);
59 rb.PushRaw(profile_base); 83 rb.PushRaw(profile_base);
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index 94d2a973d..9404d6b8c 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -652,7 +652,8 @@ void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) {
652 // TODO(bunnei): This should be configurable 652 // TODO(bunnei): This should be configurable
653 IPC::ResponseBuilder rb{ctx, 4}; 653 IPC::ResponseBuilder rb{ctx, 4};
654 rb.Push(RESULT_SUCCESS); 654 rb.Push(RESULT_SUCCESS);
655 rb.Push(static_cast<u64>(Service::Set::LanguageCode::EN_US)); 655 rb.Push(
656 static_cast<u64>(Service::Set::GetLanguageCodeFromIndex(Settings::values.language_index)));
656 LOG_DEBUG(Service_AM, "called"); 657 LOG_DEBUG(Service_AM, "called");
657} 658}
658 659
diff --git a/src/core/hle/service/set/set.cpp b/src/core/hle/service/set/set.cpp
index 1651f6122..a461e72ec 100644
--- a/src/core/hle/service/set/set.cpp
+++ b/src/core/hle/service/set/set.cpp
@@ -8,6 +8,7 @@
8#include "core/hle/kernel/client_port.h" 8#include "core/hle/kernel/client_port.h"
9#include "core/hle/kernel/client_session.h" 9#include "core/hle/kernel/client_session.h"
10#include "core/hle/service/set/set.h" 10#include "core/hle/service/set/set.h"
11#include "core/settings.h"
11 12
12namespace Service::Set { 13namespace Service::Set {
13 14
@@ -31,6 +32,10 @@ constexpr std::array<LanguageCode, 17> available_language_codes = {{
31 LanguageCode::ZH_HANT, 32 LanguageCode::ZH_HANT,
32}}; 33}};
33 34
35LanguageCode GetLanguageCodeFromIndex(size_t index) {
36 return available_language_codes.at(index);
37}
38
34void SET::GetAvailableLanguageCodes(Kernel::HLERequestContext& ctx) { 39void SET::GetAvailableLanguageCodes(Kernel::HLERequestContext& ctx) {
35 ctx.WriteBuffer(available_language_codes); 40 ctx.WriteBuffer(available_language_codes);
36 41
@@ -49,9 +54,17 @@ void SET::GetAvailableLanguageCodeCount(Kernel::HLERequestContext& ctx) {
49 LOG_DEBUG(Service_SET, "called"); 54 LOG_DEBUG(Service_SET, "called");
50} 55}
51 56
57void SET::GetLanguageCode(Kernel::HLERequestContext& ctx) {
58 IPC::ResponseBuilder rb{ctx, 4};
59 rb.Push(RESULT_SUCCESS);
60 rb.Push(static_cast<u64>(available_language_codes[Settings::values.language_index]));
61
62 LOG_DEBUG(Service_SET, "called {}", Settings::values.language_index);
63}
64
52SET::SET() : ServiceFramework("set") { 65SET::SET() : ServiceFramework("set") {
53 static const FunctionInfo functions[] = { 66 static const FunctionInfo functions[] = {
54 {0, nullptr, "GetLanguageCode"}, 67 {0, &SET::GetLanguageCode, "GetLanguageCode"},
55 {1, &SET::GetAvailableLanguageCodes, "GetAvailableLanguageCodes"}, 68 {1, &SET::GetAvailableLanguageCodes, "GetAvailableLanguageCodes"},
56 {2, nullptr, "MakeLanguageCode"}, 69 {2, nullptr, "MakeLanguageCode"},
57 {3, &SET::GetAvailableLanguageCodeCount, "GetAvailableLanguageCodeCount"}, 70 {3, &SET::GetAvailableLanguageCodeCount, "GetAvailableLanguageCodeCount"},
diff --git a/src/core/hle/service/set/set.h b/src/core/hle/service/set/set.h
index a2472ec4c..4232b6162 100644
--- a/src/core/hle/service/set/set.h
+++ b/src/core/hle/service/set/set.h
@@ -28,6 +28,7 @@ enum class LanguageCode : u64 {
28 ZH_HANS = 0x00736E61482D687A, 28 ZH_HANS = 0x00736E61482D687A,
29 ZH_HANT = 0x00746E61482D687A, 29 ZH_HANT = 0x00746E61482D687A,
30}; 30};
31LanguageCode GetLanguageCodeFromIndex(size_t idx);
31 32
32class SET final : public ServiceFramework<SET> { 33class SET final : public ServiceFramework<SET> {
33public: 34public:
@@ -35,6 +36,7 @@ public:
35 ~SET() = default; 36 ~SET() = default;
36 37
37private: 38private:
39 void GetLanguageCode(Kernel::HLERequestContext& ctx);
38 void GetAvailableLanguageCodes(Kernel::HLERequestContext& ctx); 40 void GetAvailableLanguageCodes(Kernel::HLERequestContext& ctx);
39 void GetAvailableLanguageCodeCount(Kernel::HLERequestContext& ctx); 41 void GetAvailableLanguageCodeCount(Kernel::HLERequestContext& ctx);
40}; 42};
diff --git a/src/core/settings.h b/src/core/settings.h
index 8cc65e434..e826d4235 100644
--- a/src/core/settings.h
+++ b/src/core/settings.h
@@ -112,6 +112,8 @@ static const std::array<const char*, NumAnalogs> mapping = {{
112struct Values { 112struct Values {
113 // System 113 // System
114 bool use_docked_mode; 114 bool use_docked_mode;
115 std::string username;
116 int language_index;
115 117
116 // Controls 118 // Controls
117 std::array<std::string, NativeButton::NumButtons> buttons; 119 std::array<std::string, NativeButton::NumButtons> buttons;
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index e8b3a9866..9d6454bbd 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -105,6 +105,8 @@ void Config::ReadValues() {
105 105
106 qt_config->beginGroup("System"); 106 qt_config->beginGroup("System");
107 Settings::values.use_docked_mode = qt_config->value("use_docked_mode", false).toBool(); 107 Settings::values.use_docked_mode = qt_config->value("use_docked_mode", false).toBool();
108 Settings::values.username = qt_config->value("username", "yuzu").toString().toStdString();
109 Settings::values.language_index = qt_config->value("language_index", 1).toInt();
108 qt_config->endGroup(); 110 qt_config->endGroup();
109 111
110 qt_config->beginGroup("Miscellaneous"); 112 qt_config->beginGroup("Miscellaneous");
@@ -214,6 +216,8 @@ void Config::SaveValues() {
214 216
215 qt_config->beginGroup("System"); 217 qt_config->beginGroup("System");
216 qt_config->setValue("use_docked_mode", Settings::values.use_docked_mode); 218 qt_config->setValue("use_docked_mode", Settings::values.use_docked_mode);
219 qt_config->setValue("username", QString::fromStdString(Settings::values.username));
220 qt_config->setValue("language_index", Settings::values.language_index);
217 qt_config->endGroup(); 221 qt_config->endGroup();
218 222
219 qt_config->beginGroup("Miscellaneous"); 223 qt_config->beginGroup("Miscellaneous");
diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp
index d09505a0f..9be2c939c 100644
--- a/src/yuzu/configuration/configure_system.cpp
+++ b/src/yuzu/configuration/configure_system.cpp
@@ -4,9 +4,10 @@
4 4
5#include <QMessageBox> 5#include <QMessageBox>
6#include "core/core.h" 6#include "core/core.h"
7#include "core/settings.h"
7#include "ui_configure_system.h" 8#include "ui_configure_system.h"
8#include "yuzu/configuration/configure_system.h" 9#include "yuzu/configuration/configure_system.h"
9#include "yuzu/ui_settings.h" 10#include "yuzu/main.h"
10 11
11static const std::array<int, 12> days_in_month = {{ 12static const std::array<int, 12> days_in_month = {{
12 31, 13 31,
@@ -38,6 +39,8 @@ ConfigureSystem::~ConfigureSystem() {}
38 39
39void ConfigureSystem::setConfiguration() { 40void ConfigureSystem::setConfiguration() {
40 enabled = !Core::System::GetInstance().IsPoweredOn(); 41 enabled = !Core::System::GetInstance().IsPoweredOn();
42 ui->edit_username->setText(QString::fromStdString(Settings::values.username));
43 ui->combo_language->setCurrentIndex(Settings::values.language_index);
41} 44}
42 45
43void ConfigureSystem::ReadSystemSettings() {} 46void ConfigureSystem::ReadSystemSettings() {}
@@ -45,6 +48,9 @@ void ConfigureSystem::ReadSystemSettings() {}
45void ConfigureSystem::applyConfiguration() { 48void ConfigureSystem::applyConfiguration() {
46 if (!enabled) 49 if (!enabled)
47 return; 50 return;
51 Settings::values.username = ui->edit_username->text().toStdString();
52 Settings::values.language_index = ui->combo_language->currentIndex();
53 Settings::Apply();
48} 54}
49 55
50void ConfigureSystem::updateBirthdayComboBox(int birthmonth_index) { 56void ConfigureSystem::updateBirthdayComboBox(int birthmonth_index) {
diff --git a/src/yuzu/configuration/configure_system.ui b/src/yuzu/configuration/configure_system.ui
index 8caf49623..f3f8db038 100644
--- a/src/yuzu/configuration/configure_system.ui
+++ b/src/yuzu/configuration/configure_system.ui
@@ -38,7 +38,7 @@
38 </sizepolicy> 38 </sizepolicy>
39 </property> 39 </property>
40 <property name="maxLength"> 40 <property name="maxLength">
41 <number>10</number> 41 <number>32</number>
42 </property> 42 </property>
43 </widget> 43 </widget>
44 </item> 44 </item>
@@ -164,7 +164,7 @@
164 </item> 164 </item>
165 <item> 165 <item>
166 <property name="text"> 166 <property name="text">
167 <string>Simplified Chinese (简体中文)</string> 167 <string>Chinese</string>
168 </property> 168 </property>
169 </item> 169 </item>
170 <item> 170 <item>
@@ -187,6 +187,31 @@
187 <string>Russian (Русский)</string> 187 <string>Russian (Русский)</string>
188 </property> 188 </property>
189 </item> 189 </item>
190 <item>
191 <property name="text">
192 <string>Taiwanese</string>
193 </property>
194 </item>
195 <item>
196 <property name="text">
197 <string>British English</string>
198 </property>
199 </item>
200 <item>
201 <property name="text">
202 <string>Canadian French</string>
203 </property>
204 </item>
205 <item>
206 <property name="text">
207 <string>Latin American Spanish</string>
208 </property>
209 </item>
210 <item>
211 <property name="text">
212 <string>Simplified Chinese</string>
213 </property>
214 </item>
190 <item> 215 <item>
191 <property name="text"> 216 <property name="text">
192 <string>Traditional Chinese (正體中文)</string> 217 <string>Traditional Chinese (正體中文)</string>
diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h
index 6553c7814..9a935a0d5 100644
--- a/src/yuzu_cmd/default_ini.h
+++ b/src/yuzu_cmd/default_ini.h
@@ -164,6 +164,16 @@ use_virtual_sd =
164# 1: Yes, 0 (default): No 164# 1: Yes, 0 (default): No
165use_docked_mode = 165use_docked_mode =
166 166
167# Sets the account username, max length is 32 characters
168# yuzu (default)
169username =
170
171# Sets the systems language index
172# 0: Japanese, 1: English (default), 2: French, 3: German, 4: Italian, 5: Spanish, 6: Chinese,
173# 7: Korean, 8: Dutch, 9: Portuguese, 10: Russian, 11: Taiwanese, 12: British English, 13: Canadian French,
174# 14: Latin American Spanish, 15: Simplified Chinese, 16: Traditional Chinese
175language_index =
176
167# The system region that yuzu will use during emulation 177# The system region that yuzu will use during emulation
168# -1: Auto-select (default), 0: Japan, 1: USA, 2: Europe, 3: Australia, 4: China, 5: Korea, 6: Taiwan 178# -1: Auto-select (default), 0: Japan, 1: USA, 2: Europe, 3: Australia, 4: China, 5: Korea, 6: Taiwan
169region_value = 179region_value =