mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-11-20 08:10:11 +00:00
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;
|
||||
}
|
||||
|
||||
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()
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -113,19 +113,22 @@ void drawProgressOverlay(QPainter *painter, const QStyleOptionViewItemV4 &option
|
||||
void drawBadges(QPainter *painter, const QStyleOptionViewItemV4 &option, BaseInstance *instance)
|
||||
{
|
||||
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())
|
||||
{
|
||||
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
|
||||
if (instance->name().contains("btw", Qt::CaseInsensitive) ||
|
||||
|
@ -38,6 +38,7 @@
|
||||
<file>herobrine.png</file>
|
||||
<file>derp.png</file>
|
||||
<file>status-running.png</file>
|
||||
<file>status-bad.png</file>
|
||||
|
||||
<!-- Update. GPLv2, https://code.google.com/p/gnome-colors/ -->
|
||||
<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