summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2018-08-16 10:37:56 -0400
committerGravatar Lioncash2018-08-16 10:37:58 -0400
commit9791f0d5905ac29cf87756f4344ed3b6d3ac9a86 (patch)
treeaa32c23d6180e0b022acb078893aef5d9d257775 /src
parentqt/main: Make installation dialog text within OnMenuInstallToNAND() translatable (diff)
downloadyuzu-9791f0d5905ac29cf87756f4344ed3b6d3ac9a86.tar.gz
yuzu-9791f0d5905ac29cf87756f4344ed3b6d3ac9a86.tar.xz
yuzu-9791f0d5905ac29cf87756f4344ed3b6d3ac9a86.zip
qt/main: Unindent code in OnMenuInstallToNAND()
We can change this into an early-return if the filename is empty. There's no need to include all of the code within the if statement.
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/main.cpp140
1 files changed, 70 insertions, 70 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index b8fc7d514..2df65023a 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -628,6 +628,10 @@ void GMainWindow::OnMenuInstallToNAND() {
628 QString filename = QFileDialog::getOpenFileName(this, tr("Install File"), 628 QString filename = QFileDialog::getOpenFileName(this, tr("Install File"),
629 UISettings::values.roms_path, file_filter); 629 UISettings::values.roms_path, file_filter);
630 630
631 if (filename.isEmpty()) {
632 return;
633 }
634
631 const auto qt_raw_copy = [this](FileSys::VirtualFile src, FileSys::VirtualFile dest) { 635 const auto qt_raw_copy = [this](FileSys::VirtualFile src, FileSys::VirtualFile dest) {
632 if (src == nullptr || dest == nullptr) 636 if (src == nullptr || dest == nullptr)
633 return false; 637 return false;
@@ -679,86 +683,82 @@ void GMainWindow::OnMenuInstallToNAND() {
679 QMessageBox::Yes; 683 QMessageBox::Yes;
680 }; 684 };
681 685
682 if (!filename.isEmpty()) { 686 if (filename.endsWith("xci", Qt::CaseInsensitive)) {
683 if (filename.endsWith("xci", Qt::CaseInsensitive)) { 687 const auto xci = std::make_shared<FileSys::XCI>(
684 const auto xci = std::make_shared<FileSys::XCI>( 688 vfs->OpenFile(filename.toStdString(), FileSys::Mode::Read));
685 vfs->OpenFile(filename.toStdString(), FileSys::Mode::Read)); 689 if (xci->GetStatus() != Loader::ResultStatus::Success) {
686 if (xci->GetStatus() != Loader::ResultStatus::Success) { 690 failed();
687 failed(); 691 return;
688 return; 692 }
689 } 693 const auto res =
690 const auto res = 694 Service::FileSystem::GetUserNANDContents()->InstallEntry(xci, false, qt_raw_copy);
691 Service::FileSystem::GetUserNANDContents()->InstallEntry(xci, false, qt_raw_copy); 695 if (res == FileSys::InstallResult::Success) {
692 if (res == FileSys::InstallResult::Success) { 696 success();
693 success(); 697 } else {
694 } else { 698 if (res == FileSys::InstallResult::ErrorAlreadyExists) {
695 if (res == FileSys::InstallResult::ErrorAlreadyExists) { 699 if (overwrite()) {
696 if (overwrite()) { 700 const auto res2 = Service::FileSystem::GetUserNANDContents()->InstallEntry(
697 const auto res2 = Service::FileSystem::GetUserNANDContents()->InstallEntry( 701 xci, true, qt_raw_copy);
698 xci, true, qt_raw_copy); 702 if (res2 == FileSys::InstallResult::Success) {
699 if (res2 == FileSys::InstallResult::Success) { 703 success();
700 success(); 704 } else {
701 } else { 705 failed();
702 failed();
703 }
704 } 706 }
705 } else {
706 failed();
707 } 707 }
708 } 708 } else {
709 } else {
710 const auto nca = std::make_shared<FileSys::NCA>(
711 vfs->OpenFile(filename.toStdString(), FileSys::Mode::Read));
712 if (nca->GetStatus() != Loader::ResultStatus::Success) {
713 failed(); 709 failed();
714 return;
715 }
716
717 const QStringList tt_options{tr("System Application"),
718 tr("System Archive"),
719 tr("System Application Update"),
720 tr("Firmware Package (Type A)"),
721 tr("Firmware Package (Type B)"),
722 tr("Game"),
723 tr("Game Update"),
724 tr("Game DLC"),
725 tr("Delta Title")};
726 bool ok;
727 const auto item = QInputDialog::getItem(
728 this, tr("Select NCA Install Type..."),
729 tr("Please select the type of title you would like to install this NCA as:\n(In "
730 "most instances, the default 'Game' is fine.)"),
731 tt_options, 5, false, &ok);
732
733 auto index = tt_options.indexOf(item);
734 if (!ok || index == -1) {
735 QMessageBox::warning(this, tr("Failed to Install"),
736 tr("The title type you selected for the NCA is invalid."));
737 return;
738 } 710 }
711 }
712 } else {
713 const auto nca = std::make_shared<FileSys::NCA>(
714 vfs->OpenFile(filename.toStdString(), FileSys::Mode::Read));
715 if (nca->GetStatus() != Loader::ResultStatus::Success) {
716 failed();
717 return;
718 }
739 719
740 if (index >= 5) 720 const QStringList tt_options{tr("System Application"),
741 index += 0x7B; 721 tr("System Archive"),
722 tr("System Application Update"),
723 tr("Firmware Package (Type A)"),
724 tr("Firmware Package (Type B)"),
725 tr("Game"),
726 tr("Game Update"),
727 tr("Game DLC"),
728 tr("Delta Title")};
729 bool ok;
730 const auto item = QInputDialog::getItem(
731 this, tr("Select NCA Install Type..."),
732 tr("Please select the type of title you would like to install this NCA as:\n(In "
733 "most instances, the default 'Game' is fine.)"),
734 tt_options, 5, false, &ok);
735
736 auto index = tt_options.indexOf(item);
737 if (!ok || index == -1) {
738 QMessageBox::warning(this, tr("Failed to Install"),
739 tr("The title type you selected for the NCA is invalid."));
740 return;
741 }
742 742
743 const auto res = Service::FileSystem::GetUserNANDContents()->InstallEntry( 743 if (index >= 5)
744 nca, static_cast<FileSys::TitleType>(index), false, qt_raw_copy); 744 index += 0x7B;
745 if (res == FileSys::InstallResult::Success) { 745
746 success(); 746 const auto res = Service::FileSystem::GetUserNANDContents()->InstallEntry(
747 } else { 747 nca, static_cast<FileSys::TitleType>(index), false, qt_raw_copy);
748 if (res == FileSys::InstallResult::ErrorAlreadyExists) { 748 if (res == FileSys::InstallResult::Success) {
749 if (overwrite()) { 749 success();
750 const auto res2 = Service::FileSystem::GetUserNANDContents()->InstallEntry( 750 } else if (res == FileSys::InstallResult::ErrorAlreadyExists) {
751 nca, static_cast<FileSys::TitleType>(index), true, qt_raw_copy); 751 if (overwrite()) {
752 if (res2 == FileSys::InstallResult::Success) { 752 const auto res2 = Service::FileSystem::GetUserNANDContents()->InstallEntry(
753 success(); 753 nca, static_cast<FileSys::TitleType>(index), true, qt_raw_copy);
754 } else { 754 if (res2 == FileSys::InstallResult::Success) {
755 failed(); 755 success();
756 }
757 }
758 } else { 756 } else {
759 failed(); 757 failed();
760 } 758 }
761 } 759 }
760 } else {
761 failed();
762 } 762 }
763 } 763 }
764} 764}