summaryrefslogtreecommitdiffstats
path: root/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-03-19 22:25:36 +0100
committerPetr Mrázek <peterix@gmail.com>2014-03-19 22:25:36 +0100
commit26b485d82f03c0191142cf9b660b4ab43962878d (patch)
tree092364c614f29865fec4bdb6bd158de1c2d4db9a /logic
parent919dea0de60d058f57a4b9bd1e5f4513a014c693 (diff)
parentad9b16bd3d6a71b4cdf1763d166bc9cc633e147c (diff)
downloadMultiMC-26b485d82f03c0191142cf9b660b4ab43962878d.tar
MultiMC-26b485d82f03c0191142cf9b660b4ab43962878d.tar.gz
MultiMC-26b485d82f03c0191142cf9b660b4ab43962878d.tar.lz
MultiMC-26b485d82f03c0191142cf9b660b4ab43962878d.tar.xz
MultiMC-26b485d82f03c0191142cf9b660b4ab43962878d.zip
Merge remote-tracking branch 'origin/feature_badges' into develop
Diffstat (limited to 'logic')
-rw-r--r--logic/BaseInstance.cpp9
-rw-r--r--logic/BaseInstance.h8
-rw-r--r--logic/BaseInstance_p.h7
-rw-r--r--logic/LegacyFTBInstance.cpp2
-rw-r--r--logic/LegacyInstance.cpp4
-rw-r--r--logic/NostalgiaInstance.cpp2
-rw-r--r--logic/OneSixFTBInstance.cpp2
-rw-r--r--logic/OneSixInstance.cpp8
8 files changed, 22 insertions, 20 deletions
diff --git a/logic/BaseInstance.cpp b/logic/BaseInstance.cpp
index c565ab59..c7b29548 100644
--- a/logic/BaseInstance.cpp
+++ b/logic/BaseInstance.cpp
@@ -37,7 +37,6 @@ BaseInstance::BaseInstance(BaseInstancePrivate *d_in, const QString &rootDir,
I_D(BaseInstance);
d->m_settings = settings_obj;
d->m_rootDir = rootDir;
- d->m_flags = 0;
settings().registerSetting("name", "Unnamed Instance");
settings().registerSetting("iconKey", "default");
@@ -147,13 +146,13 @@ SettingsObject &BaseInstance::settings() const
return *d->m_settings;
}
-BaseInstance::InstanceFlags BaseInstance::flags() const
+QSet<BaseInstance::InstanceFlag> BaseInstance::flags() const
{
I_D(const BaseInstance);
- return InstanceFlags(d->m_flags);
+ return QSet<InstanceFlag>(d->m_flags);
}
-void BaseInstance::setFlags(const BaseInstance::InstanceFlags flags)
+void BaseInstance::setFlags(const QSet<InstanceFlag> &flags)
{
I_D(BaseInstance);
if (flags != d->m_flags)
@@ -166,7 +165,7 @@ void BaseInstance::setFlags(const BaseInstance::InstanceFlags flags)
bool BaseInstance::canLaunch() const
{
- return !(flags() & VersionBrokenFlag);
+ return !flags().contains(VersionBrokenFlag);
}
bool BaseInstance::reload()
diff --git a/logic/BaseInstance.h b/logic/BaseInstance.h
index 195fd339..d38ae409 100644
--- a/logic/BaseInstance.h
+++ b/logic/BaseInstance.h
@@ -17,6 +17,7 @@
#include <QObject>
#include <QDateTime>
+#include <QSet>
#include <settingsobject.h>
@@ -184,9 +185,8 @@ public:
NoFlags = 0x00,
VersionBrokenFlag = 0x01
};
- Q_DECLARE_FLAGS(InstanceFlags, InstanceFlag)
- InstanceFlags flags() const;
- void setFlags(const BaseInstance::InstanceFlags flags);
+ QSet<InstanceFlag> flags() const;
+ void setFlags(const QSet<InstanceFlag> &flags);
bool canLaunch() const;
@@ -218,4 +218,4 @@ protected:
// pointer for lazy people
typedef std::shared_ptr<BaseInstance> InstancePtr;
-Q_DECLARE_OPERATORS_FOR_FLAGS(BaseInstance::InstanceFlags)
+Q_DECLARE_METATYPE(BaseInstance::InstanceFlag)
diff --git a/logic/BaseInstance_p.h b/logic/BaseInstance_p.h
index 73eebec7..8cf3b27d 100644
--- a/logic/BaseInstance_p.h
+++ b/logic/BaseInstance_p.h
@@ -14,10 +14,13 @@
*/
#pragma once
+
#include <QString>
+#include <QSet>
+
#include <settingsobject.h>
-class BaseInstance;
+#include "BaseInstance.h"
#define I_D(Class) Class##Private *const d = (Class##Private * const)inst_d.get()
@@ -26,5 +29,5 @@ struct BaseInstancePrivate
QString m_rootDir;
QString m_group;
SettingsObject *m_settings;
- int m_flags;
+ QSet<BaseInstance::InstanceFlag> m_flags;
};
diff --git a/logic/LegacyFTBInstance.cpp b/logic/LegacyFTBInstance.cpp
index 23cb259d..3c3356c9 100644
--- a/logic/LegacyFTBInstance.cpp
+++ b/logic/LegacyFTBInstance.cpp
@@ -7,7 +7,7 @@ LegacyFTBInstance::LegacyFTBInstance(const QString &rootDir, SettingsObject *set
QString LegacyFTBInstance::getStatusbarDescription()
{
- if (flags() & VersionBrokenFlag)
+ if (flags().contains(VersionBrokenFlag))
{
return "Legacy FTB: " + intendedVersionId() + " (broken)";
}
diff --git a/logic/LegacyInstance.cpp b/logic/LegacyInstance.cpp
index 3b9181e0..4f2dfd9b 100644
--- a/logic/LegacyInstance.cpp
+++ b/logic/LegacyInstance.cpp
@@ -268,7 +268,7 @@ QString LegacyInstance::defaultCustomBaseJar() const
bool LegacyInstance::menuActionEnabled(QString action_name) const
{
- if (flags() & VersionBrokenFlag)
+ if (flags().contains(VersionBrokenFlag))
{
return false;
}
@@ -281,7 +281,7 @@ bool LegacyInstance::menuActionEnabled(QString action_name) const
QString LegacyInstance::getStatusbarDescription()
{
- if (flags() & VersionBrokenFlag)
+ if (flags().contains(VersionBrokenFlag))
{
return "Legacy : " + intendedVersionId() + " (broken)";
}
diff --git a/logic/NostalgiaInstance.cpp b/logic/NostalgiaInstance.cpp
index 96ce4cc7..52820725 100644
--- a/logic/NostalgiaInstance.cpp
+++ b/logic/NostalgiaInstance.cpp
@@ -23,7 +23,7 @@ NostalgiaInstance::NostalgiaInstance(const QString &rootDir, SettingsObject *set
QString NostalgiaInstance::getStatusbarDescription()
{
- if (flags() & VersionBrokenFlag)
+ if (flags().contains(VersionBrokenFlag))
{
return "Nostalgia : " + intendedVersionId() + " (broken)";
}
diff --git a/logic/OneSixFTBInstance.cpp b/logic/OneSixFTBInstance.cpp
index 8f70ed08..172830bb 100644
--- a/logic/OneSixFTBInstance.cpp
+++ b/logic/OneSixFTBInstance.cpp
@@ -119,7 +119,7 @@ bool OneSixFTBInstance::providesVersionFile() const
QString OneSixFTBInstance::getStatusbarDescription()
{
- if (flags() & VersionBrokenFlag)
+ if (flags().contains(VersionBrokenFlag))
{
return "OneSix FTB: " + intendedVersionId() + " (broken)";
}
diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp
index ed7ad993..ccc25845 100644
--- a/logic/OneSixInstance.cpp
+++ b/logic/OneSixInstance.cpp
@@ -333,14 +333,14 @@ void OneSixInstance::reloadVersion()
{
d->version->reload(false, externalPatches());
d->vanillaVersion->reload(true, externalPatches());
- setFlags(flags() & ~VersionBrokenFlag);
+ d->m_flags.remove(VersionBrokenFlag);
emit versionReloaded();
}
catch(MMCError & error)
{
d->version->clear();
d->vanillaVersion->clear();
- setFlags(flags() | VersionBrokenFlag);
+ d->m_flags.insert(VersionBrokenFlag);
//TODO: rethrow to show some error message(s)?
emit versionReloaded();
throw;
@@ -379,7 +379,7 @@ QString OneSixInstance::defaultCustomBaseJar() const
bool OneSixInstance::menuActionEnabled(QString action_name) const
{
- if (flags() & VersionBrokenFlag)
+ if (flags().contains(VersionBrokenFlag))
{
return false;
}
@@ -397,7 +397,7 @@ QString OneSixInstance::getStatusbarDescription()
{
descr += " (custom)";
}
- if (flags() & VersionBrokenFlag)
+ if (flags().contains(VersionBrokenFlag))
{
descr += " (broken)";
}