2014-05-09 15:16:25 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
2014-05-09 23:53:32 +00:00
|
|
|
#include <QList>
|
2015-05-17 21:38:28 +00:00
|
|
|
#include <QJsonDocument>
|
2016-03-19 02:06:32 +00:00
|
|
|
#include <QDateTime>
|
2014-05-09 23:53:32 +00:00
|
|
|
#include "JarMod.h"
|
2014-05-09 15:16:25 +00:00
|
|
|
|
2015-01-27 21:31:07 +00:00
|
|
|
class MinecraftProfile;
|
2016-02-21 00:44:27 +00:00
|
|
|
|
|
|
|
enum ProblemSeverity
|
|
|
|
{
|
|
|
|
PROBLEM_NONE,
|
|
|
|
PROBLEM_WARNING,
|
|
|
|
PROBLEM_ERROR
|
|
|
|
};
|
|
|
|
|
2016-03-12 23:23:45 +00:00
|
|
|
/// where is a version from?
|
|
|
|
enum VersionSource
|
|
|
|
{
|
|
|
|
Local, //!< version loaded from a file in the cache.
|
|
|
|
Remote, //!< incomplete version on a remote server.
|
|
|
|
};
|
|
|
|
|
2016-02-21 00:44:27 +00:00
|
|
|
class PatchProblem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PatchProblem(ProblemSeverity severity, const QString & description)
|
|
|
|
{
|
|
|
|
m_severity = severity;
|
|
|
|
m_description = description;
|
|
|
|
}
|
|
|
|
const QString & getDescription() const
|
|
|
|
{
|
|
|
|
return m_description;
|
|
|
|
}
|
|
|
|
const ProblemSeverity getSeverity() const
|
|
|
|
{
|
|
|
|
return m_severity;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
ProblemSeverity m_severity;
|
|
|
|
QString m_description;
|
|
|
|
};
|
|
|
|
|
2016-03-19 02:06:32 +00:00
|
|
|
class ProfilePatch : public std::enable_shared_from_this<ProfilePatch>
|
2014-05-09 15:16:25 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-01-27 21:31:07 +00:00
|
|
|
virtual ~ProfilePatch(){};
|
2016-03-13 19:57:01 +00:00
|
|
|
virtual void applyTo(MinecraftProfile *profile) = 0;
|
2015-01-27 21:31:07 +00:00
|
|
|
|
2014-05-11 10:37:21 +00:00
|
|
|
virtual bool isMinecraftVersion() = 0;
|
2014-05-09 15:16:25 +00:00
|
|
|
virtual bool hasJarMods() = 0;
|
2014-05-09 23:53:32 +00:00
|
|
|
virtual QList<JarmodPtr> getJarMods() = 0;
|
2015-01-27 21:31:07 +00:00
|
|
|
|
2015-05-17 21:38:28 +00:00
|
|
|
virtual bool isMoveable() = 0;
|
|
|
|
virtual bool isCustomizable() = 0;
|
|
|
|
virtual bool isRevertible() = 0;
|
|
|
|
virtual bool isRemovable() = 0;
|
|
|
|
virtual bool isCustom() = 0;
|
|
|
|
virtual bool isEditable() = 0;
|
|
|
|
virtual bool isVersionChangeable() = 0;
|
|
|
|
|
2014-05-09 23:53:32 +00:00
|
|
|
virtual void setOrder(int order) = 0;
|
|
|
|
virtual int getOrder() = 0;
|
2015-01-27 21:31:07 +00:00
|
|
|
|
2016-03-12 23:23:45 +00:00
|
|
|
virtual QString getID() = 0;
|
|
|
|
virtual QString getName() = 0;
|
|
|
|
virtual QString getVersion() = 0;
|
|
|
|
virtual QDateTime getReleaseDateTime() = 0;
|
|
|
|
|
|
|
|
virtual QString getFilename() = 0;
|
|
|
|
|
|
|
|
virtual VersionSource getVersionSource() = 0;
|
2016-02-21 00:44:27 +00:00
|
|
|
|
2016-03-19 02:06:32 +00:00
|
|
|
virtual std::shared_ptr<class VersionFile> getVersionFile() = 0;
|
|
|
|
|
2016-02-21 00:44:27 +00:00
|
|
|
virtual const QList<PatchProblem>& getProblems()
|
|
|
|
{
|
|
|
|
return m_problems;
|
|
|
|
}
|
|
|
|
virtual void addProblem(ProblemSeverity severity, const QString &description)
|
|
|
|
{
|
|
|
|
if(severity > m_problemSeverity)
|
|
|
|
{
|
|
|
|
m_problemSeverity = severity;
|
|
|
|
}
|
|
|
|
m_problems.append(PatchProblem(severity, description));
|
|
|
|
}
|
|
|
|
virtual ProblemSeverity getProblemSeverity()
|
|
|
|
{
|
|
|
|
return m_problemSeverity;
|
|
|
|
}
|
|
|
|
virtual bool hasFailed()
|
|
|
|
{
|
|
|
|
return getProblemSeverity() == PROBLEM_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
QList<PatchProblem> m_problems;
|
|
|
|
ProblemSeverity m_problemSeverity = PROBLEM_NONE;
|
2014-05-09 15:16:25 +00:00
|
|
|
};
|
|
|
|
|
2015-01-27 21:31:07 +00:00
|
|
|
typedef std::shared_ptr<ProfilePatch> ProfilePatchPtr;
|