general: Address review comments

This commit is contained in:
german77 2022-11-13 15:14:08 -06:00
parent a253d1557d
commit 75e6ec85e1
14 changed files with 200 additions and 190 deletions

View File

@ -11,7 +11,7 @@ namespace Core::Frontend {
CabinetApplet::~CabinetApplet() = default; CabinetApplet::~CabinetApplet() = default;
void DefaultCabinetApplet::ShowCabinetApplet( void DefaultCabinetApplet::ShowCabinetApplet(
std::function<void(bool, const std::string&)> callback, const CabinetParameters& parameters, const CabinetCallback& callback, const CabinetParameters& parameters,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const { std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const {
LOG_WARNING(Service_AM, "(STUBBED) called"); LOG_WARNING(Service_AM, "(STUBBED) called");
callback(false, {}); callback(false, {});

View File

@ -18,18 +18,19 @@ struct CabinetParameters {
Service::NFP::CabinetMode mode; Service::NFP::CabinetMode mode;
}; };
using CabinetCallback = std::function<void(bool, const std::string&)>;
class CabinetApplet { class CabinetApplet {
public: public:
virtual ~CabinetApplet(); virtual ~CabinetApplet();
virtual void ShowCabinetApplet(std::function<void(bool, const std::string&)> callback, virtual void ShowCabinetApplet(const CabinetCallback& callback,
const CabinetParameters& parameters, const CabinetParameters& parameters,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const = 0; std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const = 0;
}; };
class DefaultCabinetApplet final : public CabinetApplet { class DefaultCabinetApplet final : public CabinetApplet {
public: public:
void ShowCabinetApplet(std::function<void(bool, const std::string&)> callback, void ShowCabinetApplet(const CabinetCallback& callback, const CabinetParameters& parameters,
const CabinetParameters& parameters,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const override; std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const override;
}; };

View File

@ -98,7 +98,7 @@ void Cabinet::Execute() {
} }
} }
void Cabinet::DisplayCompleted(bool apply_changes, const std::string& amiibo_name) { void Cabinet::DisplayCompleted(bool apply_changes, std::string_view amiibo_name) {
Service::Mii::MiiManager manager; Service::Mii::MiiManager manager;
ReturnValueForAmiiboSettings applet_output{}; ReturnValueForAmiiboSettings applet_output{};
@ -118,7 +118,7 @@ void Cabinet::DisplayCompleted(bool apply_changes, const std::string& amiibo_nam
switch (applet_input_common.applet_mode) { switch (applet_input_common.applet_mode) {
case Service::NFP::CabinetMode::StartNicknameAndOwnerSettings: { case Service::NFP::CabinetMode::StartNicknameAndOwnerSettings: {
Service::NFP::AmiiboName name{}; Service::NFP::AmiiboName name{};
memcpy(name.data(), amiibo_name.data(), std::min(amiibo_name.size(), name.size() - 1)); std::memcpy(name.data(), amiibo_name.data(), std::min(amiibo_name.size(), name.size() - 1));
nfp_device->SetNicknameAndOwner(name); nfp_device->SetNicknameAndOwner(name);
break; break;
} }
@ -142,12 +142,12 @@ void Cabinet::DisplayCompleted(bool apply_changes, const std::string& amiibo_nam
const auto tag_result = nfp_device->GetTagInfo(applet_output.tag_info); const auto tag_result = nfp_device->GetTagInfo(applet_output.tag_info);
nfp_device->Finalize(); nfp_device->Finalize();
if (reg_result.IsSuccess() && tag_result.IsSuccess()) { if (reg_result.IsSuccess()) {
applet_output.result = CabinetResult::All; applet_output.result |= CabinetResult::RegisterInfo;
} else if (reg_result.IsSuccess()) { }
applet_output.result = CabinetResult::RegisterInfo;
} else if (tag_result.IsSuccess()) { if (tag_result.IsSuccess()) {
applet_output.result = CabinetResult::TagInfo; applet_output.result |= CabinetResult::TagInfo;
} }
std::vector<u8> out_data(sizeof(ReturnValueForAmiiboSettings)); std::vector<u8> out_data(sizeof(ReturnValueForAmiiboSettings));

View File

@ -25,16 +25,17 @@ class NfpDevice;
namespace Service::AM::Applets { namespace Service::AM::Applets {
enum class CabinetAppletVersion : s32 { enum class CabinetAppletVersion : u32 {
Version1 = 0x1, Version1 = 0x1,
}; };
enum class CabinetResult : u8 { enum class CabinetResult : u8 {
Cancel, Cancel = 0,
TagInfo = 1 << 1, TagInfo = 1 << 1,
RegisterInfo = 1 << 2, RegisterInfo = 1 << 2,
All = TagInfo | RegisterInfo, All = TagInfo | RegisterInfo,
}; };
DECLARE_ENUM_FLAG_OPERATORS(CabinetResult)
// This is nn::nfp::AmiiboSettingsStartParam // This is nn::nfp::AmiiboSettingsStartParam
struct AmiiboSettingsStartParam { struct AmiiboSettingsStartParam {
@ -45,7 +46,7 @@ struct AmiiboSettingsStartParam {
static_assert(sizeof(AmiiboSettingsStartParam) == 0x30, static_assert(sizeof(AmiiboSettingsStartParam) == 0x30,
"AmiiboSettingsStartParam is an invalid size"); "AmiiboSettingsStartParam is an invalid size");
#pragma pack(1) #pragma pack(push, 1)
// This is nn::nfp::StartParamForAmiiboSettings // This is nn::nfp::StartParamForAmiiboSettings
struct StartParamForAmiiboSettings { struct StartParamForAmiiboSettings {
u8 param_1; u8 param_1;
@ -72,7 +73,7 @@ struct ReturnValueForAmiiboSettings {
}; };
static_assert(sizeof(ReturnValueForAmiiboSettings) == 0x188, static_assert(sizeof(ReturnValueForAmiiboSettings) == 0x188,
"ReturnValueForAmiiboSettings is an invalid size"); "ReturnValueForAmiiboSettings is an invalid size");
#pragma pack() #pragma pack(pop)
class Cabinet final : public Applet { class Cabinet final : public Applet {
public: public:
@ -86,7 +87,7 @@ public:
Result GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;
void DisplayCompleted(bool apply_changes, const std::string& amiibo_name); void DisplayCompleted(bool apply_changes, std::string_view amiibo_name);
void Cancel(); void Cancel();
private: private:

View File

@ -148,7 +148,7 @@ void NfpDevice::Finalize() {
device_state = DeviceState::Unavailable; device_state = DeviceState::Unavailable;
} }
Result NfpDevice::StartDetection([[maybe_unused]] TagProtocol allowed_protocol) { Result NfpDevice::StartDetection(TagProtocol allowed_protocol) {
if (device_state != DeviceState::Initialized && device_state != DeviceState::TagRemoved) { if (device_state != DeviceState::Initialized && device_state != DeviceState::TagRemoved) {
LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); LOG_ERROR(Service_NFP, "Wrong device state {}", device_state);
return WrongDeviceState; return WrongDeviceState;
@ -475,6 +475,8 @@ Result NfpDevice::OpenApplicationArea(u32 access_id) {
} }
Result NfpDevice::GetApplicationAreaId(u32& application_area_id) const { Result NfpDevice::GetApplicationAreaId(u32& application_area_id) const {
application_area_id = {};
if (device_state != DeviceState::TagMounted) { if (device_state != DeviceState::TagMounted) {
LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); LOG_ERROR(Service_NFP, "Wrong device state {}", device_state);
if (device_state == DeviceState::TagRemoved) { if (device_state == DeviceState::TagRemoved) {

View File

@ -109,7 +109,7 @@ VirtualAmiibo::Info VirtualAmiibo::CloseAmiibo() {
return Info::Success; return Info::Success;
} }
std::string VirtualAmiibo::GetLastFilePath() { std::string VirtualAmiibo::GetLastFilePath() const {
return file_path; return file_path;
} }

View File

@ -50,7 +50,7 @@ public:
Info ReloadAmiibo(); Info ReloadAmiibo();
Info CloseAmiibo(); Info CloseAmiibo();
std::string GetLastFilePath(); std::string GetLastFilePath() const;
private: private:
static constexpr std::size_t amiibo_size = 0x21C; static constexpr std::size_t amiibo_size = 0x21C;

View File

@ -18,9 +18,9 @@ add_executable(yuzu
about_dialog.cpp about_dialog.cpp
about_dialog.h about_dialog.h
aboutdialog.ui aboutdialog.ui
applets/qt_amiibo_manager.cpp applets/qt_amiibo_settings.cpp
applets/qt_amiibo_manager.h applets/qt_amiibo_settings.h
applets/qt_amiibo_manager.ui applets/qt_amiibo_settings.ui
applets/qt_controller.cpp applets/qt_controller.cpp
applets/qt_controller.h applets/qt_controller.h
applets/qt_controller.ui applets/qt_controller.ui

View File

@ -1,93 +0,0 @@
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <array>
#include <memory>
#include <QDialog>
#include "core/frontend/applets/cabinet.h"
class GMainWindow;
class QCheckBox;
class QComboBox;
class QDialogButtonBox;
class QGroupBox;
class QLabel;
class InputProfiles;
namespace InputCommon {
class InputSubsystem;
}
namespace Ui {
class QtAmiiboManagerDialog;
}
namespace Core {
class System;
}
namespace Core::HID {
class HIDCore;
enum class NpadStyleIndex : u8;
} // namespace Core::HID
namespace Service::NFP {
class NfpDevice;
} // namespace Service::NFP
class QtAmiiboManagerDialog final : public QDialog {
Q_OBJECT
public:
explicit QtAmiiboManagerDialog(QWidget* parent, Core::Frontend::CabinetParameters parameters_,
InputCommon::InputSubsystem* input_subsystem_,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device_);
~QtAmiiboManagerDialog() override;
int exec() override;
std::string GetName();
private:
void LoadInfo();
void LoadAmiiboApiInfo(std::string amiibo_id);
void LoadAmiiboData();
void LoadAmiiboGameInfo();
void SetGameDataName(u32 application_area_id);
void SetManagerDescription();
std::unique_ptr<Ui::QtAmiiboManagerDialog> ui;
InputCommon::InputSubsystem* input_subsystem;
std::shared_ptr<Service::NFP::NfpDevice> nfp_device;
// Parameters sent in from the backend HLE applet.
Core::Frontend::CabinetParameters parameters;
// If false amiibo manager failed to load
bool is_initalized{};
};
class QtAmiiboManager final : public QObject, public Core::Frontend::CabinetApplet {
Q_OBJECT
public:
explicit QtAmiiboManager(GMainWindow& parent);
~QtAmiiboManager() override;
void ShowCabinetApplet(std::function<void(bool, const std::string&)> callback_,
const Core::Frontend::CabinetParameters& parameters,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const override;
signals:
void MainWindowShowAmiiboManager(const Core::Frontend::CabinetParameters& parameters,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const;
private:
void MainWindowFinished(bool is_success, std::string name);
mutable std::function<void(bool, const std::string&)> callback;
};

View File

@ -12,17 +12,17 @@
#include "core/hle/service/nfp/nfp_result.h" #include "core/hle/service/nfp/nfp_result.h"
#include "input_common/drivers/virtual_amiibo.h" #include "input_common/drivers/virtual_amiibo.h"
#include "input_common/main.h" #include "input_common/main.h"
#include "ui_qt_amiibo_manager.h" #include "ui_qt_amiibo_settings.h"
#include "web_service/web_backend.h" #include "web_service/web_backend.h"
#include "yuzu/applets/qt_amiibo_manager.h" #include "yuzu/applets/qt_amiibo_settings.h"
#include "yuzu/main.h" #include "yuzu/main.h"
QtAmiiboManagerDialog::QtAmiiboManagerDialog(QWidget* parent, QtAmiiboSettingsDialog::QtAmiiboSettingsDialog(QWidget* parent,
Core::Frontend::CabinetParameters parameters_, Core::Frontend::CabinetParameters parameters_,
InputCommon::InputSubsystem* input_subsystem_, InputCommon::InputSubsystem* input_subsystem_,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device_) std::shared_ptr<Service::NFP::NfpDevice> nfp_device_)
: QDialog(parent), ui(std::make_unique<Ui::QtAmiiboManagerDialog>()), : QDialog(parent), ui(std::make_unique<Ui::QtAmiiboSettingsDialog>()),
input_subsystem{input_subsystem_}, nfp_device{nfp_device_}, input_subsystem{input_subsystem_}, nfp_device{std::move(nfp_device_)},
parameters(std::move(parameters_)) { parameters(std::move(parameters_)) {
ui->setupUi(this); ui->setupUi(this);
@ -31,20 +31,20 @@ QtAmiiboManagerDialog::QtAmiiboManagerDialog(QWidget* parent,
resize(0, 0); resize(0, 0);
} }
QtAmiiboManagerDialog::~QtAmiiboManagerDialog() = default; QtAmiiboSettingsDialog::~QtAmiiboSettingsDialog() = default;
int QtAmiiboManagerDialog::exec() { int QtAmiiboSettingsDialog::exec() {
if (!is_initalized) { if (!is_initalized) {
return QDialog::Rejected; return QDialog::Rejected;
} }
return QDialog::exec(); return QDialog::exec();
} }
std::string QtAmiiboManagerDialog::GetName() { std::string QtAmiiboSettingsDialog::GetName() const {
return ui->amiiboCustomNameValue->text().toStdString(); return ui->amiiboCustomNameValue->text().toStdString();
} }
void QtAmiiboManagerDialog::LoadInfo() { void QtAmiiboSettingsDialog::LoadInfo() {
if (input_subsystem->GetVirtualAmiibo()->ReloadAmiibo() != if (input_subsystem->GetVirtualAmiibo()->ReloadAmiibo() !=
InputCommon::VirtualAmiibo::Info::Success) { InputCommon::VirtualAmiibo::Info::Success) {
return; return;
@ -56,29 +56,41 @@ void QtAmiiboManagerDialog::LoadInfo() {
} }
nfp_device->Mount(Service::NFP::MountTarget::All); nfp_device->Mount(Service::NFP::MountTarget::All);
Service::NFP::ModelInfo model_info{}; LoadAmiiboInfo();
const auto model_result = nfp_device->GetModelInfo(model_info);
if (model_result.IsSuccess()) {
const auto amiibo_id =
fmt::format("{:04x}{:02x}{:02x}{:04x}{:02x}02", Common::swap16(model_info.character_id),
model_info.character_variant, model_info.amiibo_type,
model_info.model_number, model_info.series);
LOG_ERROR(Input, "{}", amiibo_id);
LoadAmiiboApiInfo(amiibo_id);
}
LoadAmiiboData(); LoadAmiiboData();
LoadAmiiboGameInfo(); LoadAmiiboGameInfo();
ui->amiiboDirectoryValue->setText( ui->amiiboDirectoryValue->setText(
QString::fromStdString(input_subsystem->GetVirtualAmiibo()->GetLastFilePath())); QString::fromStdString(input_subsystem->GetVirtualAmiibo()->GetLastFilePath()));
SetManagerDescription(); SetSettingsDescription();
is_initalized = true; is_initalized = true;
} }
void QtAmiiboManagerDialog::LoadAmiiboApiInfo(std::string amiibo_id) { void QtAmiiboSettingsDialog::LoadAmiiboInfo() {
Service::NFP::ModelInfo model_info{};
const auto model_result = nfp_device->GetModelInfo(model_info);
if (model_result.IsFailure()) {
ui->amiiboImageLabel->setVisible(false);
ui->amiiboInfoGroup->setVisible(false);
return;
}
const auto amiibo_id =
fmt::format("{:04x}{:02x}{:02x}{:04x}{:02x}02", Common::swap16(model_info.character_id),
model_info.character_variant, model_info.amiibo_type, model_info.model_number,
model_info.series);
LOG_DEBUG(Frontend, "Loading amiibo id {}", amiibo_id);
// Note: This function is not being used until we host the images on our server
// LoadAmiiboApiInfo(amiibo_id);
ui->amiiboImageLabel->setVisible(false);
ui->amiiboInfoGroup->setVisible(false);
}
void QtAmiiboSettingsDialog::LoadAmiiboApiInfo(std::string_view amiibo_id) {
// TODO: Host this data on our website
WebService::Client client{"https://amiiboapi.com", {}, {}}; WebService::Client client{"https://amiiboapi.com", {}, {}};
WebService::Client image_client{"https://raw.githubusercontent.com", {}, {}}; WebService::Client image_client{"https://raw.githubusercontent.com", {}, {}};
const auto url_path = fmt::format("/api/amiibo/?id={}", amiibo_id); const auto url_path = fmt::format("/api/amiibo/?id={}", amiibo_id);
@ -124,7 +136,7 @@ void QtAmiiboManagerDialog::LoadAmiiboApiInfo(std::string amiibo_id) {
ui->amiiboImageLabel->setPixmap(pixmap); ui->amiiboImageLabel->setPixmap(pixmap);
} }
void QtAmiiboManagerDialog::LoadAmiiboData() { void QtAmiiboSettingsDialog::LoadAmiiboData() {
Service::NFP::RegisterInfo register_info{}; Service::NFP::RegisterInfo register_info{};
Service::NFP::CommonInfo common_info{}; Service::NFP::CommonInfo common_info{};
const auto register_result = nfp_device->GetRegisterInfo(register_info); const auto register_result = nfp_device->GetRegisterInfo(register_info);
@ -166,7 +178,7 @@ void QtAmiiboManagerDialog::LoadAmiiboData() {
ui->modificationDateValue->setDate(modification_date); ui->modificationDateValue->setDate(modification_date);
} }
void QtAmiiboManagerDialog::LoadAmiiboGameInfo() { void QtAmiiboSettingsDialog::LoadAmiiboGameInfo() {
u32 application_area_id{}; u32 application_area_id{};
const auto application_result = nfp_device->GetApplicationAreaId(application_area_id); const auto application_result = nfp_device->GetApplicationAreaId(application_area_id);
@ -179,27 +191,27 @@ void QtAmiiboManagerDialog::LoadAmiiboGameInfo() {
SetGameDataName(application_area_id); SetGameDataName(application_area_id);
} }
void QtAmiiboManagerDialog::SetGameDataName(u32 application_area_id) { void QtAmiiboSettingsDialog::SetGameDataName(u32 application_area_id) {
const std::array<std::pair<u32, QString>, 12> game_name_list = { static constexpr std::array<std::pair<u32, const char*>, 12> game_name_list = {
// 3ds, wii u // 3ds, wii u
std::pair<u32, QString>{0x10110E00, QStringLiteral("Super Smash Bros (3DS/WiiU)")}, std::pair<u32, const char*>{0x10110E00, "Super Smash Bros (3DS/WiiU)"},
{0x00132600, QStringLiteral("Mario & Luigi: Paper Jam")}, {0x00132600, "Mario & Luigi: Paper Jam"},
{0x0014F000, QStringLiteral("Animal Crossing: Happy Home Designer")}, {0x0014F000, "Animal Crossing: Happy Home Designer"},
{0x00152600, QStringLiteral("Chibi-Robo!: Zip Lash")}, {0x00152600, "Chibi-Robo!: Zip Lash"},
{0x10161f00, QStringLiteral("Mario Party 10")}, {0x10161f00, "Mario Party 10"},
{0x1019C800, QStringLiteral("The Legend of Zelda: Twilight Princess HD")}, {0x1019C800, "The Legend of Zelda: Twilight Princess HD"},
// switch // switch
{0x10162B00, QStringLiteral("Splatoon 2")}, {0x10162B00, "Splatoon 2"},
{0x1016e100, QStringLiteral("Shovel Knight: Treasure Trove")}, {0x1016e100, "Shovel Knight: Treasure Trove"},
{0x1019C800, QStringLiteral("The Legend of Zelda: Breath of the Wild")}, {0x1019C800, "The Legend of Zelda: Breath of the Wild"},
{0x34F80200, QStringLiteral("Super Smash Bros. Ultimate")}, {0x34F80200, "Super Smash Bros. Ultimate"},
{0x38600500, QStringLiteral("Splatoon 3")}, {0x38600500, "Splatoon 3"},
{0x3B440400, QStringLiteral("The Legend of Zelda: Link's Awakening")}, {0x3B440400, "The Legend of Zelda: Link's Awakening"},
}; };
for (const auto& [game_id, game_name] : game_name_list) { for (const auto& [game_id, game_name] : game_name_list) {
if (application_area_id == game_id) { if (application_area_id == game_id) {
ui->gameIdValue->setText(game_name); ui->gameIdValue->setText(QString::fromStdString(game_name));
return; return;
} }
} }
@ -208,11 +220,11 @@ void QtAmiiboManagerDialog::SetGameDataName(u32 application_area_id) {
ui->gameIdValue->setText(QString::fromStdString(application_area_string)); ui->gameIdValue->setText(QString::fromStdString(application_area_string));
} }
void QtAmiiboManagerDialog::SetManagerDescription() { void QtAmiiboSettingsDialog::SetSettingsDescription() {
switch (parameters.mode) { switch (parameters.mode) {
case Service::NFP::CabinetMode::StartFormatter: case Service::NFP::CabinetMode::StartFormatter:
ui->cabinetActionDescriptionLabel->setText( ui->cabinetActionDescriptionLabel->setText(
tr("The following amiibo data will be formated:")); tr("The following amiibo data will be formatted:"));
break; break;
case Service::NFP::CabinetMode::StartGameDataEraser: case Service::NFP::CabinetMode::StartGameDataEraser:
ui->cabinetActionDescriptionLabel->setText(tr("The following game data will removed:")); ui->cabinetActionDescriptionLabel->setText(tr("The following game data will removed:"));
@ -221,27 +233,28 @@ void QtAmiiboManagerDialog::SetManagerDescription() {
ui->cabinetActionDescriptionLabel->setText(tr("Set nickname and owner:")); ui->cabinetActionDescriptionLabel->setText(tr("Set nickname and owner:"));
break; break;
case Service::NFP::CabinetMode::StartRestorer: case Service::NFP::CabinetMode::StartRestorer:
ui->cabinetActionDescriptionLabel->setText(tr("Do you wish to restore this amiibo:")); ui->cabinetActionDescriptionLabel->setText(tr("Do you wish to restore this amiibo?"));
break; break;
} }
} }
QtAmiiboManager::QtAmiiboManager(GMainWindow& parent) { QtAmiiboSettings::QtAmiiboSettings(GMainWindow& parent) {
connect(this, &QtAmiiboManager::MainWindowShowAmiiboManager, &parent, connect(this, &QtAmiiboSettings::MainWindowShowAmiiboSettings, &parent,
&GMainWindow::AmiiboManagerShowDialog, Qt::QueuedConnection); &GMainWindow::AmiiboSettingsShowDialog, Qt::QueuedConnection);
connect(&parent, &GMainWindow::AmiiboManagerFinished, this, connect(&parent, &GMainWindow::AmiiboSettingsFinished, this,
&QtAmiiboManager::MainWindowFinished, Qt::QueuedConnection); &QtAmiiboSettings::MainWindowFinished, Qt::QueuedConnection);
} }
QtAmiiboManager::~QtAmiiboManager() = default; QtAmiiboSettings::~QtAmiiboSettings() = default;
void QtAmiiboManager::ShowCabinetApplet(std::function<void(bool, const std::string&)> callback_, void QtAmiiboSettings::ShowCabinetApplet(
const Core::Frontend::CabinetParameters& parameters, const Core::Frontend::CabinetCallback& callback_,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const { const Core::Frontend::CabinetParameters& parameters,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const {
callback = std::move(callback_); callback = std::move(callback_);
emit MainWindowShowAmiiboManager(parameters, nfp_device); emit MainWindowShowAmiiboSettings(parameters, nfp_device);
} }
void QtAmiiboManager::MainWindowFinished(bool is_success, std::string name) { void QtAmiiboSettings::MainWindowFinished(bool is_success, const std::string& name) {
callback(is_success, name); callback(is_success, name);
} }

View File

@ -0,0 +1,83 @@
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <array>
#include <memory>
#include <QDialog>
#include "core/frontend/applets/cabinet.h"
class GMainWindow;
class QCheckBox;
class QComboBox;
class QDialogButtonBox;
class QGroupBox;
class QLabel;
namespace InputCommon {
class InputSubsystem;
}
namespace Ui {
class QtAmiiboSettingsDialog;
}
namespace Service::NFP {
class NfpDevice;
} // namespace Service::NFP
class QtAmiiboSettingsDialog final : public QDialog {
Q_OBJECT
public:
explicit QtAmiiboSettingsDialog(QWidget* parent, Core::Frontend::CabinetParameters parameters_,
InputCommon::InputSubsystem* input_subsystem_,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device_);
~QtAmiiboSettingsDialog() override;
int exec() override;
std::string GetName() const;
private:
void LoadInfo();
void LoadAmiiboInfo();
void LoadAmiiboApiInfo(std::string_view amiibo_id);
void LoadAmiiboData();
void LoadAmiiboGameInfo();
void SetGameDataName(u32 application_area_id);
void SetSettingsDescription();
std::unique_ptr<Ui::QtAmiiboSettingsDialog> ui;
InputCommon::InputSubsystem* input_subsystem;
std::shared_ptr<Service::NFP::NfpDevice> nfp_device;
// Parameters sent in from the backend HLE applet.
Core::Frontend::CabinetParameters parameters;
// If false amiibo settings failed to load
bool is_initalized{};
};
class QtAmiiboSettings final : public QObject, public Core::Frontend::CabinetApplet {
Q_OBJECT
public:
explicit QtAmiiboSettings(GMainWindow& parent);
~QtAmiiboSettings() override;
void ShowCabinetApplet(const Core::Frontend::CabinetCallback& callback_,
const Core::Frontend::CabinetParameters& parameters,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const override;
signals:
void MainWindowShowAmiiboSettings(const Core::Frontend::CabinetParameters& parameters,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const;
private:
void MainWindowFinished(bool is_success, const std::string& name);
mutable Core::Frontend::CabinetCallback callback;
};

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>QtAmiiboManagerDialog</class> <class>QtAmiiboSettingsDialog</class>
<widget class="QDialog" name="QtAmiiboManagerDialog"> <widget class="QDialog" name="QtAmiiboSettingsDialog">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Amiibo Manager</string> <string>Amiibo Settings</string>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true"/> <string notr="true"/>
@ -121,9 +121,12 @@
</property> </property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin"> <property name="spacing">
<number>20</number> <number>20</number>
</property> </property>
<property name="leftMargin">
<number>15</number>
</property>
<property name="rightMargin"> <property name="rightMargin">
<number>15</number> <number>15</number>
</property> </property>
@ -152,7 +155,7 @@
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<property name="leftMargin"> <property name="leftMargin">
<number>20</number> <number>0</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>8</number> <number>8</number>
@ -478,13 +481,13 @@
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>
<signal>accepted()</signal> <signal>accepted()</signal>
<receiver>QtAmiiboManagerDialog</receiver> <receiver>QtAmiiboSettingsDialog</receiver>
<slot>accept()</slot> <slot>accept()</slot>
</connection> </connection>
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>
<signal>rejected()</signal> <signal>rejected()</signal>
<receiver>QtAmiiboManagerDialog</receiver> <receiver>QtAmiiboSettingsDialog</receiver>
<slot>reject()</slot> <slot>reject()</slot>
</connection> </connection>
</connections> </connections>

View File

@ -15,7 +15,7 @@
#endif #endif
// VFS includes must be before glad as they will conflict with Windows file api, which uses defines. // VFS includes must be before glad as they will conflict with Windows file api, which uses defines.
#include "applets/qt_amiibo_manager.h" #include "applets/qt_amiibo_settings.h"
#include "applets/qt_controller.h" #include "applets/qt_controller.h"
#include "applets/qt_error.h" #include "applets/qt_error.h"
#include "applets/qt_profile_select.h" #include "applets/qt_profile_select.h"
@ -577,19 +577,19 @@ void GMainWindow::RegisterMetaTypes() {
qRegisterMetaType<Core::SystemResultStatus>("Core::SystemResultStatus"); qRegisterMetaType<Core::SystemResultStatus>("Core::SystemResultStatus");
} }
void GMainWindow::AmiiboManagerShowDialog(const Core::Frontend::CabinetParameters& parameters, void GMainWindow::AmiiboSettingsShowDialog(const Core::Frontend::CabinetParameters& parameters,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device) { std::shared_ptr<Service::NFP::NfpDevice> nfp_device) {
QtAmiiboManagerDialog dialog(this, parameters, input_subsystem.get(), nfp_device); QtAmiiboSettingsDialog dialog(this, parameters, input_subsystem.get(), nfp_device);
dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint |
Qt::WindowTitleHint | Qt::WindowSystemMenuHint); Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
dialog.setWindowModality(Qt::WindowModal); dialog.setWindowModality(Qt::WindowModal);
if (dialog.exec() == QDialog::Rejected) { if (dialog.exec() == QDialog::Rejected) {
emit AmiiboManagerFinished(false, {}); emit AmiiboSettingsFinished(false, {});
return; return;
} }
emit AmiiboManagerFinished(true, dialog.GetName()); emit AmiiboSettingsFinished(true, dialog.GetName());
} }
void GMainWindow::ControllerSelectorReconfigureControllers( void GMainWindow::ControllerSelectorReconfigureControllers(
@ -1569,7 +1569,7 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p
system->SetFilesystem(vfs); system->SetFilesystem(vfs);
system->SetAppletFrontendSet({ system->SetAppletFrontendSet({
std::make_unique<QtAmiiboManager>(*this), // Amiibo Manager std::make_unique<QtAmiiboSettings>(*this), // Amiibo Settings
std::make_unique<QtControllerSelector>(*this), // Controller Selector std::make_unique<QtControllerSelector>(*this), // Controller Selector
std::make_unique<QtErrorDisplay>(*this), // Error Display std::make_unique<QtErrorDisplay>(*this), // Error Display
nullptr, // Mii Editor nullptr, // Mii Editor

View File

@ -154,7 +154,7 @@ signals:
void UpdateInstallProgress(); void UpdateInstallProgress();
void AmiiboManagerFinished(bool is_success, std::string name); void AmiiboSettingsFinished(bool is_success, const std::string& name);
void ControllerSelectorReconfigureFinished(); void ControllerSelectorReconfigureFinished();
@ -177,8 +177,8 @@ public slots:
void OnExecuteProgram(std::size_t program_index); void OnExecuteProgram(std::size_t program_index);
void OnExit(); void OnExit();
void OnSaveConfig(); void OnSaveConfig();
void AmiiboManagerShowDialog(const Core::Frontend::CabinetParameters& parameters, void AmiiboSettingsShowDialog(const Core::Frontend::CabinetParameters& parameters,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device); std::shared_ptr<Service::NFP::NfpDevice> nfp_device);
void ControllerSelectorReconfigureControllers( void ControllerSelectorReconfigureControllers(
const Core::Frontend::ControllerParameters& parameters); const Core::Frontend::ControllerParameters& parameters);
void SoftwareKeyboardInitialize( void SoftwareKeyboardInitialize(