Instance flags. Currently used for marking instances as broken. Can later be used for badges.
This commit is contained in:
parent
4e8be668cb
commit
0b56b5efaf
@ -354,6 +354,7 @@ void MainWindow::showInstanceContextMenu(const QPoint &pos)
|
||||
|
||||
QMenu myMenu;
|
||||
myMenu.addActions(actions);
|
||||
myMenu.setEnabled(m_selectedInstance->canLaunch());
|
||||
myMenu.exec(view->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
@ -1366,7 +1367,7 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex &
|
||||
(BaseInstance *)current.data(InstanceList::InstancePointerRole)
|
||||
.value<void *>()))
|
||||
{
|
||||
ui->instanceToolBar->setEnabled(true);
|
||||
ui->instanceToolBar->setEnabled(m_selectedInstance->canLaunch());
|
||||
renameButton->setText(m_selectedInstance->name());
|
||||
ui->actionChangeInstLWJGLVersion->setEnabled(
|
||||
m_selectedInstance->menuActionEnabled("actionChangeInstLWJGLVersion"));
|
||||
|
@ -37,6 +37,7 @@ 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");
|
||||
@ -146,6 +147,28 @@ SettingsObject &BaseInstance::settings() const
|
||||
return *d->m_settings;
|
||||
}
|
||||
|
||||
BaseInstance::InstanceFlags BaseInstance::flags() const
|
||||
{
|
||||
I_D(const BaseInstance);
|
||||
return InstanceFlags(d->m_flags);
|
||||
}
|
||||
|
||||
void BaseInstance::setFlags(const BaseInstance::InstanceFlags flags)
|
||||
{
|
||||
I_D(BaseInstance);
|
||||
if (flags != d->m_flags)
|
||||
{
|
||||
d->m_flags = flags;
|
||||
emit flagsChanged();
|
||||
emit propertiesChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool BaseInstance::canLaunch() const
|
||||
{
|
||||
return !(flags() & VersionBrokenFlag);
|
||||
}
|
||||
|
||||
QString BaseInstance::baseJar() const
|
||||
{
|
||||
I_D(BaseInstance);
|
||||
|
@ -175,6 +175,17 @@ public:
|
||||
/// FIXME: this really should be elsewhere...
|
||||
virtual QString instanceConfigFolder() const = 0;
|
||||
|
||||
enum InstanceFlag
|
||||
{
|
||||
NoFlags = 0x00,
|
||||
VersionBrokenFlag = 0x01
|
||||
};
|
||||
Q_DECLARE_FLAGS(InstanceFlags, InstanceFlag)
|
||||
InstanceFlags flags() const;
|
||||
void setFlags(const BaseInstance::InstanceFlags flags);
|
||||
|
||||
bool canLaunch() const;
|
||||
|
||||
signals:
|
||||
/*!
|
||||
* \brief Signal emitted when properties relevant to the instance view change
|
||||
@ -189,6 +200,8 @@ signals:
|
||||
*/
|
||||
void nuked(BaseInstance *inst);
|
||||
|
||||
void flagsChanged();
|
||||
|
||||
protected slots:
|
||||
void iconUpdated(QString key);
|
||||
|
||||
@ -198,3 +211,5 @@ protected:
|
||||
|
||||
// pointer for lazy people
|
||||
typedef std::shared_ptr<BaseInstance> InstancePtr;
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(BaseInstance::InstanceFlags)
|
||||
|
@ -26,4 +26,5 @@ struct BaseInstancePrivate
|
||||
QString m_rootDir;
|
||||
QString m_group;
|
||||
SettingsObject *m_settings;
|
||||
int m_flags;
|
||||
};
|
@ -7,6 +7,10 @@ LegacyFTBInstance::LegacyFTBInstance(const QString &rootDir, SettingsObject *set
|
||||
|
||||
QString LegacyFTBInstance::getStatusbarDescription()
|
||||
{
|
||||
if (flags() & VersionBrokenFlag)
|
||||
{
|
||||
return "Legacy FTB: " + intendedVersionId() + " (broken)";
|
||||
}
|
||||
return "Legacy FTB: " + intendedVersionId();
|
||||
}
|
||||
|
||||
|
@ -268,13 +268,23 @@ QString LegacyInstance::defaultCustomBaseJar() const
|
||||
|
||||
bool LegacyInstance::menuActionEnabled(QString action_name) const
|
||||
{
|
||||
if (action_name == "actionChangeInstMCVersion")
|
||||
if (flags() & VersionBrokenFlag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (action_name == "actionChangeInstMCVersion")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QString LegacyInstance::getStatusbarDescription()
|
||||
{
|
||||
if (flags() & VersionBrokenFlag)
|
||||
{
|
||||
return "Legacy : " + intendedVersionId() + " (broken)";
|
||||
}
|
||||
if (shouldUpdate())
|
||||
return "Legacy : " + currentVersionId() + " -> " + intendedVersionId();
|
||||
else
|
||||
|
@ -23,6 +23,10 @@ NostalgiaInstance::NostalgiaInstance(const QString &rootDir, SettingsObject *set
|
||||
|
||||
QString NostalgiaInstance::getStatusbarDescription()
|
||||
{
|
||||
if (flags() & VersionBrokenFlag)
|
||||
{
|
||||
return "Nostalgia : " + intendedVersionId() + " (broken)";
|
||||
}
|
||||
return "Nostalgia : " + intendedVersionId();
|
||||
}
|
||||
|
||||
|
@ -97,6 +97,10 @@ QString OneSixFTBInstance::id() const
|
||||
|
||||
QString OneSixFTBInstance::getStatusbarDescription()
|
||||
{
|
||||
if (flags() & VersionBrokenFlag)
|
||||
{
|
||||
return "OneSix FTB: " + intendedVersionId() + " (broken)";
|
||||
}
|
||||
return "OneSix FTB: " + intendedVersionId();
|
||||
}
|
||||
bool OneSixFTBInstance::menuActionEnabled(QString action_name) const
|
||||
|
@ -325,11 +325,12 @@ bool OneSixInstance::reloadVersion(QWidget *widgetParent)
|
||||
}
|
||||
if (ret)
|
||||
{
|
||||
setFlags(flags() & ~VersionBrokenFlag);
|
||||
emit versionReloaded();
|
||||
}
|
||||
else
|
||||
{
|
||||
nuke();
|
||||
setFlags(flags() | VersionBrokenFlag);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -366,8 +367,14 @@ QString OneSixInstance::defaultCustomBaseJar() const
|
||||
|
||||
bool OneSixInstance::menuActionEnabled(QString action_name) const
|
||||
{
|
||||
if (action_name == "actionChangeInstLWJGLVersion")
|
||||
if (flags() & VersionBrokenFlag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (action_name == "actionChangeInstLWJGLVersion")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -376,7 +383,11 @@ QString OneSixInstance::getStatusbarDescription()
|
||||
QString descr = "OneSix : " + intendedVersionId();
|
||||
if (versionIsCustom())
|
||||
{
|
||||
descr + " (custom)";
|
||||
descr += " (custom)";
|
||||
}
|
||||
if (flags() & VersionBrokenFlag)
|
||||
{
|
||||
descr += " (broken)";
|
||||
}
|
||||
return descr;
|
||||
}
|
||||
|
@ -846,7 +846,7 @@ bool OneSixVersionBuilder::build(const bool onlyVanilla)
|
||||
{
|
||||
QMessageBox::critical(
|
||||
m_widgetParent, QObject::tr("Error"),
|
||||
QObject::tr("The version descriptors of this instance are now compatible with the current version of MultiMC"));
|
||||
QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -880,7 +880,7 @@ bool OneSixVersionBuilder::build(const bool onlyVanilla)
|
||||
{
|
||||
QMessageBox::critical(
|
||||
m_widgetParent, QObject::tr("Error"),
|
||||
QObject::tr("The version descriptors of this instance are now compatible with the current version of MultiMC"));
|
||||
QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -931,7 +931,7 @@ bool OneSixVersionBuilder::build(const bool onlyVanilla)
|
||||
{
|
||||
QMessageBox::critical(
|
||||
m_widgetParent, QObject::tr("Error"),
|
||||
QObject::tr("The version descriptors of this instance are now compatible with the current version of MultiMC"));
|
||||
QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1024,7 +1024,7 @@ bool OneSixVersionBuilder::read(const QJsonObject &obj)
|
||||
{
|
||||
QMessageBox::critical(
|
||||
m_widgetParent, QObject::tr("Error"),
|
||||
QObject::tr("The version descriptors of this instance are now compatible with the current version of MultiMC"));
|
||||
QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user