diff options
| author | 2019-04-28 19:01:23 -0400 | |
|---|---|---|
| committer | 2019-09-30 17:26:10 -0400 | |
| commit | f0551aef0912c02e273021fd5186f49283ebcb14 (patch) | |
| tree | fd5d1258f971d3df6c1064d2c2e0caebc91d3673 /src | |
| parent | bcat: Implement cmd 90201 ClearDeliveryCacheStorage (diff) | |
| download | yuzu-f0551aef0912c02e273021fd5186f49283ebcb14.tar.gz yuzu-f0551aef0912c02e273021fd5186f49283ebcb14.tar.xz yuzu-f0551aef0912c02e273021fd5186f49283ebcb14.zip | |
yuzu: Add UI tab to configure BCAT services
Also displays current events if boxcat is selected.
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure.ui | 11 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_dialog.cpp | 1 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_service.cpp | 129 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_service.h | 34 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_service.ui | 121 |
6 files changed, 302 insertions, 0 deletions
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index dc6fa07fc..fffb20220 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt | |||
| @@ -66,6 +66,8 @@ add_executable(yuzu | |||
| 66 | configuration/configure_profile_manager.cpp | 66 | configuration/configure_profile_manager.cpp |
| 67 | configuration/configure_profile_manager.h | 67 | configuration/configure_profile_manager.h |
| 68 | configuration/configure_profile_manager.ui | 68 | configuration/configure_profile_manager.ui |
| 69 | configuration/configure_service.cpp | ||
| 70 | configuration/configure_service.h | ||
| 69 | configuration/configure_system.cpp | 71 | configuration/configure_system.cpp |
| 70 | configuration/configure_system.h | 72 | configuration/configure_system.h |
| 71 | configuration/configure_system.ui | 73 | configuration/configure_system.ui |
| @@ -186,6 +188,10 @@ if (YUZU_USE_QT_WEB_ENGINE) | |||
| 186 | target_compile_definitions(yuzu PRIVATE -DYUZU_USE_QT_WEB_ENGINE) | 188 | target_compile_definitions(yuzu PRIVATE -DYUZU_USE_QT_WEB_ENGINE) |
| 187 | endif () | 189 | endif () |
| 188 | 190 | ||
| 191 | if (YUZU_ENABLE_BOXCAT) | ||
| 192 | target_compile_definitions(yuzu PRIVATE -DYUZU_ENABLE_BOXCAT) | ||
| 193 | endif () | ||
| 194 | |||
| 189 | if(UNIX AND NOT APPLE) | 195 | if(UNIX AND NOT APPLE) |
| 190 | install(TARGETS yuzu RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") | 196 | install(TARGETS yuzu RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") |
| 191 | endif() | 197 | endif() |
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 @@ | |||
| 98 | <string>Web</string> | 98 | <string>Web</string> |
| 99 | </attribute> | 99 | </attribute> |
| 100 | </widget> | 100 | </widget> |
| 101 | <widget class="ConfigureService" name="serviceTab"> | ||
| 102 | <attribute name="title"> | ||
| 103 | <string>Services</string> | ||
| 104 | </attribute> | ||
| 105 | </widget> | ||
| 101 | </widget> | 106 | </widget> |
| 102 | </item> | 107 | </item> |
| 103 | </layout> | 108 | </layout> |
| @@ -178,6 +183,12 @@ | |||
| 178 | <header>configuration/configure_hotkeys.h</header> | 183 | <header>configuration/configure_hotkeys.h</header> |
| 179 | <container>1</container> | 184 | <container>1</container> |
| 180 | </customwidget> | 185 | </customwidget> |
| 186 | <customwidget> | ||
| 187 | <class>ConfigureService</class> | ||
| 188 | <extends>QWidget</extends> | ||
| 189 | <header>configuration/configure_service.h</header> | ||
| 190 | <container>1</container> | ||
| 191 | </customwidget> | ||
| 181 | </customwidgets> | 192 | </customwidgets> |
| 182 | <resources/> | 193 | <resources/> |
| 183 | <connections> | 194 | <connections> |
diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index 7c875ae87..520b7e193 100644 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp | |||
| @@ -44,6 +44,7 @@ void ConfigureDialog::ApplyConfiguration() { | |||
| 44 | ui->audioTab->ApplyConfiguration(); | 44 | ui->audioTab->ApplyConfiguration(); |
| 45 | ui->debugTab->ApplyConfiguration(); | 45 | ui->debugTab->ApplyConfiguration(); |
| 46 | ui->webTab->ApplyConfiguration(); | 46 | ui->webTab->ApplyConfiguration(); |
| 47 | ui->serviceTab->ApplyConfiguration(); | ||
| 47 | Settings::Apply(); | 48 | Settings::Apply(); |
| 48 | Settings::LogSettings(); | 49 | Settings::LogSettings(); |
| 49 | } | 50 | } |
diff --git a/src/yuzu/configuration/configure_service.cpp b/src/yuzu/configuration/configure_service.cpp new file mode 100644 index 000000000..fca785d0e --- /dev/null +++ b/src/yuzu/configuration/configure_service.cpp | |||
| @@ -0,0 +1,129 @@ | |||
| 1 | // Copyright 2019 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <QGraphicsItem> | ||
| 6 | #include <QtConcurrent/QtConcurrent> | ||
| 7 | #include "core/hle/service/bcat/backend/boxcat.h" | ||
| 8 | #include "core/settings.h" | ||
| 9 | #include "ui_configure_service.h" | ||
| 10 | #include "yuzu/configuration/configure_service.h" | ||
| 11 | |||
| 12 | namespace { | ||
| 13 | QString FormatEventStatusString(const Service::BCAT::EventStatus& status) { | ||
| 14 | QString out; | ||
| 15 | |||
| 16 | if (status.header.has_value()) { | ||
| 17 | out += QStringLiteral("<i>%1</i><br>").arg(QString::fromStdString(*status.header)); | ||
| 18 | } | ||
| 19 | |||
| 20 | if (status.events.size() == 1) { | ||
| 21 | out += QStringLiteral("%1<br>").arg(QString::fromStdString(status.events.front())); | ||
| 22 | } else { | ||
| 23 | for (const auto event : status.events) { | ||
| 24 | out += QStringLiteral("- %1<br>").arg(QString::fromStdString(event)); | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | if (status.footer.has_value()) { | ||
| 29 | out += QStringLiteral("<i>%1</i><br>").arg(QString::fromStdString(*status.footer)); | ||
| 30 | } | ||
| 31 | |||
| 32 | return out; | ||
| 33 | } | ||
| 34 | } // Anonymous namespace | ||
| 35 | |||
| 36 | ConfigureService::ConfigureService(QWidget* parent) | ||
| 37 | : QWidget(parent), ui(std::make_unique<Ui::ConfigureService>()), watcher(this) { | ||
| 38 | ui->setupUi(this); | ||
| 39 | |||
| 40 | ui->bcat_source->addItem(QStringLiteral("None")); | ||
| 41 | ui->bcat_empty_label->setHidden(true); | ||
| 42 | ui->bcat_empty_header->setHidden(true); | ||
| 43 | |||
| 44 | #ifdef YUZU_ENABLE_BOXCAT | ||
| 45 | ui->bcat_source->addItem(QStringLiteral("Boxcat"), QStringLiteral("boxcat")); | ||
| 46 | #endif | ||
| 47 | |||
| 48 | connect(ui->bcat_source, QOverload<int>::of(&QComboBox::currentIndexChanged), this, | ||
| 49 | &ConfigureService::OnBCATImplChanged); | ||
| 50 | |||
| 51 | this->setConfiguration(); | ||
| 52 | } | ||
| 53 | |||
| 54 | ConfigureService::~ConfigureService() = default; | ||
| 55 | |||
| 56 | void ConfigureService::applyConfiguration() { | ||
| 57 | Settings::values.bcat_backend = ui->bcat_source->currentText().toLower().toStdString(); | ||
| 58 | } | ||
| 59 | |||
| 60 | void ConfigureService::retranslateUi() { | ||
| 61 | ui->retranslateUi(this); | ||
| 62 | } | ||
| 63 | |||
| 64 | void ConfigureService::setConfiguration() { | ||
| 65 | int index = ui->bcat_source->findData(QString::fromStdString(Settings::values.bcat_backend)); | ||
| 66 | ui->bcat_source->setCurrentIndex(index == -1 ? 0 : index); | ||
| 67 | } | ||
| 68 | |||
| 69 | std::pair<QString, QString> ConfigureService::BCATDownloadEvents() { | ||
| 70 | std::optional<std::string> global; | ||
| 71 | std::map<std::string, Service::BCAT::EventStatus> map; | ||
| 72 | const auto res = Service::BCAT::Boxcat::GetStatus(global, map); | ||
| 73 | |||
| 74 | switch (res) { | ||
| 75 | case Service::BCAT::Boxcat::StatusResult::Offline: | ||
| 76 | return {"", tr("The boxcat service is offline or you are not connected to the internet.")}; | ||
| 77 | case Service::BCAT::Boxcat::StatusResult::ParseError: | ||
| 78 | return {"", | ||
| 79 | tr("There was an error while processing the boxcat event data. Contact the yuzu " | ||
| 80 | "developers.")}; | ||
| 81 | case Service::BCAT::Boxcat::StatusResult::BadClientVersion: | ||
| 82 | return {"", | ||
| 83 | tr("The version of yuzu you are using is either too new or too old for the server. " | ||
| 84 | "Try updating to the latest official release of yuzu.")}; | ||
| 85 | } | ||
| 86 | |||
| 87 | if (map.empty()) { | ||
| 88 | return {QStringLiteral("Current Boxcat Events"), | ||
| 89 | tr("There are currently no events on boxcat.")}; | ||
| 90 | } | ||
| 91 | |||
| 92 | QString out; | ||
| 93 | for (const auto& [key, value] : map) { | ||
| 94 | out += QStringLiteral("%1<b>%2</b><br>%3") | ||
| 95 | .arg(out.isEmpty() ? "" : "<br>") | ||
| 96 | .arg(QString::fromStdString(key)) | ||
| 97 | .arg(FormatEventStatusString(value)); | ||
| 98 | } | ||
| 99 | return {QStringLiteral("Current Boxcat Events"), out}; | ||
| 100 | } | ||
| 101 | |||
| 102 | void ConfigureService::OnBCATImplChanged() { | ||
| 103 | #ifdef YUZU_ENABLE_BOXCAT | ||
| 104 | const auto boxcat = ui->bcat_source->currentText() == QStringLiteral("Boxcat"); | ||
| 105 | ui->bcat_empty_header->setHidden(!boxcat); | ||
| 106 | ui->bcat_empty_label->setHidden(!boxcat); | ||
| 107 | ui->bcat_empty_header->setText(""); | ||
| 108 | ui->bcat_empty_label->setText(tr("Yuzu is retrieving the latest boxcat status...")); | ||
| 109 | |||
| 110 | if (!boxcat) | ||
| 111 | return; | ||
| 112 | |||
| 113 | const auto future = QtConcurrent::run([this] { return BCATDownloadEvents(); }); | ||
| 114 | |||
| 115 | watcher.setFuture(future); | ||
| 116 | connect(&watcher, &QFutureWatcher<std::pair<QString, QString>>::finished, this, | ||
| 117 | [this] { OnUpdateBCATEmptyLabel(watcher.result()); }); | ||
| 118 | #endif | ||
| 119 | } | ||
| 120 | |||
| 121 | void ConfigureService::OnUpdateBCATEmptyLabel(std::pair<QString, QString> string) { | ||
| 122 | #ifdef YUZU_ENABLE_BOXCAT | ||
| 123 | const auto boxcat = ui->bcat_source->currentText() == QStringLiteral("Boxcat"); | ||
| 124 | if (boxcat) { | ||
| 125 | ui->bcat_empty_header->setText(string.first); | ||
| 126 | ui->bcat_empty_label->setText(string.second); | ||
| 127 | } | ||
| 128 | #endif | ||
| 129 | } | ||
diff --git a/src/yuzu/configuration/configure_service.h b/src/yuzu/configuration/configure_service.h new file mode 100644 index 000000000..ee50d5a79 --- /dev/null +++ b/src/yuzu/configuration/configure_service.h | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | // Copyright 2019 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <memory> | ||
| 8 | #include <QFutureWatcher> | ||
| 9 | #include <QWidget> | ||
| 10 | |||
| 11 | namespace Ui { | ||
| 12 | class ConfigureService; | ||
| 13 | } | ||
| 14 | |||
| 15 | class ConfigureService : public QWidget { | ||
| 16 | Q_OBJECT | ||
| 17 | |||
| 18 | public: | ||
| 19 | explicit ConfigureService(QWidget* parent = nullptr); | ||
| 20 | ~ConfigureService() override; | ||
| 21 | |||
| 22 | void applyConfiguration(); | ||
| 23 | void retranslateUi(); | ||
| 24 | |||
| 25 | private: | ||
| 26 | void setConfiguration(); | ||
| 27 | |||
| 28 | std::pair<QString, QString> BCATDownloadEvents(); | ||
| 29 | void OnBCATImplChanged(); | ||
| 30 | void OnUpdateBCATEmptyLabel(std::pair<QString, QString> string); | ||
| 31 | |||
| 32 | std::unique_ptr<Ui::ConfigureService> ui; | ||
| 33 | QFutureWatcher<std::pair<QString, QString>> watcher; | ||
| 34 | }; | ||
diff --git a/src/yuzu/configuration/configure_service.ui b/src/yuzu/configuration/configure_service.ui new file mode 100644 index 000000000..f5b683d25 --- /dev/null +++ b/src/yuzu/configuration/configure_service.ui | |||
| @@ -0,0 +1,121 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <ui version="4.0"> | ||
| 3 | <class>ConfigureService</class> | ||
| 4 | <widget class="QWidget" name="ConfigureService"> | ||
| 5 | <property name="geometry"> | ||
| 6 | <rect> | ||
| 7 | <x>0</x> | ||
| 8 | <y>0</y> | ||
| 9 | <width>433</width> | ||
| 10 | <height>561</height> | ||
| 11 | </rect> | ||
| 12 | </property> | ||
| 13 | <property name="windowTitle"> | ||
| 14 | <string>Form</string> | ||
| 15 | </property> | ||
| 16 | <layout class="QVBoxLayout" name="verticalLayout"> | ||
| 17 | <item> | ||
| 18 | <layout class="QVBoxLayout" name="verticalLayout_3"> | ||
| 19 | <item> | ||
| 20 | <widget class="QGroupBox" name="groupBox"> | ||
| 21 | <property name="title"> | ||
| 22 | <string>BCAT</string> | ||
| 23 | </property> | ||
| 24 | <layout class="QGridLayout" name="gridLayout"> | ||
| 25 | <item row="1" column="1" colspan="2"> | ||
| 26 | <widget class="QLabel" name="label_2"> | ||
| 27 | <property name="maximumSize"> | ||
| 28 | <size> | ||
| 29 | <width>260</width> | ||
| 30 | <height>16777215</height> | ||
| 31 | </size> | ||
| 32 | </property> | ||
| 33 | <property name="text"> | ||
| 34 | <string>BCAT is Nintendo's way of sending data to games to engage its community and unlock additional content.</string> | ||
| 35 | </property> | ||
| 36 | <property name="wordWrap"> | ||
| 37 | <bool>true</bool> | ||
| 38 | </property> | ||
| 39 | </widget> | ||
| 40 | </item> | ||
| 41 | <item row="0" column="0"> | ||
| 42 | <widget class="QLabel" name="label"> | ||
| 43 | <property name="maximumSize"> | ||
| 44 | <size> | ||
| 45 | <width>16777215</width> | ||
| 46 | <height>16777215</height> | ||
| 47 | </size> | ||
| 48 | </property> | ||
| 49 | <property name="text"> | ||
| 50 | <string>BCAT Backend</string> | ||
| 51 | </property> | ||
| 52 | </widget> | ||
| 53 | </item> | ||
| 54 | <item row="3" column="1" colspan="2"> | ||
| 55 | <widget class="QLabel" name="bcat_empty_label"> | ||
| 56 | <property name="enabled"> | ||
| 57 | <bool>true</bool> | ||
| 58 | </property> | ||
| 59 | <property name="maximumSize"> | ||
| 60 | <size> | ||
| 61 | <width>260</width> | ||
| 62 | <height>16777215</height> | ||
| 63 | </size> | ||
| 64 | </property> | ||
| 65 | <property name="text"> | ||
| 66 | <string/> | ||
| 67 | </property> | ||
| 68 | <property name="alignment"> | ||
| 69 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> | ||
| 70 | </property> | ||
| 71 | <property name="wordWrap"> | ||
| 72 | <bool>true</bool> | ||
| 73 | </property> | ||
| 74 | </widget> | ||
| 75 | </item> | ||
| 76 | <item row="2" column="1" colspan="2"> | ||
| 77 | <widget class="QLabel" name="label_3"> | ||
| 78 | <property name="text"> | ||
| 79 | <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> | ||
| 80 | </property> | ||
| 81 | </widget> | ||
| 82 | </item> | ||
| 83 | <item row="0" column="1" colspan="2"> | ||
| 84 | <widget class="QComboBox" name="bcat_source"/> | ||
| 85 | </item> | ||
| 86 | <item row="3" column="0"> | ||
| 87 | <widget class="QLabel" name="bcat_empty_header"> | ||
| 88 | <property name="text"> | ||
| 89 | <string/> | ||
| 90 | </property> | ||
| 91 | <property name="alignment"> | ||
| 92 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> | ||
| 93 | </property> | ||
| 94 | <property name="wordWrap"> | ||
| 95 | <bool>true</bool> | ||
| 96 | </property> | ||
| 97 | </widget> | ||
| 98 | </item> | ||
| 99 | </layout> | ||
| 100 | </widget> | ||
| 101 | </item> | ||
| 102 | </layout> | ||
| 103 | </item> | ||
| 104 | <item> | ||
| 105 | <spacer name="verticalSpacer"> | ||
| 106 | <property name="orientation"> | ||
| 107 | <enum>Qt::Vertical</enum> | ||
| 108 | </property> | ||
| 109 | <property name="sizeHint" stdset="0"> | ||
| 110 | <size> | ||
| 111 | <width>20</width> | ||
| 112 | <height>40</height> | ||
| 113 | </size> | ||
| 114 | </property> | ||
| 115 | </spacer> | ||
| 116 | </item> | ||
| 117 | </layout> | ||
| 118 | </widget> | ||
| 119 | <resources/> | ||
| 120 | <connections/> | ||
| 121 | </ui> | ||