Remove version patch reordering. Remove the main class display from onesix edit mods.
This commit is contained in:
parent
47bc7e5ee3
commit
ffff2cd324
@ -110,7 +110,6 @@ void OneSixModEditDialog::updateVersionControls()
|
|||||||
{
|
{
|
||||||
ui->forgeBtn->setEnabled(true);
|
ui->forgeBtn->setEnabled(true);
|
||||||
ui->liteloaderBtn->setEnabled(true);
|
ui->liteloaderBtn->setEnabled(true);
|
||||||
ui->mainClassEdit->setText(m_version->mainClass);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixModEditDialog::disableVersionControls()
|
void OneSixModEditDialog::disableVersionControls()
|
||||||
@ -119,7 +118,6 @@ void OneSixModEditDialog::disableVersionControls()
|
|||||||
ui->liteloaderBtn->setEnabled(false);
|
ui->liteloaderBtn->setEnabled(false);
|
||||||
ui->reloadLibrariesBtn->setEnabled(false);
|
ui->reloadLibrariesBtn->setEnabled(false);
|
||||||
ui->removeLibraryBtn->setEnabled(false);
|
ui->removeLibraryBtn->setEnabled(false);
|
||||||
ui->mainClassEdit->setText("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixModEditDialog::on_reloadLibrariesBtn_clicked()
|
void OneSixModEditDialog::on_reloadLibrariesBtn_clicked()
|
||||||
@ -131,6 +129,7 @@ void OneSixModEditDialog::on_removeLibraryBtn_clicked()
|
|||||||
{
|
{
|
||||||
if (ui->libraryTreeView->currentIndex().isValid())
|
if (ui->libraryTreeView->currentIndex().isValid())
|
||||||
{
|
{
|
||||||
|
// FIXME: use actual model, not reloading.
|
||||||
if (!m_version->remove(ui->libraryTreeView->currentIndex().row()))
|
if (!m_version->remove(ui->libraryTreeView->currentIndex().row()))
|
||||||
{
|
{
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Couldn't remove file"));
|
QMessageBox::critical(this, tr("Error"), tr("Couldn't remove file"));
|
||||||
@ -144,97 +143,31 @@ void OneSixModEditDialog::on_removeLibraryBtn_clicked()
|
|||||||
|
|
||||||
void OneSixModEditDialog::on_resetLibraryOrderBtn_clicked()
|
void OneSixModEditDialog::on_resetLibraryOrderBtn_clicked()
|
||||||
{
|
{
|
||||||
QDir(m_inst->instanceRoot()).remove("order.json");
|
// FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S).
|
||||||
m_inst->reloadVersion();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixModEditDialog::on_moveLibraryUpBtn_clicked()
|
void OneSixModEditDialog::on_moveLibraryUpBtn_clicked()
|
||||||
{
|
{
|
||||||
|
// FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S).
|
||||||
QMap<QString, int> order = getExistingOrder();
|
|
||||||
if (order.size() < 2 || ui->libraryTreeView->selectionModel()->selectedIndexes().isEmpty())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const int ourRow = ui->libraryTreeView->selectionModel()->selectedIndexes().first().row();
|
|
||||||
const QString ourId = m_version->versionFileId(ourRow);
|
|
||||||
const int ourOrder = order[ourId];
|
|
||||||
if (ourId.isNull() || ourId.startsWith("org.multimc."))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMap<int, QString> sortedOrder = invert(order);
|
|
||||||
|
|
||||||
QList<int> sortedOrders = sortedOrder.keys();
|
|
||||||
const int ourIndex = sortedOrders.indexOf(ourOrder);
|
|
||||||
if (ourIndex <= 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const int ourNewOrder = sortedOrders.at(ourIndex - 1);
|
|
||||||
order[ourId] = ourNewOrder;
|
|
||||||
order[sortedOrder[sortedOrders[ourIndex - 1]]] = ourOrder;
|
|
||||||
|
|
||||||
// FIXME: why is GUI code doing this in particular? why isn't this part of a model?
|
|
||||||
if (!OneSixVersionBuilder::writeOverrideOrders(order, m_inst))
|
|
||||||
{
|
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Couldn't save the new order"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_inst->reloadVersion();
|
|
||||||
ui->libraryTreeView->selectionModel()->select(m_version->index(ourRow - 1), QItemSelectionModel::SelectCurrent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: WHY IS THIS DUPLICATED?
|
|
||||||
void OneSixModEditDialog::on_moveLibraryDownBtn_clicked()
|
void OneSixModEditDialog::on_moveLibraryDownBtn_clicked()
|
||||||
{
|
{
|
||||||
QMap<QString, int> order = getExistingOrder();
|
// FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S).
|
||||||
if (order.size() < 2 || ui->libraryTreeView->selectionModel()->selectedIndexes().isEmpty())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const int ourRow = ui->libraryTreeView->selectionModel()->selectedIndexes().first().row();
|
|
||||||
const QString ourId = m_version->versionFileId(ourRow);
|
|
||||||
const int ourOrder = order[ourId];
|
|
||||||
if (ourId.isNull() || ourId.startsWith("org.multimc."))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMap<int, QString> sortedOrder = invert(order);
|
|
||||||
|
|
||||||
QList<int> sortedOrders = sortedOrder.keys();
|
|
||||||
const int ourIndex = sortedOrders.indexOf(ourOrder);
|
|
||||||
if ((ourIndex + 1) >= sortedOrders.size())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const int ourNewOrder = sortedOrders.at(ourIndex + 1);
|
|
||||||
order[ourId] = ourNewOrder;
|
|
||||||
order[sortedOrder[sortedOrders[ourIndex + 1]]] = ourOrder;
|
|
||||||
|
|
||||||
// FIXME: why is GUI code doing this in particular? why isn't this part of a model?
|
|
||||||
if (!OneSixVersionBuilder::writeOverrideOrders(order, m_inst))
|
|
||||||
{
|
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Couldn't save the new order"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_inst->reloadVersion();
|
|
||||||
ui->libraryTreeView->selectionModel()->select(m_version->index(ourRow + 1), QItemSelectionModel::SelectCurrent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixModEditDialog::on_forgeBtn_clicked()
|
void OneSixModEditDialog::on_forgeBtn_clicked()
|
||||||
{
|
{
|
||||||
|
// FIXME: use actual model, not reloading. Move logic to model.
|
||||||
|
|
||||||
|
// FIXME: model::isCustom();
|
||||||
if (QDir(m_inst->instanceRoot()).exists("custom.json"))
|
if (QDir(m_inst->instanceRoot()).exists("custom.json"))
|
||||||
{
|
{
|
||||||
if (QMessageBox::question(this, tr("Revert?"), tr("This action will remove your custom.json. Continue?")) != QMessageBox::Yes)
|
if (QMessageBox::question(this, tr("Revert?"), tr("This action will remove your custom.json. Continue?")) != QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// FIXME: model::revertToBase();
|
||||||
QDir(m_inst->instanceRoot()).remove("custom.json");
|
QDir(m_inst->instanceRoot()).remove("custom.json");
|
||||||
m_inst->reloadVersion();
|
m_inst->reloadVersion();
|
||||||
}
|
}
|
||||||
@ -351,35 +284,6 @@ bool OneSixModEditDialog::resourcePackListFilter(QKeyEvent *keyEvent)
|
|||||||
return QDialog::eventFilter(ui->resPackTreeView, keyEvent);
|
return QDialog::eventFilter(ui->resPackTreeView, keyEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, int> OneSixModEditDialog::getExistingOrder() const
|
|
||||||
{
|
|
||||||
|
|
||||||
QMap<QString, int> order;
|
|
||||||
// default
|
|
||||||
{
|
|
||||||
for (auto & file : m_version->versionFiles)
|
|
||||||
{
|
|
||||||
if (file.id.startsWith("org.multimc."))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
order.insert(file.id, file.order);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// overriden
|
|
||||||
{
|
|
||||||
QMap<QString, int> overridenOrder = OneSixVersionBuilder::readOverrideOrders(m_inst);
|
|
||||||
for (auto id : order.keys())
|
|
||||||
{
|
|
||||||
if (overridenOrder.contains(id))
|
|
||||||
{
|
|
||||||
order[id] = overridenOrder[id];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return order;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OneSixModEditDialog::eventFilter(QObject *obj, QEvent *ev)
|
bool OneSixModEditDialog::eventFilter(QObject *obj, QEvent *ev)
|
||||||
{
|
{
|
||||||
if (ev->type() != QEvent::KeyPress)
|
if (ev->type() != QEvent::KeyPress)
|
||||||
|
@ -48,24 +48,6 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Main Class:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="mainClassEdit">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -108,13 +90,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="resetLibraryOrderBtn">
|
|
||||||
<property name="text">
|
|
||||||
<string>Reset order</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="Line" name="line_2">
|
<widget class="Line" name="line_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -124,6 +99,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="moveLibraryUpBtn">
|
<widget class="QPushButton" name="moveLibraryUpBtn">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>This isn't implemented yet.</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Move up</string>
|
<string>Move up</string>
|
||||||
</property>
|
</property>
|
||||||
@ -131,11 +112,30 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="moveLibraryDownBtn">
|
<widget class="QPushButton" name="moveLibraryDownBtn">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>This isn't implemented yet.</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Move down</string>
|
<string>Move down</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="resetLibraryOrderBtn">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>This isn't implemented yet.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Reset order</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_7">
|
<spacer name="verticalSpacer_7">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -71,6 +71,7 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi
|
|||||||
file->version = QString();
|
file->version = QString();
|
||||||
file->mcVersion = QString();
|
file->mcVersion = QString();
|
||||||
file->applyTo(m_version);
|
file->applyTo(m_version);
|
||||||
|
m_version->versionFiles.append(file);
|
||||||
}
|
}
|
||||||
// else, if there's custom json, we just do that.
|
// else, if there's custom json, we just do that.
|
||||||
else if (QFile::exists(root.absoluteFilePath("custom.json")))
|
else if (QFile::exists(root.absoluteFilePath("custom.json")))
|
||||||
@ -82,6 +83,7 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi
|
|||||||
file->fileId = "org.multimc.custom.json";
|
file->fileId = "org.multimc.custom.json";
|
||||||
file->version = QString();
|
file->version = QString();
|
||||||
file->applyTo(m_version);
|
file->applyTo(m_version);
|
||||||
|
m_version->versionFiles.append(file);
|
||||||
// QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC"));
|
// QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC"));
|
||||||
// QObject::tr("Error while applying %1. Please check MultiMC-0.log for more info.")
|
// QObject::tr("Error while applying %1. Please check MultiMC-0.log for more info.")
|
||||||
}
|
}
|
||||||
@ -96,6 +98,7 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi
|
|||||||
file->version = m_instance->intendedVersionId();
|
file->version = m_instance->intendedVersionId();
|
||||||
file->mcVersion = m_instance->intendedVersionId();
|
file->mcVersion = m_instance->intendedVersionId();
|
||||||
file->applyTo(m_version);
|
file->applyTo(m_version);
|
||||||
|
m_version->versionFiles.append(file);
|
||||||
// QObject::tr("Error while applying %1. Please check MultiMC-0.log for more info.").arg(root.absoluteFilePath("version.json")));
|
// QObject::tr("Error while applying %1. Please check MultiMC-0.log for more info.").arg(root.absoluteFilePath("version.json")));
|
||||||
|
|
||||||
if (onlyVanilla)
|
if (onlyVanilla)
|
||||||
@ -103,17 +106,12 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi
|
|||||||
|
|
||||||
// patches/
|
// patches/
|
||||||
// load all, put into map for ordering, apply in the right order
|
// load all, put into map for ordering, apply in the right order
|
||||||
QMap<QString, int> overrideOrder = readOverrideOrders(m_instance);
|
|
||||||
|
|
||||||
QMap<int, QPair<QString, VersionFilePtr>> files;
|
QMap<int, QPair<QString, VersionFilePtr>> files;
|
||||||
for (auto info : patches.entryInfoList(QStringList() << "*.json", QDir::Files))
|
for (auto info : patches.entryInfoList(QStringList() << "*.json", QDir::Files))
|
||||||
{
|
{
|
||||||
QLOG_INFO() << "Reading" << info.fileName();
|
QLOG_INFO() << "Reading" << info.fileName();
|
||||||
auto file = parseJsonFile(info, true);
|
auto file = parseJsonFile(info, true);
|
||||||
if (overrideOrder.contains(file->fileId))
|
|
||||||
{
|
|
||||||
file->order = overrideOrder.value(file->fileId);
|
|
||||||
}
|
|
||||||
if (files.contains(file->order))
|
if (files.contains(file->order))
|
||||||
{
|
{
|
||||||
throw VersionBuildError(QObject::tr("%1 has the same order as %2").arg(file->fileId, files[file->order].second->fileId));
|
throw VersionBuildError(QObject::tr("%1 has the same order as %2").arg(file->fileId, files[file->order].second->fileId));
|
||||||
@ -125,6 +123,7 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi
|
|||||||
QLOG_DEBUG() << "Applying file with order" << order;
|
QLOG_DEBUG() << "Applying file with order" << order;
|
||||||
auto & filePair = files[order];
|
auto & filePair = files[order];
|
||||||
filePair.second->applyTo(m_version);
|
filePair.second->applyTo(m_version);
|
||||||
|
m_version->versionFiles.append(filePair.second);
|
||||||
}
|
}
|
||||||
} while(0);
|
} while(0);
|
||||||
|
|
||||||
@ -167,6 +166,7 @@ void OneSixVersionBuilder::readJsonAndApply(const QJsonObject &obj)
|
|||||||
// QObject::tr("Error while reading. Please check MultiMC-0.log for more info."));
|
// QObject::tr("Error while reading. Please check MultiMC-0.log for more info."));
|
||||||
|
|
||||||
file->applyTo(m_version);
|
file->applyTo(m_version);
|
||||||
|
m_version->versionFiles.append(file);
|
||||||
// QObject::tr("Error while applying. Please check MultiMC-0.log for more info."));
|
// QObject::tr("Error while applying. Please check MultiMC-0.log for more info."));
|
||||||
// QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC"));
|
// QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC"));
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ bool VersionFinal::canRemove(const int index) const
|
|||||||
{
|
{
|
||||||
if (index < versionFiles.size())
|
if (index < versionFiles.size())
|
||||||
{
|
{
|
||||||
return versionFiles.at(index).id != "org.multimc.version.json";
|
return versionFiles.at(index)->fileId != "org.multimc.version.json";
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -67,14 +67,14 @@ QString VersionFinal::versionFileId(const int index) const
|
|||||||
{
|
{
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
return versionFiles.at(index).id;
|
return versionFiles.at(index)->fileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VersionFinal::remove(const int index)
|
bool VersionFinal::remove(const int index)
|
||||||
{
|
{
|
||||||
if (canRemove(index))
|
if (canRemove(index))
|
||||||
{
|
{
|
||||||
return QFile::remove(versionFiles.at(index).filename);
|
return QFile::remove(versionFiles.at(index)->filename);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -135,9 +135,9 @@ QVariant VersionFinal::data(const QModelIndex &index, int role) const
|
|||||||
switch (column)
|
switch (column)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return versionFiles.at(row).name;
|
return versionFiles.at(row)->name;
|
||||||
case 1:
|
case 1:
|
||||||
return versionFiles.at(row).version;
|
return versionFiles.at(row)->version;
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -119,11 +119,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
// QList<Rule> rules;
|
// QList<Rule> rules;
|
||||||
|
|
||||||
QList<VersionFile> versionFiles;
|
QList<VersionFilePtr> versionFiles;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OneSixInstance *m_instance;
|
OneSixInstance *m_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
QDebug operator<<(QDebug &dbg, const VersionFinal *version);
|
|
||||||
QDebug operator<<(QDebug &dbg, const OneSixLibrary *library);
|
|
||||||
|
Loading…
Reference in New Issue
Block a user