Derpstances. Everything renamed. Launching does not yet work.
This commit is contained in:
parent
b182f12c20
commit
a1a06cc89f
@ -297,8 +297,8 @@ gui/dialogs/IconPickerDialog.h
|
||||
gui/dialogs/IconPickerDialog.cpp
|
||||
gui/dialogs/LegacyModEditDialog.h
|
||||
gui/dialogs/LegacyModEditDialog.cpp
|
||||
gui/dialogs/OneSixModEditDialog.h
|
||||
gui/dialogs/OneSixModEditDialog.cpp
|
||||
gui/dialogs/DerpModEditDialog.h
|
||||
gui/dialogs/DerpModEditDialog.cpp
|
||||
gui/dialogs/ModEditDialogCommon.h
|
||||
gui/dialogs/ModEditDialogCommon.cpp
|
||||
gui/dialogs/EditNotesDialog.h
|
||||
@ -405,32 +405,34 @@ logic/LegacyUpdate.cpp
|
||||
logic/LegacyForge.h
|
||||
logic/LegacyForge.cpp
|
||||
|
||||
# 1.6 instances
|
||||
logic/OneSixInstance.h
|
||||
logic/OneSixInstance.cpp
|
||||
logic/OneSixInstance_p.h
|
||||
logic/OneSixUpdate.h
|
||||
logic/OneSixUpdate.cpp
|
||||
logic/OneSixVersion.h
|
||||
logic/OneSixVersion.cpp
|
||||
logic/OneSixLibrary.h
|
||||
logic/OneSixLibrary.cpp
|
||||
logic/OneSixRule.h
|
||||
logic/OneSixRule.cpp
|
||||
# Derp instances
|
||||
logic/DerpUpdate.h
|
||||
logic/DerpUpdate.cpp
|
||||
logic/DerpVersion.h
|
||||
logic/DerpVersion.cpp
|
||||
logic/DerpLibrary.h
|
||||
logic/DerpLibrary.cpp
|
||||
logic/DerpRule.h
|
||||
logic/DerpRule.cpp
|
||||
logic/OpSys.h
|
||||
logic/OpSys.cpp
|
||||
logic/ForgeInstaller.h
|
||||
logic/ForgeInstaller.cpp
|
||||
logic/LiteLoaderInstaller.h
|
||||
logic/LiteLoaderInstaller.cpp
|
||||
logic/DerpInstance.h
|
||||
logic/DerpInstance.cpp
|
||||
logic/DerpInstance_p.h
|
||||
logic/DerpVersionBuilder.h
|
||||
logic/DerpVersionBuilder.cpp
|
||||
|
||||
# Nostalgia
|
||||
logic/NostalgiaInstance.h
|
||||
logic/NostalgiaInstance.cpp
|
||||
|
||||
# FTB
|
||||
logic/OneSixFTBInstance.h
|
||||
logic/OneSixFTBInstance.cpp
|
||||
logic/DerpFTBInstance.h
|
||||
logic/DerpFTBInstance.cpp
|
||||
logic/LegacyFTBInstance.h
|
||||
logic/LegacyFTBInstance.cpp
|
||||
|
||||
@ -506,7 +508,7 @@ gui/dialogs/InstanceSettings.ui
|
||||
gui/dialogs/ProgressDialog.ui
|
||||
gui/dialogs/IconPickerDialog.ui
|
||||
gui/dialogs/LegacyModEditDialog.ui
|
||||
gui/dialogs/OneSixModEditDialog.ui
|
||||
gui/dialogs/DerpModEditDialog.ui
|
||||
gui/dialogs/EditNotesDialog.ui
|
||||
gui/dialogs/AccountListDialog.ui
|
||||
gui/dialogs/AccountSelectDialog.ui
|
||||
|
@ -84,7 +84,7 @@
|
||||
#include "logic/BaseInstance.h"
|
||||
#include "logic/InstanceFactory.h"
|
||||
#include "logic/MinecraftProcess.h"
|
||||
#include "logic/OneSixUpdate.h"
|
||||
#include "logic/DerpUpdate.h"
|
||||
#include "logic/JavaUtils.h"
|
||||
#include "logic/NagUtils.h"
|
||||
#include "logic/SkinUtils.h"
|
||||
@ -1257,7 +1257,7 @@ void MainWindow::on_actionChangeInstMCVersion_triggered()
|
||||
|
||||
VersionSelectDialog vselect(m_selectedInstance->versionList().get(),
|
||||
tr("Change Minecraft version"), this);
|
||||
vselect.setFilter(1, "OneSix");
|
||||
vselect.setFilter(1, "Derp");
|
||||
if(!vselect.exec() || !vselect.selectedVersion())
|
||||
return;
|
||||
|
||||
|
@ -23,9 +23,9 @@
|
||||
#include <QKeyEvent>
|
||||
#include <QDesktopServices>
|
||||
|
||||
#include "OneSixModEditDialog.h"
|
||||
#include "DerpModEditDialog.h"
|
||||
#include "ModEditDialogCommon.h"
|
||||
#include "ui_OneSixModEditDialog.h"
|
||||
#include "ui_DerpModEditDialog.h"
|
||||
|
||||
#include "gui/Platform.h"
|
||||
#include "gui/dialogs/CustomMessageBox.h"
|
||||
@ -34,14 +34,14 @@
|
||||
#include "gui/dialogs/ProgressDialog.h"
|
||||
|
||||
#include "logic/ModList.h"
|
||||
#include "logic/OneSixVersion.h"
|
||||
#include "logic/DerpVersion.h"
|
||||
#include "logic/EnabledItemFilter.h"
|
||||
#include "logic/lists/ForgeVersionList.h"
|
||||
#include "logic/ForgeInstaller.h"
|
||||
#include "logic/LiteLoaderInstaller.h"
|
||||
|
||||
OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent)
|
||||
: QDialog(parent), ui(new Ui::OneSixModEditDialog), m_inst(inst)
|
||||
DerpModEditDialog::DerpModEditDialog(DerpInstance *inst, QWidget *parent)
|
||||
: QDialog(parent), ui(new Ui::DerpModEditDialog), m_inst(inst)
|
||||
{
|
||||
MultiMCPlatform::fixWM_CLASS(this);
|
||||
ui->setupUi(this);
|
||||
@ -81,64 +81,35 @@ OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent)
|
||||
ui->resPackTreeView->installEventFilter(this);
|
||||
m_resourcepacks->startWatching();
|
||||
}
|
||||
|
||||
connect(m_inst, &DerpInstance::versionReloaded, this, &DerpModEditDialog::updateVersionControls);
|
||||
}
|
||||
|
||||
OneSixModEditDialog::~OneSixModEditDialog()
|
||||
DerpModEditDialog::~DerpModEditDialog()
|
||||
{
|
||||
m_mods->stopWatching();
|
||||
m_resourcepacks->stopWatching();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void OneSixModEditDialog::updateVersionControls()
|
||||
void DerpModEditDialog::updateVersionControls()
|
||||
{
|
||||
bool customVersion = m_inst->versionIsCustom();
|
||||
ui->customizeBtn->setEnabled(!customVersion);
|
||||
ui->revertBtn->setEnabled(customVersion);
|
||||
ui->forgeBtn->setEnabled(true);
|
||||
ui->liteloaderBtn->setEnabled(LiteLoaderInstaller(m_inst->intendedVersionId()).canApply());
|
||||
ui->customEditorBtn->setEnabled(customVersion);
|
||||
}
|
||||
|
||||
void OneSixModEditDialog::disableVersionControls()
|
||||
void DerpModEditDialog::disableVersionControls()
|
||||
{
|
||||
ui->customizeBtn->setEnabled(false);
|
||||
ui->revertBtn->setEnabled(false);
|
||||
ui->forgeBtn->setEnabled(false);
|
||||
ui->liteloaderBtn->setEnabled(false);
|
||||
ui->customEditorBtn->setEnabled(false);
|
||||
}
|
||||
|
||||
void OneSixModEditDialog::on_customizeBtn_clicked()
|
||||
void DerpModEditDialog::on_customEditorBtn_clicked()
|
||||
{
|
||||
if (m_inst->customizeVersion())
|
||||
{
|
||||
m_version = m_inst->getFullVersion();
|
||||
main_model->setSourceModel(m_version.get());
|
||||
updateVersionControls();
|
||||
}
|
||||
}
|
||||
|
||||
void OneSixModEditDialog::on_revertBtn_clicked()
|
||||
{
|
||||
auto response = CustomMessageBox::selectable(
|
||||
this, tr("Revert?"), tr("Do you want to revert the "
|
||||
"version of this instance to its original configuration?"),
|
||||
QMessageBox::Question, QMessageBox::Yes | QMessageBox::No)->exec();
|
||||
if (response == QMessageBox::Yes)
|
||||
{
|
||||
if (m_inst->revertCustomVersion())
|
||||
{
|
||||
m_version = m_inst->getFullVersion();
|
||||
main_model->setSourceModel(m_version.get());
|
||||
updateVersionControls();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OneSixModEditDialog::on_customEditorBtn_clicked()
|
||||
{
|
||||
if (m_inst->versionIsCustom())
|
||||
if (QDir(m_inst->instanceRoot()).exists("custom.json"))
|
||||
{
|
||||
if (!MMC->openJsonEditor(m_inst->instanceRoot() + "/custom.json"))
|
||||
{
|
||||
@ -147,40 +118,12 @@ void OneSixModEditDialog::on_customEditorBtn_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void OneSixModEditDialog::on_forgeBtn_clicked()
|
||||
void DerpModEditDialog::on_forgeBtn_clicked()
|
||||
{
|
||||
VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this);
|
||||
vselect.setFilter(1, m_inst->currentVersionId());
|
||||
if (vselect.exec() && vselect.selectedVersion())
|
||||
{
|
||||
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.get());
|
||||
updateVersionControls();
|
||||
}
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_inst->customizeVersion();
|
||||
m_version = m_inst->getFullVersion();
|
||||
main_model->setSourceModel(m_version.get());
|
||||
updateVersionControls();
|
||||
}
|
||||
ForgeVersionPtr forgeVersion =
|
||||
std::dynamic_pointer_cast<ForgeVersion>(vselect.selectedVersion());
|
||||
if (!forgeVersion)
|
||||
@ -220,7 +163,7 @@ void OneSixModEditDialog::on_forgeBtn_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void OneSixModEditDialog::on_liteloaderBtn_clicked()
|
||||
void DerpModEditDialog::on_liteloaderBtn_clicked()
|
||||
{
|
||||
LiteLoaderInstaller liteloader(m_inst->intendedVersionId());
|
||||
if (!liteloader.canApply())
|
||||
@ -231,13 +174,6 @@ void OneSixModEditDialog::on_liteloaderBtn_clicked()
|
||||
"into this version of Minecraft"));
|
||||
return;
|
||||
}
|
||||
if (!m_inst->versionIsCustom())
|
||||
{
|
||||
m_inst->customizeVersion();
|
||||
m_version = m_inst->getFullVersion();
|
||||
main_model->setSourceModel(m_version.get());
|
||||
updateVersionControls();
|
||||
}
|
||||
if (!liteloader.apply(m_version))
|
||||
{
|
||||
QMessageBox::critical(
|
||||
@ -246,7 +182,7 @@ void OneSixModEditDialog::on_liteloaderBtn_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
bool OneSixModEditDialog::loaderListFilter(QKeyEvent *keyEvent)
|
||||
bool DerpModEditDialog::loaderListFilter(QKeyEvent *keyEvent)
|
||||
{
|
||||
switch (keyEvent->key())
|
||||
{
|
||||
@ -262,7 +198,7 @@ bool OneSixModEditDialog::loaderListFilter(QKeyEvent *keyEvent)
|
||||
return QDialog::eventFilter(ui->loaderModTreeView, keyEvent);
|
||||
}
|
||||
|
||||
bool OneSixModEditDialog::resourcePackListFilter(QKeyEvent *keyEvent)
|
||||
bool DerpModEditDialog::resourcePackListFilter(QKeyEvent *keyEvent)
|
||||
{
|
||||
switch (keyEvent->key())
|
||||
{
|
||||
@ -278,7 +214,7 @@ bool OneSixModEditDialog::resourcePackListFilter(QKeyEvent *keyEvent)
|
||||
return QDialog::eventFilter(ui->resPackTreeView, keyEvent);
|
||||
}
|
||||
|
||||
bool OneSixModEditDialog::eventFilter(QObject *obj, QEvent *ev)
|
||||
bool DerpModEditDialog::eventFilter(QObject *obj, QEvent *ev)
|
||||
{
|
||||
if (ev->type() != QEvent::KeyPress)
|
||||
{
|
||||
@ -292,12 +228,12 @@ bool OneSixModEditDialog::eventFilter(QObject *obj, QEvent *ev)
|
||||
return QDialog::eventFilter(obj, ev);
|
||||
}
|
||||
|
||||
void OneSixModEditDialog::on_buttonBox_rejected()
|
||||
void DerpModEditDialog::on_buttonBox_rejected()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void OneSixModEditDialog::on_addModBtn_clicked()
|
||||
void DerpModEditDialog::on_addModBtn_clicked()
|
||||
{
|
||||
QStringList fileNames = QFileDialog::getOpenFileNames(
|
||||
this, QApplication::translate("LegacyModEditDialog", "Select Loader Mods"));
|
||||
@ -308,7 +244,7 @@ void OneSixModEditDialog::on_addModBtn_clicked()
|
||||
m_mods->startWatching();
|
||||
}
|
||||
}
|
||||
void OneSixModEditDialog::on_rmModBtn_clicked()
|
||||
void DerpModEditDialog::on_rmModBtn_clicked()
|
||||
{
|
||||
int first, last;
|
||||
auto list = ui->loaderModTreeView->selectionModel()->selectedRows();
|
||||
@ -319,12 +255,12 @@ void OneSixModEditDialog::on_rmModBtn_clicked()
|
||||
m_mods->deleteMods(first, last);
|
||||
m_mods->startWatching();
|
||||
}
|
||||
void OneSixModEditDialog::on_viewModBtn_clicked()
|
||||
void DerpModEditDialog::on_viewModBtn_clicked()
|
||||
{
|
||||
openDirInDefaultProgram(m_inst->loaderModsDir(), true);
|
||||
}
|
||||
|
||||
void OneSixModEditDialog::on_addResPackBtn_clicked()
|
||||
void DerpModEditDialog::on_addResPackBtn_clicked()
|
||||
{
|
||||
QStringList fileNames = QFileDialog::getOpenFileNames(
|
||||
this, QApplication::translate("LegacyModEditDialog", "Select Resource Packs"));
|
||||
@ -335,7 +271,7 @@ void OneSixModEditDialog::on_addResPackBtn_clicked()
|
||||
m_resourcepacks->startWatching();
|
||||
}
|
||||
}
|
||||
void OneSixModEditDialog::on_rmResPackBtn_clicked()
|
||||
void DerpModEditDialog::on_rmResPackBtn_clicked()
|
||||
{
|
||||
int first, last;
|
||||
auto list = ui->resPackTreeView->selectionModel()->selectedRows();
|
||||
@ -346,12 +282,12 @@ void OneSixModEditDialog::on_rmResPackBtn_clicked()
|
||||
m_resourcepacks->deleteMods(first, last);
|
||||
m_resourcepacks->startWatching();
|
||||
}
|
||||
void OneSixModEditDialog::on_viewResPackBtn_clicked()
|
||||
void DerpModEditDialog::on_viewResPackBtn_clicked()
|
||||
{
|
||||
openDirInDefaultProgram(m_inst->resourcePacksDir(), true);
|
||||
}
|
||||
|
||||
void OneSixModEditDialog::loaderCurrent(QModelIndex current, QModelIndex previous)
|
||||
void DerpModEditDialog::loaderCurrent(QModelIndex current, QModelIndex previous)
|
||||
{
|
||||
if (!current.isValid())
|
||||
{
|
@ -16,21 +16,21 @@
|
||||
#pragma once
|
||||
#include <QDialog>
|
||||
|
||||
#include <logic/OneSixInstance.h>
|
||||
#include <logic/DerpInstance.h>
|
||||
|
||||
class EnabledItemFilter;
|
||||
namespace Ui
|
||||
{
|
||||
class OneSixModEditDialog;
|
||||
class DerpModEditDialog;
|
||||
}
|
||||
|
||||
class OneSixModEditDialog : public QDialog
|
||||
class DerpModEditDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OneSixModEditDialog(OneSixInstance *inst, QWidget *parent = 0);
|
||||
virtual ~OneSixModEditDialog();
|
||||
explicit DerpModEditDialog(DerpInstance *inst, QWidget *parent = 0);
|
||||
virtual ~DerpModEditDialog();
|
||||
|
||||
private
|
||||
slots:
|
||||
@ -45,8 +45,6 @@ slots:
|
||||
void on_buttonBox_rejected();
|
||||
void on_forgeBtn_clicked();
|
||||
void on_liteloaderBtn_clicked();
|
||||
void on_customizeBtn_clicked();
|
||||
void on_revertBtn_clicked();
|
||||
void on_customEditorBtn_clicked();
|
||||
void updateVersionControls();
|
||||
void disableVersionControls();
|
||||
@ -57,12 +55,12 @@ protected:
|
||||
bool resourcePackListFilter(QKeyEvent *ev);
|
||||
|
||||
private:
|
||||
Ui::OneSixModEditDialog *ui;
|
||||
std::shared_ptr<OneSixVersion> m_version;
|
||||
Ui::DerpModEditDialog *ui;
|
||||
std::shared_ptr<DerpVersion> m_version;
|
||||
std::shared_ptr<ModList> m_mods;
|
||||
std::shared_ptr<ModList> m_resourcepacks;
|
||||
EnabledItemFilter *main_model;
|
||||
OneSixInstance *m_inst;
|
||||
DerpInstance *m_inst;
|
||||
public
|
||||
slots:
|
||||
void loaderCurrent(QModelIndex current, QModelIndex previous);
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OneSixModEditDialog</class>
|
||||
<widget class="QDialog" name="OneSixModEditDialog">
|
||||
<class>DerpModEditDialog</class>
|
||||
<widget class="QDialog" name="DerpModEditDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -84,29 +84,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="customizeBtn">
|
||||
<property name="toolTip">
|
||||
<string>Create an customized copy of the base version</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Customize</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="revertBtn">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Revert to original base version</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Revert</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="frameShadow">
|
@ -27,7 +27,7 @@
|
||||
class QDialog;
|
||||
class Task;
|
||||
class MinecraftProcess;
|
||||
class OneSixUpdate;
|
||||
class DerpUpdate;
|
||||
class InstanceList;
|
||||
class BaseInstancePrivate;
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
#include "OneSixFTBInstance.h"
|
||||
#include "DerpFTBInstance.h"
|
||||
|
||||
#include "OneSixVersion.h"
|
||||
#include "OneSixLibrary.h"
|
||||
#include "DerpVersion.h"
|
||||
#include "DerpLibrary.h"
|
||||
#include "tasks/SequentialTask.h"
|
||||
#include "ForgeInstaller.h"
|
||||
#include "lists/ForgeVersionList.h"
|
||||
#include "MultiMC.h"
|
||||
|
||||
class OneSixFTBInstanceForge : public Task
|
||||
class DerpFTBInstanceForge : public Task
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit OneSixFTBInstanceForge(const QString &version, OneSixFTBInstance *inst, QObject *parent = 0) :
|
||||
explicit DerpFTBInstanceForge(const QString &version, DerpFTBInstance *inst, QObject *parent = 0) :
|
||||
Task(parent), instance(inst), version("Forge " + version)
|
||||
{
|
||||
}
|
||||
@ -38,7 +38,7 @@ public:
|
||||
fjob = new NetJob("Forge download");
|
||||
fjob->addNetAction(CacheDownload::make(forgeVersion->installer_url, entry));
|
||||
connect(fjob, &NetJob::failed, [this](){emitFailed(m_failReason);});
|
||||
connect(fjob, &NetJob::succeeded, this, &OneSixFTBInstanceForge::installForge);
|
||||
connect(fjob, &NetJob::succeeded, this, &DerpFTBInstanceForge::installForge);
|
||||
connect(fjob, &NetJob::progress, [this](qint64 c, qint64 total){ setProgress(100 * c / total); });
|
||||
fjob->start();
|
||||
}
|
||||
@ -60,8 +60,6 @@ slots:
|
||||
emitFailed(tr("Couldn't load the version config"));
|
||||
return;
|
||||
}
|
||||
instance->revertCustomVersion();
|
||||
instance->customizeVersion();
|
||||
auto version = instance->getFullVersion();
|
||||
if (!forge.apply(version))
|
||||
{
|
||||
@ -72,41 +70,41 @@ slots:
|
||||
}
|
||||
|
||||
private:
|
||||
OneSixFTBInstance *instance;
|
||||
DerpFTBInstance *instance;
|
||||
QString version;
|
||||
ForgeVersionPtr forgeVersion;
|
||||
MetaEntryPtr entry;
|
||||
NetJob *fjob;
|
||||
};
|
||||
|
||||
OneSixFTBInstance::OneSixFTBInstance(const QString &rootDir, SettingsObject *settings, QObject *parent) :
|
||||
OneSixInstance(rootDir, settings, parent)
|
||||
DerpFTBInstance::DerpFTBInstance(const QString &rootDir, SettingsObject *settings, QObject *parent) :
|
||||
DerpInstance(rootDir, settings, parent)
|
||||
{
|
||||
QFile f(QDir(minecraftRoot()).absoluteFilePath("pack.json"));
|
||||
if (f.open(QFile::ReadOnly))
|
||||
{
|
||||
QString data = QString::fromUtf8(f.readAll());
|
||||
QRegularExpressionMatch match = QRegularExpression("net.minecraftforge:minecraftforge:[\\.\\d]*").match(data);
|
||||
m_forge.reset(new OneSixLibrary(match.captured()));
|
||||
m_forge.reset(new DerpLibrary(match.captured()));
|
||||
m_forge->finalize();
|
||||
}
|
||||
}
|
||||
|
||||
QString OneSixFTBInstance::id() const
|
||||
QString DerpFTBInstance::id() const
|
||||
{
|
||||
return "FTB/" + BaseInstance::id();
|
||||
}
|
||||
|
||||
QString OneSixFTBInstance::getStatusbarDescription()
|
||||
QString DerpFTBInstance::getStatusbarDescription()
|
||||
{
|
||||
return "OneSix FTB: " + intendedVersionId();
|
||||
return "Derp FTB: " + intendedVersionId();
|
||||
}
|
||||
bool OneSixFTBInstance::menuActionEnabled(QString action_name) const
|
||||
bool DerpFTBInstance::menuActionEnabled(QString action_name) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<Task> OneSixFTBInstance::doUpdate(bool only_prepare)
|
||||
std::shared_ptr<Task> DerpFTBInstance::doUpdate(bool only_prepare)
|
||||
{
|
||||
std::shared_ptr<SequentialTask> task;
|
||||
task.reset(new SequentialTask(this));
|
||||
@ -114,12 +112,12 @@ std::shared_ptr<Task> OneSixFTBInstance::doUpdate(bool only_prepare)
|
||||
{
|
||||
task->addTask(std::shared_ptr<Task>(MMC->forgelist()->getLoadTask()));
|
||||
}
|
||||
task->addTask(OneSixInstance::doUpdate(only_prepare));
|
||||
task->addTask(std::shared_ptr<Task>(new OneSixFTBInstanceForge(m_forge->version(), this, this)));
|
||||
task->addTask(DerpInstance::doUpdate(only_prepare));
|
||||
task->addTask(std::shared_ptr<Task>(new DerpFTBInstanceForge(m_forge->version(), this, this)));
|
||||
//FIXME: yes. this may appear dumb. but the previous step can change the list, so we do it all again.
|
||||
//TODO: Add a graph task. Construct graphs of tasks so we may capture the logic properly.
|
||||
task->addTask(OneSixInstance::doUpdate(only_prepare));
|
||||
task->addTask(DerpInstance::doUpdate(only_prepare));
|
||||
return task;
|
||||
}
|
||||
|
||||
#include "OneSixFTBInstance.moc"
|
||||
#include "DerpFTBInstance.moc"
|
@ -1,14 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "OneSixInstance.h"
|
||||
#include "DerpInstance.h"
|
||||
|
||||
class OneSixLibrary;
|
||||
class DerpLibrary;
|
||||
|
||||
class OneSixFTBInstance : public OneSixInstance
|
||||
class DerpFTBInstance : public DerpInstance
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit OneSixFTBInstance(const QString &rootDir, SettingsObject *settings,
|
||||
explicit DerpFTBInstance(const QString &rootDir, SettingsObject *settings,
|
||||
QObject *parent = 0);
|
||||
virtual QString getStatusbarDescription();
|
||||
virtual bool menuActionEnabled(QString action_name) const;
|
||||
@ -18,5 +18,5 @@ public:
|
||||
virtual QString id() const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<OneSixLibrary> m_forge;
|
||||
std::shared_ptr<DerpLibrary> m_forge;
|
||||
};
|
@ -13,37 +13,35 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "MultiMC.h"
|
||||
#include "OneSixInstance.h"
|
||||
#include "OneSixInstance_p.h"
|
||||
#include "OneSixUpdate.h"
|
||||
#include "MinecraftProcess.h"
|
||||
#include "OneSixVersion.h"
|
||||
#include "JavaChecker.h"
|
||||
#include "logic/icons/IconList.h"
|
||||
#include "DerpInstance.h"
|
||||
|
||||
#include <setting.h>
|
||||
#include <pathutils.h>
|
||||
#include <cmdutils.h>
|
||||
#include <JlCompress.h>
|
||||
#include "gui/dialogs/OneSixModEditDialog.h"
|
||||
#include "logger/QsLog.h"
|
||||
#include "logic/assets/AssetsUtils.h"
|
||||
#include <QIcon>
|
||||
|
||||
OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *setting_obj,
|
||||
QObject *parent)
|
||||
: BaseInstance(new OneSixInstancePrivate(), rootDir, setting_obj, parent)
|
||||
#include "DerpInstance_p.h"
|
||||
#include "DerpUpdate.h"
|
||||
#include "DerpVersion.h"
|
||||
#include "pathutils.h"
|
||||
#include "logger/QsLog.h"
|
||||
#include "assets/AssetsUtils.h"
|
||||
#include "MultiMC.h"
|
||||
#include "icons/IconList.h"
|
||||
#include "MinecraftProcess.h"
|
||||
#include "gui/dialogs/DerpModEditDialog.h"
|
||||
|
||||
DerpInstance::DerpInstance(const QString &rootDir, SettingsObject *settings, QObject *parent)
|
||||
: BaseInstance(new DerpInstancePrivate(), rootDir, settings, parent)
|
||||
{
|
||||
I_D(OneSixInstance);
|
||||
I_D(DerpInstance);
|
||||
d->m_settings->registerSetting("IntendedVersion", "");
|
||||
d->m_settings->registerSetting("ShouldUpdate", false);
|
||||
d->version.reset(new DerpVersion(this, this));
|
||||
reloadFullVersion();
|
||||
}
|
||||
|
||||
std::shared_ptr<Task> OneSixInstance::doUpdate(bool only_prepare)
|
||||
|
||||
std::shared_ptr<Task> DerpInstance::doUpdate(bool only_prepare)
|
||||
{
|
||||
return std::shared_ptr<Task>(new OneSixUpdate(this, only_prepare));
|
||||
return std::shared_ptr<Task>(new DerpUpdate(this, only_prepare));
|
||||
}
|
||||
|
||||
QString replaceTokensIn(QString text, QMap<QString, QString> with)
|
||||
@ -70,7 +68,7 @@ QString replaceTokensIn(QString text, QMap<QString, QString> with)
|
||||
return result;
|
||||
}
|
||||
|
||||
QDir OneSixInstance::reconstructAssets(std::shared_ptr<OneSixVersion> version)
|
||||
QDir DerpInstance::reconstructAssets(std::shared_ptr<DerpVersion> version)
|
||||
{
|
||||
QDir assetsDir = QDir("assets/");
|
||||
QDir indexDir = QDir(PathCombine(assetsDir.path(), "indexes"));
|
||||
@ -130,9 +128,9 @@ QDir OneSixInstance::reconstructAssets(std::shared_ptr<OneSixVersion> version)
|
||||
return virtualRoot;
|
||||
}
|
||||
|
||||
QStringList OneSixInstance::processMinecraftArgs(MojangAccountPtr account)
|
||||
QStringList DerpInstance::processMinecraftArgs(MojangAccountPtr account)
|
||||
{
|
||||
I_D(OneSixInstance);
|
||||
I_D(DerpInstance);
|
||||
auto version = d->version;
|
||||
QString args_pattern = version->minecraftArguments;
|
||||
|
||||
@ -182,9 +180,9 @@ QStringList OneSixInstance::processMinecraftArgs(MojangAccountPtr account)
|
||||
return parts;
|
||||
}
|
||||
|
||||
MinecraftProcess *OneSixInstance::prepareForLaunch(MojangAccountPtr account)
|
||||
MinecraftProcess *DerpInstance::prepareForLaunch(MojangAccountPtr account)
|
||||
{
|
||||
I_D(OneSixInstance);
|
||||
I_D(DerpInstance);
|
||||
|
||||
QIcon icon = MMC->icons()->getIcon(iconKey());
|
||||
auto pixmap = icon.pixmap(128, 128);
|
||||
@ -229,7 +227,9 @@ MinecraftProcess *OneSixInstance::prepareForLaunch(MojangAccountPtr account)
|
||||
QDir natives_dir(PathCombine(instanceRoot(), "natives/"));
|
||||
launchScript += "windowTitle " + windowTitle() + "\n";
|
||||
launchScript += "natives " + natives_dir.absolutePath() + "\n";
|
||||
launchScript += "launch onesix\n";
|
||||
launchScript += "launch onesix";
|
||||
|
||||
qDebug() << launchScript;
|
||||
|
||||
// create the process and set its parameters
|
||||
MinecraftProcess *proc = new MinecraftProcess(this);
|
||||
@ -239,16 +239,16 @@ MinecraftProcess *OneSixInstance::prepareForLaunch(MojangAccountPtr account)
|
||||
return proc;
|
||||
}
|
||||
|
||||
void OneSixInstance::cleanupAfterRun()
|
||||
void DerpInstance::cleanupAfterRun()
|
||||
{
|
||||
QString target_dir = PathCombine(instanceRoot(), "natives/");
|
||||
QDir dir(target_dir);
|
||||
dir.removeRecursively();
|
||||
}
|
||||
|
||||
std::shared_ptr<ModList> OneSixInstance::loaderModList()
|
||||
std::shared_ptr<ModList> DerpInstance::loaderModList()
|
||||
{
|
||||
I_D(OneSixInstance);
|
||||
I_D(DerpInstance);
|
||||
if (!d->loader_mod_list)
|
||||
{
|
||||
d->loader_mod_list.reset(new ModList(loaderModsDir()));
|
||||
@ -257,9 +257,9 @@ std::shared_ptr<ModList> OneSixInstance::loaderModList()
|
||||
return d->loader_mod_list;
|
||||
}
|
||||
|
||||
std::shared_ptr<ModList> OneSixInstance::resourcePackList()
|
||||
std::shared_ptr<ModList> DerpInstance::resourcePackList()
|
||||
{
|
||||
I_D(OneSixInstance);
|
||||
I_D(DerpInstance);
|
||||
if (!d->resource_pack_list)
|
||||
{
|
||||
d->resource_pack_list.reset(new ModList(resourcePacksDir()));
|
||||
@ -268,34 +268,32 @@ std::shared_ptr<ModList> OneSixInstance::resourcePackList()
|
||||
return d->resource_pack_list;
|
||||
}
|
||||
|
||||
QDialog *OneSixInstance::createModEditDialog(QWidget *parent)
|
||||
QDialog *DerpInstance::createModEditDialog(QWidget *parent)
|
||||
{
|
||||
return new OneSixModEditDialog(this, parent);
|
||||
return new DerpModEditDialog(this, parent);
|
||||
}
|
||||
|
||||
bool OneSixInstance::setIntendedVersionId(QString version)
|
||||
bool DerpInstance::setIntendedVersionId(QString version)
|
||||
{
|
||||
settings().set("IntendedVersion", version);
|
||||
setShouldUpdate(true);
|
||||
auto pathCustom = PathCombine(instanceRoot(), "custom.json");
|
||||
auto pathOrig = PathCombine(instanceRoot(), "version.json");
|
||||
QFile::remove(pathCustom);
|
||||
QFile::remove(pathOrig);
|
||||
reloadFullVersion();
|
||||
return true;
|
||||
}
|
||||
|
||||
QString OneSixInstance::intendedVersionId() const
|
||||
QString DerpInstance::intendedVersionId() const
|
||||
{
|
||||
return settings().get("IntendedVersion").toString();
|
||||
}
|
||||
|
||||
void OneSixInstance::setShouldUpdate(bool val)
|
||||
void DerpInstance::setShouldUpdate(bool val)
|
||||
{
|
||||
settings().set("ShouldUpdate", val);
|
||||
}
|
||||
|
||||
bool OneSixInstance::shouldUpdate() const
|
||||
bool DerpInstance::shouldUpdate() const
|
||||
{
|
||||
QVariant var = settings().get("ShouldUpdate");
|
||||
if (!var.isValid() || var.toBool() == false)
|
||||
@ -305,94 +303,53 @@ bool OneSixInstance::shouldUpdate() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OneSixInstance::versionIsCustom()
|
||||
bool DerpInstance::versionIsCustom()
|
||||
{
|
||||
QString verpath_custom = PathCombine(instanceRoot(), "custom.json");
|
||||
QFile versionfile(verpath_custom);
|
||||
return versionfile.exists();
|
||||
QDir patches(PathCombine(instanceRoot(), "patches/"));
|
||||
return QFile::exists(PathCombine(instanceRoot(), "custom.json"))
|
||||
|| (patches.exists() && patches.count() >= 0);
|
||||
}
|
||||
|
||||
QString OneSixInstance::currentVersionId() const
|
||||
QString DerpInstance::currentVersionId() const
|
||||
{
|
||||
return intendedVersionId();
|
||||
}
|
||||
|
||||
bool OneSixInstance::customizeVersion()
|
||||
bool DerpInstance::reloadFullVersion(QWidget *widgetParent)
|
||||
{
|
||||
if (!versionIsCustom())
|
||||
{
|
||||
auto pathCustom = PathCombine(instanceRoot(), "custom.json");
|
||||
auto pathOrig = PathCombine(instanceRoot(), "version.json");
|
||||
QFile::copy(pathOrig, pathCustom);
|
||||
return reloadFullVersion();
|
||||
}
|
||||
else
|
||||
return true;
|
||||
I_D(DerpInstance);
|
||||
|
||||
bool ret = d->version->reload(widgetParent);
|
||||
emit versionReloaded();
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool OneSixInstance::revertCustomVersion()
|
||||
std::shared_ptr<DerpVersion> DerpInstance::getFullVersion()
|
||||
{
|
||||
if (versionIsCustom())
|
||||
{
|
||||
auto path = PathCombine(instanceRoot(), "custom.json");
|
||||
QFile::remove(path);
|
||||
return reloadFullVersion();
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OneSixInstance::reloadFullVersion()
|
||||
{
|
||||
I_D(OneSixInstance);
|
||||
|
||||
QString verpath = PathCombine(instanceRoot(), "version.json");
|
||||
{
|
||||
QString verpath_custom = PathCombine(instanceRoot(), "custom.json");
|
||||
QFile versionfile(verpath_custom);
|
||||
if (versionfile.exists())
|
||||
verpath = verpath_custom;
|
||||
}
|
||||
|
||||
auto version = OneSixVersion::fromFile(verpath);
|
||||
if (version)
|
||||
{
|
||||
d->version = version;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
d->version.reset();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<OneSixVersion> OneSixInstance::getFullVersion()
|
||||
{
|
||||
I_D(OneSixInstance);
|
||||
I_D(DerpInstance);
|
||||
return d->version;
|
||||
}
|
||||
|
||||
QString OneSixInstance::defaultBaseJar() const
|
||||
QString DerpInstance::defaultBaseJar() const
|
||||
{
|
||||
return "versions/" + intendedVersionId() + "/" + intendedVersionId() + ".jar";
|
||||
}
|
||||
|
||||
QString OneSixInstance::defaultCustomBaseJar() const
|
||||
QString DerpInstance::defaultCustomBaseJar() const
|
||||
{
|
||||
return PathCombine(instanceRoot(), "custom.jar");
|
||||
}
|
||||
|
||||
bool OneSixInstance::menuActionEnabled(QString action_name) const
|
||||
bool DerpInstance::menuActionEnabled(QString action_name) const
|
||||
{
|
||||
if (action_name == "actionChangeInstLWJGLVersion")
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
QString OneSixInstance::getStatusbarDescription()
|
||||
QString DerpInstance::getStatusbarDescription()
|
||||
{
|
||||
QString descr = "One Six : " + intendedVersionId();
|
||||
QString descr = "Derp : " + intendedVersionId();
|
||||
if (versionIsCustom())
|
||||
{
|
||||
descr + " (custom)";
|
||||
@ -400,17 +357,17 @@ QString OneSixInstance::getStatusbarDescription()
|
||||
return descr;
|
||||
}
|
||||
|
||||
QString OneSixInstance::loaderModsDir() const
|
||||
QString DerpInstance::loaderModsDir() const
|
||||
{
|
||||
return PathCombine(minecraftRoot(), "mods");
|
||||
}
|
||||
|
||||
QString OneSixInstance::resourcePacksDir() const
|
||||
QString DerpInstance::resourcePacksDir() const
|
||||
{
|
||||
return PathCombine(minecraftRoot(), "resourcepacks");
|
||||
}
|
||||
|
||||
QString OneSixInstance::instanceConfigFolder() const
|
||||
QString DerpInstance::instanceConfigFolder() const
|
||||
{
|
||||
return PathCombine(minecraftRoot(), "config");
|
||||
}
|
@ -15,20 +15,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QStringList>
|
||||
#include <QDir>
|
||||
|
||||
#include "BaseInstance.h"
|
||||
|
||||
class OneSixVersion;
|
||||
class Task;
|
||||
class ModList;
|
||||
#include "DerpVersion.h"
|
||||
#include "ModList.h"
|
||||
|
||||
class OneSixInstance : public BaseInstance
|
||||
class DerpInstance : public BaseInstance
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit OneSixInstance(const QString &rootDir, SettingsObject *settings,
|
||||
explicit DerpInstance(const QString &rootDir, SettingsObject *settings,
|
||||
QObject *parent = 0);
|
||||
|
||||
////// Mod Lists //////
|
||||
@ -55,14 +51,10 @@ public:
|
||||
|
||||
virtual QDialog *createModEditDialog(QWidget *parent) override;
|
||||
|
||||
/// reload the full version json file. return true on success!
|
||||
bool reloadFullVersion();
|
||||
/// reload the full version json files. return true on success!
|
||||
bool reloadFullVersion(QWidget *widgetParent = 0);
|
||||
/// get the current full version info
|
||||
std::shared_ptr<OneSixVersion> getFullVersion();
|
||||
/// revert the current custom version back to base
|
||||
bool revertCustomVersion();
|
||||
/// customize the current base version
|
||||
bool customizeVersion();
|
||||
std::shared_ptr<DerpVersion> getFullVersion();
|
||||
/// is the current version original, or custom?
|
||||
virtual bool versionIsCustom() override;
|
||||
|
||||
@ -72,7 +64,10 @@ public:
|
||||
virtual bool menuActionEnabled(QString action_name) const override;
|
||||
virtual QString getStatusbarDescription() override;
|
||||
|
||||
signals:
|
||||
void versionReloaded();
|
||||
|
||||
private:
|
||||
QStringList processMinecraftArgs(MojangAccountPtr account);
|
||||
QDir reconstructAssets(std::shared_ptr<OneSixVersion> version);
|
||||
QDir reconstructAssets(std::shared_ptr<DerpVersion> version);
|
||||
};
|
@ -15,16 +15,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "BaseInstance_p.h"
|
||||
#include "DerpVersion.h"
|
||||
#include "ModList.h"
|
||||
|
||||
#include "logic/BaseInstance_p.h"
|
||||
#include "logic/OneSixVersion.h"
|
||||
#include "logic/OneSixLibrary.h"
|
||||
#include "logic/ModList.h"
|
||||
|
||||
struct OneSixInstancePrivate : public BaseInstancePrivate
|
||||
struct DerpInstancePrivate : public BaseInstancePrivate
|
||||
{
|
||||
std::shared_ptr<OneSixVersion> version;
|
||||
std::shared_ptr<DerpVersion> version;
|
||||
std::shared_ptr<ModList> loader_mod_list;
|
||||
std::shared_ptr<ModList> resource_pack_list;
|
||||
};
|
@ -15,15 +15,15 @@
|
||||
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "OneSixLibrary.h"
|
||||
#include "OneSixRule.h"
|
||||
#include "DerpLibrary.h"
|
||||
#include "DerpRule.h"
|
||||
#include "OpSys.h"
|
||||
#include "logic/net/URLConstants.h"
|
||||
#include <pathutils.h>
|
||||
#include <JlCompress.h>
|
||||
#include "logger/QsLog.h"
|
||||
|
||||
void OneSixLibrary::finalize()
|
||||
void DerpLibrary::finalize()
|
||||
{
|
||||
QStringList parts = m_name.split(':');
|
||||
QString relative = parts[0];
|
||||
@ -76,67 +76,67 @@ void OneSixLibrary::finalize()
|
||||
}
|
||||
}
|
||||
|
||||
void OneSixLibrary::setName(QString name)
|
||||
void DerpLibrary::setName(const QString &name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
void OneSixLibrary::setBaseUrl(QString base_url)
|
||||
void DerpLibrary::setBaseUrl(const QString &base_url)
|
||||
{
|
||||
m_base_url = base_url;
|
||||
}
|
||||
void OneSixLibrary::setIsNative()
|
||||
void DerpLibrary::setIsNative()
|
||||
{
|
||||
m_is_native = true;
|
||||
}
|
||||
void OneSixLibrary::addNative(OpSys os, QString suffix)
|
||||
void DerpLibrary::addNative(OpSys os, const QString &suffix)
|
||||
{
|
||||
m_is_native = true;
|
||||
m_native_suffixes[os] = suffix;
|
||||
}
|
||||
void OneSixLibrary::setRules(QList<std::shared_ptr<Rule>> rules)
|
||||
void DerpLibrary::setRules(QList<std::shared_ptr<Rule>> rules)
|
||||
{
|
||||
m_rules = rules;
|
||||
}
|
||||
bool OneSixLibrary::isActive()
|
||||
bool DerpLibrary::isActive() const
|
||||
{
|
||||
return m_is_active;
|
||||
}
|
||||
bool OneSixLibrary::isNative()
|
||||
bool DerpLibrary::isNative() const
|
||||
{
|
||||
return m_is_native;
|
||||
}
|
||||
QString OneSixLibrary::downloadUrl()
|
||||
QString DerpLibrary::downloadUrl() const
|
||||
{
|
||||
if (m_absolute_url.size())
|
||||
return m_absolute_url;
|
||||
return m_download_url;
|
||||
}
|
||||
QString OneSixLibrary::storagePath()
|
||||
QString DerpLibrary::storagePath() const
|
||||
{
|
||||
return m_storage_path;
|
||||
}
|
||||
|
||||
void OneSixLibrary::setAbsoluteUrl(QString absolute_url)
|
||||
void DerpLibrary::setAbsoluteUrl(const QString &absolute_url)
|
||||
{
|
||||
m_absolute_url = absolute_url;
|
||||
}
|
||||
|
||||
QString OneSixLibrary::absoluteUrl()
|
||||
QString DerpLibrary::absoluteUrl() const
|
||||
{
|
||||
return m_absolute_url;
|
||||
}
|
||||
|
||||
void OneSixLibrary::setHint(QString hint)
|
||||
void DerpLibrary::setHint(const QString &hint)
|
||||
{
|
||||
m_hint = hint;
|
||||
}
|
||||
|
||||
QString OneSixLibrary::hint()
|
||||
QString DerpLibrary::hint() const
|
||||
{
|
||||
return m_hint;
|
||||
}
|
||||
|
||||
bool OneSixLibrary::filesExist()
|
||||
bool DerpLibrary::filesExist()
|
||||
{
|
||||
QString storage = storagePath();
|
||||
if (storage.contains("${arch}"))
|
||||
@ -167,7 +167,7 @@ bool OneSixLibrary::filesExist()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OneSixLibrary::extractTo(QString target_dir)
|
||||
bool DerpLibrary::extractTo(QString target_dir)
|
||||
{
|
||||
QString storage = storagePath();
|
||||
if (storage.contains("${arch}"))
|
||||
@ -220,7 +220,7 @@ bool OneSixLibrary::extractTo(QString target_dir)
|
||||
return true;
|
||||
}
|
||||
|
||||
QJsonObject OneSixLibrary::toJson()
|
||||
QJsonObject DerpLibrary::toJson()
|
||||
{
|
||||
QJsonObject libRoot;
|
||||
libRoot.insert("name", m_name);
|
@ -26,7 +26,7 @@
|
||||
|
||||
class Rule;
|
||||
|
||||
class OneSixLibrary
|
||||
class DerpLibrary
|
||||
{
|
||||
private:
|
||||
// basic values used internally (so far)
|
||||
@ -63,7 +63,7 @@ public:
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
OneSixLibrary(QString name)
|
||||
DerpLibrary(const QString &name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
@ -84,48 +84,48 @@ public:
|
||||
void finalize();
|
||||
|
||||
/// Set the library composite name
|
||||
void setName(QString name);
|
||||
void setName(const QString &name);
|
||||
/// get a decent-looking name
|
||||
QString name()
|
||||
QString name() const
|
||||
{
|
||||
return m_decentname;
|
||||
}
|
||||
/// get a decent-looking version
|
||||
QString version()
|
||||
QString version() const
|
||||
{
|
||||
return m_decentversion;
|
||||
}
|
||||
/// what kind of library is it? (for display)
|
||||
QString type()
|
||||
QString type() const
|
||||
{
|
||||
return m_decenttype;
|
||||
}
|
||||
/// Set the url base for downloads
|
||||
void setBaseUrl(QString base_url);
|
||||
void setBaseUrl(const QString &base_url);
|
||||
|
||||
/// Call this to mark the library as 'native' (it's a zip archive with DLLs)
|
||||
void setIsNative();
|
||||
/// Attach a name suffix to the specified OS native
|
||||
void addNative(OpSys os, QString suffix);
|
||||
void addNative(OpSys os, const QString &suffix);
|
||||
/// Set the load rules
|
||||
void setRules(QList<std::shared_ptr<Rule>> rules);
|
||||
|
||||
/// Returns true if the library should be loaded (or extracted, in case of natives)
|
||||
bool isActive();
|
||||
bool isActive() const;
|
||||
/// Returns true if the library is native
|
||||
bool isNative();
|
||||
bool isNative() const;
|
||||
/// Get the URL to download the library from
|
||||
QString downloadUrl();
|
||||
QString downloadUrl() const;
|
||||
/// Get the relative path where the library should be saved
|
||||
QString storagePath();
|
||||
QString storagePath() const;
|
||||
|
||||
/// set an absolute URL for the library. This is an MMC extension.
|
||||
void setAbsoluteUrl(QString absolute_url);
|
||||
QString absoluteUrl();
|
||||
void setAbsoluteUrl(const QString &absolute_url);
|
||||
QString absoluteUrl() const;
|
||||
|
||||
/// set a hint about how to treat the library. This is an MMC extension.
|
||||
void setHint(QString hint);
|
||||
QString hint();
|
||||
void setHint(const QString &hint);
|
||||
QString hint() const;
|
||||
|
||||
bool extractTo(QString target_dir);
|
||||
bool filesExist();
|
@ -16,7 +16,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "OneSixRule.h"
|
||||
#include "DerpRule.h"
|
||||
|
||||
QList<std::shared_ptr<Rule>> rulesFromJsonV4(QJsonObject &objectWithRules)
|
||||
{
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "logic/OneSixLibrary.h"
|
||||
#include "logic/DerpLibrary.h"
|
||||
|
||||
enum RuleAction
|
||||
{
|
||||
@ -33,7 +33,7 @@ class Rule
|
||||
{
|
||||
protected:
|
||||
RuleAction m_result;
|
||||
virtual bool applies(OneSixLibrary *parent) = 0;
|
||||
virtual bool applies(DerpLibrary *parent) = 0;
|
||||
|
||||
public:
|
||||
Rule(RuleAction result) : m_result(result)
|
||||
@ -41,7 +41,7 @@ public:
|
||||
}
|
||||
virtual ~Rule() {};
|
||||
virtual QJsonObject toJson() = 0;
|
||||
RuleAction apply(OneSixLibrary *parent)
|
||||
RuleAction apply(DerpLibrary *parent)
|
||||
{
|
||||
if (applies(parent))
|
||||
return m_result;
|
||||
@ -60,7 +60,7 @@ private:
|
||||
QString m_version_regexp;
|
||||
|
||||
protected:
|
||||
virtual bool applies(OneSixLibrary *)
|
||||
virtual bool applies(DerpLibrary *)
|
||||
{
|
||||
return (m_system == currentSystem);
|
||||
}
|
||||
@ -81,7 +81,7 @@ public:
|
||||
class ImplicitRule : public Rule
|
||||
{
|
||||
protected:
|
||||
virtual bool applies(OneSixLibrary *)
|
||||
virtual bool applies(DerpLibrary *)
|
||||
{
|
||||
return true;
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "MultiMC.h"
|
||||
#include "OneSixUpdate.h"
|
||||
#include "DerpUpdate.h"
|
||||
|
||||
#include <QtNetwork>
|
||||
|
||||
@ -25,9 +25,9 @@
|
||||
|
||||
#include "BaseInstance.h"
|
||||
#include "lists/MinecraftVersionList.h"
|
||||
#include "OneSixVersion.h"
|
||||
#include "OneSixLibrary.h"
|
||||
#include "OneSixInstance.h"
|
||||
#include "DerpVersion.h"
|
||||
#include "DerpLibrary.h"
|
||||
#include "DerpInstance.h"
|
||||
#include "net/ForgeMirrors.h"
|
||||
#include "net/URLConstants.h"
|
||||
#include "assets/AssetsUtils.h"
|
||||
@ -35,12 +35,12 @@
|
||||
#include "pathutils.h"
|
||||
#include <JlCompress.h>
|
||||
|
||||
OneSixUpdate::OneSixUpdate(BaseInstance *inst, bool only_prepare, QObject *parent)
|
||||
DerpUpdate::DerpUpdate(BaseInstance *inst, bool only_prepare, QObject *parent)
|
||||
: Task(parent), m_inst(inst), m_only_prepare(only_prepare)
|
||||
{
|
||||
}
|
||||
|
||||
void OneSixUpdate::executeTask()
|
||||
void DerpUpdate::executeTask()
|
||||
{
|
||||
QString intendedVersion = m_inst->intendedVersionId();
|
||||
|
||||
@ -77,7 +77,7 @@ void OneSixUpdate::executeTask()
|
||||
}
|
||||
}
|
||||
|
||||
void OneSixUpdate::versionFileStart()
|
||||
void DerpUpdate::versionFileStart()
|
||||
{
|
||||
QLOG_INFO() << m_inst->name() << ": getting version file.";
|
||||
setStatus(tr("Getting the version files from Mojang..."));
|
||||
@ -94,10 +94,10 @@ void OneSixUpdate::versionFileStart()
|
||||
specificVersionDownloadJob->start();
|
||||
}
|
||||
|
||||
void OneSixUpdate::versionFileFinished()
|
||||
void DerpUpdate::versionFileFinished()
|
||||
{
|
||||
NetActionPtr DlJob = specificVersionDownloadJob->first();
|
||||
OneSixInstance *inst = (OneSixInstance *)m_inst;
|
||||
DerpInstance *inst = (DerpInstance *)m_inst;
|
||||
|
||||
QString version_id = targetVersion->descriptor();
|
||||
QString inst_dir = m_inst->instanceRoot();
|
||||
@ -142,16 +142,16 @@ void OneSixUpdate::versionFileFinished()
|
||||
jarlibStart();
|
||||
}
|
||||
|
||||
void OneSixUpdate::versionFileFailed()
|
||||
void DerpUpdate::versionFileFailed()
|
||||
{
|
||||
emitFailed("Failed to download the version description. Try again.");
|
||||
}
|
||||
|
||||
void OneSixUpdate::assetIndexStart()
|
||||
void DerpUpdate::assetIndexStart()
|
||||
{
|
||||
setStatus(tr("Updating assets index..."));
|
||||
OneSixInstance *inst = (OneSixInstance *)m_inst;
|
||||
std::shared_ptr<OneSixVersion> version = inst->getFullVersion();
|
||||
DerpInstance *inst = (DerpInstance *)m_inst;
|
||||
std::shared_ptr<DerpVersion> version = inst->getFullVersion();
|
||||
QString assetName = version->assets;
|
||||
QUrl indexUrl = "http://" + URLConstants::AWS_DOWNLOAD_INDEXES + assetName + ".json";
|
||||
QString localPath = assetName + ".json";
|
||||
@ -170,12 +170,12 @@ void OneSixUpdate::assetIndexStart()
|
||||
jarlibDownloadJob->start();
|
||||
}
|
||||
|
||||
void OneSixUpdate::assetIndexFinished()
|
||||
void DerpUpdate::assetIndexFinished()
|
||||
{
|
||||
AssetsIndex index;
|
||||
|
||||
OneSixInstance *inst = (OneSixInstance *)m_inst;
|
||||
std::shared_ptr<OneSixVersion> version = inst->getFullVersion();
|
||||
DerpInstance *inst = (DerpInstance *)m_inst;
|
||||
std::shared_ptr<DerpVersion> version = inst->getFullVersion();
|
||||
QString assetName = version->assets;
|
||||
|
||||
QString asset_fname = "assets/indexes/" + assetName + ".json";
|
||||
@ -215,26 +215,26 @@ void OneSixUpdate::assetIndexFinished()
|
||||
assetsFinished();
|
||||
}
|
||||
|
||||
void OneSixUpdate::assetIndexFailed()
|
||||
void DerpUpdate::assetIndexFailed()
|
||||
{
|
||||
emitFailed("Failed to download the assets index!");
|
||||
}
|
||||
|
||||
void OneSixUpdate::assetsFinished()
|
||||
void DerpUpdate::assetsFinished()
|
||||
{
|
||||
prepareForLaunch();
|
||||
}
|
||||
|
||||
void OneSixUpdate::assetsFailed()
|
||||
void DerpUpdate::assetsFailed()
|
||||
{
|
||||
emitFailed("Failed to download assets!");
|
||||
}
|
||||
|
||||
void OneSixUpdate::jarlibStart()
|
||||
void DerpUpdate::jarlibStart()
|
||||
{
|
||||
setStatus(tr("Getting the library files from Mojang..."));
|
||||
QLOG_INFO() << m_inst->name() << ": downloading libraries";
|
||||
OneSixInstance *inst = (OneSixInstance *)m_inst;
|
||||
DerpInstance *inst = (DerpInstance *)m_inst;
|
||||
bool successful = inst->reloadFullVersion();
|
||||
if (!successful)
|
||||
{
|
||||
@ -244,7 +244,7 @@ void OneSixUpdate::jarlibStart()
|
||||
}
|
||||
|
||||
// Build a list of URLs that will need to be downloaded.
|
||||
std::shared_ptr<OneSixVersion> version = inst->getFullVersion();
|
||||
std::shared_ptr<DerpVersion> version = inst->getFullVersion();
|
||||
// minecraft.jar for this version
|
||||
{
|
||||
QString version_id = version->id;
|
||||
@ -318,12 +318,12 @@ void OneSixUpdate::jarlibStart()
|
||||
jarlibDownloadJob->start();
|
||||
}
|
||||
|
||||
void OneSixUpdate::jarlibFinished()
|
||||
void DerpUpdate::jarlibFinished()
|
||||
{
|
||||
assetIndexStart();
|
||||
}
|
||||
|
||||
void OneSixUpdate::jarlibFailed()
|
||||
void DerpUpdate::jarlibFailed()
|
||||
{
|
||||
QStringList failed = jarlibDownloadJob->getFailedFiles();
|
||||
QString failed_all = failed.join("\n");
|
||||
@ -331,17 +331,17 @@ void OneSixUpdate::jarlibFailed()
|
||||
"\n\nPlease try again.");
|
||||
}
|
||||
|
||||
void OneSixUpdate::prepareForLaunch()
|
||||
void DerpUpdate::prepareForLaunch()
|
||||
{
|
||||
setStatus(tr("Preparing for launch..."));
|
||||
QLOG_INFO() << m_inst->name() << ": preparing for launch";
|
||||
auto onesix_inst = (OneSixInstance *)m_inst;
|
||||
auto derp_inst = (DerpInstance *)m_inst;
|
||||
|
||||
// delete any leftovers, if they are present.
|
||||
onesix_inst->cleanupAfterRun();
|
||||
derp_inst->cleanupAfterRun();
|
||||
|
||||
QString natives_dir_raw = PathCombine(onesix_inst->instanceRoot(), "natives/");
|
||||
auto version = onesix_inst->getFullVersion();
|
||||
QString natives_dir_raw = PathCombine(derp_inst->instanceRoot(), "natives/");
|
||||
auto version = derp_inst->getFullVersion();
|
||||
if (!version)
|
||||
{
|
||||
emitFailed("The version information for this instance is not complete. Try re-creating "
|
@ -25,11 +25,11 @@
|
||||
class MinecraftVersion;
|
||||
class BaseInstance;
|
||||
|
||||
class OneSixUpdate : public Task
|
||||
class DerpUpdate : public Task
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit OneSixUpdate(BaseInstance *inst, bool prepare_for_launch, QObject *parent = 0);
|
||||
explicit DerpUpdate(BaseInstance *inst, bool prepare_for_launch, QObject *parent = 0);
|
||||
virtual void executeTask();
|
||||
|
||||
private
|
164
logic/DerpVersion.cpp
Normal file
164
logic/DerpVersion.cpp
Normal file
@ -0,0 +1,164 @@
|
||||
/* Copyright 2013 MultiMC Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "DerpVersion.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "DerpVersionBuilder.h"
|
||||
|
||||
DerpVersion::DerpVersion(DerpInstance *instance, QObject *parent)
|
||||
: QAbstractListModel(parent), m_instance(instance)
|
||||
{
|
||||
}
|
||||
|
||||
bool DerpVersion::reload(QWidget *widgetParent)
|
||||
{
|
||||
return DerpVersionBuilder::build(this, m_instance, widgetParent);
|
||||
}
|
||||
|
||||
QList<std::shared_ptr<DerpLibrary> > DerpVersion::getActiveNormalLibs()
|
||||
{
|
||||
QList<std::shared_ptr<DerpLibrary> > output;
|
||||
for (auto lib : libraries)
|
||||
{
|
||||
if (lib->isActive() && !lib->isNative())
|
||||
{
|
||||
output.append(lib);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
QList<std::shared_ptr<DerpLibrary> > DerpVersion::getActiveNativeLibs()
|
||||
{
|
||||
QList<std::shared_ptr<DerpLibrary> > output;
|
||||
for (auto lib : libraries)
|
||||
{
|
||||
if (lib->isActive() && lib->isNative())
|
||||
{
|
||||
output.append(lib);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
QVariant DerpVersion::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
int row = index.row();
|
||||
int column = index.column();
|
||||
|
||||
if (row < 0 || row >= libraries.size())
|
||||
return QVariant();
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case 0:
|
||||
return libraries[row]->name();
|
||||
case 1:
|
||||
return libraries[row]->type();
|
||||
case 2:
|
||||
return libraries[row]->version();
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Qt::ItemFlags DerpVersion::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return Qt::NoItemFlags;
|
||||
int row = index.row();
|
||||
if (libraries[row]->isActive())
|
||||
{
|
||||
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemNeverHasChildren;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Qt::ItemNeverHasChildren;
|
||||
}
|
||||
// return QAbstractListModel::flags(index);
|
||||
}
|
||||
|
||||
QVariant DerpVersion::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || orientation != Qt::Horizontal)
|
||||
return QVariant();
|
||||
switch (section)
|
||||
{
|
||||
case 0:
|
||||
return QString("Name");
|
||||
case 1:
|
||||
return QString("Type");
|
||||
case 2:
|
||||
return QString("Version");
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
int DerpVersion::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return libraries.size();
|
||||
}
|
||||
|
||||
int DerpVersion::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug &dbg, const DerpVersion *version)
|
||||
{
|
||||
dbg.nospace() << "DerpVersion("
|
||||
<< "\n\tid=" << version->id
|
||||
<< "\n\ttime=" << version->time
|
||||
<< "\n\treleaseTime=" << version->releaseTime
|
||||
<< "\n\ttype=" << version->type
|
||||
<< "\n\tassets=" << version->assets
|
||||
<< "\n\tprocessArguments=" << version->processArguments
|
||||
<< "\n\tminecraftArguments=" << version->minecraftArguments
|
||||
<< "\n\tminimumLauncherVersion=" << version->minimumLauncherVersion
|
||||
<< "\n\tmainClass=" << version->mainClass
|
||||
<< "\n\tlibraries=";
|
||||
for (auto lib : version->libraries)
|
||||
{
|
||||
dbg.nospace() << "\n\t\t" << lib.get();
|
||||
}
|
||||
dbg.nospace() << "\n)";
|
||||
return dbg.maybeSpace();
|
||||
}
|
||||
QDebug operator<<(QDebug &dbg, const DerpLibrary *library)
|
||||
{
|
||||
dbg.nospace() << "DerpLibrary("
|
||||
<< "\n\t\t\trawName=" << library->rawName()
|
||||
<< "\n\t\t\tname=" << library->name()
|
||||
<< "\n\t\t\tversion=" << library->version()
|
||||
<< "\n\t\t\ttype=" << library->type()
|
||||
<< "\n\t\t\tisActive=" << library->isActive()
|
||||
<< "\n\t\t\tisNative=" << library->isNative()
|
||||
<< "\n\t\t\tdownloadUrl=" << library->downloadUrl()
|
||||
<< "\n\t\t\tstoragePath=" << library->storagePath()
|
||||
<< "\n\t\t\tabsolutePath=" << library->absoluteUrl()
|
||||
<< "\n\t\t\thint=" << library->hint();
|
||||
dbg.nospace() << "\n\t\t)";
|
||||
return dbg.maybeSpace();
|
||||
}
|
110
logic/DerpVersion.h
Normal file
110
logic/DerpVersion.h
Normal file
@ -0,0 +1,110 @@
|
||||
/* Copyright 2013 MultiMC Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <memory>
|
||||
|
||||
#include "DerpLibrary.h"
|
||||
|
||||
class DerpInstance;
|
||||
|
||||
class DerpVersion : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DerpVersion(DerpInstance *instance, QObject *parent = 0);
|
||||
|
||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const;
|
||||
virtual int columnCount(const QModelIndex &parent) const;
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
|
||||
bool reload(QWidget *widgetParent);
|
||||
|
||||
public:
|
||||
QList<std::shared_ptr<DerpLibrary>> getActiveNormalLibs();
|
||||
QList<std::shared_ptr<DerpLibrary>> getActiveNativeLibs();
|
||||
|
||||
// data members
|
||||
public:
|
||||
/// the ID - determines which jar to use! ACTUALLY IMPORTANT!
|
||||
QString id;
|
||||
/// Last updated time - as a string
|
||||
QString time;
|
||||
/// Release time - as a string
|
||||
QString releaseTime;
|
||||
/// Release type - "release" or "snapshot"
|
||||
QString type;
|
||||
/// Assets type - "legacy" or a version ID
|
||||
QString assets;
|
||||
/**
|
||||
* DEPRECATED: Old versions of the new vanilla launcher used this
|
||||
* ex: "username_session_version"
|
||||
*/
|
||||
QString processArguments;
|
||||
/**
|
||||
* arguments that should be used for launching minecraft
|
||||
*
|
||||
* ex: "--username ${auth_player_name} --session ${auth_session}
|
||||
* --version ${version_name} --gameDir ${game_directory} --assetsDir ${game_assets}"
|
||||
*/
|
||||
QString minecraftArguments;
|
||||
/**
|
||||
* the minimum launcher version required by this version ... current is 4 (at point of
|
||||
* writing)
|
||||
*/
|
||||
int minimumLauncherVersion = 0xDEADBEEF;
|
||||
/**
|
||||
* The main class to load first
|
||||
*/
|
||||
QString mainClass;
|
||||
|
||||
/// the list of libs - both active and inactive, native and java
|
||||
QList<std::shared_ptr<DerpLibrary>> libraries;
|
||||
|
||||
/*
|
||||
FIXME: add support for those rules here? Looks like a pile of quick hacks to me though.
|
||||
|
||||
"rules": [
|
||||
{
|
||||
"action": "allow"
|
||||
},
|
||||
{
|
||||
"action": "disallow",
|
||||
"os": {
|
||||
"name": "osx",
|
||||
"version": "^10\\.5\\.\\d$"
|
||||
}
|
||||
}
|
||||
],
|
||||
"incompatibilityReason": "There is a bug in LWJGL which makes it incompatible with OSX
|
||||
10.5.8. Please go to New Profile and use 1.5.2 for now. Sorry!"
|
||||
}
|
||||
*/
|
||||
// QList<Rule> rules;
|
||||
|
||||
private:
|
||||
DerpInstance *m_instance;
|
||||
};
|
||||
|
||||
QDebug operator<<(QDebug &dbg, const DerpVersion *version);
|
||||
QDebug operator<<(QDebug &dbg, const DerpLibrary *library);
|
279
logic/DerpVersionBuilder.cpp
Normal file
279
logic/DerpVersionBuilder.cpp
Normal file
@ -0,0 +1,279 @@
|
||||
/* Copyright 2013 MultiMC Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "DerpVersionBuilder.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QObject>
|
||||
#include <QDir>
|
||||
|
||||
#include "DerpVersion.h"
|
||||
#include "DerpInstance.h"
|
||||
#include "DerpRule.h"
|
||||
|
||||
DerpVersionBuilder::DerpVersionBuilder()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool DerpVersionBuilder::build(DerpVersion *version, DerpInstance *instance, QWidget *widgetParent)
|
||||
{
|
||||
DerpVersionBuilder builder;
|
||||
builder.m_version = version;
|
||||
builder.m_instance = instance;
|
||||
builder.m_widgetParent = widgetParent;
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
bool DerpVersionBuilder::build()
|
||||
{
|
||||
clear();
|
||||
|
||||
QDir root(m_instance->instanceRoot());
|
||||
QDir patches(root.absoluteFilePath("patches/"));
|
||||
|
||||
// version.json -> patches/*.json -> custom.json
|
||||
|
||||
// version.json
|
||||
{
|
||||
QJsonObject obj;
|
||||
if (!read(QFileInfo(root.absoluteFilePath("version.json")), &obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!apply(obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// patches/
|
||||
{
|
||||
// load all, put into map for ordering, apply in the right order
|
||||
|
||||
QMap<int, QJsonObject> objects;
|
||||
for (auto info : patches.entryInfoList(QStringList() << "*.json", QDir::Files))
|
||||
{
|
||||
QJsonObject obj;
|
||||
if (!read(info, &obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!obj.contains("order") || !obj.value("order").isDouble())
|
||||
{
|
||||
QMessageBox::critical(m_widgetParent, QObject::tr("Error"), QObject::tr("Missing or invalid 'order' in %1").arg(info.absoluteFilePath()));
|
||||
return false;
|
||||
}
|
||||
objects.insert(obj.value("order").toDouble(), obj);
|
||||
}
|
||||
for (auto object : objects.values())
|
||||
{
|
||||
if (!apply(object))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// custom.json
|
||||
{
|
||||
if (QFile::exists(root.absoluteFilePath("custom.json")))
|
||||
{
|
||||
QJsonObject obj;
|
||||
if (!read(QFileInfo(root.absoluteFilePath("custom.json")), &obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!apply(obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DerpVersionBuilder::clear()
|
||||
{
|
||||
m_version->id.clear();
|
||||
m_version->time.clear();
|
||||
m_version->releaseTime.clear();
|
||||
m_version->type.clear();
|
||||
m_version->assets.clear();
|
||||
m_version->processArguments.clear();
|
||||
m_version->minecraftArguments.clear();
|
||||
m_version->minimumLauncherVersion = 0xDEADBEAF;
|
||||
m_version->mainClass.clear();
|
||||
m_version->libraries.clear();
|
||||
}
|
||||
|
||||
void applyString(const QJsonObject &obj, const QString &key, QString &out)
|
||||
{
|
||||
if (obj.contains(key) && obj.value(key).isString())
|
||||
{
|
||||
out = obj.value(key).toString();
|
||||
}
|
||||
}
|
||||
void applyString(const QJsonObject &obj, const QString &key, std::shared_ptr<DerpLibrary> lib, void(DerpLibrary::*func)(const QString &val))
|
||||
{
|
||||
if (obj.contains(key) && obj.value(key).isString())
|
||||
{
|
||||
(lib.get()->*func)(obj.value(key).toString());
|
||||
}
|
||||
}
|
||||
bool DerpVersionBuilder::apply(const QJsonObject &object)
|
||||
{
|
||||
applyString(object, "id", m_version->id);
|
||||
applyString(object, "mainClass", m_version->mainClass);
|
||||
applyString(object, "processArguments", m_version->processArguments);
|
||||
{
|
||||
const QString toCompare = m_version->processArguments.toLower();
|
||||
if (toCompare == "legacy")
|
||||
{
|
||||
m_version->minecraftArguments = " ${auth_player_name} ${auth_session}";
|
||||
}
|
||||
else if (toCompare == "username_session")
|
||||
{
|
||||
m_version->minecraftArguments = "--username ${auth_player_name} --session ${auth_session}";
|
||||
}
|
||||
else if (toCompare == "username_session_version")
|
||||
{
|
||||
m_version->minecraftArguments = "--username ${auth_player_name} --session ${auth_session} --version ${profile_name}";
|
||||
}
|
||||
}
|
||||
applyString(object, "minecraftArguments", m_version->minecraftArguments);
|
||||
applyString(object, "type", m_version->type);
|
||||
applyString(object, "releaseTime", m_version->releaseTime);
|
||||
applyString(object, "time", m_version->time);
|
||||
applyString(object, "assets", m_version->assets);
|
||||
{
|
||||
if (m_version->assets.isEmpty())
|
||||
{
|
||||
m_version->assets = "legacy";
|
||||
}
|
||||
}
|
||||
if (object.contains("minimumLauncherVersion"))
|
||||
{
|
||||
auto minLauncherVersionVal = object.value("minimumLauncherVersion");
|
||||
if (minLauncherVersionVal.isDouble())
|
||||
{
|
||||
m_version->minimumLauncherVersion = minLauncherVersionVal.toDouble();
|
||||
}
|
||||
}
|
||||
|
||||
// libraries
|
||||
{
|
||||
auto librariesValue = object.value("libraries");
|
||||
if (!librariesValue.isArray())
|
||||
{
|
||||
QMessageBox::critical(m_widgetParent, QObject::tr("Error"), QObject::tr("One json files contains a libraries field, but it's not an array"));
|
||||
return false;
|
||||
}
|
||||
for (auto libVal : librariesValue.toArray())
|
||||
{
|
||||
if (!libVal.isObject())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
QJsonObject libObj = libVal.toObject();
|
||||
|
||||
// Library name
|
||||
auto nameVal = libObj.value("name");
|
||||
if (!nameVal.isString())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<DerpLibrary> library(new DerpLibrary(nameVal.toString()));
|
||||
|
||||
applyString(libObj, "url", library, &DerpLibrary::setBaseUrl);
|
||||
applyString(libObj, "MMC-hint", library, &DerpLibrary::setHint);
|
||||
applyString(libObj, "MMC-absulute_url", library, &DerpLibrary::setAbsoluteUrl);
|
||||
applyString(libObj, "MMC-absoluteUrl", library, &DerpLibrary::setAbsoluteUrl);
|
||||
|
||||
auto extractVal = libObj.value("extract");
|
||||
if (extractVal.isObject())
|
||||
{
|
||||
QStringList excludes;
|
||||
auto extractObj = extractVal.toObject();
|
||||
auto excludesVal = extractObj.value("exclude");
|
||||
if (excludesVal.isArray())
|
||||
{
|
||||
auto excludesList = excludesVal.toArray();
|
||||
for (auto excludeVal : excludesList)
|
||||
{
|
||||
if (excludeVal.isString())
|
||||
{
|
||||
excludes.append(excludeVal.toString());
|
||||
}
|
||||
}
|
||||
library->extract_excludes = excludes;
|
||||
}
|
||||
}
|
||||
|
||||
auto nativesVal = libObj.value("natives");
|
||||
if (nativesVal.isObject())
|
||||
{
|
||||
library->setIsNative();
|
||||
auto nativesObj = nativesVal.toObject();
|
||||
for (auto it = nativesObj.begin(); it != nativesObj.end(); ++it)
|
||||
{
|
||||
auto osType = OpSys_fromString(it.key());
|
||||
if (osType == Os_Other)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!it.value().isString())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
library->addNative(osType, it.value().toString());
|
||||
}
|
||||
}
|
||||
|
||||
library->setRules(rulesFromJsonV4(libObj));
|
||||
library->finalize();
|
||||
m_version->libraries.append(library);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DerpVersionBuilder::read(const QFileInfo &fileInfo, QJsonObject *out)
|
||||
{
|
||||
QFile file(fileInfo.absoluteFilePath());
|
||||
if (!file.open(QFile::ReadOnly))
|
||||
{
|
||||
QMessageBox::critical(m_widgetParent, QObject::tr("Error"), QObject::tr("Unable to open %1: %2").arg(file.fileName(), file.errorString()));
|
||||
return false;
|
||||
}
|
||||
QJsonParseError error;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(file.readAll(), &error);
|
||||
if (error.error != QJsonParseError::NoError)
|
||||
{
|
||||
QMessageBox::critical(m_widgetParent, QObject::tr("Error"), QObject::tr("Unable to parse %1: %2 at %3").arg(file.fileName(), error.errorString()).arg(error.offset));
|
||||
return false;
|
||||
}
|
||||
*out = doc.object();
|
||||
return true;
|
||||
}
|
43
logic/DerpVersionBuilder.h
Normal file
43
logic/DerpVersionBuilder.h
Normal file
@ -0,0 +1,43 @@
|
||||
/* Copyright 2013 MultiMC Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
class DerpVersion;
|
||||
class DerpInstance;
|
||||
class QWidget;
|
||||
class QJsonObject;
|
||||
class QFileInfo;
|
||||
|
||||
class DerpVersionBuilder
|
||||
{
|
||||
DerpVersionBuilder();
|
||||
public:
|
||||
static bool build(DerpVersion *version, DerpInstance *instance, QWidget *widgetParent);
|
||||
|
||||
private:
|
||||
DerpVersion *m_version;
|
||||
DerpInstance *m_instance;
|
||||
QWidget *m_widgetParent;
|
||||
|
||||
bool build();
|
||||
|
||||
void clear();
|
||||
bool apply(const QJsonObject &object);
|
||||
|
||||
bool read(const QFileInfo &fileInfo, QJsonObject *out);
|
||||
};
|
@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
#include "ForgeInstaller.h"
|
||||
#include "OneSixVersion.h"
|
||||
#include "OneSixLibrary.h"
|
||||
#include "DerpVersion.h"
|
||||
#include "DerpLibrary.h"
|
||||
#include "net/HttpMetaCache.h"
|
||||
#include <quazip.h>
|
||||
#include <quazipfile.h>
|
||||
@ -23,9 +23,15 @@
|
||||
#include <QStringList>
|
||||
#include "MultiMC.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QSaveFile>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
// DERPFIX
|
||||
|
||||
ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
|
||||
{
|
||||
std::shared_ptr<OneSixVersion> newVersion;
|
||||
std::shared_ptr<DerpVersion> newVersion;
|
||||
m_universal_url = universal_url;
|
||||
|
||||
QuaZip zip(filename);
|
||||
@ -58,7 +64,7 @@ ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
|
||||
|
||||
// read the forge version info
|
||||
{
|
||||
newVersion = OneSixVersion::fromJson(versionInfoVal.toObject());
|
||||
// DERPFIX newVersion = DerpVersion::fromJson(versionInfoVal.toObject());
|
||||
if (!newVersion)
|
||||
return;
|
||||
}
|
||||
@ -68,7 +74,7 @@ ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
|
||||
internalPath = installObj.value("filePath").toString();
|
||||
|
||||
// where do we put the library? decode the mojang path
|
||||
OneSixLibrary lib(libraryName);
|
||||
DerpLibrary lib(libraryName);
|
||||
lib.finalize();
|
||||
|
||||
auto cacheentry = MMC->metacache()->resolveEntry("libraries", lib.storagePath());
|
||||
@ -103,11 +109,10 @@ ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
|
||||
realVersionId = m_forge_version->id = installObj.value("minecraft").toString();
|
||||
}
|
||||
|
||||
bool ForgeInstaller::apply(std::shared_ptr<OneSixVersion> to)
|
||||
bool ForgeInstaller::apply(std::shared_ptr<DerpVersion> to)
|
||||
{
|
||||
if (!m_forge_version)
|
||||
return false;
|
||||
to->externalUpdateStart();
|
||||
int sliding_insert_window = 0;
|
||||
{
|
||||
// for each library in the version we are adding (except for the blacklisted)
|
||||
@ -150,6 +155,5 @@ bool ForgeInstaller::apply(std::shared_ptr<OneSixVersion> to)
|
||||
to->minecraftArguments = m_forge_version->minecraftArguments;
|
||||
to->processArguments = m_forge_version->processArguments;
|
||||
}
|
||||
to->externalUpdateFinish();
|
||||
return to->toOriginalFile();
|
||||
return true;
|
||||
}
|
||||
|
@ -17,18 +17,18 @@
|
||||
#include <QString>
|
||||
#include <memory>
|
||||
|
||||
class OneSixVersion;
|
||||
class DerpVersion;
|
||||
|
||||
class ForgeInstaller
|
||||
{
|
||||
public:
|
||||
ForgeInstaller(QString filename, QString universal_url);
|
||||
|
||||
bool apply(std::shared_ptr<OneSixVersion> to);
|
||||
bool apply(std::shared_ptr<DerpVersion> to);
|
||||
|
||||
private:
|
||||
// the version, read from the installer
|
||||
std::shared_ptr<OneSixVersion> m_forge_version;
|
||||
std::shared_ptr<DerpVersion> m_forge_version;
|
||||
QString internalPath;
|
||||
QString finalPath;
|
||||
QString realVersionId;
|
||||
|
@ -21,9 +21,10 @@
|
||||
#include "BaseInstance.h"
|
||||
#include "LegacyInstance.h"
|
||||
#include "LegacyFTBInstance.h"
|
||||
#include "OneSixInstance.h"
|
||||
#include "OneSixFTBInstance.h"
|
||||
#include "DerpInstance.h"
|
||||
#include "DerpFTBInstance.h"
|
||||
#include "NostalgiaInstance.h"
|
||||
#include "DerpInstance.h"
|
||||
#include "BaseVersion.h"
|
||||
#include "MinecraftVersion.h"
|
||||
|
||||
@ -50,14 +51,14 @@ InstanceFactory::InstLoadError InstanceFactory::loadInstance(BaseInstance *&inst
|
||||
QString inst_type = m_settings->get("InstanceType").toString();
|
||||
|
||||
// FIXME: replace with a map lookup, where instance classes register their types
|
||||
if (inst_type == "Legacy")
|
||||
if (inst_type == "Derp" || inst_type == "OneSix")
|
||||
{
|
||||
inst = new DerpInstance(instDir, m_settings, this);
|
||||
}
|
||||
else if (inst_type == "Legacy")
|
||||
{
|
||||
inst = new LegacyInstance(instDir, m_settings, this);
|
||||
}
|
||||
else if (inst_type == "OneSix")
|
||||
{
|
||||
inst = new OneSixInstance(instDir, m_settings, this);
|
||||
}
|
||||
else if (inst_type == "Nostalgia")
|
||||
{
|
||||
inst = new NostalgiaInstance(instDir, m_settings, this);
|
||||
@ -66,9 +67,9 @@ InstanceFactory::InstLoadError InstanceFactory::loadInstance(BaseInstance *&inst
|
||||
{
|
||||
inst = new LegacyFTBInstance(instDir, m_settings, this);
|
||||
}
|
||||
else if (inst_type == "OneSixFTB")
|
||||
else if (inst_type == "OneSixFTB" || inst_type == "DerpFTB")
|
||||
{
|
||||
inst = new OneSixFTBInstance(instDir, m_settings, this);
|
||||
inst = new DerpFTBInstance(instDir, m_settings, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -101,14 +102,15 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *&
|
||||
switch (mcVer->type)
|
||||
{
|
||||
case MinecraftVersion::Legacy:
|
||||
// TODO derp
|
||||
m_settings->set("InstanceType", "Legacy");
|
||||
inst = new LegacyInstance(instDir, m_settings, this);
|
||||
inst->setIntendedVersionId(version->descriptor());
|
||||
inst->setShouldUseCustomBaseJar(false);
|
||||
break;
|
||||
case MinecraftVersion::OneSix:
|
||||
m_settings->set("InstanceType", "OneSix");
|
||||
inst = new OneSixInstance(instDir, m_settings, this);
|
||||
case MinecraftVersion::Derp:
|
||||
m_settings->set("InstanceType", "Derp");
|
||||
inst = new DerpInstance(instDir, m_settings, this);
|
||||
inst->setIntendedVersionId(version->descriptor());
|
||||
inst->setShouldUseCustomBaseJar(false);
|
||||
break;
|
||||
@ -135,9 +137,9 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *&
|
||||
inst->setIntendedVersionId(version->descriptor());
|
||||
inst->setShouldUseCustomBaseJar(false);
|
||||
break;
|
||||
case MinecraftVersion::OneSix:
|
||||
m_settings->set("InstanceType", "OneSixFTB");
|
||||
inst = new OneSixFTBInstance(instDir, m_settings, this);
|
||||
case MinecraftVersion::Derp:
|
||||
m_settings->set("InstanceType", "DerpFTB");
|
||||
inst = new DerpFTBInstance(instDir, m_settings, this);
|
||||
inst->setIntendedVersionId(version->descriptor());
|
||||
inst->setShouldUseCustomBaseJar(false);
|
||||
break;
|
||||
@ -174,8 +176,8 @@ InstanceFactory::InstCreateError InstanceFactory::copyInstance(BaseInstance *&ne
|
||||
m_settings->registerSetting("InstanceType", "Legacy");
|
||||
QString inst_type = m_settings->get("InstanceType").toString();
|
||||
|
||||
if(inst_type == "OneSixFTB")
|
||||
m_settings->set("InstanceType", "OneSix");
|
||||
if(inst_type == "OneSixFTB" || inst_type == "DerpFTB")
|
||||
m_settings->set("InstanceType", "Derp");
|
||||
if(inst_type == "LegacyFTB")
|
||||
m_settings->set("InstanceType", "Legacy");
|
||||
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
virtual QString intendedVersionId() const override;
|
||||
virtual bool setIntendedVersionId(QString version) override;
|
||||
// the `version' of Legacy instances is defined by the launcher code.
|
||||
// in contrast with OneSix, where `version' is described in a json file
|
||||
// in contrast with Derp, where `version' is described in a json file
|
||||
virtual bool versionIsCustom() override
|
||||
{
|
||||
return false;
|
||||
|
@ -15,8 +15,8 @@
|
||||
|
||||
#include "LiteLoaderInstaller.h"
|
||||
|
||||
#include "OneSixVersion.h"
|
||||
#include "OneSixLibrary.h"
|
||||
#include "DerpVersion.h"
|
||||
#include "DerpLibrary.h"
|
||||
|
||||
QMap<QString, QString> LiteLoaderInstaller::m_launcherWrapperVersionMapping;
|
||||
|
||||
@ -36,9 +36,9 @@ bool LiteLoaderInstaller::canApply() const
|
||||
return m_launcherWrapperVersionMapping.contains(m_mcVersion);
|
||||
}
|
||||
|
||||
bool LiteLoaderInstaller::apply(std::shared_ptr<OneSixVersion> to)
|
||||
bool LiteLoaderInstaller::apply(std::shared_ptr<DerpVersion> to)
|
||||
{
|
||||
to->externalUpdateStart();
|
||||
// DERPFIX
|
||||
|
||||
applyLaunchwrapper(to);
|
||||
applyLiteLoader(to);
|
||||
@ -51,15 +51,14 @@ bool LiteLoaderInstaller::apply(std::shared_ptr<OneSixVersion> to)
|
||||
" --tweakClass com.mumfrey.liteloader.launch.LiteLoaderTweaker");
|
||||
}
|
||||
|
||||
to->externalUpdateFinish();
|
||||
return to->toOriginalFile();
|
||||
return true;
|
||||
}
|
||||
|
||||
void LiteLoaderInstaller::applyLaunchwrapper(std::shared_ptr<OneSixVersion> to)
|
||||
void LiteLoaderInstaller::applyLaunchwrapper(std::shared_ptr<DerpVersion> to)
|
||||
{
|
||||
const QString intendedVersion = m_launcherWrapperVersionMapping[m_mcVersion];
|
||||
|
||||
QMutableListIterator<std::shared_ptr<OneSixLibrary>> it(to->libraries);
|
||||
QMutableListIterator<std::shared_ptr<DerpLibrary>> it(to->libraries);
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
@ -76,15 +75,15 @@ void LiteLoaderInstaller::applyLaunchwrapper(std::shared_ptr<OneSixVersion> to)
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<OneSixLibrary> lib(new OneSixLibrary(
|
||||
std::shared_ptr<DerpLibrary> lib(new DerpLibrary(
|
||||
"net.minecraft:launchwrapper:" + m_launcherWrapperVersionMapping[m_mcVersion]));
|
||||
lib->finalize();
|
||||
to->libraries.prepend(lib);
|
||||
}
|
||||
|
||||
void LiteLoaderInstaller::applyLiteLoader(std::shared_ptr<OneSixVersion> to)
|
||||
void LiteLoaderInstaller::applyLiteLoader(std::shared_ptr<DerpVersion> to)
|
||||
{
|
||||
QMutableListIterator<std::shared_ptr<OneSixLibrary>> it(to->libraries);
|
||||
QMutableListIterator<std::shared_ptr<DerpLibrary>> it(to->libraries);
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
@ -94,8 +93,8 @@ void LiteLoaderInstaller::applyLiteLoader(std::shared_ptr<OneSixVersion> to)
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<OneSixLibrary> lib(
|
||||
new OneSixLibrary("com.mumfrey:liteloader:" + m_mcVersion));
|
||||
std::shared_ptr<DerpLibrary> lib(
|
||||
new DerpLibrary("com.mumfrey:liteloader:" + m_mcVersion));
|
||||
lib->setBaseUrl("http://dl.liteloader.com/versions/");
|
||||
lib->finalize();
|
||||
to->libraries.prepend(lib);
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include <QMap>
|
||||
#include <memory>
|
||||
|
||||
class OneSixVersion;
|
||||
class DerpVersion;
|
||||
|
||||
class LiteLoaderInstaller
|
||||
{
|
||||
@ -27,13 +27,13 @@ public:
|
||||
|
||||
bool canApply() const;
|
||||
|
||||
bool apply(std::shared_ptr<OneSixVersion> to);
|
||||
bool apply(std::shared_ptr<DerpVersion> to);
|
||||
|
||||
private:
|
||||
QString m_mcVersion;
|
||||
|
||||
void applyLaunchwrapper(std::shared_ptr<OneSixVersion> to);
|
||||
void applyLiteLoader(std::shared_ptr<OneSixVersion> to);
|
||||
void applyLaunchwrapper(std::shared_ptr<DerpVersion> to);
|
||||
void applyLiteLoader(std::shared_ptr<DerpVersion> to);
|
||||
|
||||
static QMap<QString, QString> m_launcherWrapperVersionMapping;
|
||||
};
|
||||
|
@ -32,7 +32,7 @@ struct MinecraftVersion : public BaseVersion
|
||||
/// This version's type. Used internally to identify what kind of version this is.
|
||||
enum VersionType
|
||||
{
|
||||
OneSix,
|
||||
Derp,
|
||||
Legacy,
|
||||
Nostalgia
|
||||
} type;
|
||||
@ -66,8 +66,8 @@ struct MinecraftVersion : public BaseVersion
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case OneSix:
|
||||
pre_final.append("OneSix");
|
||||
case Derp:
|
||||
pre_final.append("Derp");
|
||||
break;
|
||||
case Legacy:
|
||||
pre_final.append("Legacy");
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
NostalgiaInstance::NostalgiaInstance(const QString &rootDir, SettingsObject *settings,
|
||||
QObject *parent)
|
||||
: OneSixInstance(rootDir, settings, parent)
|
||||
: DerpInstance(rootDir, settings, parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "OneSixInstance.h"
|
||||
#include "DerpInstance.h"
|
||||
|
||||
class NostalgiaInstance : public OneSixInstance
|
||||
class NostalgiaInstance : public DerpInstance
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -13,14 +13,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "logic/OneSixVersion.h"
|
||||
#include "logic/OneSixLibrary.h"
|
||||
#include "logic/OneSixRule.h"
|
||||
#include "logic/DerpVersion.h"
|
||||
#include "logic/DerpLibrary.h"
|
||||
#include "logic/DerpRule.h"
|
||||
|
||||
#include "logger/QsLog.h"
|
||||
|
||||
std::shared_ptr<OneSixVersion> fromJsonV4(QJsonObject root,
|
||||
std::shared_ptr<OneSixVersion> fullVersion)
|
||||
std::shared_ptr<DerpVersion> fromJsonV4(QJsonObject root,
|
||||
std::shared_ptr<DerpVersion> fullVersion)
|
||||
{
|
||||
fullVersion->id = root.value("id").toString();
|
||||
|
||||
@ -93,7 +93,7 @@ std::shared_ptr<OneSixVersion> fromJsonV4(QJsonObject root,
|
||||
auto nameVal = libObj.value("name");
|
||||
if (!nameVal.isString())
|
||||
continue;
|
||||
std::shared_ptr<OneSixLibrary> library(new OneSixLibrary(nameVal.toString()));
|
||||
std::shared_ptr<DerpLibrary> library(new DerpLibrary(nameVal.toString()));
|
||||
|
||||
auto urlVal = libObj.value("url");
|
||||
if (urlVal.isString())
|
||||
@ -158,9 +158,9 @@ std::shared_ptr<OneSixVersion> fromJsonV4(QJsonObject root,
|
||||
return fullVersion;
|
||||
}
|
||||
|
||||
std::shared_ptr<OneSixVersion> OneSixVersion::fromJson(QJsonObject root)
|
||||
std::shared_ptr<DerpVersion> DerpVersion::fromJson(QJsonObject root)
|
||||
{
|
||||
std::shared_ptr<OneSixVersion> readVersion(new OneSixVersion());
|
||||
std::shared_ptr<DerpVersion> readVersion(new DerpVersion());
|
||||
int launcher_ver = readVersion->minimumLauncherVersion =
|
||||
root.value("minimumLauncherVersion").toDouble();
|
||||
|
||||
@ -169,16 +169,16 @@ std::shared_ptr<OneSixVersion> OneSixVersion::fromJson(QJsonObject root)
|
||||
return fromJsonV4(root, readVersion);
|
||||
else
|
||||
{
|
||||
return std::shared_ptr<OneSixVersion>();
|
||||
return std::shared_ptr<DerpVersion>();
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<OneSixVersion> OneSixVersion::fromFile(QString filepath)
|
||||
std::shared_ptr<DerpVersion> DerpVersion::fromFile(QString filepath)
|
||||
{
|
||||
QFile file(filepath);
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
return std::shared_ptr<OneSixVersion>();
|
||||
return std::shared_ptr<DerpVersion>();
|
||||
}
|
||||
|
||||
auto data = file.readAll();
|
||||
@ -187,12 +187,12 @@ std::shared_ptr<OneSixVersion> OneSixVersion::fromFile(QString filepath)
|
||||
|
||||
if (jsonError.error != QJsonParseError::NoError)
|
||||
{
|
||||
return std::shared_ptr<OneSixVersion>();
|
||||
return std::shared_ptr<DerpVersion>();
|
||||
}
|
||||
|
||||
if (!jsonDoc.isObject())
|
||||
{
|
||||
return std::shared_ptr<OneSixVersion>();
|
||||
return std::shared_ptr<DerpVersion>();
|
||||
}
|
||||
QJsonObject root = jsonDoc.object();
|
||||
auto version = fromJson(root);
|
||||
@ -201,7 +201,7 @@ std::shared_ptr<OneSixVersion> OneSixVersion::fromFile(QString filepath)
|
||||
return version;
|
||||
}
|
||||
|
||||
bool OneSixVersion::toOriginalFile()
|
||||
bool DerpVersion::toOriginalFile()
|
||||
{
|
||||
if (original_file.isEmpty())
|
||||
return false;
|
||||
@ -232,9 +232,9 @@ bool OneSixVersion::toOriginalFile()
|
||||
return file.commit();
|
||||
}
|
||||
|
||||
QList<std::shared_ptr<OneSixLibrary>> OneSixVersion::getActiveNormalLibs()
|
||||
QList<std::shared_ptr<DerpLibrary>> DerpVersion::getActiveNormalLibs()
|
||||
{
|
||||
QList<std::shared_ptr<OneSixLibrary>> output;
|
||||
QList<std::shared_ptr<DerpLibrary>> output;
|
||||
for (auto lib : libraries)
|
||||
{
|
||||
if (lib->isActive() && !lib->isNative())
|
||||
@ -245,9 +245,9 @@ QList<std::shared_ptr<OneSixLibrary>> OneSixVersion::getActiveNormalLibs()
|
||||
return output;
|
||||
}
|
||||
|
||||
QList<std::shared_ptr<OneSixLibrary>> OneSixVersion::getActiveNativeLibs()
|
||||
QList<std::shared_ptr<DerpLibrary>> DerpVersion::getActiveNativeLibs()
|
||||
{
|
||||
QList<std::shared_ptr<OneSixLibrary>> output;
|
||||
QList<std::shared_ptr<DerpLibrary>> output;
|
||||
for (auto lib : libraries)
|
||||
{
|
||||
if (lib->isActive() && lib->isNative())
|
||||
@ -258,17 +258,17 @@ QList<std::shared_ptr<OneSixLibrary>> OneSixVersion::getActiveNativeLibs()
|
||||
return output;
|
||||
}
|
||||
|
||||
void OneSixVersion::externalUpdateStart()
|
||||
void DerpVersion::externalUpdateStart()
|
||||
{
|
||||
beginResetModel();
|
||||
}
|
||||
|
||||
void OneSixVersion::externalUpdateFinish()
|
||||
void DerpVersion::externalUpdateFinish()
|
||||
{
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
QVariant OneSixVersion::data(const QModelIndex &index, int role) const
|
||||
QVariant DerpVersion::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
@ -296,7 +296,7 @@ QVariant OneSixVersion::data(const QModelIndex &index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Qt::ItemFlags OneSixVersion::flags(const QModelIndex &index) const
|
||||
Qt::ItemFlags DerpVersion::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return Qt::NoItemFlags;
|
||||
@ -312,7 +312,7 @@ Qt::ItemFlags OneSixVersion::flags(const QModelIndex &index) const
|
||||
// return QAbstractListModel::flags(index);
|
||||
}
|
||||
|
||||
QVariant OneSixVersion::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
QVariant DerpVersion::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || orientation != Qt::Horizontal)
|
||||
return QVariant();
|
||||
@ -329,12 +329,12 @@ QVariant OneSixVersion::headerData(int section, Qt::Orientation orientation, int
|
||||
}
|
||||
}
|
||||
|
||||
int OneSixVersion::rowCount(const QModelIndex &parent) const
|
||||
int DerpVersion::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return libraries.size();
|
||||
}
|
||||
|
||||
int OneSixVersion::columnCount(const QModelIndex &parent) const
|
||||
int DerpVersion::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
@ -17,9 +17,9 @@
|
||||
#include <QtCore>
|
||||
#include <memory>
|
||||
|
||||
class OneSixLibrary;
|
||||
class DerpLibrary;
|
||||
|
||||
class OneSixVersion : public QAbstractListModel
|
||||
class DerpVersion : public QAbstractListModel
|
||||
{
|
||||
// Things required to implement the Qt list model
|
||||
public:
|
||||
@ -33,12 +33,12 @@ public:
|
||||
// serialization/deserialization
|
||||
public:
|
||||
bool toOriginalFile();
|
||||
static std::shared_ptr<OneSixVersion> fromJson(QJsonObject root);
|
||||
static std::shared_ptr<OneSixVersion> fromFile(QString filepath);
|
||||
static std::shared_ptr<DerpVersion> fromJson(QJsonObject root);
|
||||
static std::shared_ptr<DerpVersion> fromFile(QString filepath);
|
||||
|
||||
public:
|
||||
QList<std::shared_ptr<OneSixLibrary>> getActiveNormalLibs();
|
||||
QList<std::shared_ptr<OneSixLibrary>> getActiveNativeLibs();
|
||||
QList<std::shared_ptr<DerpLibrary>> getActiveNormalLibs();
|
||||
QList<std::shared_ptr<DerpLibrary>> getActiveNativeLibs();
|
||||
// called when something starts/stops messing with the object
|
||||
// FIXME: these are ugly in every possible way.
|
||||
void externalUpdateStart();
|
||||
@ -81,7 +81,7 @@ public:
|
||||
QString mainClass;
|
||||
|
||||
/// the list of libs - both active and inactive, native and java
|
||||
QList<std::shared_ptr<OneSixLibrary>> libraries;
|
||||
QList<std::shared_ptr<DerpLibrary>> libraries;
|
||||
|
||||
/*
|
||||
FIXME: add support for those rules here? Looks like a pile of quick hacks to me though.
|
||||
|
@ -234,18 +234,18 @@ void MCVListLoadTask::list_downloaded()
|
||||
}
|
||||
// Parse the type.
|
||||
MinecraftVersion::VersionType versionType;
|
||||
// OneSix or Legacy. use filter to determine type
|
||||
// Derp or Legacy. use filter to determine type
|
||||
if (versionTypeStr == "release")
|
||||
{
|
||||
versionType = legacyWhitelist.contains(versionID) ? MinecraftVersion::Legacy
|
||||
: MinecraftVersion::OneSix;
|
||||
: MinecraftVersion::Derp;
|
||||
is_latest = (versionID == latestReleaseID);
|
||||
is_snapshot = false;
|
||||
}
|
||||
else if (versionTypeStr == "snapshot") // It's a snapshot... yay
|
||||
{
|
||||
versionType = legacyWhitelist.contains(versionID) ? MinecraftVersion::Legacy
|
||||
: MinecraftVersion::OneSix;
|
||||
: MinecraftVersion::Derp;
|
||||
is_latest = (versionID == latestSnapshotID);
|
||||
is_snapshot = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user