Save info is plugin is linked and loaded inside config info

This commit is contained in:
Maschell 2024-08-04 15:07:30 +02:00
parent 629dc0393f
commit e584d8c1df
3 changed files with 22 additions and 10 deletions

View File

@ -1,12 +1,22 @@
#include "ConfigDisplayItem.h" #include "ConfigDisplayItem.h"
#include "config/WUPSConfig.h" #include "config/WUPSConfig.h"
ConfigDisplayItem::ConfigDisplayItem(GeneralConfigInformation &info, std::unique_ptr<WUPSConfigAPIBackend::WUPSConfig> config) : mConfig(std::move(config)), mInfo(std::move(info)) { ConfigDisplayItem::ConfigDisplayItem(GeneralConfigInformation &info,
std::unique_ptr<WUPSConfigAPIBackend::WUPSConfig> config,
const bool isActive) : mConfig(std::move(config)),
mInfo(std::move(info)),
mIsActivePlugin(isActive) {
assert(mConfig); assert(mConfig);
} }
const GeneralConfigInformation &ConfigDisplayItem::getConfigInformation() const { const GeneralConfigInformation &ConfigDisplayItem::getConfigInformation() const {
return mInfo; return mInfo;
} }
const WUPSConfigAPIBackend::WUPSConfig &ConfigDisplayItem::getConfig() const { const WUPSConfigAPIBackend::WUPSConfig &ConfigDisplayItem::getConfig() const {
return *mConfig; return *mConfig;
}
bool ConfigDisplayItem::isActivePlugin() const {
return mIsActivePlugin;
} }

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "config/WUPSConfig.h" #include "config/WUPSConfig.h"
#include "plugin/PluginData.h"
#include <memory> #include <memory>
#include <string> #include <string>
@ -8,17 +9,21 @@ struct GeneralConfigInformation {
std::string name; std::string name;
std::string author; std::string author;
std::string version; std::string version;
std::shared_ptr<PluginData> pluginData;
}; };
class ConfigDisplayItem { class ConfigDisplayItem {
public: public:
ConfigDisplayItem(GeneralConfigInformation &info, std::unique_ptr<WUPSConfigAPIBackend::WUPSConfig> config); ConfigDisplayItem(GeneralConfigInformation &info, std::unique_ptr<WUPSConfigAPIBackend::WUPSConfig> config, bool isActive);
[[nodiscard]] const GeneralConfigInformation &getConfigInformation() const; [[nodiscard]] const GeneralConfigInformation &getConfigInformation() const;
[[nodiscard]] const WUPSConfigAPIBackend::WUPSConfig &getConfig() const; [[nodiscard]] const WUPSConfigAPIBackend::WUPSConfig &getConfig() const;
[[nodiscard]] bool isActivePlugin() const;
private: private:
std::unique_ptr<WUPSConfigAPIBackend::WUPSConfig> mConfig; std::unique_ptr<WUPSConfigAPIBackend::WUPSConfig> mConfig;
GeneralConfigInformation mInfo; GeneralConfigInformation mInfo;
bool mIsActivePlugin;
}; };

View File

@ -77,13 +77,11 @@ void ConfigUtils::displayMenu() {
std::vector<ConfigDisplayItem> configs; std::vector<ConfigDisplayItem> configs;
for (const auto &plugin : gLoadedPlugins) { for (const auto &plugin : gLoadedPlugins) {
if (!plugin.isLinkedAndLoaded()) {
continue;
}
GeneralConfigInformation info; GeneralConfigInformation info;
info.name = plugin.getMetaInformation().getName(); info.name = plugin.getMetaInformation().getName();
info.author = plugin.getMetaInformation().getAuthor(); info.author = plugin.getMetaInformation().getAuthor();
info.version = plugin.getMetaInformation().getVersion(); info.version = plugin.getMetaInformation().getVersion();
info.pluginData = plugin.getPluginDataCopy();
std::unique_ptr<WUPSConfigAPIBackend::WUPSConfig> config; std::unique_ptr<WUPSConfigAPIBackend::WUPSConfig> config;
if (const auto configData = plugin.getConfigData()) { if (const auto configData = plugin.getConfigData()) {
@ -124,8 +122,7 @@ void ConfigUtils::displayMenu() {
if (!config) { if (!config) {
config = make_unique_nothrow<WUPSConfigAPIBackend::WUPSConfig>(info.name); config = make_unique_nothrow<WUPSConfigAPIBackend::WUPSConfig>(info.name);
} }
configs.emplace_back(info, std::move(config), plugin.isLinkedAndLoaded());
configs.emplace_back(info, std::move(config));
} }
// Sort Configs by name // Sort Configs by name