2017-07-13 11:26:03 +03:00
|
|
|
/*
|
|
|
|
* cmodlist.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2013-08-22 14:22:49 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-08-16 16:42:27 +03:00
|
|
|
#include "StdInc.h"
|
|
|
|
|
2013-09-21 18:29:26 +00:00
|
|
|
#include <QVariantMap>
|
2013-08-22 14:22:49 +00:00
|
|
|
#include <QVariant>
|
2016-01-09 21:23:55 +01:00
|
|
|
#include <QVector>
|
2013-08-22 14:22:49 +00:00
|
|
|
|
2022-07-29 09:52:39 +03:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2013-09-21 18:29:26 +00:00
|
|
|
class JsonNode;
|
|
|
|
|
2022-07-29 09:52:39 +03:00
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
2013-08-22 14:22:49 +00:00
|
|
|
namespace ModStatus
|
|
|
|
{
|
2018-04-13 12:34:58 +07:00
|
|
|
enum EModStatus
|
|
|
|
{
|
|
|
|
MASK_NONE = 0,
|
|
|
|
ENABLED = 1,
|
|
|
|
INSTALLED = 2,
|
|
|
|
UPDATEABLE = 4,
|
|
|
|
MASK_ALL = 255
|
|
|
|
};
|
2013-08-22 14:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class CModEntry
|
|
|
|
{
|
|
|
|
// repository contains newest version only (if multiple are available)
|
2013-09-21 18:29:26 +00:00
|
|
|
QVariantMap repository;
|
|
|
|
QVariantMap localData;
|
2013-11-03 12:07:23 +00:00
|
|
|
QVariantMap modSettings;
|
2013-08-22 14:22:49 +00:00
|
|
|
|
|
|
|
QString modname;
|
2018-04-13 12:34:58 +07:00
|
|
|
|
2023-03-14 13:37:22 +02:00
|
|
|
QVariant getValueImpl(QString value, bool localized) const;
|
2013-08-22 14:22:49 +00:00
|
|
|
public:
|
2013-11-03 12:07:23 +00:00
|
|
|
CModEntry(QVariantMap repository, QVariantMap localData, QVariantMap modSettings, QString modname);
|
2013-08-22 14:22:49 +00:00
|
|
|
|
|
|
|
// installed and enabled
|
|
|
|
bool isEnabled() const;
|
|
|
|
// installed but disabled
|
|
|
|
bool isDisabled() const;
|
|
|
|
// available in any of repositories but not installed
|
|
|
|
bool isAvailable() const;
|
|
|
|
// installed and greater version exists in repository
|
|
|
|
bool isUpdateable() const;
|
|
|
|
// installed
|
|
|
|
bool isInstalled() const;
|
2022-09-10 20:30:41 +04:00
|
|
|
// vcmi essential files
|
|
|
|
bool isEssential() const;
|
2022-09-17 17:43:59 +04:00
|
|
|
// checks if verison is compatible with vcmi
|
|
|
|
bool isCompatible() const;
|
2023-10-21 23:55:20 +03:00
|
|
|
// returns true if mod should be visible in Launcher
|
|
|
|
bool isVisible() const;
|
2023-03-14 15:59:33 +02:00
|
|
|
// installed and enabled
|
|
|
|
bool isTranslation() const;
|
2023-10-21 23:55:20 +03:00
|
|
|
// returns true if this is a submod
|
|
|
|
bool isSubmod() const;
|
2013-08-22 14:22:49 +00:00
|
|
|
|
|
|
|
// see ModStatus enum
|
|
|
|
int getModStatus() const;
|
|
|
|
|
|
|
|
QString getName() const;
|
|
|
|
|
|
|
|
// get value of some field in mod structure. Returns empty optional if value is not present
|
|
|
|
QVariant getValue(QString value) const;
|
2023-03-14 13:37:22 +02:00
|
|
|
QVariant getBaseValue(QString value) const;
|
2013-08-22 14:22:49 +00:00
|
|
|
|
2023-11-19 20:44:28 +02:00
|
|
|
QStringList getDependencies() const;
|
|
|
|
QStringList getConflicts() const;
|
|
|
|
|
2014-01-30 12:35:17 +00:00
|
|
|
static QString sizeToString(double size);
|
2013-08-22 14:22:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CModList
|
|
|
|
{
|
2013-09-21 18:29:26 +00:00
|
|
|
QVector<QVariantMap> repositories;
|
|
|
|
QVariantMap localModList;
|
|
|
|
QVariantMap modSettings;
|
2013-08-22 14:22:49 +00:00
|
|
|
|
2023-10-28 16:44:58 +00:00
|
|
|
QVariantMap copyField(QVariantMap data, QString from, QString to) const;
|
2018-04-13 12:34:58 +07:00
|
|
|
|
2013-08-22 14:22:49 +00:00
|
|
|
public:
|
2013-08-24 20:11:51 +00:00
|
|
|
virtual void resetRepositories();
|
2022-09-10 20:30:41 +04:00
|
|
|
virtual void reloadRepositories();
|
2013-09-21 18:29:26 +00:00
|
|
|
virtual void addRepository(QVariantMap data);
|
|
|
|
virtual void setLocalModList(QVariantMap data);
|
|
|
|
virtual void setModSettings(QVariant data);
|
2014-03-20 17:06:25 +00:00
|
|
|
virtual void modChanged(QString modID);
|
2013-08-22 14:22:49 +00:00
|
|
|
|
|
|
|
// returns mod by name. Note: mod MUST exist
|
|
|
|
CModEntry getMod(QString modname) const;
|
|
|
|
|
|
|
|
// returns list of all mods necessary to run selected one, including mod itself
|
|
|
|
// order is: first mods in list don't have any dependencies, last mod is modname
|
|
|
|
// note: may include mods not present in list
|
|
|
|
QStringList getRequirements(QString modname);
|
|
|
|
|
|
|
|
bool hasMod(QString modname) const;
|
|
|
|
|
|
|
|
// returns list of all available mods
|
|
|
|
QVector<QString> getModList() const;
|
2014-03-23 12:08:01 +00:00
|
|
|
|
|
|
|
QVector<QString> getChildren(QString parent) const;
|
2013-11-03 12:07:23 +00:00
|
|
|
};
|