NOISSUE add a badge for crashed instances
Not persistent across MultiMC runs.
This commit is contained in:
parent
3780a25d27
commit
87dd951505
@ -172,44 +172,9 @@ SettingsObjectPtr BaseInstance::settings() const
|
|||||||
return m_settings;
|
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
|
bool BaseInstance::canLaunch() const
|
||||||
{
|
{
|
||||||
return (!(flags() & VersionBrokenFlag)) && (!isRunning());
|
return (!hasVersionBroken() && !isRunning());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseInstance::reload()
|
bool BaseInstance::reload()
|
||||||
|
@ -218,16 +218,44 @@ public:
|
|||||||
|
|
||||||
virtual QString typeName() const = 0;
|
virtual QString typeName() const = 0;
|
||||||
|
|
||||||
enum InstanceFlag
|
bool hasVersionBroken() const
|
||||||
{
|
{
|
||||||
VersionBrokenFlag = 0x01,
|
return m_hasBrokenVersion;
|
||||||
UpdateAvailable = 0x02
|
}
|
||||||
};
|
void setVersionBroken(bool value)
|
||||||
Q_DECLARE_FLAGS(InstanceFlags, InstanceFlag)
|
{
|
||||||
InstanceFlags flags() const;
|
if(m_hasBrokenVersion != value)
|
||||||
void setFlags(const InstanceFlags &flags);
|
{
|
||||||
void setFlag(const InstanceFlag flag);
|
m_hasBrokenVersion = value;
|
||||||
void unsetFlag(const InstanceFlag flag);
|
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;
|
bool canLaunch() const;
|
||||||
virtual bool canExport() const = 0;
|
virtual bool canExport() const = 0;
|
||||||
@ -254,8 +282,6 @@ signals:
|
|||||||
*/
|
*/
|
||||||
void groupChanged();
|
void groupChanged();
|
||||||
|
|
||||||
void flagsChanged();
|
|
||||||
|
|
||||||
void launchTaskChanged(std::shared_ptr<LaunchTask>);
|
void launchTaskChanged(std::shared_ptr<LaunchTask>);
|
||||||
|
|
||||||
void runningStatusChanged(bool running);
|
void runningStatusChanged(bool running);
|
||||||
@ -269,7 +295,7 @@ protected: /* data */
|
|||||||
QString m_rootDir;
|
QString m_rootDir;
|
||||||
QString m_group;
|
QString m_group;
|
||||||
SettingsObjectPtr m_settings;
|
SettingsObjectPtr m_settings;
|
||||||
InstanceFlags m_flags;
|
// InstanceFlags m_flags;
|
||||||
bool m_isRunning = false;
|
bool m_isRunning = false;
|
||||||
std::shared_ptr<LaunchTask> m_launchProcess;
|
std::shared_ptr<LaunchTask> m_launchProcess;
|
||||||
QDateTime m_timeStarted;
|
QDateTime m_timeStarted;
|
||||||
@ -277,8 +303,11 @@ protected: /* data */
|
|||||||
|
|
||||||
private: /* data */
|
private: /* data */
|
||||||
Status m_status = Status::Present;
|
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(std::shared_ptr<BaseInstance>)
|
||||||
Q_DECLARE_METATYPE(BaseInstance::InstanceFlag)
|
//Q_DECLARE_METATYPE(BaseInstance::InstanceFlag)
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(BaseInstance::InstanceFlags)
|
//Q_DECLARE_OPERATORS_FOR_FLAGS(BaseInstance::InstanceFlags)
|
||||||
|
@ -7,7 +7,7 @@ public:
|
|||||||
NullInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir)
|
NullInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir)
|
||||||
:BaseInstance(globalSettings, settings, rootDir)
|
:BaseInstance(globalSettings, settings, rootDir)
|
||||||
{
|
{
|
||||||
setFlag(BaseInstance::VersionBrokenFlag);
|
setVersionBroken(true);
|
||||||
}
|
}
|
||||||
virtual ~NullInstance() {};
|
virtual ~NullInstance() {};
|
||||||
virtual bool setIntendedVersionId(QString) override
|
virtual bool setIntendedVersionId(QString) override
|
||||||
|
@ -56,6 +56,7 @@ void LaunchTask::prependStep(std::shared_ptr<LaunchStep> step)
|
|||||||
|
|
||||||
void LaunchTask::executeTask()
|
void LaunchTask::executeTask()
|
||||||
{
|
{
|
||||||
|
m_instance->setCrashed(false);
|
||||||
if(!m_steps.size())
|
if(!m_steps.size())
|
||||||
{
|
{
|
||||||
state = LaunchTask::Finished;
|
state = LaunchTask::Finished;
|
||||||
@ -217,6 +218,7 @@ void LaunchTask::emitFailed(QString reason)
|
|||||||
{
|
{
|
||||||
m_instance->cleanupAfterRun();
|
m_instance->cleanupAfterRun();
|
||||||
m_instance->setRunning(false);
|
m_instance->setRunning(false);
|
||||||
|
m_instance->setCrashed(true);
|
||||||
Task::emitFailed(reason);
|
Task::emitFailed(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,7 +369,7 @@ QString MinecraftInstance::prettifyTimeDuration(int64_t duration)
|
|||||||
QString MinecraftInstance::getStatusbarDescription()
|
QString MinecraftInstance::getStatusbarDescription()
|
||||||
{
|
{
|
||||||
QStringList traits;
|
QStringList traits;
|
||||||
if (flags() & VersionBrokenFlag)
|
if (hasVersionBroken())
|
||||||
{
|
{
|
||||||
traits.append(tr("broken"));
|
traits.append(tr("broken"));
|
||||||
}
|
}
|
||||||
@ -380,12 +380,10 @@ QString MinecraftInstance::getStatusbarDescription()
|
|||||||
{
|
{
|
||||||
description.append(tr(", played for %1").arg(prettifyTimeDuration(totalTimePlayed())));
|
description.append(tr(", played for %1").arg(prettifyTimeDuration(totalTimePlayed())));
|
||||||
}
|
}
|
||||||
/*
|
if(hasCrashed())
|
||||||
if(traits.size())
|
|
||||||
{
|
{
|
||||||
description.append(QString(" (%1)").arg(traits.join(", ")));
|
description.append(tr(", has crashed."));
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,15 +526,7 @@ QString OneSixInstance::currentVersionId() const
|
|||||||
void OneSixInstance::reloadProfile()
|
void OneSixInstance::reloadProfile()
|
||||||
{
|
{
|
||||||
m_profile->reload();
|
m_profile->reload();
|
||||||
auto severity = m_profile->getProblemSeverity();
|
setVersionBroken(m_profile->getProblemSeverity() == ProblemSeverity::PROBLEM_ERROR);
|
||||||
if(severity == ProblemSeverity::PROBLEM_ERROR)
|
|
||||||
{
|
|
||||||
setFlag(VersionBrokenFlag);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
unsetFlag(VersionBrokenFlag);
|
|
||||||
}
|
|
||||||
emit versionReloaded();
|
emit versionReloaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ void LibrariesTask::executeTask()
|
|||||||
qDebug() << m_inst->name() << ": downloading libraries";
|
qDebug() << m_inst->name() << ": downloading libraries";
|
||||||
OneSixInstance *inst = (OneSixInstance *)m_inst;
|
OneSixInstance *inst = (OneSixInstance *)m_inst;
|
||||||
inst->reloadProfile();
|
inst->reloadProfile();
|
||||||
if(inst->flags() & BaseInstance::VersionBrokenFlag)
|
if(inst->hasVersionBroken())
|
||||||
{
|
{
|
||||||
emitFailed(tr("Failed to load the version description files - check the instance for errors."));
|
emitFailed(tr("Failed to load the version description files - check the instance for errors."));
|
||||||
return;
|
return;
|
||||||
|
@ -113,19 +113,22 @@ void drawProgressOverlay(QPainter *painter, const QStyleOptionViewItemV4 &option
|
|||||||
void drawBadges(QPainter *painter, const QStyleOptionViewItemV4 &option, BaseInstance *instance)
|
void drawBadges(QPainter *painter, const QStyleOptionViewItemV4 &option, BaseInstance *instance)
|
||||||
{
|
{
|
||||||
QList<QString> pixmaps;
|
QList<QString> pixmaps;
|
||||||
const BaseInstance::InstanceFlags flags = instance->flags();
|
|
||||||
if (flags & BaseInstance::VersionBrokenFlag)
|
|
||||||
{
|
|
||||||
pixmaps.append("broken");
|
|
||||||
}
|
|
||||||
if (flags & BaseInstance::UpdateAvailable)
|
|
||||||
{
|
|
||||||
pixmaps.append("updateavailable");
|
|
||||||
}
|
|
||||||
if (instance->isRunning())
|
if (instance->isRunning())
|
||||||
{
|
{
|
||||||
pixmaps.append("status-running");
|
pixmaps.append("status-running");
|
||||||
}
|
}
|
||||||
|
else if (instance->hasCrashed())
|
||||||
|
{
|
||||||
|
pixmaps.append("status-bad");
|
||||||
|
}
|
||||||
|
if (instance->hasVersionBroken())
|
||||||
|
{
|
||||||
|
pixmaps.append("broken");
|
||||||
|
}
|
||||||
|
if (instance->hasUpdateAvailable())
|
||||||
|
{
|
||||||
|
pixmaps.append("updateavailable");
|
||||||
|
}
|
||||||
|
|
||||||
// begin easter eggs
|
// begin easter eggs
|
||||||
if (instance->name().contains("btw", Qt::CaseInsensitive) ||
|
if (instance->name().contains("btw", Qt::CaseInsensitive) ||
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
<file>herobrine.png</file>
|
<file>herobrine.png</file>
|
||||||
<file>derp.png</file>
|
<file>derp.png</file>
|
||||||
<file>status-running.png</file>
|
<file>status-running.png</file>
|
||||||
|
<file>status-bad.png</file>
|
||||||
|
|
||||||
<!-- Update. GPLv2, https://code.google.com/p/gnome-colors/ -->
|
<!-- Update. GPLv2, https://code.google.com/p/gnome-colors/ -->
|
||||||
<file>updateavailable.png</file>
|
<file>updateavailable.png</file>
|
||||||
|
BIN
application/resources/instances/status-bad.png
Normal file
BIN
application/resources/instances/status-bad.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in New Issue
Block a user