summaryrefslogtreecommitdiffstats
path: root/api/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-11-04 01:17:28 +0100
committerPetr Mrázek <peterix@gmail.com>2016-11-04 01:19:04 +0100
commit87dd9515052661e622587cafcf972ea1beee8195 (patch)
treeb0e491c544180a9629f78b4fb9df3a383858b26b /api/logic
parent3780a25d27ae5c803ce9ed075928fff365104987 (diff)
downloadMultiMC-87dd9515052661e622587cafcf972ea1beee8195.tar
MultiMC-87dd9515052661e622587cafcf972ea1beee8195.tar.gz
MultiMC-87dd9515052661e622587cafcf972ea1beee8195.tar.lz
MultiMC-87dd9515052661e622587cafcf972ea1beee8195.tar.xz
MultiMC-87dd9515052661e622587cafcf972ea1beee8195.zip
NOISSUE add a badge for crashed instances
Not persistent across MultiMC runs.
Diffstat (limited to 'api/logic')
-rw-r--r--api/logic/BaseInstance.cpp37
-rw-r--r--api/logic/BaseInstance.h57
-rw-r--r--api/logic/NullInstance.h2
-rw-r--r--api/logic/launch/LaunchTask.cpp2
-rw-r--r--api/logic/minecraft/MinecraftInstance.cpp8
-rw-r--r--api/logic/minecraft/onesix/OneSixInstance.cpp10
-rw-r--r--api/logic/minecraft/onesix/update/LibrariesTask.cpp2
7 files changed, 52 insertions, 66 deletions
diff --git a/api/logic/BaseInstance.cpp b/api/logic/BaseInstance.cpp
index b499c106..b7a7f9fd 100644
--- a/api/logic/BaseInstance.cpp
+++ b/api/logic/BaseInstance.cpp
@@ -172,44 +172,9 @@ SettingsObjectPtr BaseInstance::settings() const
return m_settings;
}
-BaseInstance::InstanceFlags BaseInstance::flags() const
-{
- return m_flags;
-}
-
-void BaseInstance::setFlags(const InstanceFlags &flags)
-{
- if (flags != m_flags)
- {
- m_flags = flags;
- emit flagsChanged();
- emit propertiesChanged(this);
- }
-}
-
-void BaseInstance::setFlag(const BaseInstance::InstanceFlag flag)
-{
- // nothing to set?
- if(flag & m_flags)
- return;
- m_flags |= flag;
- emit flagsChanged();
- emit propertiesChanged(this);
-}
-
-void BaseInstance::unsetFlag(const BaseInstance::InstanceFlag flag)
-{
- // nothing to unset?
- if(!(flag & m_flags))
- return;
- m_flags &= ~flag;
- emit flagsChanged();
- emit propertiesChanged(this);
-}
-
bool BaseInstance::canLaunch() const
{
- return (!(flags() & VersionBrokenFlag)) && (!isRunning());
+ return (!hasVersionBroken() && !isRunning());
}
bool BaseInstance::reload()
diff --git a/api/logic/BaseInstance.h b/api/logic/BaseInstance.h
index 669bad79..147dd703 100644
--- a/api/logic/BaseInstance.h
+++ b/api/logic/BaseInstance.h
@@ -218,16 +218,44 @@ public:
virtual QString typeName() const = 0;
- enum InstanceFlag
+ bool hasVersionBroken() const
{
- VersionBrokenFlag = 0x01,
- UpdateAvailable = 0x02
- };
- Q_DECLARE_FLAGS(InstanceFlags, InstanceFlag)
- InstanceFlags flags() const;
- void setFlags(const InstanceFlags &flags);
- void setFlag(const InstanceFlag flag);
- void unsetFlag(const InstanceFlag flag);
+ return m_hasBrokenVersion;
+ }
+ void setVersionBroken(bool value)
+ {
+ if(m_hasBrokenVersion != value)
+ {
+ m_hasBrokenVersion = value;
+ emit propertiesChanged(this);
+ }
+ }
+
+ bool hasUpdateAvailable() const
+ {
+ return m_hasUpdate;
+ }
+ void setUpdateAvailable(bool value)
+ {
+ if(m_hasUpdate != value)
+ {
+ m_hasUpdate = value;
+ emit propertiesChanged(this);
+ }
+ }
+
+ bool hasCrashed() const
+ {
+ return m_crashed;
+ }
+ void setCrashed(bool value)
+ {
+ if(m_crashed != value)
+ {
+ m_crashed = value;
+ emit propertiesChanged(this);
+ }
+ }
bool canLaunch() const;
virtual bool canExport() const = 0;
@@ -254,8 +282,6 @@ signals:
*/
void groupChanged();
- void flagsChanged();
-
void launchTaskChanged(std::shared_ptr<LaunchTask>);
void runningStatusChanged(bool running);
@@ -269,7 +295,7 @@ protected: /* data */
QString m_rootDir;
QString m_group;
SettingsObjectPtr m_settings;
- InstanceFlags m_flags;
+ // InstanceFlags m_flags;
bool m_isRunning = false;
std::shared_ptr<LaunchTask> m_launchProcess;
QDateTime m_timeStarted;
@@ -277,8 +303,11 @@ protected: /* data */
private: /* data */
Status m_status = Status::Present;
+ bool m_crashed = false;
+ bool m_hasUpdate = false;
+ bool m_hasBrokenVersion = false;
};
Q_DECLARE_METATYPE(std::shared_ptr<BaseInstance>)
-Q_DECLARE_METATYPE(BaseInstance::InstanceFlag)
-Q_DECLARE_OPERATORS_FOR_FLAGS(BaseInstance::InstanceFlags)
+//Q_DECLARE_METATYPE(BaseInstance::InstanceFlag)
+//Q_DECLARE_OPERATORS_FOR_FLAGS(BaseInstance::InstanceFlags)
diff --git a/api/logic/NullInstance.h b/api/logic/NullInstance.h
index 4fb31854..5323d135 100644
--- a/api/logic/NullInstance.h
+++ b/api/logic/NullInstance.h
@@ -7,7 +7,7 @@ public:
NullInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir)
:BaseInstance(globalSettings, settings, rootDir)
{
- setFlag(BaseInstance::VersionBrokenFlag);
+ setVersionBroken(true);
}
virtual ~NullInstance() {};
virtual bool setIntendedVersionId(QString) override
diff --git a/api/logic/launch/LaunchTask.cpp b/api/logic/launch/LaunchTask.cpp
index 9c09caf4..a006e519 100644
--- a/api/logic/launch/LaunchTask.cpp
+++ b/api/logic/launch/LaunchTask.cpp
@@ -56,6 +56,7 @@ void LaunchTask::prependStep(std::shared_ptr<LaunchStep> step)
void LaunchTask::executeTask()
{
+ m_instance->setCrashed(false);
if(!m_steps.size())
{
state = LaunchTask::Finished;
@@ -217,6 +218,7 @@ void LaunchTask::emitFailed(QString reason)
{
m_instance->cleanupAfterRun();
m_instance->setRunning(false);
+ m_instance->setCrashed(true);
Task::emitFailed(reason);
}
diff --git a/api/logic/minecraft/MinecraftInstance.cpp b/api/logic/minecraft/MinecraftInstance.cpp
index d3af5011..f0d47733 100644
--- a/api/logic/minecraft/MinecraftInstance.cpp
+++ b/api/logic/minecraft/MinecraftInstance.cpp
@@ -369,7 +369,7 @@ QString MinecraftInstance::prettifyTimeDuration(int64_t duration)
QString MinecraftInstance::getStatusbarDescription()
{
QStringList traits;
- if (flags() & VersionBrokenFlag)
+ if (hasVersionBroken())
{
traits.append(tr("broken"));
}
@@ -380,12 +380,10 @@ QString MinecraftInstance::getStatusbarDescription()
{
description.append(tr(", played for %1").arg(prettifyTimeDuration(totalTimePlayed())));
}
- /*
- if(traits.size())
+ if(hasCrashed())
{
- description.append(QString(" (%1)").arg(traits.join(", ")));
+ description.append(tr(", has crashed."));
}
- */
return description;
}
diff --git a/api/logic/minecraft/onesix/OneSixInstance.cpp b/api/logic/minecraft/onesix/OneSixInstance.cpp
index d89a7612..859e2e69 100644
--- a/api/logic/minecraft/onesix/OneSixInstance.cpp
+++ b/api/logic/minecraft/onesix/OneSixInstance.cpp
@@ -526,15 +526,7 @@ QString OneSixInstance::currentVersionId() const
void OneSixInstance::reloadProfile()
{
m_profile->reload();
- auto severity = m_profile->getProblemSeverity();
- if(severity == ProblemSeverity::PROBLEM_ERROR)
- {
- setFlag(VersionBrokenFlag);
- }
- else
- {
- unsetFlag(VersionBrokenFlag);
- }
+ setVersionBroken(m_profile->getProblemSeverity() == ProblemSeverity::PROBLEM_ERROR);
emit versionReloaded();
}
diff --git a/api/logic/minecraft/onesix/update/LibrariesTask.cpp b/api/logic/minecraft/onesix/update/LibrariesTask.cpp
index 1efbc64c..f60c2b5e 100644
--- a/api/logic/minecraft/onesix/update/LibrariesTask.cpp
+++ b/api/logic/minecraft/onesix/update/LibrariesTask.cpp
@@ -13,7 +13,7 @@ void LibrariesTask::executeTask()
qDebug() << m_inst->name() << ": downloading libraries";
OneSixInstance *inst = (OneSixInstance *)m_inst;
inst->reloadProfile();
- if(inst->flags() & BaseInstance::VersionBrokenFlag)
+ if(inst->hasVersionBroken())
{
emitFailed(tr("Failed to load the version description files - check the instance for errors."));
return;