summaryrefslogtreecommitdiff
path: root/src/yuzu
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu')
-rw-r--r--src/yuzu/CMakeLists.txt7
-rw-r--r--src/yuzu/configuration/config.cpp25
-rw-r--r--src/yuzu/configuration/config.h2
-rw-r--r--src/yuzu/configuration/configure.ui11
-rw-r--r--src/yuzu/configuration/configure_dialog.cpp5
-rw-r--r--src/yuzu/configuration/configure_general.cpp2
-rw-r--r--src/yuzu/configuration/configure_general.ui7
-rw-r--r--src/yuzu/configuration/configure_input_player.cpp22
-rw-r--r--src/yuzu/configuration/configure_service.cpp138
-rw-r--r--src/yuzu/configuration/configure_service.h34
-rw-r--r--src/yuzu/configuration/configure_service.ui124
-rw-r--r--src/yuzu/configuration/configure_web.cpp73
-rw-r--r--src/yuzu/configuration/configure_web.ui12
-rw-r--r--src/yuzu/debugger/wait_tree.cpp26
-rw-r--r--src/yuzu/debugger/wait_tree.h4
-rw-r--r--src/yuzu/game_list.cpp8
-rw-r--r--src/yuzu/game_list_p.h9
-rw-r--r--src/yuzu/game_list_worker.cpp12
-rw-r--r--src/yuzu/game_list_worker.h5
-rw-r--r--src/yuzu/main.cpp66
-rw-r--r--src/yuzu/main.h4
-rw-r--r--src/yuzu/uisettings.cpp2
-rw-r--r--src/yuzu/uisettings.h3
23 files changed, 511 insertions, 90 deletions
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt
index dc6fa07fc..ff1c1d985 100644
--- a/src/yuzu/CMakeLists.txt
+++ b/src/yuzu/CMakeLists.txt
@@ -66,6 +66,9 @@ add_executable(yuzu
configuration/configure_profile_manager.cpp
configuration/configure_profile_manager.h
configuration/configure_profile_manager.ui
+ configuration/configure_service.cpp
+ configuration/configure_service.h
+ configuration/configure_service.ui
configuration/configure_system.cpp
configuration/configure_system.h
configuration/configure_system.ui
@@ -186,6 +189,10 @@ if (YUZU_USE_QT_WEB_ENGINE)
target_compile_definitions(yuzu PRIVATE -DYUZU_USE_QT_WEB_ENGINE)
endif ()
+if (YUZU_ENABLE_BOXCAT)
+ target_compile_definitions(yuzu PRIVATE -DYUZU_ENABLE_BOXCAT)
+endif ()
+
if(UNIX AND NOT APPLE)
install(TARGETS yuzu RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
endif()
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 92d9fb161..f92a4b3c3 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -525,6 +525,17 @@ void Config::ReadDebuggingValues() {
qt_config->endGroup();
}
+void Config::ReadServiceValues() {
+ qt_config->beginGroup(QStringLiteral("Services"));
+ Settings::values.bcat_backend =
+ ReadSetting(QStringLiteral("bcat_backend"), QStringLiteral("boxcat"))
+ .toString()
+ .toStdString();
+ Settings::values.bcat_boxcat_local =
+ ReadSetting(QStringLiteral("bcat_boxcat_local"), false).toBool();
+ qt_config->endGroup();
+}
+
void Config::ReadDisabledAddOnValues() {
const auto size = qt_config->beginReadArray(QStringLiteral("DisabledAddOns"));
@@ -705,6 +716,8 @@ void Config::ReadUIValues() {
UISettings::values.callout_flags = ReadSetting(QStringLiteral("calloutFlags"), 0).toUInt();
UISettings::values.show_console = ReadSetting(QStringLiteral("showConsole"), false).toBool();
UISettings::values.profile_index = ReadSetting(QStringLiteral("profileIndex"), 0).toUInt();
+ UISettings::values.pause_when_in_background =
+ ReadSetting(QStringLiteral("pauseWhenInBackground"), false).toBool();
ApplyDefaultProfileIfInputInvalid();
@@ -769,6 +782,7 @@ void Config::ReadValues() {
ReadMiscellaneousValues();
ReadDebuggingValues();
ReadWebServiceValues();
+ ReadServiceValues();
ReadDisabledAddOnValues();
ReadUIValues();
}
@@ -866,6 +880,7 @@ void Config::SaveValues() {
SaveMiscellaneousValues();
SaveDebuggingValues();
SaveWebServiceValues();
+ SaveServiceValues();
SaveDisabledAddOnValues();
SaveUIValues();
}
@@ -963,6 +978,14 @@ void Config::SaveDebuggingValues() {
qt_config->endGroup();
}
+void Config::SaveServiceValues() {
+ qt_config->beginGroup(QStringLiteral("Services"));
+ WriteSetting(QStringLiteral("bcat_backend"),
+ QString::fromStdString(Settings::values.bcat_backend), QStringLiteral("null"));
+ WriteSetting(QStringLiteral("bcat_boxcat_local"), Settings::values.bcat_boxcat_local, false);
+ qt_config->endGroup();
+}
+
void Config::SaveDisabledAddOnValues() {
qt_config->beginWriteArray(QStringLiteral("DisabledAddOns"));
@@ -1103,6 +1126,8 @@ void Config::SaveUIValues() {
WriteSetting(QStringLiteral("calloutFlags"), UISettings::values.callout_flags, 0);
WriteSetting(QStringLiteral("showConsole"), UISettings::values.show_console, false);
WriteSetting(QStringLiteral("profileIndex"), UISettings::values.profile_index, 0);
+ WriteSetting(QStringLiteral("pauseWhenInBackground"),
+ UISettings::values.pause_when_in_background, false);
qt_config->endGroup();
}
diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h
index 6b523ecdd..ba6888004 100644
--- a/src/yuzu/configuration/config.h
+++ b/src/yuzu/configuration/config.h
@@ -42,6 +42,7 @@ private:
void ReadCoreValues();
void ReadDataStorageValues();
void ReadDebuggingValues();
+ void ReadServiceValues();
void ReadDisabledAddOnValues();
void ReadMiscellaneousValues();
void ReadPathValues();
@@ -65,6 +66,7 @@ private:
void SaveCoreValues();
void SaveDataStorageValues();
void SaveDebuggingValues();
+ void SaveServiceValues();
void SaveDisabledAddOnValues();
void SaveMiscellaneousValues();
void SavePathValues();
diff --git a/src/yuzu/configuration/configure.ui b/src/yuzu/configuration/configure.ui
index 49fadd0ef..372427ae2 100644
--- a/src/yuzu/configuration/configure.ui
+++ b/src/yuzu/configuration/configure.ui
@@ -98,6 +98,11 @@
<string>Web</string>
</attribute>
</widget>
+ <widget class="ConfigureService" name="serviceTab">
+ <attribute name="title">
+ <string>Services</string>
+ </attribute>
+ </widget>
</widget>
</item>
</layout>
@@ -178,6 +183,12 @@
<header>configuration/configure_hotkeys.h</header>
<container>1</container>
</customwidget>
+ <customwidget>
+ <class>ConfigureService</class>
+ <extends>QWidget</extends>
+ <header>configuration/configure_service.h</header>
+ <container>1</container>
+ </customwidget>
</customwidgets>
<resources/>
<connections>
diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp
index 7c875ae87..25b2e1b05 100644
--- a/src/yuzu/configuration/configure_dialog.cpp
+++ b/src/yuzu/configuration/configure_dialog.cpp
@@ -44,6 +44,7 @@ void ConfigureDialog::ApplyConfiguration() {
ui->audioTab->ApplyConfiguration();
ui->debugTab->ApplyConfiguration();
ui->webTab->ApplyConfiguration();
+ ui->serviceTab->ApplyConfiguration();
Settings::Apply();
Settings::LogSettings();
}
@@ -74,7 +75,8 @@ Q_DECLARE_METATYPE(QList<QWidget*>);
void ConfigureDialog::PopulateSelectionList() {
const std::array<std::pair<QString, QList<QWidget*>>, 4> items{
{{tr("General"), {ui->generalTab, ui->webTab, ui->debugTab, ui->gameListTab}},
- {tr("System"), {ui->systemTab, ui->profileManagerTab, ui->filesystemTab, ui->audioTab}},
+ {tr("System"),
+ {ui->systemTab, ui->profileManagerTab, ui->serviceTab, ui->filesystemTab, ui->audioTab}},
{tr("Graphics"), {ui->graphicsTab}},
{tr("Controls"), {ui->inputTab, ui->hotkeysTab}}},
};
@@ -108,6 +110,7 @@ void ConfigureDialog::UpdateVisibleTabs() {
{ui->webTab, tr("Web")},
{ui->gameListTab, tr("Game List")},
{ui->filesystemTab, tr("Filesystem")},
+ {ui->serviceTab, tr("Services")},
};
[[maybe_unused]] const QSignalBlocker blocker(ui->tabWidget);
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp
index 98bc9b391..34e1d7fea 100644
--- a/src/yuzu/configuration/configure_general.cpp
+++ b/src/yuzu/configuration/configure_general.cpp
@@ -31,6 +31,7 @@ void ConfigureGeneral::SetConfiguration() {
ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing);
ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot);
ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme));
+ ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background);
ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit);
ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked());
@@ -42,6 +43,7 @@ void ConfigureGeneral::ApplyConfiguration() {
UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked();
UISettings::values.theme =
ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString();
+ UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked();
Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked();
Settings::values.frame_limit = ui->frame_limit->value();
diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui
index 0bb91d64b..26b3486ff 100644
--- a/src/yuzu/configuration/configure_general.ui
+++ b/src/yuzu/configuration/configure_general.ui
@@ -65,6 +65,13 @@
</property>
</widget>
</item>
+ <item>
+ <widget class="QCheckBox" name="toggle_background_pause">
+ <property name="text">
+ <string>Pause emulation when in background</string>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
</layout>
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index a968cfb5d..67c9a7c6d 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -245,10 +245,24 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
button->setContextMenuPolicy(Qt::CustomContextMenu);
connect(button, &QPushButton::clicked, [=] {
- HandleClick(
- button_map[button_id],
- [=](const Common::ParamPackage& params) { buttons_param[button_id] = params; },
- InputCommon::Polling::DeviceType::Button);
+ HandleClick(button_map[button_id],
+ [=](Common::ParamPackage params) {
+ // Workaround for ZL & ZR for analog triggers like on XBOX controllors.
+ // Analog triggers (from controllers like the XBOX controller) would not
+ // work due to a different range of their signals (from 0 to 255 on
+ // analog triggers instead of -32768 to 32768 on analog joysticks). The
+ // SDL driver misinterprets analog triggers as analog joysticks.
+ // TODO: reinterpret the signal range for analog triggers to map the
+ // values correctly. This is required for the correct emulation of the
+ // analog triggers of the GameCube controller.
+ if (button_id == Settings::NativeButton::ZL ||
+ button_id == Settings::NativeButton::ZR) {
+ params.Set("direction", "+");
+ params.Set("threshold", "0.5");
+ }
+ buttons_param[button_id] = std::move(params);
+ },
+ InputCommon::Polling::DeviceType::Button);
});
connect(button, &QPushButton::customContextMenuRequested, [=](const QPoint& menu_location) {
QMenu context_menu;
diff --git a/src/yuzu/configuration/configure_service.cpp b/src/yuzu/configuration/configure_service.cpp
new file mode 100644
index 000000000..06566e981
--- /dev/null
+++ b/src/yuzu/configuration/configure_service.cpp
@@ -0,0 +1,138 @@
+// Copyright 2019 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include <QGraphicsItem>
+#include <QtConcurrent/QtConcurrent>
+#include "core/hle/service/bcat/backend/boxcat.h"
+#include "core/settings.h"
+#include "ui_configure_service.h"
+#include "yuzu/configuration/configure_service.h"
+
+namespace {
+QString FormatEventStatusString(const Service::BCAT::EventStatus& status) {
+ QString out;
+
+ if (status.header.has_value()) {
+ out += QStringLiteral("<i>%1</i><br>").arg(QString::fromStdString(*status.header));
+ }
+
+ if (status.events.size() == 1) {
+ out += QStringLiteral("%1<br>").arg(QString::fromStdString(status.events.front()));
+ } else {
+ for (const auto& event : status.events) {
+ out += QStringLiteral("- %1<br>").arg(QString::fromStdString(event));
+ }
+ }
+
+ if (status.footer.has_value()) {
+ out += QStringLiteral("<i>%1</i><br>").arg(QString::fromStdString(*status.footer));
+ }
+
+ return out;
+}
+} // Anonymous namespace
+
+ConfigureService::ConfigureService(QWidget* parent)
+ : QWidget(parent), ui(std::make_unique<Ui::ConfigureService>()) {
+ ui->setupUi(this);
+
+ ui->bcat_source->addItem(QStringLiteral("None"));
+ ui->bcat_empty_label->setHidden(true);
+ ui->bcat_empty_header->setHidden(true);
+
+#ifdef YUZU_ENABLE_BOXCAT
+ ui->bcat_source->addItem(QStringLiteral("Boxcat"), QStringLiteral("boxcat"));
+#endif
+
+ connect(ui->bcat_source, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
+ &ConfigureService::OnBCATImplChanged);
+
+ this->SetConfiguration();
+}
+
+ConfigureService::~ConfigureService() = default;
+
+void ConfigureService::ApplyConfiguration() {
+ Settings::values.bcat_backend = ui->bcat_source->currentText().toLower().toStdString();
+}
+
+void ConfigureService::RetranslateUi() {
+ ui->retranslateUi(this);
+}
+
+void ConfigureService::SetConfiguration() {
+ const int index =
+ ui->bcat_source->findData(QString::fromStdString(Settings::values.bcat_backend));
+ ui->bcat_source->setCurrentIndex(index == -1 ? 0 : index);
+}
+
+std::pair<QString, QString> ConfigureService::BCATDownloadEvents() {
+ std::optional<std::string> global;
+ std::map<std::string, Service::BCAT::EventStatus> map;
+ const auto res = Service::BCAT::Boxcat::GetStatus(global, map);
+
+ switch (res) {
+ case Service::BCAT::Boxcat::StatusResult::Success:
+ break;
+ case Service::BCAT::Boxcat::StatusResult::Offline:
+ return {QString{},
+ tr("The boxcat service is offline or you are not connected to the internet.")};
+ case Service::BCAT::Boxcat::StatusResult::ParseError:
+ return {QString{},
+ tr("There was an error while processing the boxcat event data. Contact the yuzu "
+ "developers.")};
+ case Service::BCAT::Boxcat::StatusResult::BadClientVersion:
+ return {QString{},
+ tr("The version of yuzu you are using is either too new or too old for the server. "
+ "Try updating to the latest official release of yuzu.")};
+ }
+
+ if (map.empty()) {
+ return {QStringLiteral("Current Boxcat Events"),
+ tr("There are currently no events on boxcat.")};
+ }
+
+ QString out;
+
+ if (global.has_value()) {
+ out += QStringLiteral("%1<br>").arg(QString::fromStdString(*global));
+ }
+
+ for (const auto& [key, value] : map) {
+ out += QStringLiteral("%1<b>%2</b><br>%3")
+ .arg(out.isEmpty() ? QString{} : QStringLiteral("<br>"))
+ .arg(QString::fromStdString(key))
+ .arg(FormatEventStatusString(value));
+ }
+ return {QStringLiteral("Current Boxcat Events"), std::move(out)};
+}
+
+void ConfigureService::OnBCATImplChanged() {
+#ifdef YUZU_ENABLE_BOXCAT
+ const auto boxcat = ui->bcat_source->currentText() == QStringLiteral("Boxcat");
+ ui->bcat_empty_header->setHidden(!boxcat);
+ ui->bcat_empty_label->setHidden(!boxcat);
+ ui->bcat_empty_header->setText(QString{});
+ ui->bcat_empty_label->setText(tr("Yuzu is retrieving the latest boxcat status..."));
+
+ if (!boxcat)
+ return;
+
+ const auto future = QtConcurrent::run([this] { return BCATDownloadEvents(); });
+
+ watcher.setFuture(future);
+ connect(&watcher, &QFutureWatcher<std::pair<QString, QString>>::finished, this,
+ [this] { OnUpdateBCATEmptyLabel(watcher.result()); });
+#endif
+}
+
+void ConfigureService::OnUpdateBCATEmptyLabel(std::pair<QString, QString> string) {
+#ifdef YUZU_ENABLE_BOXCAT
+ const auto boxcat = ui->bcat_source->currentText() == QStringLiteral("Boxcat");
+ if (boxcat) {
+ ui->bcat_empty_header->setText(string.first);
+ ui->bcat_empty_label->setText(string.second);
+ }
+#endif
+}
diff --git a/src/yuzu/configuration/configure_service.h b/src/yuzu/configuration/configure_service.h
new file mode 100644
index 000000000..f5c1b703a
--- /dev/null
+++ b/src/yuzu/configuration/configure_service.h
@@ -0,0 +1,34 @@
+// Copyright 2019 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <memory>
+#include <QFutureWatcher>
+#include <QWidget>
+
+namespace Ui {
+class ConfigureService;
+}
+
+class ConfigureService : public QWidget {
+ Q_OBJECT
+
+public:
+ explicit ConfigureService(QWidget* parent = nullptr);
+ ~ConfigureService() override;
+
+ void ApplyConfiguration();
+ void RetranslateUi();
+
+private:
+ void SetConfiguration();
+
+ std::pair<QString, QString> BCATDownloadEvents();
+ void OnBCATImplChanged();
+ void OnUpdateBCATEmptyLabel(std::pair<QString, QString> string);
+
+ std::unique_ptr<Ui::ConfigureService> ui;
+ QFutureWatcher<std::pair<QString, QString>> watcher{this};
+};
diff --git a/src/yuzu/configuration/configure_service.ui b/src/yuzu/configuration/configure_service.ui
new file mode 100644
index 000000000..9668dd557
--- /dev/null
+++ b/src/yuzu/configuration/configure_service.ui
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ConfigureService</class>
+ <widget class="QWidget" name="ConfigureService">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>433</width>
+ <height>561</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>BCAT</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="1" column="1" colspan="2">
+ <widget class="QLabel" name="label_2">
+ <property name="maximumSize">
+ <size>
+ <width>260</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>BCAT is Nintendo's way of sending data to games to engage its community and unlock additional content.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>BCAT Backend</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" colspan="2">
+ <widget class="QLabel" name="bcat_empty_label">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>260</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" colspan="2">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://yuzu-emu.org/help/feature/boxcat&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Learn more about BCAT, Boxcat, and Current Events&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="openExternalLinks">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="2">
+ <widget class="QComboBox" name="bcat_source"/>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="bcat_empty_header">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/yuzu/configuration/configure_web.cpp b/src/yuzu/configuration/configure_web.cpp
index 336b062b3..8637f5b3c 100644
--- a/src/yuzu/configuration/configure_web.cpp
+++ b/src/yuzu/configuration/configure_web.cpp
@@ -11,6 +11,31 @@
#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::ConfigureWeb>()) {
ui->setupUi(this);
@@ -63,13 +88,18 @@ void ConfigureWeb::SetConfiguration() {
ui->web_signup_link->setOpenExternalLinks(true);
ui->web_token_info_link->setOpenExternalLinks(true);
+ if (Settings::values.yuzu_username.empty()) {
+ ui->username->setText(tr("Unspecified"));
+ } else {
+ ui->username->setText(QString::fromStdString(Settings::values.yuzu_username));
+ }
+
ui->toggle_telemetry->setChecked(Settings::values.enable_telemetry);
- ui->edit_username->setText(QString::fromStdString(Settings::values.yuzu_username));
- ui->edit_token->setText(QString::fromStdString(Settings::values.yuzu_token));
+ ui->edit_token->setText(QString::fromStdString(
+ GenerateDisplayToken(Settings::values.yuzu_username, Settings::values.yuzu_token)));
// Connect after setting the values, to avoid calling OnLoginChanged now
connect(ui->edit_token, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged);
- connect(ui->edit_username, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged);
user_verified = true;
@@ -80,12 +110,13 @@ void ConfigureWeb::ApplyConfiguration() {
Settings::values.enable_telemetry = ui->toggle_telemetry->isChecked();
UISettings::values.enable_discord_presence = ui->toggle_discordrpc->isChecked();
if (user_verified) {
- Settings::values.yuzu_username = ui->edit_username->text().toStdString();
- Settings::values.yuzu_token = ui->edit_token->text().toStdString();
+ Settings::values.yuzu_username =
+ UsernameFromDisplayToken(ui->edit_token->text().toStdString());
+ Settings::values.yuzu_token = TokenFromDisplayToken(ui->edit_token->text().toStdString());
} else {
- QMessageBox::warning(this, tr("Username and token not verified"),
- tr("Username and token were not verified. The changes to your "
- "username and/or token have not been saved."));
+ QMessageBox::warning(
+ this, tr("Token not verified"),
+ tr("Token was not verified. The change to your token has not been saved."));
}
}
@@ -96,17 +127,15 @@ void ConfigureWeb::RefreshTelemetryID() {
}
void ConfigureWeb::OnLoginChanged() {
- if (ui->edit_username->text().isEmpty() && ui->edit_token->text().isEmpty()) {
+ if (ui->edit_token->text().isEmpty()) {
user_verified = true;
const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("checked")).pixmap(16);
- ui->label_username_verified->setPixmap(pixmap);
ui->label_token_verified->setPixmap(pixmap);
} else {
user_verified = false;
const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("failed")).pixmap(16);
- ui->label_username_verified->setPixmap(pixmap);
ui->label_token_verified->setPixmap(pixmap);
}
}
@@ -114,10 +143,11 @@ void ConfigureWeb::OnLoginChanged() {
void ConfigureWeb::VerifyLogin() {
ui->button_verify_login->setDisabled(true);
ui->button_verify_login->setText(tr("Verifying..."));
- verify_watcher.setFuture(QtConcurrent::run([username = ui->edit_username->text().toStdString(),
- token = ui->edit_token->text().toStdString()] {
- return Core::VerifyLogin(username, token);
- }));
+ verify_watcher.setFuture(QtConcurrent::run(
+ [username = UsernameFromDisplayToken(ui->edit_token->text().toStdString()),
+ token = TokenFromDisplayToken(ui->edit_token->text().toStdString())] {
+ return Core::VerifyLogin(username, token);
+ }));
}
void ConfigureWeb::OnLoginVerified() {
@@ -127,16 +157,15 @@ void ConfigureWeb::OnLoginVerified() {
user_verified = true;
const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("checked")).pixmap(16);
- ui->label_username_verified->setPixmap(pixmap);
ui->label_token_verified->setPixmap(pixmap);
+ ui->username->setText(
+ QString::fromStdString(UsernameFromDisplayToken(ui->edit_token->text().toStdString())));
} else {
const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("failed")).pixmap(16);
- ui->label_username_verified->setPixmap(pixmap);
ui->label_token_verified->setPixmap(pixmap);
-
- QMessageBox::critical(
- this, tr("Verification failed"),
- tr("Verification failed. Check that you have entered your username and token "
- "correctly, and that your internet connection is working."));
+ 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."));
}
}
diff --git a/src/yuzu/configuration/configure_web.ui b/src/yuzu/configuration/configure_web.ui
index 2f4b9dd73..8c07d1165 100644
--- a/src/yuzu/configuration/configure_web.ui
+++ b/src/yuzu/configuration/configure_web.ui
@@ -55,11 +55,7 @@
</widget>
</item>
<item row="0" column="1" colspan="3">
- <widget class="QLineEdit" name="edit_username">
- <property name="maxLength">
- <number>36</number>
- </property>
- </widget>
+ <widget class="QLabel" name="username" />
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_token">
@@ -79,14 +75,10 @@
</property>
</widget>
</item>
- <item row="0" column="4">
- <widget class="QLabel" name="label_username_verified">
- </widget>
- </item>
<item row="1" column="1" colspan="3">
<widget class="QLineEdit" name="edit_token">
<property name="maxLength">
- <number>36</number>
+ <number>80</number>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
diff --git a/src/yuzu/debugger/wait_tree.cpp b/src/yuzu/debugger/wait_tree.cpp
index cd8180f8b..188f798c0 100644
--- a/src/yuzu/debugger/wait_tree.cpp
+++ b/src/yuzu/debugger/wait_tree.cpp
@@ -66,10 +66,7 @@ std::vector<std::unique_ptr<WaitTreeThread>> WaitTreeItem::MakeThreadItemList()
};
const auto& system = Core::System::GetInstance();
- add_threads(system.Scheduler(0).GetThreadList());
- add_threads(system.Scheduler(1).GetThreadList());
- add_threads(system.Scheduler(2).GetThreadList());
- add_threads(system.Scheduler(3).GetThreadList());
+ add_threads(system.GlobalScheduler().GetThreadList());
return item_list;
}
@@ -175,17 +172,6 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeWaitObject::GetChildren() con
return list;
}
-QString WaitTreeWaitObject::GetResetTypeQString(Kernel::ResetType reset_type) {
- switch (reset_type) {
- case Kernel::ResetType::Automatic:
- return tr("automatic reset");
- case Kernel::ResetType::Manual:
- return tr("manual reset");
- }
- UNREACHABLE();
- return {};
-}
-
WaitTreeObjectList::WaitTreeObjectList(
const std::vector<Kernel::SharedPtr<Kernel::WaitObject>>& list, bool w_all)
: object_list(list), wait_all(w_all) {}
@@ -339,16 +325,6 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThread::GetChildren() const {
WaitTreeEvent::WaitTreeEvent(const Kernel::ReadableEvent& object) : WaitTreeWaitObject(object) {}
WaitTreeEvent::~WaitTreeEvent() = default;
-std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeEvent::GetChildren() const {
- std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeWaitObject::GetChildren());
-
- list.push_back(std::make_unique<WaitTreeText>(
- tr("reset type = %1")
- .arg(GetResetTypeQString(
- static_cast<const Kernel::ReadableEvent&>(object).GetResetType()))));
- return list;
-}
-
WaitTreeThreadList::WaitTreeThreadList(const std::vector<Kernel::SharedPtr<Kernel::Thread>>& list)
: thread_list(list) {}
WaitTreeThreadList::~WaitTreeThreadList() = default;
diff --git a/src/yuzu/debugger/wait_tree.h b/src/yuzu/debugger/wait_tree.h
index 62886609d..f2b13be24 100644
--- a/src/yuzu/debugger/wait_tree.h
+++ b/src/yuzu/debugger/wait_tree.h
@@ -111,8 +111,6 @@ public:
protected:
const Kernel::WaitObject& object;
-
- static QString GetResetTypeQString(Kernel::ResetType reset_type);
};
class WaitTreeObjectList : public WaitTreeExpandableItem {
@@ -146,8 +144,6 @@ class WaitTreeEvent : public WaitTreeWaitObject {
public:
explicit WaitTreeEvent(const Kernel::ReadableEvent& object);
~WaitTreeEvent() override;
-
- std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
};
class WaitTreeThreadList : public WaitTreeExpandableItem {
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp
index d5fab2f1f..a2b88c787 100644
--- a/src/yuzu/game_list.cpp
+++ b/src/yuzu/game_list.cpp
@@ -172,9 +172,7 @@ void GameList::onTextChanged(const QString& new_text) {
const int folder_count = tree_view->model()->rowCount();
QString edit_filter_text = new_text.toLower();
QStandardItem* folder;
- QStandardItem* child;
int children_total = 0;
- QModelIndex root_index = item_model->invisibleRootItem()->index();
// If the searchfield is empty every item is visible
// Otherwise the filter gets applied
@@ -272,6 +270,8 @@ void GameList::onUpdateThemedIcons() {
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
Qt::DecorationRole);
break;
+ default:
+ break;
}
}
}
@@ -392,6 +392,8 @@ void GameList::ValidateEntry(const QModelIndex& item) {
case GameListItemType::AddDir:
emit AddDirectory();
break;
+ default:
+ break;
}
}
@@ -462,6 +464,8 @@ void GameList::PopupContextMenu(const QPoint& menu_location) {
case GameListItemType::SysNandDir:
AddPermDirPopup(context_menu, selected);
break;
+ default:
+ break;
}
context_menu.exec(tree_view->viewport()->mapToGlobal(menu_location));
}
diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h
index a8d888fee..1c2b37afd 100644
--- a/src/yuzu/game_list_p.h
+++ b/src/yuzu/game_list_p.h
@@ -247,7 +247,7 @@ public:
Qt::DecorationRole);
setData(QObject::tr("System Titles"), Qt::DisplayRole);
break;
- case GameListItemType::CustomDir:
+ case GameListItemType::CustomDir: {
const QString icon_name = QFileInfo::exists(game_dir->path)
? QStringLiteral("folder")
: QStringLiteral("bad_folder");
@@ -256,8 +256,11 @@ public:
Qt::DecorationRole);
setData(game_dir->path, Qt::DisplayRole);
break;
- };
- };
+ }
+ default:
+ break;
+ }
+ }
int type() const override {
return static_cast<int>(dir_type);
diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp
index fd21a9761..4c81ef12b 100644
--- a/src/yuzu/game_list_worker.cpp
+++ b/src/yuzu/game_list_worker.cpp
@@ -326,10 +326,10 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa
}
} else {
std::vector<u8> icon;
- const auto res1 = loader->ReadIcon(icon);
+ [[maybe_unused]] const auto res1 = loader->ReadIcon(icon);
std::string name = " ";
- const auto res3 = loader->ReadTitle(name);
+ [[maybe_unused]] const auto res3 = loader->ReadTitle(name);
const FileSys::PatchManager patch{program_id};
@@ -354,20 +354,20 @@ void GameListWorker::run() {
for (UISettings::GameDir& game_dir : game_dirs) {
if (game_dir.path == QStringLiteral("SDMC")) {
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SdmcDir);
- emit DirEntryReady({game_list_dir});
+ emit DirEntryReady(game_list_dir);
AddTitlesToGameList(game_list_dir);
} else if (game_dir.path == QStringLiteral("UserNAND")) {
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::UserNandDir);
- emit DirEntryReady({game_list_dir});
+ emit DirEntryReady(game_list_dir);
AddTitlesToGameList(game_list_dir);
} else if (game_dir.path == QStringLiteral("SysNAND")) {
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SysNandDir);
- emit DirEntryReady({game_list_dir});
+ emit DirEntryReady(game_list_dir);
AddTitlesToGameList(game_list_dir);
} else {
watch_list.append(game_dir.path);
auto* const game_list_dir = new GameListDir(game_dir);
- emit DirEntryReady({game_list_dir});
+ emit DirEntryReady(game_list_dir);
provider->ClearAllEntries();
ScanFileSystem(ScanTarget::FillManualContentProvider, game_dir.path.toStdString(), 2,
game_list_dir);
diff --git a/src/yuzu/game_list_worker.h b/src/yuzu/game_list_worker.h
index 6e52fca89..84e4e1b42 100644
--- a/src/yuzu/game_list_worker.h
+++ b/src/yuzu/game_list_worker.h
@@ -75,8 +75,9 @@ private:
std::shared_ptr<FileSys::VfsFilesystem> vfs;
FileSys::ManualContentProvider* provider;
- QStringList watch_list;
- const CompatibilityList& compatibility_list;
QVector<UISettings::GameDir>& game_dirs;
+ const CompatibilityList& compatibility_list;
+
+ QStringList watch_list;
std::atomic_bool stop_processing;
};
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 2d82df739..867f8e913 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -675,6 +675,24 @@ void GMainWindow::RestoreUIState() {
Debugger::ToggleConsole();
}
+void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) {
+ if (!UISettings::values.pause_when_in_background) {
+ return;
+ }
+ if (state != Qt::ApplicationHidden && state != Qt::ApplicationInactive &&
+ state != Qt::ApplicationActive) {
+ LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state);
+ }
+ if (ui.action_Pause->isEnabled() &&
+ (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) {
+ auto_paused = true;
+ OnPauseGame();
+ } else if (ui.action_Start->isEnabled() && auto_paused && state == Qt::ApplicationActive) {
+ auto_paused = false;
+ OnStartGame();
+ }
+}
+
void GMainWindow::ConnectWidgetEvents() {
connect(game_list, &GameList::GameChosen, this, &GMainWindow::OnGameListLoadFile);
connect(game_list, &GameList::OpenDirectory, this, &GMainWindow::OnGameListOpenDirectory);
@@ -799,6 +817,9 @@ QStringList GMainWindow::GetUnsupportedGLExtensions() {
if (!GLAD_GL_ARB_multi_bind) {
unsupported_ext.append(QStringLiteral("ARB_multi_bind"));
}
+ if (!GLAD_GL_ARB_clip_control) {
+ unsupported_ext.append(QStringLiteral("ARB_clip_control"));
+ }
// Extensions required to support some texture formats.
if (!GLAD_GL_EXT_texture_compression_s3tc) {
@@ -1821,6 +1842,10 @@ void GMainWindow::OnLoadAmiibo() {
return;
}
+ LoadAmiibo(filename);
+}
+
+void GMainWindow::LoadAmiibo(const QString& filename) {
Core::System& system{Core::System::GetInstance()};
Service::SM::ServiceManager& sm = system.ServiceManager();
auto nfc = sm.GetService<Service::NFP::Module::Interface>("nfp:user");
@@ -1889,15 +1914,24 @@ void GMainWindow::OnCaptureScreenshot() {
}
void GMainWindow::UpdateWindowTitle(const QString& title_name) {
- const QString full_name = QString::fromUtf8(Common::g_build_fullname);
- const QString branch_name = QString::fromUtf8(Common::g_scm_branch);
- const QString description = QString::fromUtf8(Common::g_scm_desc);
+ const auto full_name = std::string(Common::g_build_fullname);
+ const auto branch_name = std::string(Common::g_scm_branch);
+ const auto description = std::string(Common::g_scm_desc);
+ const auto build_id = std::string(Common::g_build_id);
+
+ const auto date =
+ QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd")).toStdString();
if (title_name.isEmpty()) {
- setWindowTitle(QStringLiteral("yuzu %1| %2-%3").arg(full_name, branch_name, description));
+ const auto fmt = std::string(Common::g_title_bar_format_idle);
+ setWindowTitle(QString::fromStdString(fmt::format(fmt.empty() ? "yuzu {0}| {1}-{2}" : fmt,
+ full_name, branch_name, description,
+ std::string{}, date, build_id)));
} else {
- setWindowTitle(QStringLiteral("yuzu %1| %4 | %2-%3")
- .arg(full_name, branch_name, description, title_name));
+ const auto fmt = std::string(Common::g_title_bar_format_running);
+ setWindowTitle(QString::fromStdString(
+ fmt::format(fmt.empty() ? "yuzu {0}| {3} | {1}-{2}" : fmt, full_name, branch_name,
+ description, title_name.toStdString(), date, build_id)));
}
}
@@ -2162,10 +2196,19 @@ static bool IsSingleFileDropEvent(QDropEvent* event) {
}
void GMainWindow::dropEvent(QDropEvent* event) {
- if (IsSingleFileDropEvent(event) && ConfirmChangeGame()) {
- const QMimeData* mimeData = event->mimeData();
- QString filename = mimeData->urls().at(0).toLocalFile();
- BootGame(filename);
+ if (!IsSingleFileDropEvent(event)) {
+ return;
+ }
+
+ const QMimeData* mime_data = event->mimeData();
+ const QString filename = mime_data->urls().at(0).toLocalFile();
+
+ if (emulation_running && QFileInfo(filename).suffix() == QStringLiteral("bin")) {
+ LoadAmiibo(filename);
+ } else {
+ if (ConfirmChangeGame()) {
+ BootGame(filename);
+ }
}
}
@@ -2311,6 +2354,9 @@ int main(int argc, char* argv[]) {
// After settings have been loaded by GMainWindow, apply the filter
main_window.show();
+ QObject::connect(&app, &QGuiApplication::applicationStateChanged, &main_window,
+ &GMainWindow::OnAppFocusStateChanged);
+
Settings::LogSettings();
int result = app.exec();
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index e942d1248..7f46bea2b 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -119,6 +119,7 @@ public slots:
void SoftwareKeyboardGetText(const Core::Frontend::SoftwareKeyboardParameters& parameters);
void SoftwareKeyboardInvokeCheckDialog(std::u16string error_message);
void WebBrowserOpenPage(std::string_view filename, std::string_view arguments);
+ void OnAppFocusStateChanged(Qt::ApplicationState state);
private:
void InitializeWidgets();
@@ -141,6 +142,7 @@ private:
void ShowTelemetryCallout();
void SetDiscordEnabled(bool state);
+ void LoadAmiibo(const QString& filename);
void SelectAndSetCurrentUser();
@@ -244,6 +246,8 @@ private:
// The path to the game currently running
QString game_path;
+ bool auto_paused = false;
+
// FS
std::shared_ptr<FileSys::VfsFilesystem> vfs;
std::unique_ptr<FileSys::ManualContentProvider> provider;
diff --git a/src/yuzu/uisettings.cpp b/src/yuzu/uisettings.cpp
index 7f7d247a3..43bad9678 100644
--- a/src/yuzu/uisettings.cpp
+++ b/src/yuzu/uisettings.cpp
@@ -9,6 +9,8 @@ namespace UISettings {
const Themes themes{{
{"Default", "default"},
{"Dark", "qdarkstyle"},
+ {"Colorful", "colorful"},
+ {"Colorful Dark", "colorful_dark"},
}};
Values values = {};
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h
index c57290006..bc7725a01 100644
--- a/src/yuzu/uisettings.h
+++ b/src/yuzu/uisettings.h
@@ -24,7 +24,7 @@ struct Shortcut {
ContextualShortcut shortcut;
};
-using Themes = std::array<std::pair<const char*, const char*>, 2>;
+using Themes = std::array<std::pair<const char*, const char*>, 4>;
extern const Themes themes;
struct GameDir {
@@ -58,6 +58,7 @@ struct Values {
bool confirm_before_closing;
bool first_start;
+ bool pause_when_in_background;
bool select_user_on_boot;