Things... and stuff... with 1.6 modding. Maybe.
This commit is contained in:
parent
930b07afd4
commit
c2c7293083
@ -230,7 +230,6 @@ void LegacyModEditDialog::on_addForgeBtn_clicked()
|
|||||||
m_jarmods->installMod(QFileInfo(entry->getFullPath()));
|
m_jarmods->installMod(QFileInfo(entry->getFullPath()));
|
||||||
m_jarmods->startWatching();
|
m_jarmods->startWatching();
|
||||||
}
|
}
|
||||||
//m_selectedInstance->setIntendedVersionId(->descriptor());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void LegacyModEditDialog::on_addJarBtn_clicked()
|
void LegacyModEditDialog::on_addJarBtn_clicked()
|
||||||
|
@ -21,9 +21,11 @@
|
|||||||
#include "logic/EnabledItemFilter.h"
|
#include "logic/EnabledItemFilter.h"
|
||||||
#include "logic/lists/ForgeVersionList.h"
|
#include "logic/lists/ForgeVersionList.h"
|
||||||
#include "gui/versionselectdialog.h"
|
#include "gui/versionselectdialog.h"
|
||||||
|
#include "ProgressDialog.h"
|
||||||
|
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
@ -38,11 +40,13 @@ OneSixModEditDialog::OneSixModEditDialog(OneSixInstance * inst, QWidget *parent)
|
|||||||
{
|
{
|
||||||
m_version = m_inst->getFullVersion();
|
m_version = m_inst->getFullVersion();
|
||||||
|
|
||||||
auto filter = new EnabledItemFilter(this);
|
main_model = new EnabledItemFilter(this);
|
||||||
filter->setActive(true);
|
main_model->setActive(true);
|
||||||
filter->setSourceModel(m_version.data());
|
main_model->setSourceModel(m_version.data());
|
||||||
ui->libraryTreeView->setModel(filter);
|
ui->libraryTreeView->setModel(main_model);
|
||||||
ui->libraryTreeView->installEventFilter( this );
|
ui->libraryTreeView->installEventFilter( this );
|
||||||
|
ui->mainClassEdit->setText(m_version->mainClass);
|
||||||
|
updateButtons();
|
||||||
}
|
}
|
||||||
// Loader mods
|
// Loader mods
|
||||||
{
|
{
|
||||||
@ -69,17 +73,86 @@ OneSixModEditDialog::~OneSixModEditDialog()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OneSixModEditDialog::updateButtons()
|
||||||
|
{
|
||||||
|
bool customVersion = m_inst->versionIsCustom();
|
||||||
|
ui->customizeBtn->setEnabled(!customVersion);
|
||||||
|
ui->revertBtn->setEnabled(customVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void OneSixModEditDialog::on_customizeBtn_clicked()
|
||||||
|
{
|
||||||
|
if(m_inst->customizeVersion())
|
||||||
|
{
|
||||||
|
m_version = m_inst->getFullVersion();
|
||||||
|
main_model->setSourceModel(m_version.data());
|
||||||
|
updateButtons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneSixModEditDialog::on_revertBtn_clicked()
|
||||||
|
{
|
||||||
|
auto reply = QMessageBox::question(this, tr("Revert?"), tr("Do you want to revert the version of this instance to its original configuration?"),QMessageBox::Yes|QMessageBox::No);
|
||||||
|
if (reply == QMessageBox::Yes)
|
||||||
|
{
|
||||||
|
if(m_inst->revertCustomVersion())
|
||||||
|
{
|
||||||
|
m_version = m_inst->getFullVersion();
|
||||||
|
main_model->setSourceModel(m_version.data());
|
||||||
|
updateButtons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void OneSixModEditDialog::on_forgeBtn_clicked()
|
void OneSixModEditDialog::on_forgeBtn_clicked()
|
||||||
{
|
{
|
||||||
VersionSelectDialog vselect(MMC->forgelist(), this);
|
VersionSelectDialog vselect(MMC->forgelist(), this);
|
||||||
vselect.setFilter(1, m_inst->currentVersionId());
|
vselect.setFilter(1, m_inst->currentVersionId());
|
||||||
if (vselect.exec() && vselect.selectedVersion())
|
if (vselect.exec() && vselect.selectedVersion())
|
||||||
{
|
{
|
||||||
//m_selectedInstance->setIntendedVersionId(vselect.selectedVersion()->descriptor());
|
if(m_inst->versionIsCustom())
|
||||||
|
{
|
||||||
|
auto reply = QMessageBox::question(this, tr("Revert?"), tr("This will revert any changes you did to the version up to this point. Is that OK?"),QMessageBox::Yes|QMessageBox::No);
|
||||||
|
if (reply == QMessageBox::Yes)
|
||||||
|
{
|
||||||
|
m_inst->revertCustomVersion();
|
||||||
|
m_inst->customizeVersion();
|
||||||
|
{
|
||||||
|
m_version = m_inst->getFullVersion();
|
||||||
|
main_model->setSourceModel(m_version.data());
|
||||||
|
updateButtons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else return;
|
||||||
|
}
|
||||||
|
ForgeVersionPtr forge = vselect.selectedVersion().dynamicCast<ForgeVersion>();
|
||||||
|
if(!forge)
|
||||||
|
return;
|
||||||
|
auto entry = MMC->metacache()->resolveEntry("minecraftforge", forge->filename);
|
||||||
|
if(entry->stale)
|
||||||
|
{
|
||||||
|
DownloadJob * fjob = new DownloadJob("Forge download");
|
||||||
|
fjob->add(forge->universal_url, entry);
|
||||||
|
ProgressDialog dlg(this);
|
||||||
|
dlg.exec(fjob);
|
||||||
|
if(dlg.result() == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
// install
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// failed to download forge :/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// install
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool OneSixModEditDialog::loaderListFilter ( QKeyEvent* keyEvent )
|
bool OneSixModEditDialog::loaderListFilter ( QKeyEvent* keyEvent )
|
||||||
{
|
{
|
||||||
switch(keyEvent->key())
|
switch(keyEvent->key())
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <logic/OneSixInstance.h>
|
#include <logic/OneSixInstance.h>
|
||||||
|
|
||||||
|
class EnabledItemFilter;
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class OneSixModEditDialog;
|
class OneSixModEditDialog;
|
||||||
}
|
}
|
||||||
@ -41,6 +42,9 @@ private slots:
|
|||||||
// Questionable: SettingsDialog doesn't need this for some reason?
|
// Questionable: SettingsDialog doesn't need this for some reason?
|
||||||
void on_buttonBox_rejected();
|
void on_buttonBox_rejected();
|
||||||
void on_forgeBtn_clicked();
|
void on_forgeBtn_clicked();
|
||||||
|
void on_customizeBtn_clicked();
|
||||||
|
void on_revertBtn_clicked();
|
||||||
|
void updateButtons();
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *ev);
|
bool eventFilter(QObject *obj, QEvent *ev);
|
||||||
bool loaderListFilter( QKeyEvent* ev );
|
bool loaderListFilter( QKeyEvent* ev );
|
||||||
@ -50,5 +54,6 @@ private:
|
|||||||
QSharedPointer<OneSixVersion> m_version;
|
QSharedPointer<OneSixVersion> m_version;
|
||||||
QSharedPointer<ModList> m_mods;
|
QSharedPointer<ModList> m_mods;
|
||||||
QSharedPointer<ModList> m_resourcepacks;
|
QSharedPointer<ModList> m_resourcepacks;
|
||||||
|
EnabledItemFilter * main_model;
|
||||||
OneSixInstance * m_inst;
|
OneSixInstance * m_inst;
|
||||||
};
|
};
|
||||||
|
@ -55,7 +55,11 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="mainClassEdit"/>
|
<widget class="QLineEdit" name="mainClassEdit">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
@ -85,6 +89,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="revertBtn">
|
<widget class="QPushButton" name="revertBtn">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Revert to original base version</string>
|
<string>Revert to original base version</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -226,6 +226,30 @@ QString OneSixInstance::currentVersionId() const
|
|||||||
return intendedVersionId();
|
return intendedVersionId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OneSixInstance::customizeVersion()
|
||||||
|
{
|
||||||
|
if(!versionIsCustom())
|
||||||
|
{
|
||||||
|
auto pathCustom = PathCombine(instanceRoot(), "custom.json");
|
||||||
|
auto pathOrig = PathCombine(instanceRoot(), "version.json");
|
||||||
|
QFile::copy(pathOrig, pathCustom);
|
||||||
|
return reloadFullVersion();
|
||||||
|
}
|
||||||
|
else return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OneSixInstance::revertCustomVersion()
|
||||||
|
{
|
||||||
|
if(versionIsCustom())
|
||||||
|
{
|
||||||
|
auto path = PathCombine(instanceRoot(), "custom.json");
|
||||||
|
QFile::remove(path);
|
||||||
|
return reloadFullVersion();
|
||||||
|
}
|
||||||
|
else return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool OneSixInstance::reloadFullVersion()
|
bool OneSixInstance::reloadFullVersion()
|
||||||
{
|
{
|
||||||
I_D(OneSixInstance);
|
I_D(OneSixInstance);
|
||||||
|
@ -41,6 +41,10 @@ public:
|
|||||||
bool reloadFullVersion();
|
bool reloadFullVersion();
|
||||||
/// get the current full version info
|
/// get the current full version info
|
||||||
QSharedPointer<OneSixVersion> getFullVersion();
|
QSharedPointer<OneSixVersion> getFullVersion();
|
||||||
|
/// revert the current custom version back to base
|
||||||
|
bool revertCustomVersion();
|
||||||
|
/// customize the current base version
|
||||||
|
bool customizeVersion();
|
||||||
/// is the current version original, or custom?
|
/// is the current version original, or custom?
|
||||||
bool versionIsCustom();
|
bool versionIsCustom();
|
||||||
|
|
||||||
|
@ -220,6 +220,7 @@ void ForgeListLoadTask::list_downloaded()
|
|||||||
QJsonArray files = obj.value("files").toArray();
|
QJsonArray files = obj.value("files").toArray();
|
||||||
QString url, jobbuildver, mcver, buildtype, filename;
|
QString url, jobbuildver, mcver, buildtype, filename;
|
||||||
QString changelog_url, installer_url;
|
QString changelog_url, installer_url;
|
||||||
|
QString installer_filename;
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
for(int j = 0; j < files.count(); j++)
|
for(int j = 0; j < files.count(); j++)
|
||||||
{
|
{
|
||||||
@ -246,6 +247,8 @@ void ForgeListLoadTask::list_downloaded()
|
|||||||
else if(buildtype == "installer")
|
else if(buildtype == "installer")
|
||||||
{
|
{
|
||||||
installer_url = file.value("url").toString();
|
installer_url = file.value("url").toString();
|
||||||
|
int lastSlash = installer_url.lastIndexOf('/');
|
||||||
|
installer_filename = installer_url.mid(lastSlash+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(valid)
|
if(valid)
|
||||||
@ -258,6 +261,7 @@ void ForgeListLoadTask::list_downloaded()
|
|||||||
fVersion->jobbuildver = jobbuildver;
|
fVersion->jobbuildver = jobbuildver;
|
||||||
fVersion->mcver = mcver;
|
fVersion->mcver = mcver;
|
||||||
fVersion->filename = filename;
|
fVersion->filename = filename;
|
||||||
|
fVersion->filename = installer_filename;
|
||||||
fVersion->m_buildnr = build_nr;
|
fVersion->m_buildnr = build_nr;
|
||||||
tempList.append(fVersion);
|
tempList.append(fVersion);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user