aboutsummaryrefslogtreecommitdiff
path: root/libs/installer_fomod_plus/patchwizard/FomodPlusPatchWizard.h
blob: 2324fb033ccd89a8bb215e67737653a0502dd977 (plain)
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
#pragma once
#include "../installer/lib/Logger.h"
#include "lib/PatchFinder.h"

#include <iplugintool.h>
#include <qtmetamacros.h>

using namespace MOBase;

class FomodPlusPatchWizard final : public IPluginTool {
    Q_OBJECT
    Q_INTERFACES(MOBase::IPlugin MOBase::IPluginTool)
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    Q_PLUGIN_METADATA(IID "io.clearing.FomodPlusPatchWizard" FILE "fomodpluspatchwizard.json")
#endif

public:
    bool init(IOrganizer* organizer) override;

    [[nodiscard]] QString name() const override { return tr("Patch Wizard"); };

    [[nodiscard]] QString author() const override { return "clearing"; };

    [[nodiscard]] QString description() const override { return tr("Find missing patches from FOMODs in your load order."); };

    [[nodiscard]] VersionInfo version() const override { return { 1, 0, 0, VersionInfo::RELEASE_BETA }; };

    [[nodiscard]] QList<PluginSetting> settings() const override { return {}; };

    [[nodiscard]] QString displayName() const override { return tr("Patch Wizard"); };

    [[nodiscard]] QString tooltip() const override { return tr("Find missing patches from FOMODs in your load order."); };

    [[nodiscard]] QIcon icon() const override { return QIcon(":/fomod/hat"); }

    void display() const override;

private:
    Logger& log = Logger::getInstance();
    QDialog* mDialog{ nullptr };
    IOrganizer* mOrganizer{ nullptr };
    std::unique_ptr<PatchFinder> mPatchFinder{ nullptr };
    std::vector<AvailablePatch> mAvailablePatches;

    void setupEmptyState() const;
    void setupPatchList() const;
    void onRescanClicked();

    void logMessage(const LogLevel level, const std::string& message) const
    {
        log.logMessage(level, "[PATCHFINDER] " + message);
    }

};