mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-22 02:41:49 -05:00
yuzu: Add UI tab to configure BCAT services
Also displays current events if boxcat is selected.
This commit is contained in:
parent
102db206e0
commit
f0551aef09
6 changed files with 302 additions and 0 deletions
|
@ -66,6 +66,8 @@ add_executable(yuzu
|
||||||
configuration/configure_profile_manager.cpp
|
configuration/configure_profile_manager.cpp
|
||||||
configuration/configure_profile_manager.h
|
configuration/configure_profile_manager.h
|
||||||
configuration/configure_profile_manager.ui
|
configuration/configure_profile_manager.ui
|
||||||
|
configuration/configure_service.cpp
|
||||||
|
configuration/configure_service.h
|
||||||
configuration/configure_system.cpp
|
configuration/configure_system.cpp
|
||||||
configuration/configure_system.h
|
configuration/configure_system.h
|
||||||
configuration/configure_system.ui
|
configuration/configure_system.ui
|
||||||
|
@ -186,6 +188,10 @@ if (YUZU_USE_QT_WEB_ENGINE)
|
||||||
target_compile_definitions(yuzu PRIVATE -DYUZU_USE_QT_WEB_ENGINE)
|
target_compile_definitions(yuzu PRIVATE -DYUZU_USE_QT_WEB_ENGINE)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if (YUZU_ENABLE_BOXCAT)
|
||||||
|
target_compile_definitions(yuzu PRIVATE -DYUZU_ENABLE_BOXCAT)
|
||||||
|
endif ()
|
||||||
|
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
install(TARGETS yuzu RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
|
install(TARGETS yuzu RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -98,6 +98,11 @@
|
||||||
<string>Web</string>
|
<string>Web</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="ConfigureService" name="serviceTab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Services</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -178,6 +183,12 @@
|
||||||
<header>configuration/configure_hotkeys.h</header>
|
<header>configuration/configure_hotkeys.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>ConfigureService</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>configuration/configure_service.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
|
|
|
@ -44,6 +44,7 @@ void ConfigureDialog::ApplyConfiguration() {
|
||||||
ui->audioTab->ApplyConfiguration();
|
ui->audioTab->ApplyConfiguration();
|
||||||
ui->debugTab->ApplyConfiguration();
|
ui->debugTab->ApplyConfiguration();
|
||||||
ui->webTab->ApplyConfiguration();
|
ui->webTab->ApplyConfiguration();
|
||||||
|
ui->serviceTab->ApplyConfiguration();
|
||||||
Settings::Apply();
|
Settings::Apply();
|
||||||
Settings::LogSettings();
|
Settings::LogSettings();
|
||||||
}
|
}
|
||||||
|
|
129
src/yuzu/configuration/configure_service.cpp
Normal file
129
src/yuzu/configuration/configure_service.cpp
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
// 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>()), watcher(this) {
|
||||||
|
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() {
|
||||||
|
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::Offline:
|
||||||
|
return {"", tr("The boxcat service is offline or you are not connected to the internet.")};
|
||||||
|
case Service::BCAT::Boxcat::StatusResult::ParseError:
|
||||||
|
return {"",
|
||||||
|
tr("There was an error while processing the boxcat event data. Contact the yuzu "
|
||||||
|
"developers.")};
|
||||||
|
case Service::BCAT::Boxcat::StatusResult::BadClientVersion:
|
||||||
|
return {"",
|
||||||
|
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;
|
||||||
|
for (const auto& [key, value] : map) {
|
||||||
|
out += QStringLiteral("%1<b>%2</b><br>%3")
|
||||||
|
.arg(out.isEmpty() ? "" : "<br>")
|
||||||
|
.arg(QString::fromStdString(key))
|
||||||
|
.arg(FormatEventStatusString(value));
|
||||||
|
}
|
||||||
|
return {QStringLiteral("Current Boxcat Events"), 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("");
|
||||||
|
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
|
||||||
|
}
|
34
src/yuzu/configuration/configure_service.h
Normal file
34
src/yuzu/configuration/configure_service.h
Normal file
|
@ -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;
|
||||||
|
};
|
121
src/yuzu/configuration/configure_service.ui
Normal file
121
src/yuzu/configuration/configure_service.ui
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
<?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>
|
||||||
|
</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>
|
Loading…
Reference in a new issue