From c92b9f9024404fbb68ac87370dd7589e1d5f237a Mon Sep 17 00:00:00 2001 From: spectranator Date: Fri, 26 Jul 2024 15:38:31 +0000 Subject: [PATCH 1/5] Automatically generate token (#22/#28) Co-authored-by: anon Co-authored-by: spectranator Reviewed-on: http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu/pulls/22 Reviewed-on: http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu/pulls/28 --- .../configure_profile_manager.cpp | 3 + src/yuzu/configuration/configure_web.cpp | 112 ++++-------------- src/yuzu/configuration/configure_web.h | 7 +- src/yuzu/configuration/configure_web.ui | 19 +-- src/yuzu/multiplayer/host_room.cpp | 5 +- 5 files changed, 39 insertions(+), 107 deletions(-) diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp index 12a04b9a0b..db5354e294 100644 --- a/src/yuzu/configuration/configure_profile_manager.cpp +++ b/src/yuzu/configuration/configure_profile_manager.cpp @@ -177,6 +177,9 @@ void ConfigureProfileManager::UpdateCurrentUser() { scene->addPixmap( GetIcon(*current_user).scaled(48, 48, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); ui->current_user_username->setText(username); + + // update the token username, process completed by ConfigureWeb::ApplyConfiguration() + Settings::values.yuzu_username = username.toStdString(); } void ConfigureProfileManager::ApplyConfiguration() { diff --git a/src/yuzu/configuration/configure_web.cpp b/src/yuzu/configuration/configure_web.cpp index e462aacfbd..d84addd825 100644 --- a/src/yuzu/configuration/configure_web.cpp +++ b/src/yuzu/configuration/configure_web.cpp @@ -5,40 +5,15 @@ #include #include #include "common/settings.h" +#include "common/uuid.h" #include "ui_configure_web.h" #include "yuzu/configuration/configure_web.h" #include "yuzu/uisettings.h" -static constexpr char token_delimiter{':'}; - -static std::string GenerateDisplayToken(const std::string& username, const std::string& token) { - if (username.empty() || token.empty()) { - return {}; - } - - const std::string unencoded_display_token{username + token_delimiter + token}; - QByteArray b{unencoded_display_token.c_str()}; - QByteArray b64 = b.toBase64(); - return b64.toStdString(); -} - -static std::string UsernameFromDisplayToken(const std::string& display_token) { - const std::string unencoded_display_token{ - QByteArray::fromBase64(display_token.c_str()).toStdString()}; - return unencoded_display_token.substr(0, unencoded_display_token.find(token_delimiter)); -} - -static std::string TokenFromDisplayToken(const std::string& display_token) { - const std::string unencoded_display_token{ - QByteArray::fromBase64(display_token.c_str()).toStdString()}; - return unencoded_display_token.substr(unencoded_display_token.find(token_delimiter) + 1); -} - ConfigureWeb::ConfigureWeb(QWidget* parent) : QWidget(parent), ui(std::make_unique()) { ui->setupUi(this); - connect(ui->button_verify_login, &QPushButton::clicked, this, &ConfigureWeb::VerifyLogin); - connect(&verify_watcher, &QFutureWatcher::finished, this, &ConfigureWeb::OnLoginVerified); + connect(ui->button_reset_token, &QPushButton::clicked, this, &ConfigureWeb::ResetToken); #ifndef USE_DISCORD_PRESENCE ui->discord_group->setVisible(false); @@ -60,94 +35,51 @@ void ConfigureWeb::changeEvent(QEvent* event) { void ConfigureWeb::RetranslateUI() { ui->retranslateUi(this); - - ui->web_signup_link->setText( - tr("Sign up")); - - ui->web_token_info_link->setText( - tr("What is my token?")); } void ConfigureWeb::SetConfiguration() { ui->web_credentials_disclaimer->setWordWrap(true); - ui->web_signup_link->setOpenExternalLinks(true); - ui->web_token_info_link->setOpenExternalLinks(true); - if (Settings::values.yuzu_username.GetValue().empty()) { ui->username->setText(tr("Unspecified")); } else { ui->username->setText(QString::fromStdString(Settings::values.yuzu_username.GetValue())); } - ui->edit_token->setText(QString::fromStdString(GenerateDisplayToken( - Settings::values.yuzu_username.GetValue(), Settings::values.yuzu_token.GetValue()))); - - // Connect after setting the values, to avoid calling OnLoginChanged now - connect(ui->edit_token, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged); - - user_verified = true; + ui->edit_token->setText(QString::fromStdString(Settings::values.yuzu_token.GetValue())); ui->toggle_discordrpc->setChecked(UISettings::values.enable_discord_presence.GetValue()); } void ConfigureWeb::ApplyConfiguration() { UISettings::values.enable_discord_presence = ui->toggle_discordrpc->isChecked(); - if (user_verified) { - Settings::values.yuzu_username = - UsernameFromDisplayToken(ui->edit_token->text().toStdString()); - Settings::values.yuzu_token = TokenFromDisplayToken(ui->edit_token->text().toStdString()); + if (Settings::values.yuzu_username.GetValue().empty()) { + // Backup: default name should already be set by ConfigureProfileManager::UpdateCurrentUser() + Settings::values.yuzu_username = "torzu"; } else { - QMessageBox::warning( - this, tr("Token not verified"), - tr("Token was not verified. The change to your token has not been saved.")); + // If a name already exist, reassign it to itself (needed for change set with a profile switch) + Settings::values.yuzu_username = Settings::values.yuzu_username.GetValue(); } -} -void ConfigureWeb::OnLoginChanged() { if (ui->edit_token->text().isEmpty()) { - user_verified = true; - // Empty = no icon - ui->label_token_verified->setPixmap(QPixmap()); - ui->label_token_verified->setToolTip(QString()); + // If no token specified, automatically generate one + Settings::values.yuzu_token = Common::UUID::MakeRandom().FormattedString(); } else { - user_verified = false; - - // Show an info icon if it's been changed, clearer than showing failure - const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("info")).pixmap(16); - ui->label_token_verified->setPixmap(pixmap); - ui->label_token_verified->setToolTip( - tr("Unverified, please click Verify before saving configuration", "Tooltip")); + // Otherwise use user-specified value + Settings::values.yuzu_token = ui->edit_token->text().toStdString(); } } -void ConfigureWeb::VerifyLogin() { - ui->button_verify_login->setDisabled(true); - ui->button_verify_login->setText(tr("Verifying...")); - ui->label_token_verified->setPixmap(QIcon::fromTheme(QStringLiteral("sync")).pixmap(16)); - ui->label_token_verified->setToolTip(tr("Verifying...")); -} - -void ConfigureWeb::OnLoginVerified() { - ui->button_verify_login->setEnabled(true); - ui->button_verify_login->setText(tr("Verify")); - if (verify_watcher.result()) { - user_verified = true; - - ui->label_token_verified->setPixmap(QIcon::fromTheme(QStringLiteral("checked")).pixmap(16)); - ui->label_token_verified->setToolTip(tr("Verified", "Tooltip")); - ui->username->setText( - QString::fromStdString(UsernameFromDisplayToken(ui->edit_token->text().toStdString()))); - } else { - ui->label_token_verified->setPixmap(QIcon::fromTheme(QStringLiteral("failed")).pixmap(16)); - ui->label_token_verified->setToolTip(tr("Verification failed", "Tooltip")); - ui->username->setText(tr("Unspecified")); - QMessageBox::critical(this, tr("Verification failed"), - tr("Verification failed. Check that you have entered your token " - "correctly, and that your internet connection is working.")); - } +void ConfigureWeb::ResetToken() { + // Generate and set token + const auto token = Common::UUID::MakeRandom().FormattedString(); + Settings::values.yuzu_token = token; + // Just to display the label_token_icon pic and tooltip for visual confirmation + ui->label_token_icon->setPixmap(QIcon::fromTheme(QStringLiteral("checked")).pixmap(16)); + ui->label_token_icon->setToolTip(tr("Token Changed", "Tooltip")); + ui->username->setText(QString::fromStdString(token)); + // Apply the changes + SetConfiguration(); } void ConfigureWeb::SetWebServiceConfigEnabled(bool enabled) { diff --git a/src/yuzu/configuration/configure_web.h b/src/yuzu/configuration/configure_web.h index 92625dd444..1535535a1f 100644 --- a/src/yuzu/configuration/configure_web.h +++ b/src/yuzu/configuration/configure_web.h @@ -25,14 +25,9 @@ private: void changeEvent(QEvent* event) override; void RetranslateUI(); - void OnLoginChanged(); - void VerifyLogin(); - void OnLoginVerified(); + void ResetToken(); void SetConfiguration(); - bool user_verified = true; - QFutureWatcher verify_watcher; - std::unique_ptr ui; }; diff --git a/src/yuzu/configuration/configure_web.ui b/src/yuzu/configuration/configure_web.ui index af86e476e1..6df2bb9b3c 100644 --- a/src/yuzu/configuration/configure_web.ui +++ b/src/yuzu/configuration/configure_web.ui @@ -6,7 +6,7 @@ 0 0 - 926 + 2280 561 @@ -28,14 +28,14 @@ - By providing your username and token, you agree to allow yuzu to collect additional usage data, which may include user identifying information. + This token is for hosting public rooms in a lobby and are automatically generated the first time you save settings. To change your username, rename or switch the profile. If you are currently connected to multiplayer, exit and restart the emulator for changes to apply. - + 0 @@ -46,12 +46,15 @@ Qt::RightToLeft - Verify + Reset Token + + false + Sign up @@ -68,7 +71,7 @@ - + @@ -82,13 +85,13 @@ 80 - - QLineEdit::Password - + + false + What is my token? diff --git a/src/yuzu/multiplayer/host_room.cpp b/src/yuzu/multiplayer/host_room.cpp index ef364ee43a..021ede7619 100644 --- a/src/yuzu/multiplayer/host_room.cpp +++ b/src/yuzu/multiplayer/host_room.cpp @@ -183,10 +183,9 @@ void HostRoomWindow::Host() { if (result.result_code != WebService::WebResult::Code::Success) { QMessageBox::warning( this, tr("Error"), - tr("Failed to announce the room to the public lobby. In order to host a " - "room publicly, you must have a valid yuzu account configured in " + tr("To host a room publicly, you must have a generated token configured in " "Emulation -> Configure -> Web. If you do not want to publish a room in " - "the public lobby, then select Unlisted instead.\nDebug Message: ") + + "a public lobby, then select Unlisted instead.\n\nDebug Message: ") + QString::fromStdString(result.result_string), QMessageBox::Ok); ui->host->setEnabled(true); From f38060714a16fad8507ee3370474525c6f2e8087 Mon Sep 17 00:00:00 2001 From: anon Date: Sat, 20 Jul 2024 02:18:39 +0000 Subject: [PATCH 2/5] Better text spacing in about dialog (partial #22) --- src/yuzu/aboutdialog.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/yuzu/aboutdialog.ui b/src/yuzu/aboutdialog.ui index fcd84e24e6..788235422b 100644 --- a/src/yuzu/aboutdialog.ui +++ b/src/yuzu/aboutdialog.ui @@ -103,7 +103,7 @@ li.unchecked::marker { content: "\2610"; } li.checked::marker { content: "\2612"; } </style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:12pt;">torzu is an experimental open-source emulator for the Nintendo Switch forked from yuzu and licensed under GPLv3.0+.</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:12pt;">This software should not be used to play games you have not legally obtained.</span></p></body></html> +<br><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:12pt;">This software should not be used to play games you have not legally obtained.</span></p></body></html> Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -121,7 +121,7 @@ li.checked::marker { content: "\2612"; } 20 - 40 + 30 From 456612d272a7a47ba03ee8cf2242adf421784c22 Mon Sep 17 00:00:00 2001 From: spectranator Date: Fri, 26 Jul 2024 18:21:41 +0200 Subject: [PATCH 3/5] Update documentation for Android --- README.md | 4 +--- build-for-android.md | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 410452bcc0..6bf47f6ab0 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ SPDX-License-Identifier: GPL-2.0-or-later

torzu is a fork of yuzu, an open-source Nintendo Switch emulator.
-It is written in C++ with portability in mind and runs on Linux and Windows +It is written in C++ with portability in mind and runs on Linux, Windows and Android

## Fake websites @@ -58,8 +58,6 @@ It is very important to me that this project is going to be a good base to fork A secondary goal is the improvement of usability on low-end systems. This includes both improving the performance of the emulator as well as making games more playable below 100% speed whenever possible (the sync CPU to render speed limit option already helps with that in few cases). -Android support is low priority but would be a nice bonus. - ## Development Most of the development happens on [Dark Git](http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/). It's also where [our central repository](http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu) is hosted. diff --git a/build-for-android.md b/build-for-android.md index d1b218db5e..c48973e6c0 100644 --- a/build-for-android.md +++ b/build-for-android.md @@ -1,11 +1,16 @@ -## Note: These build instructions are a work-in-progress. +## Using Android Studio + +**Note: These build instructions are a work-in-progress.** + ### Dependencies * [Android Studio](https://developer.android.com/studio) * [NDK 25.2.9519653 and CMake 3.22.1](https://developer.android.com/studio/projects/install-ndk#default-version) * [Git](https://git-scm.com/download) + #### WINDOWS ONLY - Additional Dependencies * **[Visual Studio 2022 Community](https://visualstudio.microsoft.com/downloads/)** - **Make sure to select "Desktop development with C++" support in the installer. Make sure to update to the latest version if already installed.** * **[Vulkan SDK](https://vulkan.lunarg.com/sdk/home#windows)** - **Make sure to select Latest SDK.** + ### Cloning yuzu with Git **from Codeberg repo (the `--recursive` option automatically clones the required Git submodules):** ``` @@ -22,6 +27,7 @@ yuzu by default will be cloned into: * `C:\Users\\torzu` on Windows * `~/torzu` on Linux * And wherever on macOS + ### Building 1. Start Android Studio, on the startup dialog select `Open`. 2. Navigate to the `torzu/src/android` directory and click on `OK`. @@ -30,3 +36,28 @@ yuzu by default will be cloned into: ### Additional Resources https://developer.android.com/studio/intro + +## Using CLI + +**Note: These build instructions are for building on Debian Bookworm or newer** + +### Dependencies +``` +sudo apt-get update +sudo apt-get install -y sdkmanager openjdk-17-jdk build-essential curl git pkg-config glslang-tools zip +sudo sdkmanager "ndk;26.1.10909125" "platforms;android-34" "build-tools;33.0.1" "cmake;3.22.1" "platform-tools" +sudo update-alternatives --config java # Select Java 17 here if possible +``` + +### Cloning Yuzu with Git +Follow clone instructions for Android Studio above + +### Build +``` +./externals/vcpkg/bootstrap-vcpkg.sh -disableMetrics +export ANDROID_HOME=/opt/android-sdk +cd src/android +./gradlew assembleRelease +``` + +The APK will be at `src/android/app/build/outputs/apk/mainline/release/app-mainline-release.apk` From c8997e4ab546f1ac29f54a2ef518821ba232b484 Mon Sep 17 00:00:00 2001 From: anon Date: Fri, 26 Jul 2024 22:15:01 +0000 Subject: [PATCH 4/5] Remove elements for removed buttons in web config (#31) Reviewed-on: http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu/pulls/31 Co-authored-by: anon Co-committed-by: anon --- src/yuzu/configuration/configure_web.ui | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/yuzu/configuration/configure_web.ui b/src/yuzu/configuration/configure_web.ui index 6df2bb9b3c..855578abfd 100644 --- a/src/yuzu/configuration/configure_web.ui +++ b/src/yuzu/configuration/configure_web.ui @@ -50,16 +50,6 @@
- - - - false - - - Sign up - - - @@ -87,16 +77,6 @@
- - - - false - - - What is my token? - - - From 1b51d49e168ad2fdff5eee95506253ae624fe7cf Mon Sep 17 00:00:00 2001 From: rancidtowpath Date: Wed, 31 Jul 2024 10:35:13 +0000 Subject: [PATCH 5/5] Update build-for-windows.md (#39) Added Python as minimal dependency for first building method. By following building steps without Python installed, I got same error as mentioned in #36. After Python installed, issue was gone and Cmake config and generate was successful. Reviewed-on: http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu/pulls/39 Co-authored-by: rancidtowpath Co-committed-by: rancidtowpath --- build-for-windows.md | 1 + 1 file changed, 1 insertion(+) diff --git a/build-for-windows.md b/build-for-windows.md index 0efbf146e2..9bcc3e5bc6 100644 --- a/build-for-windows.md +++ b/build-for-windows.md @@ -7,6 +7,7 @@ On Windows, all library dependencies are automatically included within the `exte * **[Visual Studio 2022 Community](https://visualstudio.microsoft.com/downloads/)** - **Make sure to select C++ support in the installer. Make sure to update to the latest version if already installed.** * **[CMake](https://cmake.org/download/)** - Used to generate Visual Studio project files. Does not matter if either 32-bit or 64-bit version is installed. * **[Vulkan SDK](https://vulkan.lunarg.com/sdk/home#windows)** - **Make sure to select Latest SDK.** + * **[Python](https://www.python.org/downloads/windows/)** - Select latest stable Windows installer. Does not matter if either 32-bit or 64-bit version is installed. ![2](https://i.imgur.com/giDwuTm.png)