diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 08e3e80f32..2ab91f4284 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,6 +6,9 @@ updates: schedule: # Check for updates to GitHub Actions every week interval: "weekly" + commit-message: + # Prefix all commit messages with "Deps/gha: " + prefix: "Deps/gha" groups: ci-deps: patterns: diff --git a/.github/workflows/linux_build_qt.yml b/.github/workflows/linux_build_qt.yml index e3deb0f5b9..5828366208 100644 --- a/.github/workflows/linux_build_qt.yml +++ b/.github/workflows/linux_build_qt.yml @@ -92,7 +92,7 @@ jobs: run: echo "timestamp=$(date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT - name: ccache cache files - uses: actions/cache@v5 + uses: actions/cache@v6 with: path: .ccache key: ${{ inputs.os }} ${{ inputs.platform }} ${{ inputs.compiler }} ccache ${{ steps.ccache_cache_timestamp.outputs.timestamp }} @@ -114,7 +114,7 @@ jobs: - name: Cache Dependencies id: cache-deps - uses: actions/cache@v5 + uses: actions/cache@v6 with: path: ~/deps key: ${{ inputs.os }} ${{ inputs.platform }} deps ${{ hashFiles('.github/workflows/scripts/linux/build-dependencies-qt.sh', '.github/workflows/scripts/common/*.patch') }} diff --git a/.github/workflows/macos_build.yml b/.github/workflows/macos_build.yml index 76e03271d4..c984df58a9 100644 --- a/.github/workflows/macos_build.yml +++ b/.github/workflows/macos_build.yml @@ -95,7 +95,7 @@ jobs: - name: Cache Dependencies id: cache-deps - uses: actions/cache@v5 + uses: actions/cache@v6 with: path: ~/deps key: ${{ inputs.os }} arm64 deps ${{ hashFiles('.github/workflows/scripts/macos/*', '.github/workflows/scripts/common/*.patch') }} @@ -116,7 +116,7 @@ jobs: run: echo "timestamp=$(date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT - name: Cache ccache cache - uses: actions/cache@v5 + uses: actions/cache@v6 with: path: .ccache key: ${{ inputs.os }} arm64 ccache ${{ steps.ccache_cache_timestamp.outputs.timestamp }} @@ -171,7 +171,7 @@ jobs: - name: Sign the Application (Apple notarization) if: ${{ inputs.sign_and_notarize == true && env.SIGN_KEY }} - uses: indygreg/apple-code-sign-action@44d0985b7f4363198e80b6fea63ac3e9dd3e9957 + uses: indygreg/apple-code-sign-action@5e7a4a01fe4dffe948ef3bcf1f4538d963cb0c72 with: input_path: 'ARMSX2.app' p12_file: cert.p12 diff --git a/.github/workflows/windows_build_qt.yml b/.github/workflows/windows_build_qt.yml index 8cf24f8804..66e2ea40b4 100644 --- a/.github/workflows/windows_build_qt.yml +++ b/.github/workflows/windows_build_qt.yml @@ -90,7 +90,7 @@ jobs: - name: Cache Dependencies id: cache-deps - uses: actions/cache@v5 + uses: actions/cache@v6 with: path: deps-arm64 key: ${{ inputs.os }} arm64 deps ${{ hashFiles('.github/workflows/scripts/windows/build-dependencies-arm64.bat', '.github/workflows/scripts/windows/*.patch', '.github/workflows/scripts/common/*.patch') }} diff --git a/.gitignore b/.gitignore index 569f7b502d..1d17d74e8d 100644 --- a/.gitignore +++ b/.gitignore @@ -66,6 +66,9 @@ oprofile_data/ *.kdev4 /.kdev4* +# Kate Projects +.kateproject* + # Resources and docs in /bin are tracked /bin/**/*.dll /bin/**/*.dmp diff --git a/bin/resources/shaders/dx11/tfx.fx b/bin/resources/shaders/dx11/tfx.fx index 5f1bd97a59..528ef12c53 100644 --- a/bin/resources/shaders/dx11/tfx.fx +++ b/bin/resources/shaders/dx11/tfx.fx @@ -198,7 +198,7 @@ struct PS_OUTPUT #if PS_RETURN_COLOR #if PS_DATE == 1 || PS_DATE == 2 - float c : SV_Target; + float c0 : SV_Target; #else float4 c0 : SV_Target0; diff --git a/common/YAML.cpp b/common/YAML.cpp index 5630c3e556..8751fb96db 100644 --- a/common/YAML.cpp +++ b/common/YAML.cpp @@ -119,10 +119,16 @@ std::optional ParseYAMLFromString(ryml::csubstr yaml, ryml::csubstr #else callbacks.m_user_data = static_cast(&context); callbacks.m_error = [](const char* msg, size_t msg_len, ryml::Location location, void* user_data) { - RapidYAMLContext* context = static_cast(user_data); - - Error::SetString(context->error, std::string(msg, msg_len)); - std::longjmp(context->env, 1); + if (RapidYAMLContext* context = static_cast(user_data)) + { + Error::SetString(context->error, std::string(msg, msg_len)); + std::longjmp(context->env, 1); + } + else + { + std::string description(msg, msg_len); + pxFailRel(description.c_str()); + } }; #endif diff --git a/pcsx2-qt/QtUtils.cpp b/pcsx2-qt/QtUtils.cpp index 053282a36c..0f7660f10d 100644 --- a/pcsx2-qt/QtUtils.cpp +++ b/pcsx2-qt/QtUtils.cpp @@ -4,10 +4,12 @@ #include "QtUtils.h" #include +#include #include #include #include #include +#include #include #include #include @@ -15,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -27,21 +30,35 @@ #include #include +#include + #ifdef Q_OS_LINUX #include #endif #include #include +#include #include #include "common/CocoaTools.h" #include "common/Console.h" +#include "common/FileSystem.h" +#include "common/Path.h" +#include "common/StringUtil.h" +#include "pcsx2/Config.h" #include "QtHost.h" #if defined(_WIN32) #include "common/RedtapeWindows.h" +#include "common/RedtapeWilCom.h" #include +#include +#include +#else +#include +#include +#include #endif namespace QtUtils @@ -549,4 +566,453 @@ namespace QtUtils const QString flag_path = QStringLiteral("%1/icons/flags/%2.svg").arg(QtHost::GetResourcesBasePath()).arg(country_code.toLower()); return QIcon(flag_path); } + + bool IsRunningInFlatpak() + { + // Checks for the existence of the `.flatpak-info` file which seems to be always present inside flatpak sandboxes. + return FileSystem::FileExists("/.flatpak-info"); + } + + bool IsRunningInAppImage() + { + // The AppImage runtime sets APPIMAGE environment variable so we can check for that. + return std::getenv("APPIMAGE") != nullptr; + } + + void CreateShortcut(QWidget* parent, const std::string& name, const std::string& game_path, + std::vector passed_cli_args, const std::string& custom_args, + const std::string& icon_path, bool is_desktop, bool prompt_for_destination) + { + const auto tr_msg = [](const char* str) { + return QCoreApplication::translate("CreateShortcut", str); + }; + +#if defined(_WIN32) + if (name.empty()) + { + Console.Error("Cannot create shortcuts without a name."); + return; + } + + // Sanitize filename + const std::string clean_name = Path::SanitizeFileName(name); + std::string clean_path = game_path.empty() ? std::string() : Path::ToNativePath(Path::RealPath(game_path)); + if (!Path::IsValidFileName(clean_name)) + { + QMessageBox::critical(parent, tr_msg("Failed to create shortcut"), tr_msg("Filename contains illegal character."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); + return; + } + + // Get path to Desktop or per-user Start Menu\Programs directory + // https://superuser.com/questions/1489874/how-can-i-get-the-real-path-of-desktop-in-windows-explorer/1789849#1789849 + // https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath + // https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid + std::string link_file; + if (wil::unique_cotaskmem_string directory; SUCCEEDED(SHGetKnownFolderPath(is_desktop ? FOLDERID_Desktop : FOLDERID_Programs, 0, NULL, &directory))) + { + std::string directory_utf8 = StringUtil::WideStringToUTF8String(directory.get()); + + if (is_desktop) + link_file = Path::ToNativePath(fmt::format("{}/{}.lnk", directory_utf8, clean_name)); + else + { + const std::string pcsx2_start_menu_dir = Path::ToNativePath(fmt::format("{}/PCSX2", directory_utf8)); + if (!FileSystem::EnsureDirectoryExists(pcsx2_start_menu_dir.c_str(), false)) + { + QMessageBox::critical(parent, tr_msg("Failed to create shortcut"), tr_msg("Could not create start menu directory."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); + return; + } + + link_file = Path::ToNativePath(fmt::format("{}/{}.lnk", pcsx2_start_menu_dir, clean_name)); + } + } + else + { + QMessageBox::critical(parent, tr_msg("Failed to create shortcut"), is_desktop ? tr_msg("'Desktop' directory not found") : tr_msg("User's 'Start Menu\\Programs' directory not found"), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); + return; + } + + // Check if the same shortcut already exists + if (prompt_for_destination && FileSystem::FileExists(link_file.c_str())) + { + QMessageBox::critical(parent, tr_msg("Failed to create shortcut"), tr_msg("A shortcut with the same name already exists."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); + return; + } + + // Shortcut CmdLine Args + bool lossless = true; + for (std::string& arg : passed_cli_args) + lossless &= EscapeShortcutCommandLine(&arg); + if (!clean_path.empty()) + lossless &= EscapeShortcutCommandLine(&clean_path); + + if (!lossless) + { + QMessageBox::critical(parent, tr_msg("Failed to create shortcut"), tr_msg("File path contains invalid character(s)."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); + return; + } + + std::string final_args = StringUtil::JoinString(passed_cli_args.begin(), passed_cli_args.end(), " "); + if (!custom_args.empty()) + { + if (!final_args.empty()) + final_args += ' '; + final_args += custom_args; + } + if (!clean_path.empty()) + { + if (!final_args.empty()) + final_args += ' '; + final_args += fmt::format("-- {}", clean_path); + } + + Console.WriteLnFmt("Creating a shortcut '{}' with arguments '{}'", link_file, final_args); + + const auto str_error = [](HRESULT hr) -> std::string { + _com_error err(hr); + const TCHAR* errMsg = err.ErrorMessage(); + return fmt::format("{} [{}]", StringUtil::WideStringToUTF8String(errMsg), hr); + }; + + // Construct the shortcut + // https://stackoverflow.com/questions/3906974/how-to-programmatically-create-a-shortcut-using-win32 + HRESULT res = CoInitialize(NULL); + if (FAILED(res)) + { + Console.ErrorFmt("Failed to create shortcut: CoInitialize failed ({})", str_error(res)); + QMessageBox::critical(parent, tr_msg("Failed to create shortcut"), tr_msg("CoInitialize failed (%1)").arg(QString::fromStdString(str_error(res))), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); + return; + } + + wil::unique_couninitialize_call co_cleanup; + + const auto report_error = [&](const QString& reason) { + Console.ErrorFmt("Failed to create shortcut: {}", reason.toStdString()); + QMessageBox::critical(parent, tr_msg("Failed to create shortcut"), reason, QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); + }; + + wil::com_ptr_nothrow pShellLink = wil::CoCreateInstanceNoThrow(CLSID_ShellLink); + wil::com_ptr_nothrow pPersistFile; + + if (!pShellLink) + { + report_error(tr_msg("CoCreateInstance failed")); + return; + } + + // Set path to the executable + const std::wstring target_file = StringUtil::UTF8StringToWideString(FileSystem::GetProgramPath()); + res = pShellLink->SetPath(target_file.c_str()); + if (FAILED(res)) + { + report_error(tr_msg("SetPath failed (%1)").arg(QString::fromStdString(str_error(res)))); + return; + } + + // Set the working directory + const std::wstring working_dir = StringUtil::UTF8StringToWideString(Path::GetDirectory(FileSystem::GetProgramPath())); + res = pShellLink->SetWorkingDirectory(working_dir.c_str()); + if (FAILED(res)) + { + report_error(tr_msg("SetWorkingDirectory failed (%1)").arg(QString::fromStdString(str_error(res)))); + return; + } + + // Set the description (shown as the shortcut's tooltip) + const std::wstring description = tr_msg("PlayStation 2 Emulator").toStdWString(); + res = pShellLink->SetDescription(description.c_str()); + if (FAILED(res)) + { + report_error(tr_msg("SetDescription failed (%1)").arg(QString::fromStdString(str_error(res)))); + return; + } + + // Set the launch arguments + if (!final_args.empty()) + { + const std::wstring target_cli_args = StringUtil::UTF8StringToWideString(final_args); + res = pShellLink->SetArguments(target_cli_args.c_str()); + if (FAILED(res)) + { + report_error(tr_msg("SetArguments failed (%1)").arg(QString::fromStdString(str_error(res)))); + return; + } + } + + // Set the icon + std::string final_icon_path; + if (!icon_path.empty()) + { + final_icon_path = Path::ToNativePath(icon_path); + if (!FileSystem::FileExists(final_icon_path.c_str())) + { + QMessageBox::critical(parent, tr_msg("Failed to create shortcut"), tr_msg("The selected icon file does not exist."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); + return; + } + } + else + { + final_icon_path = Path::ToNativePath(Path::Combine(Path::GetDirectory(FileSystem::GetProgramPath()), "resources/icons/AppIconLarge.ico")); + } + + const std::wstring w_icon_path = StringUtil::UTF8StringToWideString(final_icon_path); + res = pShellLink->SetIconLocation(w_icon_path.c_str(), 0); + if (FAILED(res)) + { + report_error(tr_msg("SetIconLocation failed (%1)").arg(QString::fromStdString(str_error(res)))); + return; + } + + // Use the IPersistFile object to save the shell link + res = pShellLink.query_to(&pPersistFile); + if (FAILED(res)) + { + report_error(tr_msg("QueryInterface failed (%1)").arg(QString::fromStdString(str_error(res)))); + return; + } + + // Save shortcut link to disk + const std::wstring w_link_file = StringUtil::UTF8StringToWideString(link_file); + res = pPersistFile->Save(w_link_file.c_str(), TRUE); + if (FAILED(res)) + { + report_error(tr_msg("Failed to save the shortcut (%1)").arg(QString::fromStdString(str_error(res)))); + return; + } + +#else + + if (name.empty()) + { + QMessageBox::critical(parent, tr_msg("Failed to create shortcut"), tr_msg("Cannot create a shortcut without a title."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); + return; + } + + const bool is_flatpak = IsRunningInFlatpak(); + + // Sanitize filename and game path + const std::string clean_name = Path::SanitizeFileName(name); + std::string clean_path = game_path.empty() ? std::string() : Path::Canonicalize(Path::RealPath(game_path)); + if (!Path::IsValidFileName(clean_name)) + { + QMessageBox::critical(parent, tr_msg("Failed to create shortcut"), tr_msg("Filename contains illegal character."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); + return; + } + + // Find the executable path + std::string executable_path = FileSystem::GetPackagePath(); + if (executable_path.empty()) + { + QMessageBox::critical(parent, tr_msg("Failed to create shortcut"), tr_msg("Executable path is empty."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); + return; + } + + // Find the destination directory + const QString link_dir = QStandardPaths::writableLocation(is_desktop ? QStandardPaths::DesktopLocation : QStandardPaths::ApplicationsLocation); + if (link_dir.isEmpty()) + { + QMessageBox::critical(parent, tr_msg("Failed to create shortcut"), tr_msg("Could not determine the shortcut destination directory."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); + return; + } + const std::string link_path = fmt::format("{}/{}.desktop", link_dir.toStdString(), clean_name); + + std::string icon_name; + if (!icon_path.empty()) + { + if (!FileSystem::FileExists(icon_path.c_str())) + { + QMessageBox::critical(parent, tr_msg("Failed to create shortcut"), tr_msg("The selected icon file does not exist."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); + return; + } + icon_name = icon_path; + } + else + { + if (is_flatpak) // Flatpak + { + executable_path = "flatpak run net.pcsx2.PCSX2"; + icon_name = "net.pcsx2.PCSX2"; + } + else + { + // Copy PCSX2 icon + icon_name = "ARMSX2"; + const std::string icon_dest = fmt::format("{}/icons/hicolor/512x512/apps/", QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation).toStdString()); + const std::string icon_path_dest = fmt::format("{}/{}.png", icon_dest, icon_name); + if (FileSystem::EnsureDirectoryExists(icon_dest.c_str(), true)) + FileSystem::CopyFilePath(Path::Combine(EmuFolders::Resources, "icons/AppIconLarge.png").c_str(), icon_path_dest.c_str(), true); + } + } + + // Shortcut CmdLine Args + bool lossless = true; + for (std::string& arg : passed_cli_args) + lossless &= EscapeShortcutCommandLine(&arg); + if (!is_flatpak) + lossless &= EscapeShortcutCommandLine(&executable_path); + if (!clean_path.empty()) + lossless &= EscapeShortcutCommandLine(&clean_path); + + if (!lossless) + { + QMessageBox::critical(parent, tr_msg("Failed to create shortcut"), tr_msg("File path contains invalid character(s)."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); + return; + } + + std::string cmdline = StringUtil::JoinString(passed_cli_args.begin(), passed_cli_args.end(), " "); + + // Assembling the .desktop file + std::string final_args = executable_path; + if (!cmdline.empty()) + final_args += fmt::format(" {}", cmdline); + if (!custom_args.empty()) + final_args += fmt::format(" {}", custom_args); + if (!clean_path.empty()) + final_args += fmt::format(" -- {}", clean_path); + std::string file_content = + "[Desktop Entry]\n" + "Version=1.0\n" + "Type=Application\n" + "Terminal=false\n" + "StartupWMClass=pcsx2-qt\n" + "Exec=" + + final_args + "\n" + + "Name=" + + name + "\n" + + "GenericName=PlayStation 2 Emulator\n" + "Icon=" + + icon_name + "\n" + + "Comment=Sony PlayStation 2 Emulator\n" + "Keywords=game;emulator;\n" + "Categories=Game;Emulator;\n"; + std::string_view sv(file_content); + + QString final_path = QString::fromStdString(link_path); + if (prompt_for_destination) + { + const QString filter(tr_msg("Desktop Shortcut Files (*.desktop)")); + final_path = QDir::toNativeSeparators(QFileDialog::getSaveFileName(parent, tr_msg("Select Shortcut Save Destination"), final_path, filter)); + if (final_path.isEmpty()) + return; + } + else + { + const std::string link_dir(Path::GetDirectory(link_path)); + if (!link_dir.empty() && !FileSystem::EnsureDirectoryExists(link_dir.c_str(), true)) + { + QMessageBox::critical(parent, tr_msg("Failed to create shortcut"), tr_msg("Could not create the shortcut directory."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); + return; + } + } + + // Write to .desktop file + if (!FileSystem::WriteStringToFile(final_path.toStdString().c_str(), sv)) + { + QMessageBox::critical(parent, tr_msg("Failed to create shortcut"), tr_msg("Failed to create .desktop file"), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); + return; + } + + if (chmod(final_path.toStdString().c_str(), S_IRWXU) != 0) // enables user to execute file + Console.ErrorFmt("Failed to change file permissions for .desktop file: {} ({})", strerror(errno), errno); +#endif + } + + bool EscapeShortcutCommandLine(std::string* arg) + { +#ifdef _WIN32 + if (!arg->empty() && arg->find_first_of(" \t\n\v\"") == std::string::npos) + return true; + + std::string temp; + temp.reserve(arg->length() + 10); + temp += '"'; + + for (auto it = arg->begin();; ++it) + { + int backslash_count = 0; + while (it != arg->end() && *it == '\\') + { + ++it; + ++backslash_count; + } + + if (it == arg->end()) + { + temp.append(backslash_count * 2, '\\'); + break; + } + + if (*it == '"') + { + temp.append(backslash_count * 2 + 1, '\\'); + temp += '"'; + } + else + { + temp.append(backslash_count, '\\'); + temp += *it; + } + } + + temp += '"'; + *arg = std::move(temp); + return true; +#else + const char* carg = arg->c_str(); + const char* cend = carg + arg->size(); + const char* RESERVED_CHARS = " \t\n\\\"'\\\\><~|%&;$*?#()`" + "\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f"; + const char* next = carg + std::strcspn(carg, RESERVED_CHARS); + + if (next == cend) + return true; // No escaping needed, don't modify + + bool lossless = true; + std::string temp = "\""; + const char* NOT_VALID_IN_QUOTE = "%`$\"\\\n" + "\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f"; + + while (true) + { + next = carg + std::strcspn(carg, NOT_VALID_IN_QUOTE); + temp.append(carg, next); + carg = next; + + if (carg == cend) + break; + + switch (*carg) + { + case '"': + case '`': + temp.push_back('\\'); + temp.push_back(*carg); + break; + case '\\': + temp.append("\\\\\\\\"); + break; + case '$': + temp.push_back('\\'); + temp.push_back('\\'); + temp.push_back(*carg); + break; + case '%': + temp.push_back('%'); + temp.push_back(*carg); + break; + default: + temp.push_back(' '); + lossless = false; + break; + } + ++carg; + } + + temp.push_back('"'); + *arg = std::move(temp); + return lossless; +#endif + } } // namespace QtUtils diff --git a/pcsx2-qt/QtUtils.h b/pcsx2-qt/QtUtils.h index bf2c629507..11adaf53b8 100644 --- a/pcsx2-qt/QtUtils.h +++ b/pcsx2-qt/QtUtils.h @@ -17,9 +17,11 @@ #include #include #include +#include #include #include #include +#include #include "common/Console.h" @@ -209,4 +211,19 @@ namespace QtUtils /// Gets a flag icon for a given language code /// Returns an empty QIcon if no flag is available for the language QIcon GetFlagIconForLanguage(const QString& language_code); + + /// Returns true if PCSX2 is running inside a Flatpak sandbox. + bool IsRunningInFlatpak(); + + /// Returns true if PCSX2 is running from an AppImage. + bool IsRunningInAppImage(); + + /// Creates a desktop or launcher (Start Menu / applications) shortcuts + void CreateShortcut(QWidget* parent, const std::string& name, const std::string& game_path, + std::vector passed_cli_args, const std::string& custom_args, + const std::string& icon_path, bool is_desktop, bool prompt_for_destination = true); + + /// Escapes the given string for use as a shortcut command line argument. + /// Returns whether the escaping operation was lossless. + bool EscapeShortcutCommandLine(std::string* arg); } // namespace QtUtils diff --git a/pcsx2-qt/SetupWizardDialog.cpp b/pcsx2-qt/SetupWizardDialog.cpp index 98d193b8a8..aefdecaef1 100644 --- a/pcsx2-qt/SetupWizardDialog.cpp +++ b/pcsx2-qt/SetupWizardDialog.cpp @@ -88,6 +88,11 @@ void SetupWizardDialog::nextPage() const int current_page = m_ui.pages->currentIndex(); if (current_page == Page_Complete) { + if (m_ui.createDesktopShortcut->isChecked()) + QtUtils::CreateShortcut(this, "PCSX2", std::string(), {}, std::string(), std::string(), true, false); + if (m_ui.addToApplicationMenu->isChecked()) + QtUtils::CreateShortcut(this, "PCSX2", std::string(), {}, std::string(), std::string(), false, false); + accept(); return; } @@ -177,6 +182,7 @@ void SetupWizardDialog::setupUi() setupGameListPage(); setupControllerPage(); setupRetroAchievementsPage(); + setupCompletePage(); } void SetupWizardDialog::setupLanguagePage() @@ -437,6 +443,22 @@ void SetupWizardDialog::setupRetroAchievementsPage() refreshRetroAchievementsLoginState(); } +void SetupWizardDialog::setupCompletePage() +{ +#if defined(_WIN32) + const bool can_create_shortcuts = true; + m_ui.addToApplicationMenu->setText(tr("Add PCSX2 to the Start Menu")); +#elif defined(__linux__) + // Only offer shortcuts for the AppImage since Flatpak creates its own launcher, and + // third-party builds (AUR, COPR, etc.) ship their own .desktop file. + const bool can_create_shortcuts = QtUtils::IsRunningInAppImage(); +#else + const bool can_create_shortcuts = false; +#endif + m_ui.createDesktopShortcut->setVisible(can_create_shortcuts); + m_ui.addToApplicationMenu->setVisible(can_create_shortcuts); +} + void SetupWizardDialog::refreshRetroAchievementsLoginState() { const std::string username(Host::GetBaseStringSettingValue("Achievements", "Username")); diff --git a/pcsx2-qt/SetupWizardDialog.h b/pcsx2-qt/SetupWizardDialog.h index 3eb4f728ea..ea133896c3 100644 --- a/pcsx2-qt/SetupWizardDialog.h +++ b/pcsx2-qt/SetupWizardDialog.h @@ -66,6 +66,7 @@ private: void setupGameListPage(); void setupControllerPage(); void setupRetroAchievementsPage(); + void setupCompletePage(); void refreshRetroAchievementsLoginState(); void pageChangedTo(int page); diff --git a/pcsx2-qt/SetupWizardDialog.ui b/pcsx2-qt/SetupWizardDialog.ui index 9c4be69bf9..7a9aaf3d23 100644 --- a/pcsx2-qt/SetupWizardDialog.ui +++ b/pcsx2-qt/SetupWizardDialog.ui @@ -23,7 +23,7 @@ 10 - + @@ -61,7 +61,6 @@ - 75 true @@ -127,7 +126,7 @@ 4 - + 4 @@ -145,7 +144,7 @@ 0 - + <html><head/><body><h1 style=" margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:xx-large; font-weight:700;">Welcome to ARMSX2!</span></h1><p>This wizard will help guide you through the configuration steps required to use the application. It is recommended if this is your first time installing ARMSX2 that you view the setup guide <a href="https://pcsx2.net/docs/">here</a>.</p><p>By default, ARMSX2 will connect to the server at <a href="https://pcsx2.net/">pcsx2.net</a> to check for updates, and if available and confirmed, download update packages from <a href="https://github.com/">github.com</a>. If you do not wish for ARMSX2 to make any network connections on startup, you should uncheck the Automatic Updates option now. The Automatic Update setting can be changed later at any time in Interface Settings.</p><p>Please choose a language and theme to begin.</p></body></html> @@ -164,7 +163,7 @@ - + @@ -222,7 +221,7 @@ - + 0 @@ -237,7 +236,7 @@ 0 - + <html><head/><body><p>ARMSX2 requires a PS2 BIOS in order to run.</p><p>For legal reasons, you must obtain a BIOS <strong>from an actual PS2 unit that you own</strong> (borrowing doesn't count).</p><p>Once dumped, this BIOS image should be placed in the bios folder within the data directory shown below, or you can instruct ARMSX2 to scan an alternative directory.</p><p>A guide for dumping your BIOS can be found <a href="https://pcsx2.net/docs/setup/bios/">here</a>.</p></body></html> @@ -256,7 +255,7 @@ - + @@ -310,7 +309,7 @@ - + @@ -342,7 +341,7 @@ - + 0 @@ -357,7 +356,7 @@ 0 - + <html><head/><body><p>ARMSX2 will automatically scan and identify games from the selected directories below, and populate the game list.<br>These games should be dumped from discs you own. Guides for dumping discs can be found <a href="https://pcsx2.net/docs/setup/dumping">here</a>.</p><p>Supported formats for dumps include:</p><p><ul><li>.bin/.iso (ISO Disc Images)</li><li>.mdf (Media Descriptor File)</li><li>.chd (Compressed Hunks of Data)</li><li>.cso (Compressed ISO)</li><li>.zso (Compressed ISO)</li><li>.gz (Gzip Compressed ISO)</li></ul></p></p></body></html> @@ -376,7 +375,7 @@ - + @@ -474,7 +473,7 @@ 0 - + <html><head/><body><p>By default, ARMSX2 will map your keyboard to the virtual PS2 controller.</p><p><span style=" font-weight:704;">To use an external controller, you must map it first. </span>On this screen, you can automatically map any controller which is currently connected. If your controller is not currently connected, you can plug it in now.</p><p>To change controller bindings in more detail, or use multi-tap, open the Settings menu and choose Controllers once you have completed the Setup Wizard.</p><p>Guides for configuring controllers can be found <a href="https://pcsx2.net/docs/post/controllers/"><span style="">here</span></a>.</p></body></html> @@ -487,7 +486,7 @@ - + Controller Port 1 @@ -496,14 +495,14 @@ - + Controller Mapped To: - + Controller Type: @@ -513,12 +512,15 @@ - + Default (Keyboard) + + controller1Type + @@ -554,13 +556,13 @@ - + Controller Port 2 - + Controller Type: @@ -573,19 +575,22 @@ - + Controller Mapped To: - + Default (Keyboard) + + controller2Type + @@ -653,7 +658,7 @@ 0 - + @@ -736,6 +741,9 @@ true + + raEnableAchievements + @@ -885,7 +893,7 @@ - + 0 @@ -900,7 +908,7 @@ 0 - + <html><head/><body><h1 style=" margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:xx-large; font-weight:700;">Setup Complete!</span></h1><p>You are now ready to run games.</p><p><span style=" font-weight:700;">Warning: Do not run untrusted programs in ARMSX2. It is not a sandbox and cannot protect your computer from malicious software.</span></p><p>Further options are available under the settings menu. You can also use the Big Picture UI for navigation entirely with a gamepad.</p><p>We hope you enjoy using ARMSX2.</p></body></html> @@ -912,12 +920,26 @@ + + + + Create Desktop shortcut + + + + + + + Add PCSX2 to the Application Menu + + + - + 6 diff --git a/pcsx2-qt/ShortcutCreationDialog.cpp b/pcsx2-qt/ShortcutCreationDialog.cpp index 9cc53b2596..c43fa093bd 100644 --- a/pcsx2-qt/ShortcutCreationDialog.cpp +++ b/pcsx2-qt/ShortcutCreationDialog.cpp @@ -3,23 +3,14 @@ #include "ShortcutCreationDialog.h" #include "QtHost.h" -#include +#include "QtUtils.h" #include #include #include -#include "common/Console.h" -#include "common/FileSystem.h" #include "common/Path.h" #include "common/StringUtil.h" #include "VMManager.h" -#if defined(_WIN32) -#include "common/RedtapeWilCom.h" -#include -#include -#include -#endif - ShortcutCreationDialog::ShortcutCreationDialog(QWidget* parent, const QString& title, const QString& path) : QDialog(parent) , m_title(title) @@ -100,7 +91,7 @@ ShortcutCreationDialog::ShortcutCreationDialog(QWidget* parent, const QString& t m_ui.resetIconButton->setEnabled(false); }); - if (std::getenv("container")) + if (QtUtils::IsRunningInFlatpak()) { m_ui.portableModeToggle->setEnabled(false); m_ui.shortcutDesktop->setEnabled(false); @@ -108,7 +99,7 @@ ShortcutCreationDialog::ShortcutCreationDialog(QWidget* parent, const QString& t } connect(m_ui.dialogButtons, &QDialogButtonBox::rejected, this, &QDialog::reject); - connect(m_ui.dialogButtons, &QDialogButtonBox::accepted, this, [&]() { + connect(m_ui.dialogButtons, &QDialogButtonBox::accepted, this, [this]() { std::vector args; if (m_ui.portableModeToggle->isChecked()) @@ -162,430 +153,10 @@ ShortcutCreationDialog::ShortcutCreationDialog(QWidget* parent, const QString& t std::string custom_args = m_ui.customArgsInput->text().toStdString(); std::string icon_path = m_ui.iconPath->text().toStdString(); - ShortcutCreationDialog::CreateShortcut(title.toStdString(), path.toStdString(), args, custom_args, icon_path, m_ui.shortcutDesktop->isChecked()); + QtUtils::CreateShortcut(this, m_title.toStdString(), m_path.toStdString(), std::move(args), custom_args, icon_path, m_ui.shortcutDesktop->isChecked()); accept(); }); } -void ShortcutCreationDialog::CreateShortcut(const std::string name, const std::string game_path, std::vector passed_cli_args, std::string custom_args, const std::string icon_path, bool is_desktop) -{ -#if defined(_WIN32) - if (name.empty()) - { - Console.Error("Cannot create shortcuts without a name."); - return; - } - - // Sanitize filename - const std::string clean_name = Path::SanitizeFileName(name).c_str(); - std::string clean_path = Path::ToNativePath(Path::RealPath(game_path)).c_str(); - if (!Path::IsValidFileName(clean_name)) - { - QMessageBox::critical(this, tr("Failed to create shortcut"), tr("Filename contains illegal character."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); - return; - } - - // Get path to Desktop or per-user Start Menu\Programs directory - // https://superuser.com/questions/1489874/how-can-i-get-the-real-path-of-desktop-in-windows-explorer/1789849#1789849 - // https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath - // https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid - std::string link_file; - if (wil::unique_cotaskmem_string directory; SUCCEEDED(SHGetKnownFolderPath(is_desktop ? FOLDERID_Desktop : FOLDERID_Programs, 0, NULL, &directory))) - { - std::string directory_utf8 = StringUtil::WideStringToUTF8String(directory.get()); - - if (is_desktop) - link_file = Path::ToNativePath(fmt::format("{}/{}.lnk", directory_utf8, clean_name)); - else - { - const std::string pcsx2_start_menu_dir = Path::ToNativePath(fmt::format("{}/PCSX2", directory_utf8)); - if (!FileSystem::EnsureDirectoryExists(pcsx2_start_menu_dir.c_str(), false)) - { - QMessageBox::critical(this, tr("Failed to create shortcut"), tr("Could not create start menu directory."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); - return; - } - - link_file = Path::ToNativePath(fmt::format("{}/{}.lnk", pcsx2_start_menu_dir, clean_name)); - } - } - else - { - QMessageBox::critical(this, tr("Failed to create shortcut"), is_desktop ? tr("'Desktop' directory not found") : tr("User's 'Start Menu\\Programs' directory not found"), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); - return; - } - - // Check if the same shortcut already exists - if (FileSystem::FileExists(link_file.c_str())) - { - QMessageBox::critical(this, tr("Failed to create shortcut"), tr("A shortcut with the same name already exists."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); - return; - } - - // Shortcut CmdLine Args - bool lossless = true; - for (std::string& arg : passed_cli_args) - lossless &= ShortcutCreationDialog::EscapeShortcutCommandLine(&arg); - - if (!lossless) - { - QMessageBox::critical(this, tr("Failed to create shortcut"), tr("File path contains invalid character(s)."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); - return; - } - - ShortcutCreationDialog::EscapeShortcutCommandLine(&clean_path); - std::string combined_args = StringUtil::JoinString(passed_cli_args.begin(), passed_cli_args.end(), " "); - std::string final_args = fmt::format("{} {} -- {}", combined_args, custom_args, clean_path); - - Console.WriteLnFmt("Creating a shortcut '{}' with arguments '{}'", link_file, final_args); - - const auto str_error = [](HRESULT hr) -> std::string { - _com_error err(hr); - const TCHAR* errMsg = err.ErrorMessage(); - return fmt::format("{} [{}]", StringUtil::WideStringToUTF8String(errMsg), hr); - }; - - // Construct the shortcut - // https://stackoverflow.com/questions/3906974/how-to-programmatically-create-a-shortcut-using-win32 - HRESULT res = CoInitialize(NULL); - if (FAILED(res)) - { - Console.ErrorFmt("Failed to create shortcut: CoInitialize failed ({})", str_error(res)); - QMessageBox::critical(this, tr("Failed to create shortcut"), tr("CoInitialize failed (%1)").arg(str_error(res)), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); - return; - } - - wil::unique_couninitialize_call co_cleanup; - - const auto report_error = [&](const QString& reason) { - Console.ErrorFmt("Failed to create shortcut: {}", reason.toStdString()); - QMessageBox::critical(this, tr("Failed to create shortcut"), reason, QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); - }; - - wil::com_ptr_nothrow pShellLink = wil::CoCreateInstanceNoThrow(CLSID_ShellLink); - wil::com_ptr_nothrow pPersistFile; - - if (!pShellLink) - { - report_error(tr("CoCreateInstance failed")); - return; - } - - // Set path to the executable - const std::wstring target_file = StringUtil::UTF8StringToWideString(FileSystem::GetProgramPath()); - res = pShellLink->SetPath(target_file.c_str()); - if (FAILED(res)) - { - report_error(tr("SetPath failed (%1)").arg(str_error(res))); - return; - } - - // Set the working directory - const std::wstring working_dir = StringUtil::UTF8StringToWideString(FileSystem::GetWorkingDirectory()); - res = pShellLink->SetWorkingDirectory(working_dir.c_str()); - if (FAILED(res)) - { - report_error(tr("SetWorkingDirectory failed (%1)").arg(str_error(res))); - return; - } - - // Set the launch arguments - if (!final_args.empty()) - { - const std::wstring target_cli_args = StringUtil::UTF8StringToWideString(final_args); - res = pShellLink->SetArguments(target_cli_args.c_str()); - if (FAILED(res)) - { - report_error(tr("SetArguments failed (%1)").arg(str_error(res))); - return; - } - } - - // Set the icon - std::string final_icon_path; - if (!icon_path.empty()) - { - final_icon_path = Path::ToNativePath(icon_path); - if (!FileSystem::FileExists(final_icon_path.c_str())) - { - QMessageBox::critical(this, tr("Failed to create shortcut"), tr("The selected icon file does not exist."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); - return; - } - } - else - { - final_icon_path = Path::ToNativePath(Path::Combine(Path::GetDirectory(FileSystem::GetProgramPath()), "resources/icons/AppIconLarge.ico")); - } - - const std::wstring w_icon_path = StringUtil::UTF8StringToWideString(final_icon_path); - res = pShellLink->SetIconLocation(w_icon_path.c_str(), 0); - if (FAILED(res)) - { - report_error(tr("SetIconLocation failed (%1)").arg(str_error(res))); - return; - } - - // Use the IPersistFile object to save the shell link - res = pShellLink.query_to(&pPersistFile); - if (FAILED(res)) - { - report_error(tr("QueryInterface failed (%1)").arg(str_error(res))); - return; - } - - // Save shortcut link to disk - const std::wstring w_link_file = StringUtil::UTF8StringToWideString(link_file); - res = pPersistFile->Save(w_link_file.c_str(), TRUE); - if (FAILED(res)) - { - report_error(tr("Failed to save the shortcut (%1)").arg(str_error(res))); - return; - } - -#else - - if (name.empty()) - { - QMessageBox::critical(this, tr("Failed to create shortcut"), tr("Cannot create a shortcut without a title."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); - return; - } - - bool is_flatpak = (std::getenv("container")); - - // Sanitize filename and game path - const std::string clean_name = Path::SanitizeFileName(name); - std::string clean_path = Path::Canonicalize(Path::RealPath(game_path)); - if (!Path::IsValidFileName(clean_name)) - { - QMessageBox::critical(this, tr("Failed to create shortcut"), tr("Filename contains illegal character."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); - return; - } - - // Find the executable path - std::string executable_path = FileSystem::GetPackagePath(); - if (executable_path.empty()) - { - QMessageBox::critical(this, tr("Failed to create shortcut"), tr("Executable path is empty."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); - return; - } - - // Find home directory - std::string link_path; - const char* home = std::getenv("HOME"); - const char* xdg_desktop_dir = std::getenv("XDG_DESKTOP_DIR"); - const char* xdg_data_home = std::getenv("XDG_DATA_HOME"); - if (home) - { - if (is_desktop) - { - if (xdg_desktop_dir) - link_path = fmt::format("{}/{}.desktop", xdg_desktop_dir, clean_name); - else - link_path = fmt::format("{}/Desktop/{}.desktop", home, clean_name); - } - else - { - if (xdg_data_home) - link_path = fmt::format("{}/applications/{}.desktop", xdg_data_home, clean_name); - else - link_path = fmt::format("{}/.local/share/applications/{}.desktop", home, clean_name); - } - } - else - { - QMessageBox::critical(this, tr("Failed to create shortcut"), tr("Path to the Home directory is empty."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); - return; - } - - std::string icon_name; - if (!icon_path.empty()) - { - if (!FileSystem::FileExists(icon_path.c_str())) - { - QMessageBox::critical(this, tr("Failed to create shortcut"), tr("The selected icon file does not exist."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); - return; - } - icon_name = icon_path; - } - else - { - // Copy PCSX2 icon - std::string icon_dest; - if (xdg_data_home) - icon_dest = fmt::format("{}/icons/hicolor/512x512/apps/", xdg_data_home); - else - icon_dest = fmt::format("{}/.local/share/icons/hicolor/512x512/apps/", home); - - if (is_flatpak) // Flatpak - { - executable_path = "flatpak run net.pcsx2.PCSX2"; - icon_name = "net.pcsx2.PCSX2"; - } - else - { - icon_name = "ARMSX2"; - std::string icon_path_dest = fmt::format("{}/{}.png", icon_dest, icon_name).c_str(); - if (FileSystem::EnsureDirectoryExists(icon_dest.c_str(), true)) - if (!FileSystem::FileExists(icon_path_dest.c_str())) - FileSystem::CopyFilePath(Path::Combine(EmuFolders::Resources, "icons/AppIconLarge.png").c_str(), icon_path_dest.c_str(), false); - } - } - - // Shortcut CmdLine Args - bool lossless = true; - for (std::string& arg : passed_cli_args) - lossless &= ShortcutCreationDialog::EscapeShortcutCommandLine(&arg); - - if (!lossless) - { - QMessageBox::critical(this, tr("Failed to create shortcut"), tr("File path contains invalid character(s)."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); - return; - } - - std::string cmdline = StringUtil::JoinString(passed_cli_args.begin(), passed_cli_args.end(), " "); - - // Further string sanitization - if (!is_flatpak) - ShortcutCreationDialog::EscapeShortcutCommandLine(&executable_path); - ShortcutCreationDialog::EscapeShortcutCommandLine(&clean_path); - - // Assembling the .desktop file - std::string final_args; - final_args = fmt::format("{} {} {} -- {}", executable_path, cmdline, custom_args, clean_path); - std::string file_content = - "[Desktop Entry]\n" - "Encoding=UTF-8\n" - "Version=1.0\n" - "Type=Application\n" - "Terminal=false\n" - "StartupWMClass=PCSX2\n" - "Exec=" + - final_args + "\n" + - "Name=" + - clean_name + "\n" + - "Icon=" + - icon_name + "\n" + - "Categories=Game;Emulator;\n"; - std::string_view sv(file_content); - - // Prompt user for shortcut saving destination - QString final_path(QStringLiteral("%1").arg(QString::fromStdString(link_path))); - const QString filter(tr("Desktop Shortcut Files (*.desktop)")); - - final_path = QDir::toNativeSeparators(QFileDialog::getSaveFileName(this, tr("Select Shortcut Save Destination"), final_path, filter)); - - if (final_path.isEmpty()) - return; - - // Write to .desktop file - if (!FileSystem::WriteStringToFile(final_path.toStdString().c_str(), sv)) - { - QMessageBox::critical(this, tr("Failed to create shortcut"), tr("Failed to create .desktop file"), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); - return; - } - - if (chmod(final_path.toStdString().c_str(), S_IRWXU) != 0) // enables user to execute file - Console.ErrorFmt("Failed to change file permissions for .desktop file: {} ({})", strerror(errno), errno); -#endif -} - -bool ShortcutCreationDialog::EscapeShortcutCommandLine(std::string* arg) -{ -#ifdef _WIN32 - if (!arg->empty() && arg->find_first_of(" \t\n\v\"") == std::string::npos) - return true; - - std::string temp; - temp.reserve(arg->length() + 10); - temp += '"'; - - for (auto it = arg->begin();; ++it) - { - int backslash_count = 0; - while (it != arg->end() && *it == '\\') - { - ++it; - ++backslash_count; - } - - if (it == arg->end()) - { - temp.append(backslash_count * 2, '\\'); - break; - } - - if (*it == '"') - { - temp.append(backslash_count * 2 + 1, '\\'); - temp += '"'; - } - else - { - temp.append(backslash_count, '\\'); - temp += *it; - } - } - - temp += '"'; - *arg = std::move(temp); - return true; -#else - const char* carg = arg->c_str(); - const char* cend = carg + arg->size(); - const char* RESERVED_CHARS = " \t\n\\\"'\\\\><~|%&;$*?#()`" - "\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0d\x0e\x0f" - "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f"; - const char* next = carg + std::strcspn(carg, RESERVED_CHARS); - - if (next == cend) - return true; // No escaping needed, don't modify - - bool lossless = true; - std::string temp = "\""; - const char* NOT_VALID_IN_QUOTE = "%`$\"\\\n" - "\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0d\x0e\x0f" - "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f"; - - while (true) - { - next = carg + std::strcspn(carg, NOT_VALID_IN_QUOTE); - temp.append(carg, next); - carg = next; - - if (carg == cend) - break; - - switch (*carg) - { - case '"': - case '`': - temp.push_back('\\'); - temp.push_back(*carg); - break; - case '\\': - temp.append("\\\\\\\\"); - break; - case '$': - temp.push_back('\\'); - temp.push_back('\\'); - temp.push_back(*carg); - break; - case '%': - temp.push_back('%'); - temp.push_back(*carg); - break; - default: - temp.push_back(' '); - lossless = false; - break; - } - ++carg; - } - - temp.push_back('"'); - *arg = std::move(temp); - return lossless; -#endif -} - #include "moc_ShortcutCreationDialog.cpp" diff --git a/pcsx2-qt/ShortcutCreationDialog.h b/pcsx2-qt/ShortcutCreationDialog.h index eee8def535..8f0d22bab3 100644 --- a/pcsx2-qt/ShortcutCreationDialog.h +++ b/pcsx2-qt/ShortcutCreationDialog.h @@ -14,13 +14,6 @@ public: ShortcutCreationDialog(QWidget* parent, const QString& title, const QString& path); ~ShortcutCreationDialog() = default; - /// Create desktop shortcut for games - void CreateShortcut(const std::string name, const std::string game_path, std::vector passed_cli_args, std::string custom_args, const std::string icon_path, bool is_desktop); - - /// Escapes the given string for use with command line arguments. - /// Returns a bool that indicates whether the escaping operation are lossless or not. - bool EscapeShortcutCommandLine(std::string* cmdline); - protected: const QString m_title; const QString m_path; diff --git a/pcsx2-qt/Translations/pcsx2-qt_en.ts b/pcsx2-qt/Translations/pcsx2-qt_en.ts index df72b90281..7259e72150 100644 --- a/pcsx2-qt/Translations/pcsx2-qt_en.ts +++ b/pcsx2-qt/Translations/pcsx2-qt_en.ts @@ -6419,42 +6419,42 @@ Do you want to overwrite? FileOperations - + Failed to show file - + Failed to show file in file explorer. The file was: %1 - + Show in Explorer Windows action to show a file in Windows Explorer - + Show in Finder macOS action to show a file in Finder - + Open Containing Directory Linux/*NIX: Opens the system file manager to the directory containing a selected file - + Failed to open URL - + Failed to open URL. The URL was: %1 @@ -12432,7 +12432,7 @@ This action cannot be undone. - + Spin GPU During Readbacks is enabled, but calibrated timestamps are unavailable. This might be really slow. @@ -23225,233 +23225,243 @@ Do you want to continue? - + Language - + BIOS Image - + Game Directories - + Controller Setup - - + + RetroAchievements - + Complete - + Language: - + Theme: - + Enable Automatic Updates - + <html><head/><body><p>PCSX2 requires a PS2 BIOS in order to run.</p><p>For legal reasons, you must obtain a BIOS <strong>from an actual PS2 unit that you own</strong> (borrowing doesn't count).</p><p>Once dumped, this BIOS image should be placed in the bios folder within the data directory shown below, or you can instruct PCSX2 to scan an alternative directory.</p><p>A guide for dumping your BIOS can be found <a href="https://pcsx2.net/docs/setup/bios/">here</a>.</p></body></html> - + BIOS Directory: - + Browse... - + Reset - + Filename - + Version - + Open BIOS Folder... - + Refresh List - + <html><head/><body><p>PCSX2 will automatically scan and identify games from the selected directories below, and populate the game list.<br>These games should be dumped from discs you own. Guides for dumping discs can be found <a href="https://pcsx2.net/docs/setup/dumping">here</a>.</p><p>Supported formats for dumps include:</p><p><ul><li>.bin/.iso (ISO Disc Images)</li><li>.mdf (Media Descriptor File)</li><li>.chd (Compressed Hunks of Data)</li><li>.cso (Compressed ISO)</li><li>.zso (Compressed ISO)</li><li>.gz (Gzip Compressed ISO)</li></ul></p></p></body></html> - + Search Directories (will be scanned for games) - + Add... - - + + Remove Part of the right-click menu for game directory entries - + Search Directory - + Scan Recursively - + <html><head/><body><p align="justify">PCSX2 supports RetroAchievements, a service that adds achievements, leaderboards, and extra challenges to classic games.</p><p align="justify">Sign in below to link your account and start earning achievements in supported titles, or create a free account at <a href="https://retroachievements.org/createaccount.php"><span style=" text-decoration: underline; color:#27bf73;">retroachievements.org/createaccount.php</span></a>.</p><p align="justify">Using RetroAchievements is completely optional and not required to use PCSX2.</p></body></html> - + RAIntegration is being used, built-in RetroAchievements support is disabled. - + Enable Achievements - + Enable Hardcore Mode - + Account - - + + Not Logged In. - + View Profile... - - + + Login... - + You can customize additional RetroAchievements options later in Settings > Achievements. - + <html><head/><body><h1 style=" margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:xx-large; font-weight:700;">Setup Complete!</span></h1><p>You are now ready to run games.</p><p><span style=" font-weight:700;">Warning: Do not run untrusted programs in PCSX2. It is not a sandbox and cannot protect your computer from malicious software.</span></p><p>Further options are available under the settings menu. You can also use the Big Picture UI for navigation entirely with a gamepad.</p><p>We hope you enjoy using PCSX2.</p></body></html> - + <html><head/><body><h1 style=" margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:xx-large; font-weight:700;">Welcome to PCSX2!</span></h1><p>This wizard will help guide you through the configuration steps required to use the application. It is recommended if this is your first time installing PCSX2 that you view the setup guide <a href="https://pcsx2.net/docs/">here</a>.</p><p>By default, PCSX2 will connect to the server at <a href="https://pcsx2.net/">pcsx2.net</a> to check for updates, and if available and confirmed, download update packages from <a href="https://github.com/">github.com</a>. If you do not wish for PCSX2 to make any network connections on startup, you should uncheck the Automatic Updates option now. The Automatic Update setting can be changed later at any time in Interface Settings.</p><p>Please choose a language and theme to begin.</p></body></html> - + <html><head/><body><p>By default, PCSX2 will map your keyboard to the virtual PS2 controller.</p><p><span style=" font-weight:704;">To use an external controller, you must map it first. </span>On this screen, you can automatically map any controller which is currently connected. If your controller is not currently connected, you can plug it in now.</p><p>To change controller bindings in more detail, or use multi-tap, open the Settings menu and choose Controllers once you have completed the Setup Wizard.</p><p>Guides for configuring controllers can be found <a href="https://pcsx2.net/docs/post/controllers/"><span style="">here</span></a>.</p></body></html> - + Controller Port 1 - - + + Controller Mapped To: - - + + Controller Type: - - - + + + Default (Keyboard) - - + + Automatic Mapping - + Controller Port 2 - + + Create Desktop shortcut + + + + + Add PCSX2 to the Application Menu + + + + &Back - - + + &Next - + &Cancel @@ -23474,73 +23484,78 @@ Are you sure you want to continue? - + &Finish - + Cancel Setup - + Are you sure you want to cancel PCSX2 setup? Any changes have been saved, and the wizard will run again next time you start PCSX2. - + Open Directory... Part of the right-click menu for game directory entries - + Select Search Directory - + Scan Recursively? - + Would you like to scan the directory "%1" recursively? Scanning recursively takes more time, but will identify files in subdirectories. - + Default (None) + Add PCSX2 to the Start Menu + + + + Username: %1 Login token generated on %2. - + Logout - + No devices available - + Automatic Binding - + No generic bindings were generated for device '%1'. The controller/source may not support automatic mapping. @@ -23695,192 +23710,65 @@ Login token generated on %2. - + Create Shortcut For %1 - + Start Menu - + Application Launcher - + Select ELF File - + ELF Files (*.elf);;All Files (*.*) - + Select Save State File - + Save States (*.p2s);;All Files (*.*) - + Icon Files (*.ico);;All Files (*.*) - + Image Files (*.png *.jpg *.svg *.webp);;All Files (*.*) - + Select Icon - + Invalid Icon - + The selected file could not be loaded as an icon. - - - - - - - - - - - - - - - - - Failed to create shortcut - - - - - - Filename contains illegal character. - - - - - Could not create start menu directory. - - - - - 'Desktop' directory not found - - - - - User's 'Start Menu\Programs' directory not found - - - - - A shortcut with the same name already exists. - - - - - - File path contains invalid character(s). - - - - - CoInitialize failed (%1) - - - - - CoCreateInstance failed - - - - - SetPath failed (%1) - - - - - SetWorkingDirectory failed (%1) - - - - - SetArguments failed (%1) - - - - - - The selected icon file does not exist. - - - - - SetIconLocation failed (%1) - - - - - QueryInterface failed (%1) - - - - - Failed to save the shortcut (%1) - - - - - Cannot create a shortcut without a title. - - - - - Executable path is empty. - - - - - Path to the Home directory is empty. - - - - - Desktop Shortcut Files (*.desktop) - - - - - Select Shortcut Save Destination - - - - - Failed to create .desktop file - - StackModel diff --git a/pcsx2/GS/GSState.cpp b/pcsx2/GS/GSState.cpp index 66fba5fa93..a28b6d5c1e 100644 --- a/pcsx2/GS/GSState.cpp +++ b/pcsx2/GS/GSState.cpp @@ -2976,7 +2976,7 @@ void GSState::InitReadFIFO(u8* mem, int len) // Read the image all in one go. m_mem.ReadImageX(m_tr.x, m_tr.y, m_tr.buff, m_tr.total, m_env.BITBLTBUF, m_env.TRXPOS, m_env.TRXREG); - if (GSConfig.SaveRT && GSConfig.ShouldDump(s_n, g_perfmon.GetFrame())) + if (GSConfig.SaveTransferImages && GSConfig.ShouldDump(s_n, g_perfmon.GetFrame())) { const std::string s(GetDrawDumpPath( "%05lld_read_%05x_%d_%s_%d_%d_%d_%d.bmp", diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp index 9ce212193e..692a0e9a02 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp @@ -603,7 +603,7 @@ bool GSDevice11::Create(GSVSyncMode vsync_mode, bool allow_present_throttle) } // 1x1 dummy texture. - const GSTexture::Usage null_usage = m_features.rov ? GSTexture::ShaderWriteTarget : GSTexture::Feedback; + const GSTexture::Usage null_usage = m_uav_texture ? GSTexture::ShaderWriteTarget : GSTexture::Feedback; m_null_texture = CreateSurface(null_usage, 1, 1, 1, GSTexture::Format::Color); if (!m_null_texture) return false; diff --git a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp index e43e5f6aca..8541f266a5 100644 --- a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp +++ b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp @@ -2719,11 +2719,9 @@ GSDevice12::ComPtr GSDevice12::GetUtilityPixelShader(const std::string bool GSDevice12::CreateNullTexture() { - const GSTexture::Usage null_access = m_features.rov ? GSTexture::ShaderWriteTarget : GSTexture::FeedbackTarget; - const DXGI_FORMAT null_uav_format = m_features.rov ? DXGI_FORMAT_R8G8B8A8_UNORM : DXGI_FORMAT_UNKNOWN; m_null_texture = - GSTexture12::Create(null_access, GSTexture::Format::Color, 1, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN, null_uav_format); + GSTexture12::Create(GSTexture::ShaderWriteTarget, GSTexture::Format::Color, 1, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_R8G8B8A8_UNORM); if (!m_null_texture) return false; diff --git a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp index ed6a3ed9c9..7e1524205c 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp +++ b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp @@ -3435,7 +3435,7 @@ void GSRendererHW::Draw() bool shuffle_target = false; const u32 page_alignment = GSLocalMemory::IsPageAlignedMasked(m_cached_ctx.TEX0.PSM, m_r); const bool page_aligned = (page_alignment & 0xF0F0) != 0; // Make sure Y is page aligned. - if (!no_rt && page_aligned && m_cached_ctx.ZBUF.ZMSK && GSLocalMemory::m_psm[m_cached_ctx.FRAME.PSM].bpp == 16 && GSLocalMemory::m_psm[m_cached_ctx.TEX0.PSM].bpp >= 16 && + if (!no_rt && page_aligned && m_cached_ctx.ZBUF.ZMSK && GSLocalMemory::m_psm[m_cached_ctx.FRAME.PSM].bpp == 16 && GSLocalMemory::m_psm[m_cached_ctx.TEX0.PSM].trbpp <= 16 && (m_vt.m_primclass == GS_SPRITE_CLASS || (m_vt.m_primclass == GS_TRIANGLE_CLASS && (m_index->tail % 6) == 0 && TrianglesAreQuads(true) && m_index->tail > 6))) { // Tail check is to make sure we have enough strips to go all the way across the page, or if it's using a region clamp could be used to draw strips. diff --git a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp index 0d14a0759c..ca2c83c633 100644 --- a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp +++ b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp @@ -4177,8 +4177,7 @@ VkShaderModule GSDeviceVK::GetUtilityFragmentShader(const std::string& source, c bool GSDeviceVK::CreateNullTexture() { - GSTexture::Usage null_usage = m_features.rov ? GSTexture::ShaderWriteTarget : GSTexture::FeedbackTarget; - m_null_texture = GSTextureVK::Create(null_usage, GSTexture::Format::Color, 1, 1, 1); + m_null_texture = GSTextureVK::Create(GSTexture::ShaderWriteTarget, GSTexture::Format::Color, 1, 1, 1); if (!m_null_texture) return false; diff --git a/pcsx2/ShaderCacheVersion.h b/pcsx2/ShaderCacheVersion.h index da27be88cb..64e4a03ee8 100644 --- a/pcsx2/ShaderCacheVersion.h +++ b/pcsx2/ShaderCacheVersion.h @@ -3,4 +3,4 @@ /// Version number for GS and other shaders. Increment whenever any of the contents of the /// shaders change, to invalidate the cache. -static constexpr u32 SHADER_CACHE_VERSION = 107; // Last changed in PR 14634 +static constexpr u32 SHADER_CACHE_VERSION = 108; // Last changed in PR 14688