diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/main.cpp | 109 | ||||
| -rw-r--r-- | src/yuzu/main.h | 1 | ||||
| -rw-r--r-- | src/yuzu/main.ui | 8 |
3 files changed, 101 insertions, 17 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 236642fb9..b2ae3db52 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -1604,6 +1604,7 @@ void GMainWindow::ConnectMenuEvents() { | |||
| 1604 | connect_menu(ui->action_Open_yuzu_Folder, &GMainWindow::OnOpenYuzuFolder); | 1604 | connect_menu(ui->action_Open_yuzu_Folder, &GMainWindow::OnOpenYuzuFolder); |
| 1605 | connect_menu(ui->action_Verify_installed_contents, &GMainWindow::OnVerifyInstalledContents); | 1605 | connect_menu(ui->action_Verify_installed_contents, &GMainWindow::OnVerifyInstalledContents); |
| 1606 | connect_menu(ui->action_Install_Firmware, &GMainWindow::OnInstallFirmware); | 1606 | connect_menu(ui->action_Install_Firmware, &GMainWindow::OnInstallFirmware); |
| 1607 | connect_menu(ui->action_Install_Keys, &GMainWindow::OnInstallDecryptionKeys); | ||
| 1607 | connect_menu(ui->action_About, &GMainWindow::OnAbout); | 1608 | connect_menu(ui->action_About, &GMainWindow::OnAbout); |
| 1608 | } | 1609 | } |
| 1609 | 1610 | ||
| @@ -1633,6 +1634,7 @@ void GMainWindow::UpdateMenuState() { | |||
| 1633 | } | 1634 | } |
| 1634 | 1635 | ||
| 1635 | ui->action_Install_Firmware->setEnabled(!emulation_running); | 1636 | ui->action_Install_Firmware->setEnabled(!emulation_running); |
| 1637 | ui->action_Install_Keys->setEnabled(!emulation_running); | ||
| 1636 | 1638 | ||
| 1637 | for (QAction* action : applet_actions) { | 1639 | for (QAction* action : applet_actions) { |
| 1638 | action->setEnabled(is_firmware_available && !emulation_running); | 1640 | action->setEnabled(is_firmware_available && !emulation_running); |
| @@ -4169,9 +4171,8 @@ void GMainWindow::OnInstallFirmware() { | |||
| 4169 | return; | 4171 | return; |
| 4170 | } | 4172 | } |
| 4171 | 4173 | ||
| 4172 | QString firmware_source_location = | 4174 | const QString firmware_source_location = QFileDialog::getExistingDirectory( |
| 4173 | QFileDialog::getExistingDirectory(this, tr("Select Dumped Firmware Source Location"), | 4175 | this, tr("Select Dumped Firmware Source Location"), {}, QFileDialog::ShowDirsOnly); |
| 4174 | QString::fromStdString(""), QFileDialog::ShowDirsOnly); | ||
| 4175 | if (firmware_source_location.isEmpty()) { | 4176 | if (firmware_source_location.isEmpty()) { |
| 4176 | return; | 4177 | return; |
| 4177 | } | 4178 | } |
| @@ -4202,8 +4203,9 @@ void GMainWindow::OnInstallFirmware() { | |||
| 4202 | std::vector<std::filesystem::path> out; | 4203 | std::vector<std::filesystem::path> out; |
| 4203 | const Common::FS::DirEntryCallable callback = | 4204 | const Common::FS::DirEntryCallable callback = |
| 4204 | [&out](const std::filesystem::directory_entry& entry) { | 4205 | [&out](const std::filesystem::directory_entry& entry) { |
| 4205 | if (entry.path().has_extension() && entry.path().extension() == ".nca") | 4206 | if (entry.path().has_extension() && entry.path().extension() == ".nca") { |
| 4206 | out.emplace_back(entry.path()); | 4207 | out.emplace_back(entry.path()); |
| 4208 | } | ||
| 4207 | 4209 | ||
| 4208 | return true; | 4210 | return true; |
| 4209 | }; | 4211 | }; |
| @@ -4235,7 +4237,6 @@ void GMainWindow::OnInstallFirmware() { | |||
| 4235 | auto firmware_vdir = sysnand_content_vdir->GetDirectoryRelative("registered"); | 4237 | auto firmware_vdir = sysnand_content_vdir->GetDirectoryRelative("registered"); |
| 4236 | 4238 | ||
| 4237 | bool success = true; | 4239 | bool success = true; |
| 4238 | bool cancelled = false; | ||
| 4239 | int i = 0; | 4240 | int i = 0; |
| 4240 | for (const auto& firmware_src_path : out) { | 4241 | for (const auto& firmware_src_path : out) { |
| 4241 | i++; | 4242 | i++; |
| @@ -4250,24 +4251,22 @@ void GMainWindow::OnInstallFirmware() { | |||
| 4250 | success = false; | 4251 | success = false; |
| 4251 | } | 4252 | } |
| 4252 | 4253 | ||
| 4253 | if (QtProgressCallback(100, 20 + (int)(((float)(i) / (float)out.size()) * 70.0))) { | 4254 | if (QtProgressCallback( |
| 4254 | success = false; | 4255 | 100, 20 + static_cast<int>(((i) / static_cast<float>(out.size())) * 70.0))) { |
| 4255 | cancelled = true; | 4256 | progress.close(); |
| 4256 | break; | 4257 | QMessageBox::warning( |
| 4258 | this, tr("Firmware install failed"), | ||
| 4259 | tr("Firmware installation cancelled, firmware may be in bad state, " | ||
| 4260 | "restart yuzu or re-install firmware.")); | ||
| 4261 | return; | ||
| 4257 | } | 4262 | } |
| 4258 | } | 4263 | } |
| 4259 | 4264 | ||
| 4260 | if (!success && !cancelled) { | 4265 | if (!success) { |
| 4261 | progress.close(); | 4266 | progress.close(); |
| 4262 | QMessageBox::critical(this, tr("Firmware install failed"), | 4267 | QMessageBox::critical(this, tr("Firmware install failed"), |
| 4263 | tr("One or more firmware files failed to copy into NAND.")); | 4268 | tr("One or more firmware files failed to copy into NAND.")); |
| 4264 | return; | 4269 | return; |
| 4265 | } else if (cancelled) { | ||
| 4266 | progress.close(); | ||
| 4267 | QMessageBox::warning(this, tr("Firmware install failed"), | ||
| 4268 | tr("Firmware installation cancelled, firmware may be in bad state, " | ||
| 4269 | "restart yuzu or re-install firmware.")); | ||
| 4270 | return; | ||
| 4271 | } | 4270 | } |
| 4272 | 4271 | ||
| 4273 | // Re-scan VFS for the newly placed firmware files. | 4272 | // Re-scan VFS for the newly placed firmware files. |
| @@ -4295,6 +4294,84 @@ void GMainWindow::OnInstallFirmware() { | |||
| 4295 | OnCheckFirmwareDecryption(); | 4294 | OnCheckFirmwareDecryption(); |
| 4296 | } | 4295 | } |
| 4297 | 4296 | ||
| 4297 | void GMainWindow::OnInstallDecryptionKeys() { | ||
| 4298 | // Don't do this while emulation is running. | ||
| 4299 | if (emu_thread != nullptr && emu_thread->IsRunning()) { | ||
| 4300 | return; | ||
| 4301 | } | ||
| 4302 | |||
| 4303 | const QString key_source_location = QFileDialog::getOpenFileName( | ||
| 4304 | this, tr("Select Dumped Keys Location"), {}, QStringLiteral("prod.keys (prod.keys)"), {}, | ||
| 4305 | QFileDialog::ReadOnly); | ||
| 4306 | if (key_source_location.isEmpty()) { | ||
| 4307 | return; | ||
| 4308 | } | ||
| 4309 | |||
| 4310 | // Verify that it contains prod.keys, title.keys and optionally, key_retail.bin | ||
| 4311 | LOG_INFO(Frontend, "Installing key files from {}", key_source_location.toStdString()); | ||
| 4312 | |||
| 4313 | const std::filesystem::path prod_key_path = key_source_location.toStdString(); | ||
| 4314 | const std::filesystem::path key_source_path = prod_key_path.parent_path(); | ||
| 4315 | if (!Common::FS::IsDir(key_source_path)) { | ||
| 4316 | return; | ||
| 4317 | } | ||
| 4318 | |||
| 4319 | bool prod_keys_found = false; | ||
| 4320 | std::vector<std::filesystem::path> source_key_files; | ||
| 4321 | |||
| 4322 | if (Common::FS::Exists(prod_key_path)) { | ||
| 4323 | prod_keys_found = true; | ||
| 4324 | source_key_files.emplace_back(prod_key_path); | ||
| 4325 | } | ||
| 4326 | |||
| 4327 | if (Common::FS::Exists(key_source_path / "title.keys")) { | ||
| 4328 | source_key_files.emplace_back(key_source_path / "title.keys"); | ||
| 4329 | } | ||
| 4330 | |||
| 4331 | if (Common::FS::Exists(key_source_path / "key_retail.bin")) { | ||
| 4332 | source_key_files.emplace_back(key_source_path / "key_retail.bin"); | ||
| 4333 | } | ||
| 4334 | |||
| 4335 | // There should be at least prod.keys. | ||
| 4336 | if (source_key_files.empty() || !prod_keys_found) { | ||
| 4337 | QMessageBox::warning(this, tr("Decryption Keys install failed"), | ||
| 4338 | tr("prod.keys is a required decryption key file.")); | ||
| 4339 | return; | ||
| 4340 | } | ||
| 4341 | |||
| 4342 | const auto yuzu_keys_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::KeysDir); | ||
| 4343 | for (auto key_file : source_key_files) { | ||
| 4344 | std::filesystem::path destination_key_file = yuzu_keys_dir / key_file.filename(); | ||
| 4345 | if (!std::filesystem::copy_file(key_file, destination_key_file, | ||
| 4346 | std::filesystem::copy_options::overwrite_existing)) { | ||
| 4347 | LOG_ERROR(Frontend, "Failed to copy file {} to {}", key_file.string(), | ||
| 4348 | destination_key_file.string()); | ||
| 4349 | QMessageBox::critical(this, tr("Decryption Keys install failed"), | ||
| 4350 | tr("One or more keys failed to copy.")); | ||
| 4351 | return; | ||
| 4352 | } | ||
| 4353 | } | ||
| 4354 | |||
| 4355 | // Reinitialize the key manager, re-read the vfs (for update/dlc files), | ||
| 4356 | // and re-populate the game list in the UI if the user has already added | ||
| 4357 | // game folders. | ||
| 4358 | Core::Crypto::KeyManager::Instance().ReloadKeys(); | ||
| 4359 | system->GetFileSystemController().CreateFactories(*vfs); | ||
| 4360 | game_list->PopulateAsync(UISettings::values.game_dirs); | ||
| 4361 | |||
| 4362 | if (ContentManager::AreKeysPresent()) { | ||
| 4363 | QMessageBox::information(this, tr("Decryption Keys install succeeded"), | ||
| 4364 | tr("Decryption Keys were successfully installed")); | ||
| 4365 | } else { | ||
| 4366 | QMessageBox::critical( | ||
| 4367 | this, tr("Decryption Keys install failed"), | ||
| 4368 | tr("Decryption Keys failed to initialize. Check that your dumping tools are " | ||
| 4369 | "up to date and re-dump keys.")); | ||
| 4370 | } | ||
| 4371 | |||
| 4372 | OnCheckFirmwareDecryption(); | ||
| 4373 | } | ||
| 4374 | |||
| 4298 | void GMainWindow::OnAbout() { | 4375 | void GMainWindow::OnAbout() { |
| 4299 | AboutDialog aboutDialog(this); | 4376 | AboutDialog aboutDialog(this); |
| 4300 | aboutDialog.exec(); | 4377 | aboutDialog.exec(); |
diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 1f0e35c67..fce643f3f 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h | |||
| @@ -381,6 +381,7 @@ private slots: | |||
| 381 | void OnOpenYuzuFolder(); | 381 | void OnOpenYuzuFolder(); |
| 382 | void OnVerifyInstalledContents(); | 382 | void OnVerifyInstalledContents(); |
| 383 | void OnInstallFirmware(); | 383 | void OnInstallFirmware(); |
| 384 | void OnInstallDecryptionKeys(); | ||
| 384 | void OnAbout(); | 385 | void OnAbout(); |
| 385 | void OnToggleFilterBar(); | 386 | void OnToggleFilterBar(); |
| 386 | void OnToggleStatusBar(); | 387 | void OnToggleStatusBar(); |
diff --git a/src/yuzu/main.ui b/src/yuzu/main.ui index 6ff444a22..85dc1f2f6 100644 --- a/src/yuzu/main.ui +++ b/src/yuzu/main.ui | |||
| @@ -165,8 +165,9 @@ | |||
| 165 | <addaction name="separator"/> | 165 | <addaction name="separator"/> |
| 166 | <addaction name="action_Configure_Tas"/> | 166 | <addaction name="action_Configure_Tas"/> |
| 167 | </widget> | 167 | </widget> |
| 168 | <addaction name="action_Verify_installed_contents"/> | 168 | <addaction name="action_Install_Keys"/> |
| 169 | <addaction name="action_Install_Firmware"/> | 169 | <addaction name="action_Install_Firmware"/> |
| 170 | <addaction name="action_Verify_installed_contents"/> | ||
| 170 | <addaction name="separator"/> | 171 | <addaction name="separator"/> |
| 171 | <addaction name="menu_cabinet_applet"/> | 172 | <addaction name="menu_cabinet_applet"/> |
| 172 | <addaction name="action_Load_Album"/> | 173 | <addaction name="action_Load_Album"/> |
| @@ -469,6 +470,11 @@ | |||
| 469 | <string>Install Firmware</string> | 470 | <string>Install Firmware</string> |
| 470 | </property> | 471 | </property> |
| 471 | </action> | 472 | </action> |
| 473 | <action name="action_Install_Keys"> | ||
| 474 | <property name="text"> | ||
| 475 | <string>Install Decryption Keys</string> | ||
| 476 | </property> | ||
| 477 | </action> | ||
| 472 | </widget> | 478 | </widget> |
| 473 | <resources> | 479 | <resources> |
| 474 | <include location="yuzu.qrc"/> | 480 | <include location="yuzu.qrc"/> |