diff options
| author | 2018-11-11 22:34:23 -0500 | |
|---|---|---|
| committer | 2018-11-11 23:09:46 -0500 | |
| commit | 2a16fd7ffc1ec4e2dc90480c04f9867fdeec6a98 (patch) | |
| tree | 682a2fc1751f8628d07f2caf3a2b34f7a1c39b52 /src | |
| parent | csrng: Use std::mt19937 engine for random number generation (diff) | |
| download | yuzu-2a16fd7ffc1ec4e2dc90480c04f9867fdeec6a98.tar.gz yuzu-2a16fd7ffc1ec4e2dc90480c04f9867fdeec6a98.tar.xz yuzu-2a16fd7ffc1ec4e2dc90480c04f9867fdeec6a98.zip | |
settings: Add config option to set RNG seed
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/settings.h | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 12 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_system.cpp | 17 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_system.ui | 228 | ||||
| -rw-r--r-- | src/yuzu_cmd/config.cpp | 7 | ||||
| -rw-r--r-- | src/yuzu_cmd/default_ini.h | 5 |
6 files changed, 171 insertions, 100 deletions
diff --git a/src/core/settings.h b/src/core/settings.h index a8954647f..83a1a7069 100644 --- a/src/core/settings.h +++ b/src/core/settings.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <atomic> | 8 | #include <atomic> |
| 9 | #include <optional> | ||
| 9 | #include <string> | 10 | #include <string> |
| 10 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 11 | 12 | ||
| @@ -114,6 +115,7 @@ struct Values { | |||
| 114 | // System | 115 | // System |
| 115 | bool use_docked_mode; | 116 | bool use_docked_mode; |
| 116 | bool enable_nfc; | 117 | bool enable_nfc; |
| 118 | std::optional<u64> rng_seed; | ||
| 117 | s32 current_user; | 119 | s32 current_user; |
| 118 | s32 language_index; | 120 | s32 language_index; |
| 119 | 121 | ||
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index d4fd60a73..d3b7fa59d 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -134,6 +134,14 @@ void Config::ReadValues() { | |||
| 134 | Service::Account::MAX_USERS - 1); | 134 | Service::Account::MAX_USERS - 1); |
| 135 | 135 | ||
| 136 | Settings::values.language_index = qt_config->value("language_index", 1).toInt(); | 136 | Settings::values.language_index = qt_config->value("language_index", 1).toInt(); |
| 137 | |||
| 138 | const auto enabled = qt_config->value("rng_seed_enabled", false).toBool(); | ||
| 139 | if (enabled) { | ||
| 140 | Settings::values.rng_seed = qt_config->value("rng_seed", 0).toULongLong(); | ||
| 141 | } else { | ||
| 142 | Settings::values.rng_seed = std::nullopt; | ||
| 143 | } | ||
| 144 | |||
| 137 | qt_config->endGroup(); | 145 | qt_config->endGroup(); |
| 138 | 146 | ||
| 139 | qt_config->beginGroup("Miscellaneous"); | 147 | qt_config->beginGroup("Miscellaneous"); |
| @@ -272,6 +280,10 @@ void Config::SaveValues() { | |||
| 272 | qt_config->setValue("current_user", Settings::values.current_user); | 280 | qt_config->setValue("current_user", Settings::values.current_user); |
| 273 | 281 | ||
| 274 | qt_config->setValue("language_index", Settings::values.language_index); | 282 | qt_config->setValue("language_index", Settings::values.language_index); |
| 283 | |||
| 284 | qt_config->setValue("rng_seed_enabled", Settings::values.rng_seed.has_value()); | ||
| 285 | qt_config->setValue("rng_seed", Settings::values.rng_seed.value_or(0)); | ||
| 286 | |||
| 275 | qt_config->endGroup(); | 287 | qt_config->endGroup(); |
| 276 | 288 | ||
| 277 | qt_config->beginGroup("Miscellaneous"); | 289 | qt_config->beginGroup("Miscellaneous"); |
diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 4803d43bb..b001266f6 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp | |||
| @@ -137,6 +137,12 @@ ConfigureSystem::ConfigureSystem(QWidget* parent) | |||
| 137 | connect(ui->pm_remove, &QPushButton::pressed, this, &ConfigureSystem::DeleteUser); | 137 | connect(ui->pm_remove, &QPushButton::pressed, this, &ConfigureSystem::DeleteUser); |
| 138 | connect(ui->pm_set_image, &QPushButton::pressed, this, &ConfigureSystem::SetUserImage); | 138 | connect(ui->pm_set_image, &QPushButton::pressed, this, &ConfigureSystem::SetUserImage); |
| 139 | 139 | ||
| 140 | connect(ui->rng_seed_checkbox, &QCheckBox::stateChanged, this, [this](bool checked) { | ||
| 141 | ui->rng_seed_edit->setEnabled(checked); | ||
| 142 | if (!checked) | ||
| 143 | ui->rng_seed_edit->setText("0000000000000000"); | ||
| 144 | }); | ||
| 145 | |||
| 140 | scene = new QGraphicsScene; | 146 | scene = new QGraphicsScene; |
| 141 | ui->current_user_icon->setScene(scene); | 147 | ui->current_user_icon->setScene(scene); |
| 142 | 148 | ||
| @@ -155,6 +161,11 @@ void ConfigureSystem::setConfiguration() { | |||
| 155 | 161 | ||
| 156 | PopulateUserList(); | 162 | PopulateUserList(); |
| 157 | UpdateCurrentUser(); | 163 | UpdateCurrentUser(); |
| 164 | |||
| 165 | ui->rng_seed_checkbox->setChecked(Settings::values.rng_seed.has_value()); | ||
| 166 | ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.has_value()); | ||
| 167 | ui->rng_seed_edit->setText( | ||
| 168 | QString::fromStdString(fmt::format("{:016X}", Settings::values.rng_seed.value_or(0)))); | ||
| 158 | } | 169 | } |
| 159 | 170 | ||
| 160 | void ConfigureSystem::PopulateUserList() { | 171 | void ConfigureSystem::PopulateUserList() { |
| @@ -195,6 +206,12 @@ void ConfigureSystem::applyConfiguration() { | |||
| 195 | return; | 206 | return; |
| 196 | 207 | ||
| 197 | Settings::values.language_index = ui->combo_language->currentIndex(); | 208 | Settings::values.language_index = ui->combo_language->currentIndex(); |
| 209 | |||
| 210 | if (ui->rng_seed_checkbox->isChecked()) | ||
| 211 | Settings::values.rng_seed = ui->rng_seed_edit->text().toULongLong(nullptr, 16); | ||
| 212 | else | ||
| 213 | Settings::values.rng_seed = std::nullopt; | ||
| 214 | |||
| 198 | Settings::Apply(); | 215 | Settings::Apply(); |
| 199 | } | 216 | } |
| 200 | 217 | ||
diff --git a/src/yuzu/configuration/configure_system.ui b/src/yuzu/configuration/configure_system.ui index 020b32a37..d0fcd0163 100644 --- a/src/yuzu/configuration/configure_system.ui +++ b/src/yuzu/configuration/configure_system.ui | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | <rect> | 6 | <rect> |
| 7 | <x>0</x> | 7 | <x>0</x> |
| 8 | <y>0</y> | 8 | <y>0</y> |
| 9 | <width>360</width> | 9 | <width>366</width> |
| 10 | <height>483</height> | 10 | <height>483</height> |
| 11 | </rect> | 11 | </rect> |
| 12 | </property> | 12 | </property> |
| @@ -22,98 +22,6 @@ | |||
| 22 | <string>System Settings</string> | 22 | <string>System Settings</string> |
| 23 | </property> | 23 | </property> |
| 24 | <layout class="QGridLayout" name="gridLayout"> | 24 | <layout class="QGridLayout" name="gridLayout"> |
| 25 | <item row="1" column="0"> | ||
| 26 | <widget class="QLabel" name="label_language"> | ||
| 27 | <property name="text"> | ||
| 28 | <string>Language</string> | ||
| 29 | </property> | ||
| 30 | </widget> | ||
| 31 | </item> | ||
| 32 | <item row="0" column="0"> | ||
| 33 | <widget class="QLabel" name="label_birthday"> | ||
| 34 | <property name="text"> | ||
| 35 | <string>Birthday</string> | ||
| 36 | </property> | ||
| 37 | </widget> | ||
| 38 | </item> | ||
| 39 | <item row="3" column="0"> | ||
| 40 | <widget class="QLabel" name="label_console_id"> | ||
| 41 | <property name="text"> | ||
| 42 | <string>Console ID:</string> | ||
| 43 | </property> | ||
| 44 | </widget> | ||
| 45 | </item> | ||
| 46 | <item row="0" column="1"> | ||
| 47 | <layout class="QHBoxLayout" name="horizontalLayout_birthday2"> | ||
| 48 | <item> | ||
| 49 | <widget class="QComboBox" name="combo_birthmonth"> | ||
| 50 | <item> | ||
| 51 | <property name="text"> | ||
| 52 | <string>January</string> | ||
| 53 | </property> | ||
| 54 | </item> | ||
| 55 | <item> | ||
| 56 | <property name="text"> | ||
| 57 | <string>February</string> | ||
| 58 | </property> | ||
| 59 | </item> | ||
| 60 | <item> | ||
| 61 | <property name="text"> | ||
| 62 | <string>March</string> | ||
| 63 | </property> | ||
| 64 | </item> | ||
| 65 | <item> | ||
| 66 | <property name="text"> | ||
| 67 | <string>April</string> | ||
| 68 | </property> | ||
| 69 | </item> | ||
| 70 | <item> | ||
| 71 | <property name="text"> | ||
| 72 | <string>May</string> | ||
| 73 | </property> | ||
| 74 | </item> | ||
| 75 | <item> | ||
| 76 | <property name="text"> | ||
| 77 | <string>June</string> | ||
| 78 | </property> | ||
| 79 | </item> | ||
| 80 | <item> | ||
| 81 | <property name="text"> | ||
| 82 | <string>July</string> | ||
| 83 | </property> | ||
| 84 | </item> | ||
| 85 | <item> | ||
| 86 | <property name="text"> | ||
| 87 | <string>August</string> | ||
| 88 | </property> | ||
| 89 | </item> | ||
| 90 | <item> | ||
| 91 | <property name="text"> | ||
| 92 | <string>September</string> | ||
| 93 | </property> | ||
| 94 | </item> | ||
| 95 | <item> | ||
| 96 | <property name="text"> | ||
| 97 | <string>October</string> | ||
| 98 | </property> | ||
| 99 | </item> | ||
| 100 | <item> | ||
| 101 | <property name="text"> | ||
| 102 | <string>November</string> | ||
| 103 | </property> | ||
| 104 | </item> | ||
| 105 | <item> | ||
| 106 | <property name="text"> | ||
| 107 | <string>December</string> | ||
| 108 | </property> | ||
| 109 | </item> | ||
| 110 | </widget> | ||
| 111 | </item> | ||
| 112 | <item> | ||
| 113 | <widget class="QComboBox" name="combo_birthday"/> | ||
| 114 | </item> | ||
| 115 | </layout> | ||
| 116 | </item> | ||
| 117 | <item row="1" column="1"> | 25 | <item row="1" column="1"> |
| 118 | <widget class="QComboBox" name="combo_language"> | 26 | <widget class="QComboBox" name="combo_language"> |
| 119 | <property name="toolTip"> | 27 | <property name="toolTip"> |
| @@ -206,6 +114,13 @@ | |||
| 206 | </item> | 114 | </item> |
| 207 | </widget> | 115 | </widget> |
| 208 | </item> | 116 | </item> |
| 117 | <item row="3" column="0"> | ||
| 118 | <widget class="QLabel" name="label_console_id"> | ||
| 119 | <property name="text"> | ||
| 120 | <string>Console ID:</string> | ||
| 121 | </property> | ||
| 122 | </widget> | ||
| 123 | </item> | ||
| 209 | <item row="2" column="0"> | 124 | <item row="2" column="0"> |
| 210 | <widget class="QLabel" name="label_sound"> | 125 | <widget class="QLabel" name="label_sound"> |
| 211 | <property name="text"> | 126 | <property name="text"> |
| @@ -213,6 +128,100 @@ | |||
| 213 | </property> | 128 | </property> |
| 214 | </widget> | 129 | </widget> |
| 215 | </item> | 130 | </item> |
| 131 | <item row="0" column="0"> | ||
| 132 | <widget class="QLabel" name="label_birthday"> | ||
| 133 | <property name="text"> | ||
| 134 | <string>Birthday</string> | ||
| 135 | </property> | ||
| 136 | </widget> | ||
| 137 | </item> | ||
| 138 | <item row="0" column="1"> | ||
| 139 | <layout class="QHBoxLayout" name="horizontalLayout_birthday2"> | ||
| 140 | <item> | ||
| 141 | <widget class="QComboBox" name="combo_birthmonth"> | ||
| 142 | <item> | ||
| 143 | <property name="text"> | ||
| 144 | <string>January</string> | ||
| 145 | </property> | ||
| 146 | </item> | ||
| 147 | <item> | ||
| 148 | <property name="text"> | ||
| 149 | <string>February</string> | ||
| 150 | </property> | ||
| 151 | </item> | ||
| 152 | <item> | ||
| 153 | <property name="text"> | ||
| 154 | <string>March</string> | ||
| 155 | </property> | ||
| 156 | </item> | ||
| 157 | <item> | ||
| 158 | <property name="text"> | ||
| 159 | <string>April</string> | ||
| 160 | </property> | ||
| 161 | </item> | ||
| 162 | <item> | ||
| 163 | <property name="text"> | ||
| 164 | <string>May</string> | ||
| 165 | </property> | ||
| 166 | </item> | ||
| 167 | <item> | ||
| 168 | <property name="text"> | ||
| 169 | <string>June</string> | ||
| 170 | </property> | ||
| 171 | </item> | ||
| 172 | <item> | ||
| 173 | <property name="text"> | ||
| 174 | <string>July</string> | ||
| 175 | </property> | ||
| 176 | </item> | ||
| 177 | <item> | ||
| 178 | <property name="text"> | ||
| 179 | <string>August</string> | ||
| 180 | </property> | ||
| 181 | </item> | ||
| 182 | <item> | ||
| 183 | <property name="text"> | ||
| 184 | <string>September</string> | ||
| 185 | </property> | ||
| 186 | </item> | ||
| 187 | <item> | ||
| 188 | <property name="text"> | ||
| 189 | <string>October</string> | ||
| 190 | </property> | ||
| 191 | </item> | ||
| 192 | <item> | ||
| 193 | <property name="text"> | ||
| 194 | <string>November</string> | ||
| 195 | </property> | ||
| 196 | </item> | ||
| 197 | <item> | ||
| 198 | <property name="text"> | ||
| 199 | <string>December</string> | ||
| 200 | </property> | ||
| 201 | </item> | ||
| 202 | </widget> | ||
| 203 | </item> | ||
| 204 | <item> | ||
| 205 | <widget class="QComboBox" name="combo_birthday"/> | ||
| 206 | </item> | ||
| 207 | </layout> | ||
| 208 | </item> | ||
| 209 | <item row="3" column="1"> | ||
| 210 | <widget class="QPushButton" name="button_regenerate_console_id"> | ||
| 211 | <property name="sizePolicy"> | ||
| 212 | <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | ||
| 213 | <horstretch>0</horstretch> | ||
| 214 | <verstretch>0</verstretch> | ||
| 215 | </sizepolicy> | ||
| 216 | </property> | ||
| 217 | <property name="layoutDirection"> | ||
| 218 | <enum>Qt::RightToLeft</enum> | ||
| 219 | </property> | ||
| 220 | <property name="text"> | ||
| 221 | <string>Regenerate</string> | ||
| 222 | </property> | ||
| 223 | </widget> | ||
| 224 | </item> | ||
| 216 | <item row="2" column="1"> | 225 | <item row="2" column="1"> |
| 217 | <widget class="QComboBox" name="combo_sound"> | 226 | <widget class="QComboBox" name="combo_sound"> |
| 218 | <item> | 227 | <item> |
| @@ -232,19 +241,38 @@ | |||
| 232 | </item> | 241 | </item> |
| 233 | </widget> | 242 | </widget> |
| 234 | </item> | 243 | </item> |
| 235 | <item row="3" column="1"> | 244 | <item row="1" column="0"> |
| 236 | <widget class="QPushButton" name="button_regenerate_console_id"> | 245 | <widget class="QLabel" name="label_language"> |
| 246 | <property name="text"> | ||
| 247 | <string>Language</string> | ||
| 248 | </property> | ||
| 249 | </widget> | ||
| 250 | </item> | ||
| 251 | <item row="4" column="0"> | ||
| 252 | <widget class="QCheckBox" name="rng_seed_checkbox"> | ||
| 253 | <property name="text"> | ||
| 254 | <string>RNG Seed</string> | ||
| 255 | </property> | ||
| 256 | </widget> | ||
| 257 | </item> | ||
| 258 | <item row="4" column="1"> | ||
| 259 | <widget class="QLineEdit" name="rng_seed_edit"> | ||
| 237 | <property name="sizePolicy"> | 260 | <property name="sizePolicy"> |
| 238 | <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | 261 | <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
| 239 | <horstretch>0</horstretch> | 262 | <horstretch>0</horstretch> |
| 240 | <verstretch>0</verstretch> | 263 | <verstretch>0</verstretch> |
| 241 | </sizepolicy> | 264 | </sizepolicy> |
| 242 | </property> | 265 | </property> |
| 243 | <property name="layoutDirection"> | 266 | <property name="font"> |
| 244 | <enum>Qt::RightToLeft</enum> | 267 | <font> |
| 268 | <family>Lucida Console</family> | ||
| 269 | </font> | ||
| 245 | </property> | 270 | </property> |
| 246 | <property name="text"> | 271 | <property name="inputMask"> |
| 247 | <string>Regenerate</string> | 272 | <string>HHHHHHHHHHHHHHHH</string> |
| 273 | </property> | ||
| 274 | <property name="maxLength"> | ||
| 275 | <number>16</number> | ||
| 248 | </property> | 276 | </property> |
| 249 | </widget> | 277 | </widget> |
| 250 | </item> | 278 | </item> |
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index b456266a6..f3134d4cb 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp | |||
| @@ -132,6 +132,13 @@ void Config::ReadValues() { | |||
| 132 | Settings::values.current_user = std::clamp<int>( | 132 | Settings::values.current_user = std::clamp<int>( |
| 133 | sdl2_config->GetInteger("System", "current_user", 0), 0, Service::Account::MAX_USERS - 1); | 133 | sdl2_config->GetInteger("System", "current_user", 0), 0, Service::Account::MAX_USERS - 1); |
| 134 | 134 | ||
| 135 | const auto enabled = sdl2_config->GetBoolean("System", "rng_seed_enabled", false); | ||
| 136 | if (enabled) { | ||
| 137 | Settings::values.rng_seed = sdl2_config->GetInteger("System", "rng_seed", 0); | ||
| 138 | } else { | ||
| 139 | Settings::values.rng_seed = std::nullopt; | ||
| 140 | } | ||
| 141 | |||
| 135 | // Miscellaneous | 142 | // Miscellaneous |
| 136 | Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Trace"); | 143 | Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Trace"); |
| 137 | Settings::values.use_dev_keys = sdl2_config->GetBoolean("Miscellaneous", "use_dev_keys", false); | 144 | Settings::values.use_dev_keys = sdl2_config->GetBoolean("Miscellaneous", "use_dev_keys", false); |
diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index e0b223cd6..dd6644d79 100644 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h | |||
| @@ -178,6 +178,11 @@ use_docked_mode = | |||
| 178 | # 1 (default): Yes, 0 : No | 178 | # 1 (default): Yes, 0 : No |
| 179 | enable_nfc = | 179 | enable_nfc = |
| 180 | 180 | ||
| 181 | # Sets the seed for the RNG generator built into the switch | ||
| 182 | # rng_seed will be ignored and randomly generated if rng_seed_enabled is false | ||
| 183 | rng_seed_enabled = | ||
| 184 | rng_seed = | ||
| 185 | |||
| 181 | # Sets the account username, max length is 32 characters | 186 | # Sets the account username, max length is 32 characters |
| 182 | # yuzu (default) | 187 | # yuzu (default) |
| 183 | username = yuzu | 188 | username = yuzu |