aboutsummaryrefslogtreecommitdiff
path: root/libs/installer_fomod_plus/patchwizard/lib/PatchFinder.h
blob: 02327e3187566a7b6a353ede2bab4dde48d62546 (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
#pragma once

#include "../../installer/lib/Logger.h"

#include <FomodDB.h>
#include <imodinterface.h>
#include <imoinfo.h>
#include <ifiletree.h>

struct AvailablePatch {
    FomodOption fomod_option;
    std::string installer_name;
    std::string patch_for_mod;
    bool installed = false;
    bool hidden    = false;
    bool userDeselected = false;  // True if user explicitly chose not to install
};

class PatchFinder {
friend class FomodPlusPatchWizard;

public:
    explicit PatchFinder(MOBase::IOrganizer* m_organizer) : m_organizer(m_organizer)
    {
        mFomodDb = std::make_unique<FomodDB>(m_organizer->basePath().toStdString());
        logMessage(DEBUG, "mFomodDb loaded.");
    }

    std::vector<AvailablePatch> getAvailablePatchesForMod(const MOBase::IModInterface* mod);
    std::vector<AvailablePatch> getAvailablePatchesForModList();

protected:
    void populateInstalledPlugins();

private:
    Logger& log = Logger::getInstance();
    MOBase::IOrganizer* m_organizer;
    std::unique_ptr<FomodDB> mFomodDb;

    // Map of { pluginPtr: [1.esp, 2.esp, 3.esp] }
    std::unordered_map<const MOBase::IModInterface*, std::vector<std::string> > m_installedPlugins;
    std::unordered_set<std::string> m_installedPluginsCacheSet;

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

};