diff options
Diffstat (limited to 'src/yuzu')
-rw-r--r-- | src/yuzu/CMakeLists.txt | 7 | ||||
-rw-r--r-- | src/yuzu/configuration/config.cpp | 21 | ||||
-rw-r--r-- | src/yuzu/configuration/config.h | 2 | ||||
-rw-r--r-- | src/yuzu/configuration/configure.ui | 11 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_dialog.cpp | 5 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_service.cpp | 138 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_service.h | 34 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_service.ui | 124 | ||||
-rw-r--r-- | src/yuzu/game_list.cpp | 8 | ||||
-rw-r--r-- | src/yuzu/game_list_p.h | 9 | ||||
-rw-r--r-- | src/yuzu/game_list_worker.cpp | 12 | ||||
-rw-r--r-- | src/yuzu/game_list_worker.h | 5 | ||||
-rw-r--r-- | src/yuzu/main.cpp | 21 | ||||
-rw-r--r-- | src/yuzu/uisettings.cpp | 2 | ||||
-rw-r--r-- | src/yuzu/uisettings.h | 2 |
15 files changed, 380 insertions, 21 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..4cb27ddb2 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")); @@ -769,6 +780,7 @@ void Config::ReadValues() { ReadMiscellaneousValues(); ReadDebuggingValues(); ReadWebServiceValues(); + ReadServiceValues(); ReadDisabledAddOnValues(); ReadUIValues(); } @@ -866,6 +878,7 @@ void Config::SaveValues() { SaveMiscellaneousValues(); SaveDebuggingValues(); SaveWebServiceValues(); + SaveServiceValues(); SaveDisabledAddOnValues(); SaveUIValues(); } @@ -963,6 +976,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")); 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_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><html><head/><body><p><a href="https://yuzu-emu.org/help/feature/boxcat"><span style=" text-decoration: underline; color:#0000ff;">Learn more about BCAT, Boxcat, and Current Events</span></a></p></body></html></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/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..451e4a4d6 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1889,15 +1889,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))); } } 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..a8eaf5f8c 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 { |