aboutsummaryrefslogtreecommitdiff
path: root/src/yuzu/applets/qt_amiibo_settings.h
blob: bc389a33fa2ec239f4bf0220f3878c814113b22d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// 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 Close() const 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;
    void MainWindowRequestExit() const;

private:
    void MainWindowFinished(bool is_success, const std::string& name);

    mutable Core::Frontend::CabinetCallback callback;
};