mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	Create a random console_unique_id (#2668)
* Create a random console_id when config save_file is created Added button in system config to refresh the console unique id * Moved the connect for the button from .ui file to constructor of ConfigureSystem * Added warning and info dialog Fixup: Make use of qt5 style connects, renamed the refresh button, removed some duplicate code, changed random device and moved all to the generate function * Changed the random generator to reflect what a real 3DS stores as console unique id Fixup: Changed the warning message * Fixup: Set and Create * Fixup: Added console id label, therfore removed second message box * Fixup: fixed the endianess * Fixup: more endianness fixes * Fixup: Endianness the 3rd
This commit is contained in:
		
							parent
							
								
									de1b6cc695
								
							
						
					
					
						commit
						8bee016145
					
				
					 5 changed files with 123 additions and 7 deletions
				
			
		|  | @ -2,6 +2,7 @@ | |||
| // Licensed under GPLv2 or any later version
 | ||||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #include <QMessageBox> | ||||
| #include "citra_qt/configuration/configure_system.h" | ||||
| #include "citra_qt/ui_settings.h" | ||||
| #include "core/core.h" | ||||
|  | @ -15,8 +16,11 @@ static const std::array<int, 12> days_in_month = {{ | |||
| 
 | ||||
| ConfigureSystem::ConfigureSystem(QWidget* parent) : QWidget(parent), ui(new Ui::ConfigureSystem) { | ||||
|     ui->setupUi(this); | ||||
|     connect(ui->combo_birthmonth, SIGNAL(currentIndexChanged(int)), | ||||
|             SLOT(updateBirthdayComboBox(int))); | ||||
|     connect(ui->combo_birthmonth, | ||||
|             static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, | ||||
|             &ConfigureSystem::updateBirthdayComboBox); | ||||
|     connect(ui->button_regenerate_console_id, &QPushButton::clicked, this, | ||||
|             &ConfigureSystem::refreshConsoleID); | ||||
| 
 | ||||
|     this->setConfiguration(); | ||||
| } | ||||
|  | @ -71,6 +75,10 @@ void ConfigureSystem::ReadSystemSettings() { | |||
|     // set sound output mode
 | ||||
|     sound_index = Service::CFG::GetSoundOutputMode(); | ||||
|     ui->combo_sound->setCurrentIndex(sound_index); | ||||
| 
 | ||||
|     // set the console id
 | ||||
|     u64 console_id = Service::CFG::GetConsoleUniqueId(); | ||||
|     ui->label_console_id->setText("Console ID: 0x" + QString::number(console_id, 16).toUpper()); | ||||
| } | ||||
| 
 | ||||
| void ConfigureSystem::applyConfiguration() { | ||||
|  | @ -140,3 +148,21 @@ void ConfigureSystem::updateBirthdayComboBox(int birthmonth_index) { | |||
|     // restore the day selection
 | ||||
|     ui->combo_birthday->setCurrentIndex(birthday_index); | ||||
| } | ||||
| 
 | ||||
| void ConfigureSystem::refreshConsoleID() { | ||||
|     QMessageBox::StandardButton reply; | ||||
|     QString warning_text = tr("This will replace your current virtual 3DS with a new one. " | ||||
|                               "Your current virtual 3DS will not be recoverable. " | ||||
|                               "This might have unexpected effects in games. This might fail, " | ||||
|                               "if you use an outdated config savegame. Continue?"); | ||||
|     reply = QMessageBox::critical(this, tr("Warning"), warning_text, | ||||
|                                   QMessageBox::No | QMessageBox::Yes); | ||||
|     if (reply == QMessageBox::No) | ||||
|         return; | ||||
|     u32 random_number; | ||||
|     u64 console_id; | ||||
|     Service::CFG::GenerateConsoleUniqueId(random_number, console_id); | ||||
|     Service::CFG::SetConsoleUniqueId(random_number, console_id); | ||||
|     Service::CFG::UpdateConfigNANDSavegame(); | ||||
|     ui->label_console_id->setText("Console ID: 0x" + QString::number(console_id, 16).toUpper()); | ||||
| } | ||||
|  |  | |||
|  | @ -23,6 +23,7 @@ public: | |||
| 
 | ||||
| public slots: | ||||
|     void updateBirthdayComboBox(int birthmonth_index); | ||||
|     void refreshConsoleID(); | ||||
| 
 | ||||
| private: | ||||
|     void ReadSystemSettings(); | ||||
|  |  | |||
|  | @ -220,6 +220,29 @@ | |||
|           </item> | ||||
|          </widget> | ||||
|         </item> | ||||
|         <item row="4" column="0"> | ||||
|          <widget class="QLabel" name="label_console_id"> | ||||
|           <property name="text"> | ||||
|            <string>Console ID:</string> | ||||
|           </property> | ||||
|          </widget> | ||||
|         </item> | ||||
|         <item row="4" column="1"> | ||||
|          <widget class="QPushButton" name="button_regenerate_console_id"> | ||||
|           <property name="sizePolicy"> | ||||
|            <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | ||||
|             <horstretch>0</horstretch> | ||||
|             <verstretch>0</verstretch> | ||||
|            </sizepolicy> | ||||
|           </property> | ||||
|           <property name="layoutDirection"> | ||||
|            <enum>Qt::RightToLeft</enum> | ||||
|           </property> | ||||
|           <property name="text"> | ||||
|            <string>Regenerate</string> | ||||
|           </property> | ||||
|          </widget> | ||||
|         </item> | ||||
|        </layout> | ||||
|       </widget> | ||||
|      </item> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue