mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-09-03 21:49:13 +00:00
Change naming from Derp -> OneSix until the new instance type supports legacy
This commit is contained in:
parent
156bc8f276
commit
7d5787025a
@ -297,8 +297,8 @@ gui/dialogs/IconPickerDialog.h
|
||||
gui/dialogs/IconPickerDialog.cpp
|
||||
gui/dialogs/LegacyModEditDialog.h
|
||||
gui/dialogs/LegacyModEditDialog.cpp
|
||||
gui/dialogs/DerpModEditDialog.h
|
||||
gui/dialogs/DerpModEditDialog.cpp
|
||||
gui/dialogs/OneSixModEditDialog.h
|
||||
gui/dialogs/OneSixModEditDialog.cpp
|
||||
gui/dialogs/ModEditDialogCommon.h
|
||||
gui/dialogs/ModEditDialogCommon.cpp
|
||||
gui/dialogs/EditNotesDialog.h
|
||||
@ -405,15 +405,15 @@ logic/LegacyUpdate.cpp
|
||||
logic/LegacyForge.h
|
||||
logic/LegacyForge.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
|
||||
# OneSix instances
|
||||
logic/OneSixUpdate.h
|
||||
logic/OneSixUpdate.cpp
|
||||
logic/OneSixVersion.h
|
||||
logic/OneSixVersion.cpp
|
||||
logic/OneSixLibrary.h
|
||||
logic/OneSixLibrary.cpp
|
||||
logic/OneSixRule.h
|
||||
logic/OneSixRule.cpp
|
||||
logic/OpSys.h
|
||||
logic/OpSys.cpp
|
||||
logic/BaseInstaller.h
|
||||
@ -422,19 +422,19 @@ 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
|
||||
logic/OneSixInstance.h
|
||||
logic/OneSixInstance.cpp
|
||||
logic/OneSixInstance_p.h
|
||||
logic/OneSixVersionBuilder.h
|
||||
logic/OneSixVersionBuilder.cpp
|
||||
|
||||
# Nostalgia
|
||||
logic/NostalgiaInstance.h
|
||||
logic/NostalgiaInstance.cpp
|
||||
|
||||
# FTB
|
||||
logic/DerpFTBInstance.h
|
||||
logic/DerpFTBInstance.cpp
|
||||
logic/OneSixFTBInstance.h
|
||||
logic/OneSixFTBInstance.cpp
|
||||
logic/LegacyFTBInstance.h
|
||||
logic/LegacyFTBInstance.cpp
|
||||
|
||||
@ -510,7 +510,7 @@ gui/dialogs/InstanceSettings.ui
|
||||
gui/dialogs/ProgressDialog.ui
|
||||
gui/dialogs/IconPickerDialog.ui
|
||||
gui/dialogs/LegacyModEditDialog.ui
|
||||
gui/dialogs/DerpModEditDialog.ui
|
||||
gui/dialogs/OneSixModEditDialog.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/DerpUpdate.h"
|
||||
#include "logic/OneSixUpdate.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, "Derp");
|
||||
vselect.setFilter(1, "OneSix");
|
||||
if(!vselect.exec() || !vselect.selectedVersion())
|
||||
return;
|
||||
|
||||
|
@ -23,9 +23,9 @@
|
||||
#include <QKeyEvent>
|
||||
#include <QDesktopServices>
|
||||
|
||||
#include "DerpModEditDialog.h"
|
||||
#include "OneSixModEditDialog.h"
|
||||
#include "ModEditDialogCommon.h"
|
||||
#include "ui_DerpModEditDialog.h"
|
||||
#include "ui_OneSixModEditDialog.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/DerpVersion.h"
|
||||
#include "logic/OneSixVersion.h"
|
||||
#include "logic/EnabledItemFilter.h"
|
||||
#include "logic/lists/ForgeVersionList.h"
|
||||
#include "logic/ForgeInstaller.h"
|
||||
#include "logic/LiteLoaderInstaller.h"
|
||||
|
||||
DerpModEditDialog::DerpModEditDialog(DerpInstance *inst, QWidget *parent)
|
||||
: QDialog(parent), ui(new Ui::DerpModEditDialog), m_inst(inst)
|
||||
OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent)
|
||||
: QDialog(parent), ui(new Ui::OneSixModEditDialog), m_inst(inst)
|
||||
{
|
||||
MultiMCPlatform::fixWM_CLASS(this);
|
||||
ui->setupUi(this);
|
||||
@ -81,17 +81,17 @@ DerpModEditDialog::DerpModEditDialog(DerpInstance *inst, QWidget *parent)
|
||||
m_resourcepacks->startWatching();
|
||||
}
|
||||
|
||||
connect(m_inst, &DerpInstance::versionReloaded, this, &DerpModEditDialog::updateVersionControls);
|
||||
connect(m_inst, &OneSixInstance::versionReloaded, this, &OneSixModEditDialog::updateVersionControls);
|
||||
}
|
||||
|
||||
DerpModEditDialog::~DerpModEditDialog()
|
||||
OneSixModEditDialog::~OneSixModEditDialog()
|
||||
{
|
||||
m_mods->stopWatching();
|
||||
m_resourcepacks->stopWatching();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DerpModEditDialog::updateVersionControls()
|
||||
void OneSixModEditDialog::updateVersionControls()
|
||||
{
|
||||
bool customVersion = m_inst->versionIsCustom();
|
||||
ui->forgeBtn->setEnabled(true);
|
||||
@ -100,7 +100,7 @@ void DerpModEditDialog::updateVersionControls()
|
||||
ui->mainClassEdit->setText(m_version->mainClass);
|
||||
}
|
||||
|
||||
void DerpModEditDialog::disableVersionControls()
|
||||
void OneSixModEditDialog::disableVersionControls()
|
||||
{
|
||||
ui->forgeBtn->setEnabled(false);
|
||||
ui->liteloaderBtn->setEnabled(false);
|
||||
@ -108,7 +108,7 @@ void DerpModEditDialog::disableVersionControls()
|
||||
ui->mainClassEdit->setText("");
|
||||
}
|
||||
|
||||
void DerpModEditDialog::on_customEditorBtn_clicked()
|
||||
void OneSixModEditDialog::on_customEditorBtn_clicked()
|
||||
{
|
||||
if (QDir(m_inst->instanceRoot()).exists("custom.json"))
|
||||
{
|
||||
@ -119,7 +119,7 @@ void DerpModEditDialog::on_customEditorBtn_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void DerpModEditDialog::on_forgeBtn_clicked()
|
||||
void OneSixModEditDialog::on_forgeBtn_clicked()
|
||||
{
|
||||
VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this);
|
||||
vselect.setFilter(1, m_inst->currentVersionId());
|
||||
@ -165,7 +165,7 @@ void DerpModEditDialog::on_forgeBtn_clicked()
|
||||
m_inst->reloadFullVersion(this);
|
||||
}
|
||||
|
||||
void DerpModEditDialog::on_liteloaderBtn_clicked()
|
||||
void OneSixModEditDialog::on_liteloaderBtn_clicked()
|
||||
{
|
||||
LiteLoaderInstaller liteloader;
|
||||
if (!liteloader.canApply(m_inst))
|
||||
@ -188,7 +188,7 @@ void DerpModEditDialog::on_liteloaderBtn_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
bool DerpModEditDialog::loaderListFilter(QKeyEvent *keyEvent)
|
||||
bool OneSixModEditDialog::loaderListFilter(QKeyEvent *keyEvent)
|
||||
{
|
||||
switch (keyEvent->key())
|
||||
{
|
||||
@ -204,7 +204,7 @@ bool DerpModEditDialog::loaderListFilter(QKeyEvent *keyEvent)
|
||||
return QDialog::eventFilter(ui->loaderModTreeView, keyEvent);
|
||||
}
|
||||
|
||||
bool DerpModEditDialog::resourcePackListFilter(QKeyEvent *keyEvent)
|
||||
bool OneSixModEditDialog::resourcePackListFilter(QKeyEvent *keyEvent)
|
||||
{
|
||||
switch (keyEvent->key())
|
||||
{
|
||||
@ -220,7 +220,7 @@ bool DerpModEditDialog::resourcePackListFilter(QKeyEvent *keyEvent)
|
||||
return QDialog::eventFilter(ui->resPackTreeView, keyEvent);
|
||||
}
|
||||
|
||||
bool DerpModEditDialog::eventFilter(QObject *obj, QEvent *ev)
|
||||
bool OneSixModEditDialog::eventFilter(QObject *obj, QEvent *ev)
|
||||
{
|
||||
if (ev->type() != QEvent::KeyPress)
|
||||
{
|
||||
@ -234,12 +234,12 @@ bool DerpModEditDialog::eventFilter(QObject *obj, QEvent *ev)
|
||||
return QDialog::eventFilter(obj, ev);
|
||||
}
|
||||
|
||||
void DerpModEditDialog::on_buttonBox_rejected()
|
||||
void OneSixModEditDialog::on_buttonBox_rejected()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void DerpModEditDialog::on_addModBtn_clicked()
|
||||
void OneSixModEditDialog::on_addModBtn_clicked()
|
||||
{
|
||||
QStringList fileNames = QFileDialog::getOpenFileNames(
|
||||
this, QApplication::translate("LegacyModEditDialog", "Select Loader Mods"));
|
||||
@ -250,7 +250,7 @@ void DerpModEditDialog::on_addModBtn_clicked()
|
||||
m_mods->startWatching();
|
||||
}
|
||||
}
|
||||
void DerpModEditDialog::on_rmModBtn_clicked()
|
||||
void OneSixModEditDialog::on_rmModBtn_clicked()
|
||||
{
|
||||
int first, last;
|
||||
auto list = ui->loaderModTreeView->selectionModel()->selectedRows();
|
||||
@ -261,12 +261,12 @@ void DerpModEditDialog::on_rmModBtn_clicked()
|
||||
m_mods->deleteMods(first, last);
|
||||
m_mods->startWatching();
|
||||
}
|
||||
void DerpModEditDialog::on_viewModBtn_clicked()
|
||||
void OneSixModEditDialog::on_viewModBtn_clicked()
|
||||
{
|
||||
openDirInDefaultProgram(m_inst->loaderModsDir(), true);
|
||||
}
|
||||
|
||||
void DerpModEditDialog::on_addResPackBtn_clicked()
|
||||
void OneSixModEditDialog::on_addResPackBtn_clicked()
|
||||
{
|
||||
QStringList fileNames = QFileDialog::getOpenFileNames(
|
||||
this, QApplication::translate("LegacyModEditDialog", "Select Resource Packs"));
|
||||
@ -277,7 +277,7 @@ void DerpModEditDialog::on_addResPackBtn_clicked()
|
||||
m_resourcepacks->startWatching();
|
||||
}
|
||||
}
|
||||
void DerpModEditDialog::on_rmResPackBtn_clicked()
|
||||
void OneSixModEditDialog::on_rmResPackBtn_clicked()
|
||||
{
|
||||
int first, last;
|
||||
auto list = ui->resPackTreeView->selectionModel()->selectedRows();
|
||||
@ -288,12 +288,12 @@ void DerpModEditDialog::on_rmResPackBtn_clicked()
|
||||
m_resourcepacks->deleteMods(first, last);
|
||||
m_resourcepacks->startWatching();
|
||||
}
|
||||
void DerpModEditDialog::on_viewResPackBtn_clicked()
|
||||
void OneSixModEditDialog::on_viewResPackBtn_clicked()
|
||||
{
|
||||
openDirInDefaultProgram(m_inst->resourcePacksDir(), true);
|
||||
}
|
||||
|
||||
void DerpModEditDialog::loaderCurrent(QModelIndex current, QModelIndex previous)
|
||||
void OneSixModEditDialog::loaderCurrent(QModelIndex current, QModelIndex previous)
|
||||
{
|
||||
if (!current.isValid())
|
||||
{
|
@ -16,21 +16,21 @@
|
||||
#pragma once
|
||||
#include <QDialog>
|
||||
|
||||
#include <logic/DerpInstance.h>
|
||||
#include <logic/OneSixInstance.h>
|
||||
|
||||
class EnabledItemFilter;
|
||||
namespace Ui
|
||||
{
|
||||
class DerpModEditDialog;
|
||||
class OneSixModEditDialog;
|
||||
}
|
||||
|
||||
class DerpModEditDialog : public QDialog
|
||||
class OneSixModEditDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DerpModEditDialog(DerpInstance *inst, QWidget *parent = 0);
|
||||
virtual ~DerpModEditDialog();
|
||||
explicit OneSixModEditDialog(OneSixInstance *inst, QWidget *parent = 0);
|
||||
virtual ~OneSixModEditDialog();
|
||||
|
||||
private
|
||||
slots:
|
||||
@ -55,12 +55,12 @@ protected:
|
||||
bool resourcePackListFilter(QKeyEvent *ev);
|
||||
|
||||
private:
|
||||
Ui::DerpModEditDialog *ui;
|
||||
std::shared_ptr<DerpVersion> m_version;
|
||||
Ui::OneSixModEditDialog *ui;
|
||||
std::shared_ptr<OneSixVersion> m_version;
|
||||
std::shared_ptr<ModList> m_mods;
|
||||
std::shared_ptr<ModList> m_resourcepacks;
|
||||
EnabledItemFilter *main_model;
|
||||
DerpInstance *m_inst;
|
||||
OneSixInstance *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>DerpModEditDialog</class>
|
||||
<widget class="QDialog" name="DerpModEditDialog">
|
||||
<class>OneSixModEditDialog</class>
|
||||
<widget class="QDialog" name="OneSixModEditDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
@ -17,9 +17,9 @@
|
||||
|
||||
#include <QFile>
|
||||
|
||||
#include "DerpVersion.h"
|
||||
#include "DerpLibrary.h"
|
||||
#include "DerpInstance.h"
|
||||
#include "OneSixVersion.h"
|
||||
#include "OneSixLibrary.h"
|
||||
#include "OneSixInstance.h"
|
||||
|
||||
#include "cmdutils.h"
|
||||
|
||||
@ -28,12 +28,12 @@ BaseInstaller::BaseInstaller()
|
||||
|
||||
}
|
||||
|
||||
bool BaseInstaller::isApplied(DerpInstance *on)
|
||||
bool BaseInstaller::isApplied(OneSixInstance *on)
|
||||
{
|
||||
return QFile::exists(filename(on->instanceRoot()));
|
||||
}
|
||||
|
||||
bool BaseInstaller::add(DerpInstance *to)
|
||||
bool BaseInstaller::add(OneSixInstance *to)
|
||||
{
|
||||
if (!patchesDir(to->instanceRoot()).exists())
|
||||
{
|
||||
@ -51,7 +51,7 @@ bool BaseInstaller::add(DerpInstance *to)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BaseInstaller::remove(DerpInstance *from)
|
||||
bool BaseInstaller::remove(OneSixInstance *from)
|
||||
{
|
||||
return QFile::remove(filename(from->instanceRoot()));
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
class DerpInstance;
|
||||
class OneSixInstance;
|
||||
class QDir;
|
||||
class QString;
|
||||
|
||||
@ -26,11 +26,11 @@ class BaseInstaller
|
||||
public:
|
||||
BaseInstaller();
|
||||
|
||||
virtual bool canApply(DerpInstance *instance) const { return true; }
|
||||
bool isApplied(DerpInstance *on);
|
||||
virtual bool canApply(OneSixInstance *instance) const { return true; }
|
||||
bool isApplied(OneSixInstance *on);
|
||||
|
||||
virtual bool add(DerpInstance *to);
|
||||
virtual bool remove(DerpInstance *from);
|
||||
virtual bool add(OneSixInstance *to);
|
||||
virtual bool remove(OneSixInstance *from);
|
||||
|
||||
protected:
|
||||
virtual QString id() const = 0;
|
||||
|
@ -27,7 +27,7 @@
|
||||
class QDialog;
|
||||
class Task;
|
||||
class MinecraftProcess;
|
||||
class DerpUpdate;
|
||||
class OneSixUpdate;
|
||||
class InstanceList;
|
||||
class BaseInstancePrivate;
|
||||
|
||||
|
@ -1,194 +0,0 @@
|
||||
/* 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)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
bool DerpVersion::reload(QWidget *widgetParent)
|
||||
{
|
||||
return DerpVersionBuilder::build(this, m_instance, widgetParent);
|
||||
}
|
||||
|
||||
void DerpVersion::clear()
|
||||
{
|
||||
id.clear();
|
||||
time.clear();
|
||||
releaseTime.clear();
|
||||
type.clear();
|
||||
assets.clear();
|
||||
processArguments.clear();
|
||||
minecraftArguments.clear();
|
||||
minimumLauncherVersion = 0xDEADBEAF;
|
||||
mainClass.clear();
|
||||
libraries.clear();
|
||||
}
|
||||
|
||||
void DerpVersion::dump() const
|
||||
{
|
||||
qDebug().nospace() << "DerpVersion("
|
||||
<< "\n\tid=" << id
|
||||
<< "\n\ttime=" << time
|
||||
<< "\n\treleaseTime=" << releaseTime
|
||||
<< "\n\ttype=" << type
|
||||
<< "\n\tassets=" << assets
|
||||
<< "\n\tprocessArguments=" << processArguments
|
||||
<< "\n\tminecraftArguments=" << minecraftArguments
|
||||
<< "\n\tminimumLauncherVersion=" << minimumLauncherVersion
|
||||
<< "\n\tmainClass=" << mainClass
|
||||
<< "\n\tlibraries=";
|
||||
for (auto lib : libraries)
|
||||
{
|
||||
qDebug().nospace() << "\n\t\t" << lib.get();
|
||||
}
|
||||
qDebug().nospace() << "\n)";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
std::shared_ptr<DerpVersion> DerpVersion::fromJson(const QJsonObject &obj)
|
||||
{
|
||||
std::shared_ptr<DerpVersion> version(new DerpVersion(0));
|
||||
if (DerpVersionBuilder::read(version.get(), obj))
|
||||
{
|
||||
return version;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
version->dump();
|
||||
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();
|
||||
}
|
@ -1,115 +0,0 @@
|
||||
/* 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);
|
||||
void clear();
|
||||
|
||||
void dump() const;
|
||||
|
||||
public:
|
||||
QList<std::shared_ptr<DerpLibrary>> getActiveNormalLibs();
|
||||
QList<std::shared_ptr<DerpLibrary>> getActiveNativeLibs();
|
||||
|
||||
static std::shared_ptr<DerpVersion> fromJson(const QJsonObject &obj);
|
||||
|
||||
// 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);
|
@ -14,15 +14,15 @@
|
||||
*/
|
||||
|
||||
#include "ForgeInstaller.h"
|
||||
#include "DerpVersion.h"
|
||||
#include "DerpLibrary.h"
|
||||
#include "OneSixVersion.h"
|
||||
#include "OneSixLibrary.h"
|
||||
#include "net/HttpMetaCache.h"
|
||||
#include <quazip.h>
|
||||
#include <quazipfile.h>
|
||||
#include <pathutils.h>
|
||||
#include <QStringList>
|
||||
#include "MultiMC.h"
|
||||
#include "DerpInstance.h"
|
||||
#include "OneSixInstance.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
|
||||
{
|
||||
std::shared_ptr<DerpVersion> newVersion;
|
||||
std::shared_ptr<OneSixVersion> newVersion;
|
||||
m_universal_url = universal_url;
|
||||
|
||||
QuaZip zip(filename);
|
||||
@ -64,7 +64,7 @@ ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
|
||||
|
||||
// read the forge version info
|
||||
{
|
||||
newVersion = DerpVersion::fromJson(versionInfoVal.toObject());
|
||||
newVersion = OneSixVersion::fromJson(versionInfoVal.toObject());
|
||||
if (!newVersion)
|
||||
return;
|
||||
}
|
||||
@ -74,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
|
||||
DerpLibrary lib(libraryName);
|
||||
OneSixLibrary lib(libraryName);
|
||||
lib.finalize();
|
||||
|
||||
auto cacheentry = MMC->metacache()->resolveEntry("libraries", lib.storagePath());
|
||||
@ -109,7 +109,7 @@ ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
|
||||
realVersionId = m_forge_version->id = installObj.value("minecraft").toString();
|
||||
}
|
||||
|
||||
bool ForgeInstaller::add(DerpInstance *to)
|
||||
bool ForgeInstaller::add(OneSixInstance *to)
|
||||
{
|
||||
if (!BaseInstaller::add(to))
|
||||
{
|
||||
|
@ -20,20 +20,20 @@
|
||||
#include <QString>
|
||||
#include <memory>
|
||||
|
||||
class DerpVersion;
|
||||
class OneSixVersion;
|
||||
|
||||
class ForgeInstaller : public BaseInstaller
|
||||
{
|
||||
public:
|
||||
ForgeInstaller(QString filename, QString universal_url);
|
||||
|
||||
bool add(DerpInstance *to) override;
|
||||
bool add(OneSixInstance *to) override;
|
||||
|
||||
QString id() const override { return "net.minecraftforge"; }
|
||||
|
||||
private:
|
||||
// the version, read from the installer
|
||||
std::shared_ptr<DerpVersion> m_forge_version;
|
||||
std::shared_ptr<OneSixVersion> m_forge_version;
|
||||
QString internalPath;
|
||||
QString finalPath;
|
||||
QString realVersionId;
|
||||
|
@ -21,10 +21,10 @@
|
||||
#include "BaseInstance.h"
|
||||
#include "LegacyInstance.h"
|
||||
#include "LegacyFTBInstance.h"
|
||||
#include "DerpInstance.h"
|
||||
#include "DerpFTBInstance.h"
|
||||
#include "OneSixInstance.h"
|
||||
#include "OneSixFTBInstance.h"
|
||||
#include "NostalgiaInstance.h"
|
||||
#include "DerpInstance.h"
|
||||
#include "OneSixInstance.h"
|
||||
#include "BaseVersion.h"
|
||||
#include "MinecraftVersion.h"
|
||||
|
||||
@ -51,9 +51,9 @@ 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 == "Derp" || inst_type == "OneSix")
|
||||
if (inst_type == "OneSix" || inst_type == "OneSix")
|
||||
{
|
||||
inst = new DerpInstance(instDir, m_settings, this);
|
||||
inst = new OneSixInstance(instDir, m_settings, this);
|
||||
}
|
||||
else if (inst_type == "Legacy")
|
||||
{
|
||||
@ -67,9 +67,9 @@ InstanceFactory::InstLoadError InstanceFactory::loadInstance(BaseInstance *&inst
|
||||
{
|
||||
inst = new LegacyFTBInstance(instDir, m_settings, this);
|
||||
}
|
||||
else if (inst_type == "OneSixFTB" || inst_type == "DerpFTB")
|
||||
else if (inst_type == "OneSixFTB" || inst_type == "OneSixFTB")
|
||||
{
|
||||
inst = new DerpFTBInstance(instDir, m_settings, this);
|
||||
inst = new OneSixFTBInstance(instDir, m_settings, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -102,15 +102,15 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *&
|
||||
switch (mcVer->type)
|
||||
{
|
||||
case MinecraftVersion::Legacy:
|
||||
// TODO derp
|
||||
// TODO OneSix
|
||||
m_settings->set("InstanceType", "Legacy");
|
||||
inst = new LegacyInstance(instDir, m_settings, this);
|
||||
inst->setIntendedVersionId(version->descriptor());
|
||||
inst->setShouldUseCustomBaseJar(false);
|
||||
break;
|
||||
case MinecraftVersion::Derp:
|
||||
m_settings->set("InstanceType", "Derp");
|
||||
inst = new DerpInstance(instDir, m_settings, this);
|
||||
case MinecraftVersion::OneSix:
|
||||
m_settings->set("InstanceType", "OneSix");
|
||||
inst = new OneSixInstance(instDir, m_settings, this);
|
||||
inst->setIntendedVersionId(version->descriptor());
|
||||
inst->setShouldUseCustomBaseJar(false);
|
||||
break;
|
||||
@ -137,9 +137,9 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *&
|
||||
inst->setIntendedVersionId(version->descriptor());
|
||||
inst->setShouldUseCustomBaseJar(false);
|
||||
break;
|
||||
case MinecraftVersion::Derp:
|
||||
m_settings->set("InstanceType", "DerpFTB");
|
||||
inst = new DerpFTBInstance(instDir, m_settings, this);
|
||||
case MinecraftVersion::OneSix:
|
||||
m_settings->set("InstanceType", "OneSixFTB");
|
||||
inst = new OneSixFTBInstance(instDir, m_settings, this);
|
||||
inst->setIntendedVersionId(version->descriptor());
|
||||
inst->setShouldUseCustomBaseJar(false);
|
||||
break;
|
||||
@ -176,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" || inst_type == "DerpFTB")
|
||||
m_settings->set("InstanceType", "Derp");
|
||||
if(inst_type == "OneSixFTB" || inst_type == "OneSixFTB")
|
||||
m_settings->set("InstanceType", "OneSix");
|
||||
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 Derp, where `version' is described in a json file
|
||||
// in contrast with OneSix, where `version' is described in a json file
|
||||
virtual bool versionIsCustom() override
|
||||
{
|
||||
return false;
|
||||
|
@ -20,9 +20,9 @@
|
||||
|
||||
#include "logger/QsLog.h"
|
||||
|
||||
#include "DerpVersion.h"
|
||||
#include "DerpLibrary.h"
|
||||
#include "DerpInstance.h"
|
||||
#include "OneSixVersion.h"
|
||||
#include "OneSixLibrary.h"
|
||||
#include "OneSixInstance.h"
|
||||
|
||||
QMap<QString, QString> LiteLoaderInstaller::m_launcherWrapperVersionMapping;
|
||||
|
||||
@ -38,12 +38,12 @@ LiteLoaderInstaller::LiteLoaderInstaller()
|
||||
}
|
||||
}
|
||||
|
||||
bool LiteLoaderInstaller::canApply(DerpInstance *instance) const
|
||||
bool LiteLoaderInstaller::canApply(OneSixInstance *instance) const
|
||||
{
|
||||
return m_launcherWrapperVersionMapping.contains(instance->intendedVersionId());
|
||||
}
|
||||
|
||||
bool LiteLoaderInstaller::add(DerpInstance *to)
|
||||
bool LiteLoaderInstaller::add(OneSixInstance *to)
|
||||
{
|
||||
if (!BaseInstaller::add(to))
|
||||
{
|
||||
@ -60,7 +60,7 @@ bool LiteLoaderInstaller::add(DerpInstance *to)
|
||||
|
||||
// launchwrapper
|
||||
{
|
||||
DerpLibrary launchwrapperLib("net.minecraft:launchwrapper:" + m_launcherWrapperVersionMapping[to->intendedVersionId()]);
|
||||
OneSixLibrary launchwrapperLib("net.minecraft:launchwrapper:" + m_launcherWrapperVersionMapping[to->intendedVersionId()]);
|
||||
launchwrapperLib.finalize();
|
||||
QJsonObject lwLibObj = launchwrapperLib.toJson();
|
||||
lwLibObj.insert("insert", QString("prepend"));
|
||||
@ -69,7 +69,7 @@ bool LiteLoaderInstaller::add(DerpInstance *to)
|
||||
|
||||
// liteloader
|
||||
{
|
||||
DerpLibrary liteloaderLib("com.mumfrey:liteloader:" + to->intendedVersionId());
|
||||
OneSixLibrary liteloaderLib("com.mumfrey:liteloader:" + to->intendedVersionId());
|
||||
liteloaderLib.setBaseUrl("http://dl.liteloader.com/versions/");
|
||||
liteloaderLib.finalize();
|
||||
QJsonObject llLibObj = liteloaderLib.toJson();
|
||||
|
@ -25,8 +25,8 @@ class LiteLoaderInstaller : public BaseInstaller
|
||||
public:
|
||||
LiteLoaderInstaller();
|
||||
|
||||
bool canApply(DerpInstance *instance) const override;
|
||||
bool add(DerpInstance *to) override;
|
||||
bool canApply(OneSixInstance *instance) const override;
|
||||
bool add(OneSixInstance *to) override;
|
||||
|
||||
private:
|
||||
virtual QString id() const override { return "com.mumfrey.liteloader"; }
|
||||
|
@ -32,7 +32,7 @@ struct MinecraftVersion : public BaseVersion
|
||||
/// This version's type. Used internally to identify what kind of version this is.
|
||||
enum VersionType
|
||||
{
|
||||
Derp,
|
||||
OneSix,
|
||||
Legacy,
|
||||
Nostalgia
|
||||
} type;
|
||||
@ -66,8 +66,8 @@ struct MinecraftVersion : public BaseVersion
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case Derp:
|
||||
pre_final.append("Derp");
|
||||
case OneSix:
|
||||
pre_final.append("OneSix");
|
||||
break;
|
||||
case Legacy:
|
||||
pre_final.append("Legacy");
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
NostalgiaInstance::NostalgiaInstance(const QString &rootDir, SettingsObject *settings,
|
||||
QObject *parent)
|
||||
: DerpInstance(rootDir, settings, parent)
|
||||
: OneSixInstance(rootDir, settings, parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DerpInstance.h"
|
||||
#include "OneSixInstance.h"
|
||||
|
||||
class NostalgiaInstance : public DerpInstance
|
||||
class NostalgiaInstance : public OneSixInstance
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -1,17 +1,17 @@
|
||||
#include "DerpFTBInstance.h"
|
||||
#include "OneSixFTBInstance.h"
|
||||
|
||||
#include "DerpVersion.h"
|
||||
#include "DerpLibrary.h"
|
||||
#include "OneSixVersion.h"
|
||||
#include "OneSixLibrary.h"
|
||||
#include "tasks/SequentialTask.h"
|
||||
#include "ForgeInstaller.h"
|
||||
#include "lists/ForgeVersionList.h"
|
||||
#include "MultiMC.h"
|
||||
|
||||
class DerpFTBInstanceForge : public Task
|
||||
class OneSixFTBInstanceForge : public Task
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DerpFTBInstanceForge(const QString &version, DerpFTBInstance *inst, QObject *parent = 0) :
|
||||
explicit OneSixFTBInstanceForge(const QString &version, OneSixFTBInstance *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, &DerpFTBInstanceForge::installForge);
|
||||
connect(fjob, &NetJob::succeeded, this, &OneSixFTBInstanceForge::installForge);
|
||||
connect(fjob, &NetJob::progress, [this](qint64 c, qint64 total){ setProgress(100 * c / total); });
|
||||
fjob->start();
|
||||
}
|
||||
@ -70,41 +70,41 @@ slots:
|
||||
}
|
||||
|
||||
private:
|
||||
DerpFTBInstance *instance;
|
||||
OneSixFTBInstance *instance;
|
||||
QString version;
|
||||
ForgeVersionPtr forgeVersion;
|
||||
MetaEntryPtr entry;
|
||||
NetJob *fjob;
|
||||
};
|
||||
|
||||
DerpFTBInstance::DerpFTBInstance(const QString &rootDir, SettingsObject *settings, QObject *parent) :
|
||||
DerpInstance(rootDir, settings, parent)
|
||||
OneSixFTBInstance::OneSixFTBInstance(const QString &rootDir, SettingsObject *settings, QObject *parent) :
|
||||
OneSixInstance(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 DerpLibrary(match.captured()));
|
||||
m_forge.reset(new OneSixLibrary(match.captured()));
|
||||
m_forge->finalize();
|
||||
}
|
||||
}
|
||||
|
||||
QString DerpFTBInstance::id() const
|
||||
QString OneSixFTBInstance::id() const
|
||||
{
|
||||
return "FTB/" + BaseInstance::id();
|
||||
}
|
||||
|
||||
QString DerpFTBInstance::getStatusbarDescription()
|
||||
QString OneSixFTBInstance::getStatusbarDescription()
|
||||
{
|
||||
return "Derp FTB: " + intendedVersionId();
|
||||
return "OneSix FTB: " + intendedVersionId();
|
||||
}
|
||||
bool DerpFTBInstance::menuActionEnabled(QString action_name) const
|
||||
bool OneSixFTBInstance::menuActionEnabled(QString action_name) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<Task> DerpFTBInstance::doUpdate(bool only_prepare)
|
||||
std::shared_ptr<Task> OneSixFTBInstance::doUpdate(bool only_prepare)
|
||||
{
|
||||
std::shared_ptr<SequentialTask> task;
|
||||
task.reset(new SequentialTask(this));
|
||||
@ -112,12 +112,12 @@ std::shared_ptr<Task> DerpFTBInstance::doUpdate(bool only_prepare)
|
||||
{
|
||||
task->addTask(std::shared_ptr<Task>(MMC->forgelist()->getLoadTask()));
|
||||
}
|
||||
task->addTask(DerpInstance::doUpdate(only_prepare));
|
||||
task->addTask(std::shared_ptr<Task>(new DerpFTBInstanceForge(m_forge->version(), this, this)));
|
||||
task->addTask(OneSixInstance::doUpdate(only_prepare));
|
||||
task->addTask(std::shared_ptr<Task>(new OneSixFTBInstanceForge(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(DerpInstance::doUpdate(only_prepare));
|
||||
task->addTask(OneSixInstance::doUpdate(only_prepare));
|
||||
return task;
|
||||
}
|
||||
|
||||
#include "DerpFTBInstance.moc"
|
||||
#include "OneSixFTBInstance.moc"
|
@ -1,14 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "DerpInstance.h"
|
||||
#include "OneSixInstance.h"
|
||||
|
||||
class DerpLibrary;
|
||||
class OneSixLibrary;
|
||||
|
||||
class DerpFTBInstance : public DerpInstance
|
||||
class OneSixFTBInstance : public OneSixInstance
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DerpFTBInstance(const QString &rootDir, SettingsObject *settings,
|
||||
explicit OneSixFTBInstance(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<DerpLibrary> m_forge;
|
||||
std::shared_ptr<OneSixLibrary> m_forge;
|
||||
};
|
@ -13,28 +13,28 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "DerpInstance.h"
|
||||
#include "OneSixInstance.h"
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
#include "DerpInstance_p.h"
|
||||
#include "DerpUpdate.h"
|
||||
#include "DerpVersion.h"
|
||||
#include "OneSixInstance_p.h"
|
||||
#include "OneSixUpdate.h"
|
||||
#include "OneSixVersion.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"
|
||||
#include "gui/dialogs/OneSixModEditDialog.h"
|
||||
|
||||
DerpInstance::DerpInstance(const QString &rootDir, SettingsObject *settings, QObject *parent)
|
||||
: BaseInstance(new DerpInstancePrivate(), rootDir, settings, parent)
|
||||
OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *settings, QObject *parent)
|
||||
: BaseInstance(new OneSixInstancePrivate(), rootDir, settings, parent)
|
||||
{
|
||||
I_D(DerpInstance);
|
||||
I_D(OneSixInstance);
|
||||
d->m_settings->registerSetting("IntendedVersion", "");
|
||||
d->m_settings->registerSetting("ShouldUpdate", false);
|
||||
d->version.reset(new DerpVersion(this, this));
|
||||
d->version.reset(new OneSixVersion(this, this));
|
||||
if (QDir(instanceRoot()).exists("version.json"))
|
||||
{
|
||||
reloadFullVersion();
|
||||
@ -45,9 +45,9 @@ DerpInstance::DerpInstance(const QString &rootDir, SettingsObject *settings, QOb
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<Task> DerpInstance::doUpdate(bool only_prepare)
|
||||
std::shared_ptr<Task> OneSixInstance::doUpdate(bool only_prepare)
|
||||
{
|
||||
return std::shared_ptr<Task>(new DerpUpdate(this, only_prepare));
|
||||
return std::shared_ptr<Task>(new OneSixUpdate(this, only_prepare));
|
||||
}
|
||||
|
||||
QString replaceTokensIn(QString text, QMap<QString, QString> with)
|
||||
@ -74,7 +74,7 @@ QString replaceTokensIn(QString text, QMap<QString, QString> with)
|
||||
return result;
|
||||
}
|
||||
|
||||
QDir DerpInstance::reconstructAssets(std::shared_ptr<DerpVersion> version)
|
||||
QDir OneSixInstance::reconstructAssets(std::shared_ptr<OneSixVersion> version)
|
||||
{
|
||||
QDir assetsDir = QDir("assets/");
|
||||
QDir indexDir = QDir(PathCombine(assetsDir.path(), "indexes"));
|
||||
@ -134,9 +134,9 @@ QDir DerpInstance::reconstructAssets(std::shared_ptr<DerpVersion> version)
|
||||
return virtualRoot;
|
||||
}
|
||||
|
||||
QStringList DerpInstance::processMinecraftArgs(MojangAccountPtr account)
|
||||
QStringList OneSixInstance::processMinecraftArgs(MojangAccountPtr account)
|
||||
{
|
||||
I_D(DerpInstance);
|
||||
I_D(OneSixInstance);
|
||||
auto version = d->version;
|
||||
QString args_pattern = version->minecraftArguments;
|
||||
|
||||
@ -186,9 +186,9 @@ QStringList DerpInstance::processMinecraftArgs(MojangAccountPtr account)
|
||||
return parts;
|
||||
}
|
||||
|
||||
MinecraftProcess *DerpInstance::prepareForLaunch(MojangAccountPtr account)
|
||||
MinecraftProcess *OneSixInstance::prepareForLaunch(MojangAccountPtr account)
|
||||
{
|
||||
I_D(DerpInstance);
|
||||
I_D(OneSixInstance);
|
||||
|
||||
QIcon icon = MMC->icons()->getIcon(iconKey());
|
||||
auto pixmap = icon.pixmap(128, 128);
|
||||
@ -248,16 +248,16 @@ MinecraftProcess *DerpInstance::prepareForLaunch(MojangAccountPtr account)
|
||||
return proc;
|
||||
}
|
||||
|
||||
void DerpInstance::cleanupAfterRun()
|
||||
void OneSixInstance::cleanupAfterRun()
|
||||
{
|
||||
QString target_dir = PathCombine(instanceRoot(), "natives/");
|
||||
QDir dir(target_dir);
|
||||
dir.removeRecursively();
|
||||
}
|
||||
|
||||
std::shared_ptr<ModList> DerpInstance::loaderModList()
|
||||
std::shared_ptr<ModList> OneSixInstance::loaderModList()
|
||||
{
|
||||
I_D(DerpInstance);
|
||||
I_D(OneSixInstance);
|
||||
if (!d->loader_mod_list)
|
||||
{
|
||||
d->loader_mod_list.reset(new ModList(loaderModsDir()));
|
||||
@ -266,9 +266,9 @@ std::shared_ptr<ModList> DerpInstance::loaderModList()
|
||||
return d->loader_mod_list;
|
||||
}
|
||||
|
||||
std::shared_ptr<ModList> DerpInstance::resourcePackList()
|
||||
std::shared_ptr<ModList> OneSixInstance::resourcePackList()
|
||||
{
|
||||
I_D(DerpInstance);
|
||||
I_D(OneSixInstance);
|
||||
if (!d->resource_pack_list)
|
||||
{
|
||||
d->resource_pack_list.reset(new ModList(resourcePacksDir()));
|
||||
@ -277,12 +277,12 @@ std::shared_ptr<ModList> DerpInstance::resourcePackList()
|
||||
return d->resource_pack_list;
|
||||
}
|
||||
|
||||
QDialog *DerpInstance::createModEditDialog(QWidget *parent)
|
||||
QDialog *OneSixInstance::createModEditDialog(QWidget *parent)
|
||||
{
|
||||
return new DerpModEditDialog(this, parent);
|
||||
return new OneSixModEditDialog(this, parent);
|
||||
}
|
||||
|
||||
bool DerpInstance::setIntendedVersionId(QString version)
|
||||
bool OneSixInstance::setIntendedVersionId(QString version)
|
||||
{
|
||||
settings().set("IntendedVersion", version);
|
||||
setShouldUpdate(true);
|
||||
@ -291,17 +291,17 @@ bool DerpInstance::setIntendedVersionId(QString version)
|
||||
return true;
|
||||
}
|
||||
|
||||
QString DerpInstance::intendedVersionId() const
|
||||
QString OneSixInstance::intendedVersionId() const
|
||||
{
|
||||
return settings().get("IntendedVersion").toString();
|
||||
}
|
||||
|
||||
void DerpInstance::setShouldUpdate(bool val)
|
||||
void OneSixInstance::setShouldUpdate(bool val)
|
||||
{
|
||||
settings().set("ShouldUpdate", val);
|
||||
}
|
||||
|
||||
bool DerpInstance::shouldUpdate() const
|
||||
bool OneSixInstance::shouldUpdate() const
|
||||
{
|
||||
QVariant var = settings().get("ShouldUpdate");
|
||||
if (!var.isValid() || var.toBool() == false)
|
||||
@ -311,60 +311,60 @@ bool DerpInstance::shouldUpdate() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DerpInstance::versionIsCustom()
|
||||
bool OneSixInstance::versionIsCustom()
|
||||
{
|
||||
QDir patches(PathCombine(instanceRoot(), "patches/"));
|
||||
return QFile::exists(PathCombine(instanceRoot(), "custom.json"))
|
||||
|| (patches.exists() && patches.count() >= 0);
|
||||
}
|
||||
|
||||
QString DerpInstance::currentVersionId() const
|
||||
QString OneSixInstance::currentVersionId() const
|
||||
{
|
||||
return intendedVersionId();
|
||||
}
|
||||
|
||||
bool DerpInstance::reloadFullVersion(QWidget *widgetParent)
|
||||
bool OneSixInstance::reloadFullVersion(QWidget *widgetParent)
|
||||
{
|
||||
I_D(DerpInstance);
|
||||
I_D(OneSixInstance);
|
||||
|
||||
bool ret = d->version->reload(widgetParent);
|
||||
emit versionReloaded();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DerpInstance::clearFullVersion()
|
||||
void OneSixInstance::clearFullVersion()
|
||||
{
|
||||
I_D(DerpInstance);
|
||||
I_D(OneSixInstance);
|
||||
d->version->clear();
|
||||
emit versionReloaded();
|
||||
}
|
||||
|
||||
std::shared_ptr<DerpVersion> DerpInstance::getFullVersion()
|
||||
std::shared_ptr<OneSixVersion> OneSixInstance::getFullVersion()
|
||||
{
|
||||
I_D(DerpInstance);
|
||||
I_D(OneSixInstance);
|
||||
return d->version;
|
||||
}
|
||||
|
||||
QString DerpInstance::defaultBaseJar() const
|
||||
QString OneSixInstance::defaultBaseJar() const
|
||||
{
|
||||
return "versions/" + intendedVersionId() + "/" + intendedVersionId() + ".jar";
|
||||
}
|
||||
|
||||
QString DerpInstance::defaultCustomBaseJar() const
|
||||
QString OneSixInstance::defaultCustomBaseJar() const
|
||||
{
|
||||
return PathCombine(instanceRoot(), "custom.jar");
|
||||
}
|
||||
|
||||
bool DerpInstance::menuActionEnabled(QString action_name) const
|
||||
bool OneSixInstance::menuActionEnabled(QString action_name) const
|
||||
{
|
||||
if (action_name == "actionChangeInstLWJGLVersion")
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
QString DerpInstance::getStatusbarDescription()
|
||||
QString OneSixInstance::getStatusbarDescription()
|
||||
{
|
||||
QString descr = "Derp : " + intendedVersionId();
|
||||
QString descr = "OneSix : " + intendedVersionId();
|
||||
if (versionIsCustom())
|
||||
{
|
||||
descr + " (custom)";
|
||||
@ -372,17 +372,17 @@ QString DerpInstance::getStatusbarDescription()
|
||||
return descr;
|
||||
}
|
||||
|
||||
QString DerpInstance::loaderModsDir() const
|
||||
QString OneSixInstance::loaderModsDir() const
|
||||
{
|
||||
return PathCombine(minecraftRoot(), "mods");
|
||||
}
|
||||
|
||||
QString DerpInstance::resourcePacksDir() const
|
||||
QString OneSixInstance::resourcePacksDir() const
|
||||
{
|
||||
return PathCombine(minecraftRoot(), "resourcepacks");
|
||||
}
|
||||
|
||||
QString DerpInstance::instanceConfigFolder() const
|
||||
QString OneSixInstance::instanceConfigFolder() const
|
||||
{
|
||||
return PathCombine(minecraftRoot(), "config");
|
||||
}
|
@ -17,14 +17,14 @@
|
||||
|
||||
#include "BaseInstance.h"
|
||||
|
||||
#include "DerpVersion.h"
|
||||
#include "OneSixVersion.h"
|
||||
#include "ModList.h"
|
||||
|
||||
class DerpInstance : public BaseInstance
|
||||
class OneSixInstance : public BaseInstance
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DerpInstance(const QString &rootDir, SettingsObject *settings,
|
||||
explicit OneSixInstance(const QString &rootDir, SettingsObject *settings,
|
||||
QObject *parent = 0);
|
||||
|
||||
////// Mod Lists //////
|
||||
@ -56,7 +56,7 @@ public:
|
||||
/// clears all version information in preparation for an update
|
||||
void clearFullVersion();
|
||||
/// get the current full version info
|
||||
std::shared_ptr<DerpVersion> getFullVersion();
|
||||
std::shared_ptr<OneSixVersion> getFullVersion();
|
||||
/// is the current version original, or custom?
|
||||
virtual bool versionIsCustom() override;
|
||||
|
||||
@ -71,5 +71,5 @@ signals:
|
||||
|
||||
private:
|
||||
QStringList processMinecraftArgs(MojangAccountPtr account);
|
||||
QDir reconstructAssets(std::shared_ptr<DerpVersion> version);
|
||||
QDir reconstructAssets(std::shared_ptr<OneSixVersion> version);
|
||||
};
|
@ -16,12 +16,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "BaseInstance_p.h"
|
||||
#include "DerpVersion.h"
|
||||
#include "OneSixVersion.h"
|
||||
#include "ModList.h"
|
||||
|
||||
struct DerpInstancePrivate : public BaseInstancePrivate
|
||||
struct OneSixInstancePrivate : public BaseInstancePrivate
|
||||
{
|
||||
std::shared_ptr<DerpVersion> version;
|
||||
std::shared_ptr<OneSixVersion> version;
|
||||
std::shared_ptr<ModList> loader_mod_list;
|
||||
std::shared_ptr<ModList> resource_pack_list;
|
||||
};
|
@ -15,15 +15,15 @@
|
||||
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "DerpLibrary.h"
|
||||
#include "DerpRule.h"
|
||||
#include "OneSixLibrary.h"
|
||||
#include "OneSixRule.h"
|
||||
#include "OpSys.h"
|
||||
#include "logic/net/URLConstants.h"
|
||||
#include <pathutils.h>
|
||||
#include <JlCompress.h>
|
||||
#include "logger/QsLog.h"
|
||||
|
||||
void DerpLibrary::finalize()
|
||||
void OneSixLibrary::finalize()
|
||||
{
|
||||
QStringList parts = m_name.split(':');
|
||||
QString relative = parts[0];
|
||||
@ -76,67 +76,67 @@ void DerpLibrary::finalize()
|
||||
}
|
||||
}
|
||||
|
||||
void DerpLibrary::setName(const QString &name)
|
||||
void OneSixLibrary::setName(const QString &name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
void DerpLibrary::setBaseUrl(const QString &base_url)
|
||||
void OneSixLibrary::setBaseUrl(const QString &base_url)
|
||||
{
|
||||
m_base_url = base_url;
|
||||
}
|
||||
void DerpLibrary::setIsNative()
|
||||
void OneSixLibrary::setIsNative()
|
||||
{
|
||||
m_is_native = true;
|
||||
}
|
||||
void DerpLibrary::addNative(OpSys os, const QString &suffix)
|
||||
void OneSixLibrary::addNative(OpSys os, const QString &suffix)
|
||||
{
|
||||
m_is_native = true;
|
||||
m_native_suffixes[os] = suffix;
|
||||
}
|
||||
void DerpLibrary::setRules(QList<std::shared_ptr<Rule>> rules)
|
||||
void OneSixLibrary::setRules(QList<std::shared_ptr<Rule>> rules)
|
||||
{
|
||||
m_rules = rules;
|
||||
}
|
||||
bool DerpLibrary::isActive() const
|
||||
bool OneSixLibrary::isActive() const
|
||||
{
|
||||
return m_is_active;
|
||||
}
|
||||
bool DerpLibrary::isNative() const
|
||||
bool OneSixLibrary::isNative() const
|
||||
{
|
||||
return m_is_native;
|
||||
}
|
||||
QString DerpLibrary::downloadUrl() const
|
||||
QString OneSixLibrary::downloadUrl() const
|
||||
{
|
||||
if (m_absolute_url.size())
|
||||
return m_absolute_url;
|
||||
return m_download_url;
|
||||
}
|
||||
QString DerpLibrary::storagePath() const
|
||||
QString OneSixLibrary::storagePath() const
|
||||
{
|
||||
return m_storage_path;
|
||||
}
|
||||
|
||||
void DerpLibrary::setAbsoluteUrl(const QString &absolute_url)
|
||||
void OneSixLibrary::setAbsoluteUrl(const QString &absolute_url)
|
||||
{
|
||||
m_absolute_url = absolute_url;
|
||||
}
|
||||
|
||||
QString DerpLibrary::absoluteUrl() const
|
||||
QString OneSixLibrary::absoluteUrl() const
|
||||
{
|
||||
return m_absolute_url;
|
||||
}
|
||||
|
||||
void DerpLibrary::setHint(const QString &hint)
|
||||
void OneSixLibrary::setHint(const QString &hint)
|
||||
{
|
||||
m_hint = hint;
|
||||
}
|
||||
|
||||
QString DerpLibrary::hint() const
|
||||
QString OneSixLibrary::hint() const
|
||||
{
|
||||
return m_hint;
|
||||
}
|
||||
|
||||
bool DerpLibrary::filesExist()
|
||||
bool OneSixLibrary::filesExist()
|
||||
{
|
||||
QString storage = storagePath();
|
||||
if (storage.contains("${arch}"))
|
||||
@ -167,7 +167,7 @@ bool DerpLibrary::filesExist()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DerpLibrary::extractTo(QString target_dir)
|
||||
bool OneSixLibrary::extractTo(QString target_dir)
|
||||
{
|
||||
QString storage = storagePath();
|
||||
if (storage.contains("${arch}"))
|
||||
@ -220,7 +220,7 @@ bool DerpLibrary::extractTo(QString target_dir)
|
||||
return true;
|
||||
}
|
||||
|
||||
QJsonObject DerpLibrary::toJson()
|
||||
QJsonObject OneSixLibrary::toJson()
|
||||
{
|
||||
QJsonObject libRoot;
|
||||
libRoot.insert("name", m_name);
|
@ -26,7 +26,7 @@
|
||||
|
||||
class Rule;
|
||||
|
||||
class DerpLibrary
|
||||
class OneSixLibrary
|
||||
{
|
||||
private:
|
||||
// basic values used internally (so far)
|
||||
@ -63,7 +63,7 @@ public:
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
DerpLibrary(const QString &name)
|
||||
OneSixLibrary(const QString &name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
@ -16,7 +16,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "DerpRule.h"
|
||||
#include "OneSixRule.h"
|
||||
|
||||
QList<std::shared_ptr<Rule>> rulesFromJsonV4(const QJsonObject &objectWithRules)
|
||||
{
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "logic/DerpLibrary.h"
|
||||
#include "logic/OneSixLibrary.h"
|
||||
|
||||
enum RuleAction
|
||||
{
|
||||
@ -33,7 +33,7 @@ class Rule
|
||||
{
|
||||
protected:
|
||||
RuleAction m_result;
|
||||
virtual bool applies(DerpLibrary *parent) = 0;
|
||||
virtual bool applies(OneSixLibrary *parent) = 0;
|
||||
|
||||
public:
|
||||
Rule(RuleAction result) : m_result(result)
|
||||
@ -41,7 +41,7 @@ public:
|
||||
}
|
||||
virtual ~Rule() {};
|
||||
virtual QJsonObject toJson() = 0;
|
||||
RuleAction apply(DerpLibrary *parent)
|
||||
RuleAction apply(OneSixLibrary *parent)
|
||||
{
|
||||
if (applies(parent))
|
||||
return m_result;
|
||||
@ -60,7 +60,7 @@ private:
|
||||
QString m_version_regexp;
|
||||
|
||||
protected:
|
||||
virtual bool applies(DerpLibrary *)
|
||||
virtual bool applies(OneSixLibrary *)
|
||||
{
|
||||
return (m_system == currentSystem);
|
||||
}
|
||||
@ -81,7 +81,7 @@ public:
|
||||
class ImplicitRule : public Rule
|
||||
{
|
||||
protected:
|
||||
virtual bool applies(DerpLibrary *)
|
||||
virtual bool applies(OneSixLibrary *)
|
||||
{
|
||||
return true;
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "MultiMC.h"
|
||||
#include "DerpUpdate.h"
|
||||
#include "OneSixUpdate.h"
|
||||
|
||||
#include <QtNetwork>
|
||||
|
||||
@ -25,9 +25,9 @@
|
||||
|
||||
#include "BaseInstance.h"
|
||||
#include "lists/MinecraftVersionList.h"
|
||||
#include "DerpVersion.h"
|
||||
#include "DerpLibrary.h"
|
||||
#include "DerpInstance.h"
|
||||
#include "OneSixVersion.h"
|
||||
#include "OneSixLibrary.h"
|
||||
#include "OneSixInstance.h"
|
||||
#include "net/ForgeMirrors.h"
|
||||
#include "net/URLConstants.h"
|
||||
#include "assets/AssetsUtils.h"
|
||||
@ -35,12 +35,12 @@
|
||||
#include "pathutils.h"
|
||||
#include <JlCompress.h>
|
||||
|
||||
DerpUpdate::DerpUpdate(BaseInstance *inst, bool only_prepare, QObject *parent)
|
||||
OneSixUpdate::OneSixUpdate(BaseInstance *inst, bool only_prepare, QObject *parent)
|
||||
: Task(parent), m_inst(inst), m_only_prepare(only_prepare)
|
||||
{
|
||||
}
|
||||
|
||||
void DerpUpdate::executeTask()
|
||||
void OneSixUpdate::executeTask()
|
||||
{
|
||||
QString intendedVersion = m_inst->intendedVersionId();
|
||||
|
||||
@ -77,7 +77,7 @@ void DerpUpdate::executeTask()
|
||||
}
|
||||
}
|
||||
|
||||
void DerpUpdate::versionFileStart()
|
||||
void OneSixUpdate::versionFileStart()
|
||||
{
|
||||
QLOG_INFO() << m_inst->name() << ": getting version file.";
|
||||
setStatus(tr("Getting the version files from Mojang..."));
|
||||
@ -94,10 +94,10 @@ void DerpUpdate::versionFileStart()
|
||||
specificVersionDownloadJob->start();
|
||||
}
|
||||
|
||||
void DerpUpdate::versionFileFinished()
|
||||
void OneSixUpdate::versionFileFinished()
|
||||
{
|
||||
NetActionPtr DlJob = specificVersionDownloadJob->first();
|
||||
DerpInstance *inst = (DerpInstance *)m_inst;
|
||||
OneSixInstance *inst = (OneSixInstance *)m_inst;
|
||||
|
||||
QString version_id = targetVersion->descriptor();
|
||||
QString inst_dir = m_inst->instanceRoot();
|
||||
@ -142,16 +142,16 @@ void DerpUpdate::versionFileFinished()
|
||||
jarlibStart();
|
||||
}
|
||||
|
||||
void DerpUpdate::versionFileFailed()
|
||||
void OneSixUpdate::versionFileFailed()
|
||||
{
|
||||
emitFailed("Failed to download the version description. Try again.");
|
||||
}
|
||||
|
||||
void DerpUpdate::assetIndexStart()
|
||||
void OneSixUpdate::assetIndexStart()
|
||||
{
|
||||
setStatus(tr("Updating assets index..."));
|
||||
DerpInstance *inst = (DerpInstance *)m_inst;
|
||||
std::shared_ptr<DerpVersion> version = inst->getFullVersion();
|
||||
OneSixInstance *inst = (OneSixInstance *)m_inst;
|
||||
std::shared_ptr<OneSixVersion> 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 DerpUpdate::assetIndexStart()
|
||||
jarlibDownloadJob->start();
|
||||
}
|
||||
|
||||
void DerpUpdate::assetIndexFinished()
|
||||
void OneSixUpdate::assetIndexFinished()
|
||||
{
|
||||
AssetsIndex index;
|
||||
|
||||
DerpInstance *inst = (DerpInstance *)m_inst;
|
||||
std::shared_ptr<DerpVersion> version = inst->getFullVersion();
|
||||
OneSixInstance *inst = (OneSixInstance *)m_inst;
|
||||
std::shared_ptr<OneSixVersion> version = inst->getFullVersion();
|
||||
QString assetName = version->assets;
|
||||
|
||||
QString asset_fname = "assets/indexes/" + assetName + ".json";
|
||||
@ -215,26 +215,26 @@ void DerpUpdate::assetIndexFinished()
|
||||
assetsFinished();
|
||||
}
|
||||
|
||||
void DerpUpdate::assetIndexFailed()
|
||||
void OneSixUpdate::assetIndexFailed()
|
||||
{
|
||||
emitFailed("Failed to download the assets index!");
|
||||
}
|
||||
|
||||
void DerpUpdate::assetsFinished()
|
||||
void OneSixUpdate::assetsFinished()
|
||||
{
|
||||
prepareForLaunch();
|
||||
}
|
||||
|
||||
void DerpUpdate::assetsFailed()
|
||||
void OneSixUpdate::assetsFailed()
|
||||
{
|
||||
emitFailed("Failed to download assets!");
|
||||
}
|
||||
|
||||
void DerpUpdate::jarlibStart()
|
||||
void OneSixUpdate::jarlibStart()
|
||||
{
|
||||
setStatus(tr("Getting the library files from Mojang..."));
|
||||
QLOG_INFO() << m_inst->name() << ": downloading libraries";
|
||||
DerpInstance *inst = (DerpInstance *)m_inst;
|
||||
OneSixInstance *inst = (OneSixInstance *)m_inst;
|
||||
bool successful = inst->reloadFullVersion();
|
||||
if (!successful)
|
||||
{
|
||||
@ -244,7 +244,7 @@ void DerpUpdate::jarlibStart()
|
||||
}
|
||||
|
||||
// Build a list of URLs that will need to be downloaded.
|
||||
std::shared_ptr<DerpVersion> version = inst->getFullVersion();
|
||||
std::shared_ptr<OneSixVersion> version = inst->getFullVersion();
|
||||
// minecraft.jar for this version
|
||||
{
|
||||
QString version_id = version->id;
|
||||
@ -318,12 +318,12 @@ void DerpUpdate::jarlibStart()
|
||||
jarlibDownloadJob->start();
|
||||
}
|
||||
|
||||
void DerpUpdate::jarlibFinished()
|
||||
void OneSixUpdate::jarlibFinished()
|
||||
{
|
||||
assetIndexStart();
|
||||
}
|
||||
|
||||
void DerpUpdate::jarlibFailed()
|
||||
void OneSixUpdate::jarlibFailed()
|
||||
{
|
||||
QStringList failed = jarlibDownloadJob->getFailedFiles();
|
||||
QString failed_all = failed.join("\n");
|
||||
@ -331,17 +331,17 @@ void DerpUpdate::jarlibFailed()
|
||||
"\n\nPlease try again.");
|
||||
}
|
||||
|
||||
void DerpUpdate::prepareForLaunch()
|
||||
void OneSixUpdate::prepareForLaunch()
|
||||
{
|
||||
setStatus(tr("Preparing for launch..."));
|
||||
QLOG_INFO() << m_inst->name() << ": preparing for launch";
|
||||
auto derp_inst = (DerpInstance *)m_inst;
|
||||
auto OneSix_inst = (OneSixInstance *)m_inst;
|
||||
|
||||
// delete any leftovers, if they are present.
|
||||
derp_inst->cleanupAfterRun();
|
||||
OneSix_inst->cleanupAfterRun();
|
||||
|
||||
QString natives_dir_raw = PathCombine(derp_inst->instanceRoot(), "natives/");
|
||||
auto version = derp_inst->getFullVersion();
|
||||
QString natives_dir_raw = PathCombine(OneSix_inst->instanceRoot(), "natives/");
|
||||
auto version = OneSix_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 DerpUpdate : public Task
|
||||
class OneSixUpdate : public Task
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DerpUpdate(BaseInstance *inst, bool prepare_for_launch, QObject *parent = 0);
|
||||
explicit OneSixUpdate(BaseInstance *inst, bool prepare_for_launch, QObject *parent = 0);
|
||||
virtual void executeTask();
|
||||
|
||||
private
|
@ -13,228 +13,60 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "logic/DerpVersion.h"
|
||||
#include "logic/DerpLibrary.h"
|
||||
#include "logic/DerpRule.h"
|
||||
#include "OneSixVersion.h"
|
||||
|
||||
#include "logger/QsLog.h"
|
||||
#include <QDebug>
|
||||
|
||||
std::shared_ptr<DerpVersion> fromJsonV4(QJsonObject root,
|
||||
std::shared_ptr<DerpVersion> fullVersion)
|
||||
#include "OneSixVersionBuilder.h"
|
||||
|
||||
OneSixVersion::OneSixVersion(OneSixInstance *instance, QObject *parent)
|
||||
: QAbstractListModel(parent), m_instance(instance)
|
||||
{
|
||||
fullVersion->id = root.value("id").toString();
|
||||
|
||||
fullVersion->mainClass = root.value("mainClass").toString();
|
||||
auto procArgsValue = root.value("processArguments");
|
||||
if (procArgsValue.isString())
|
||||
{
|
||||
fullVersion->processArguments = procArgsValue.toString();
|
||||
QString toCompare = fullVersion->processArguments.toLower();
|
||||
if (toCompare == "legacy")
|
||||
{
|
||||
fullVersion->minecraftArguments = " ${auth_player_name} ${auth_session}";
|
||||
}
|
||||
else if (toCompare == "username_session")
|
||||
{
|
||||
fullVersion->minecraftArguments =
|
||||
"--username ${auth_player_name} --session ${auth_session}";
|
||||
}
|
||||
else if (toCompare == "username_session_version")
|
||||
{
|
||||
fullVersion->minecraftArguments = "--username ${auth_player_name} "
|
||||
"--session ${auth_session} "
|
||||
"--version ${profile_name}";
|
||||
}
|
||||
}
|
||||
|
||||
auto minecraftArgsValue = root.value("minecraftArguments");
|
||||
if (minecraftArgsValue.isString())
|
||||
{
|
||||
fullVersion->minecraftArguments = minecraftArgsValue.toString();
|
||||
}
|
||||
|
||||
auto minecraftTypeValue = root.value("type");
|
||||
if (minecraftTypeValue.isString())
|
||||
{
|
||||
fullVersion->type = minecraftTypeValue.toString();
|
||||
}
|
||||
|
||||
fullVersion->releaseTime = root.value("releaseTime").toString();
|
||||
fullVersion->time = root.value("time").toString();
|
||||
|
||||
auto assetsID = root.value("assets");
|
||||
if (assetsID.isString())
|
||||
{
|
||||
fullVersion->assets = assetsID.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
fullVersion->assets = "legacy";
|
||||
}
|
||||
|
||||
QLOG_DEBUG() << "Assets version:" << fullVersion->assets;
|
||||
|
||||
// Iterate through the list, if it's a list.
|
||||
auto librariesValue = root.value("libraries");
|
||||
if (!librariesValue.isArray())
|
||||
return fullVersion;
|
||||
|
||||
QJsonArray libList = root.value("libraries").toArray();
|
||||
for (auto libVal : libList)
|
||||
{
|
||||
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()));
|
||||
|
||||
auto urlVal = libObj.value("url");
|
||||
if (urlVal.isString())
|
||||
{
|
||||
library->setBaseUrl(urlVal.toString());
|
||||
}
|
||||
auto hintVal = libObj.value("MMC-hint");
|
||||
if (hintVal.isString())
|
||||
{
|
||||
library->setHint(hintVal.toString());
|
||||
}
|
||||
auto urlAbsVal = libObj.value("MMC-absoluteUrl");
|
||||
auto urlAbsuVal = libObj.value("MMC-absulute_url"); // compatibility
|
||||
if (urlAbsVal.isString())
|
||||
{
|
||||
library->setAbsoluteUrl(urlAbsVal.toString());
|
||||
}
|
||||
else if (urlAbsuVal.isString())
|
||||
{
|
||||
library->setAbsoluteUrl(urlAbsuVal.toString());
|
||||
}
|
||||
// Extract excludes (if any)
|
||||
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();
|
||||
auto iter = nativesObj.begin();
|
||||
while (iter != nativesObj.end())
|
||||
{
|
||||
auto osType = OpSys_fromString(iter.key());
|
||||
if (osType == Os_Other)
|
||||
continue;
|
||||
if (!iter.value().isString())
|
||||
continue;
|
||||
library->addNative(osType, iter.value().toString());
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
library->setRules(rulesFromJsonV4(libObj));
|
||||
library->finalize();
|
||||
fullVersion->libraries.append(library);
|
||||
}
|
||||
return fullVersion;
|
||||
clear();
|
||||
}
|
||||
|
||||
std::shared_ptr<DerpVersion> DerpVersion::fromJson(QJsonObject root)
|
||||
bool OneSixVersion::reload(QWidget *widgetParent)
|
||||
{
|
||||
std::shared_ptr<DerpVersion> readVersion(new DerpVersion());
|
||||
int launcher_ver = readVersion->minimumLauncherVersion =
|
||||
root.value("minimumLauncherVersion").toDouble();
|
||||
|
||||
// ADD MORE HERE :D
|
||||
if (launcher_ver > 0 && launcher_ver <= 13)
|
||||
return fromJsonV4(root, readVersion);
|
||||
else
|
||||
{
|
||||
return std::shared_ptr<DerpVersion>();
|
||||
}
|
||||
return OneSixVersionBuilder::build(this, m_instance, widgetParent);
|
||||
}
|
||||
|
||||
std::shared_ptr<DerpVersion> DerpVersion::fromFile(QString filepath)
|
||||
void OneSixVersion::clear()
|
||||
{
|
||||
QFile file(filepath);
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
return std::shared_ptr<DerpVersion>();
|
||||
}
|
||||
|
||||
auto data = file.readAll();
|
||||
QJsonParseError jsonError;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
|
||||
|
||||
if (jsonError.error != QJsonParseError::NoError)
|
||||
{
|
||||
return std::shared_ptr<DerpVersion>();
|
||||
}
|
||||
|
||||
if (!jsonDoc.isObject())
|
||||
{
|
||||
return std::shared_ptr<DerpVersion>();
|
||||
}
|
||||
QJsonObject root = jsonDoc.object();
|
||||
auto version = fromJson(root);
|
||||
if (version)
|
||||
version->original_file = filepath;
|
||||
return version;
|
||||
id.clear();
|
||||
time.clear();
|
||||
releaseTime.clear();
|
||||
type.clear();
|
||||
assets.clear();
|
||||
processArguments.clear();
|
||||
minecraftArguments.clear();
|
||||
minimumLauncherVersion = 0xDEADBEAF;
|
||||
mainClass.clear();
|
||||
libraries.clear();
|
||||
}
|
||||
|
||||
bool DerpVersion::toOriginalFile()
|
||||
void OneSixVersion::dump() const
|
||||
{
|
||||
if (original_file.isEmpty())
|
||||
return false;
|
||||
QSaveFile file(original_file);
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
qDebug().nospace() << "OneSixVersion("
|
||||
<< "\n\tid=" << id
|
||||
<< "\n\ttime=" << time
|
||||
<< "\n\treleaseTime=" << releaseTime
|
||||
<< "\n\ttype=" << type
|
||||
<< "\n\tassets=" << assets
|
||||
<< "\n\tprocessArguments=" << processArguments
|
||||
<< "\n\tminecraftArguments=" << minecraftArguments
|
||||
<< "\n\tminimumLauncherVersion=" << minimumLauncherVersion
|
||||
<< "\n\tmainClass=" << mainClass
|
||||
<< "\n\tlibraries=";
|
||||
for (auto lib : libraries)
|
||||
{
|
||||
return false;
|
||||
qDebug().nospace() << "\n\t\t" << lib.get();
|
||||
}
|
||||
// serialize base attributes (those we care about anyway)
|
||||
QJsonObject root;
|
||||
root.insert("minecraftArguments", minecraftArguments);
|
||||
root.insert("mainClass", mainClass);
|
||||
root.insert("minimumLauncherVersion", minimumLauncherVersion);
|
||||
root.insert("time", time);
|
||||
root.insert("id", id);
|
||||
root.insert("type", type);
|
||||
// screw processArguments
|
||||
root.insert("releaseTime", releaseTime);
|
||||
QJsonArray libarray;
|
||||
for (const auto &lib : libraries)
|
||||
{
|
||||
libarray.append(lib->toJson());
|
||||
}
|
||||
if (libarray.count())
|
||||
root.insert("libraries", libarray);
|
||||
QJsonDocument doc(root);
|
||||
file.write(doc.toJson());
|
||||
return file.commit();
|
||||
qDebug().nospace() << "\n)";
|
||||
}
|
||||
|
||||
QList<std::shared_ptr<DerpLibrary>> DerpVersion::getActiveNormalLibs()
|
||||
QList<std::shared_ptr<OneSixLibrary> > OneSixVersion::getActiveNormalLibs()
|
||||
{
|
||||
QList<std::shared_ptr<DerpLibrary>> output;
|
||||
QList<std::shared_ptr<OneSixLibrary> > output;
|
||||
for (auto lib : libraries)
|
||||
{
|
||||
if (lib->isActive() && !lib->isNative())
|
||||
@ -245,9 +77,9 @@ QList<std::shared_ptr<DerpLibrary>> DerpVersion::getActiveNormalLibs()
|
||||
return output;
|
||||
}
|
||||
|
||||
QList<std::shared_ptr<DerpLibrary>> DerpVersion::getActiveNativeLibs()
|
||||
QList<std::shared_ptr<OneSixLibrary> > OneSixVersion::getActiveNativeLibs()
|
||||
{
|
||||
QList<std::shared_ptr<DerpLibrary>> output;
|
||||
QList<std::shared_ptr<OneSixLibrary> > output;
|
||||
for (auto lib : libraries)
|
||||
{
|
||||
if (lib->isActive() && lib->isNative())
|
||||
@ -258,17 +90,17 @@ QList<std::shared_ptr<DerpLibrary>> DerpVersion::getActiveNativeLibs()
|
||||
return output;
|
||||
}
|
||||
|
||||
void DerpVersion::externalUpdateStart()
|
||||
std::shared_ptr<OneSixVersion> OneSixVersion::fromJson(const QJsonObject &obj)
|
||||
{
|
||||
beginResetModel();
|
||||
std::shared_ptr<OneSixVersion> version(new OneSixVersion(0));
|
||||
if (OneSixVersionBuilder::read(version.get(), obj))
|
||||
{
|
||||
return version;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DerpVersion::externalUpdateFinish()
|
||||
{
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
QVariant DerpVersion::data(const QModelIndex &index, int role) const
|
||||
QVariant OneSixVersion::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
@ -296,7 +128,7 @@ QVariant DerpVersion::data(const QModelIndex &index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Qt::ItemFlags DerpVersion::flags(const QModelIndex &index) const
|
||||
Qt::ItemFlags OneSixVersion::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return Qt::NoItemFlags;
|
||||
@ -312,7 +144,7 @@ Qt::ItemFlags DerpVersion::flags(const QModelIndex &index) const
|
||||
// return QAbstractListModel::flags(index);
|
||||
}
|
||||
|
||||
QVariant DerpVersion::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
QVariant OneSixVersion::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || orientation != Qt::Horizontal)
|
||||
return QVariant();
|
||||
@ -329,12 +161,34 @@ QVariant DerpVersion::headerData(int section, Qt::Orientation orientation, int r
|
||||
}
|
||||
}
|
||||
|
||||
int DerpVersion::rowCount(const QModelIndex &parent) const
|
||||
int OneSixVersion::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return libraries.size();
|
||||
}
|
||||
|
||||
int DerpVersion::columnCount(const QModelIndex &parent) const
|
||||
int OneSixVersion::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug &dbg, const OneSixVersion *version)
|
||||
{
|
||||
version->dump();
|
||||
return dbg.maybeSpace();
|
||||
}
|
||||
QDebug operator<<(QDebug &dbg, const OneSixLibrary *library)
|
||||
{
|
||||
dbg.nospace() << "OneSixLibrary("
|
||||
<< "\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();
|
||||
}
|
||||
|
@ -14,15 +14,23 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QtCore>
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <memory>
|
||||
|
||||
class DerpLibrary;
|
||||
#include "OneSixLibrary.h"
|
||||
|
||||
class DerpVersion : public QAbstractListModel
|
||||
class OneSixInstance;
|
||||
|
||||
class OneSixVersion : public QAbstractListModel
|
||||
{
|
||||
// Things required to implement the Qt list model
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit OneSixVersion(OneSixInstance *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,
|
||||
@ -30,24 +38,19 @@ public:
|
||||
virtual int columnCount(const QModelIndex &parent) const;
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
|
||||
// serialization/deserialization
|
||||
public:
|
||||
bool toOriginalFile();
|
||||
static std::shared_ptr<DerpVersion> fromJson(QJsonObject root);
|
||||
static std::shared_ptr<DerpVersion> fromFile(QString filepath);
|
||||
bool reload(QWidget *widgetParent);
|
||||
void clear();
|
||||
|
||||
void dump() const;
|
||||
|
||||
public:
|
||||
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();
|
||||
void externalUpdateFinish();
|
||||
QList<std::shared_ptr<OneSixLibrary>> getActiveNormalLibs();
|
||||
QList<std::shared_ptr<OneSixLibrary>> getActiveNativeLibs();
|
||||
|
||||
static std::shared_ptr<OneSixVersion> fromJson(const QJsonObject &obj);
|
||||
|
||||
// data members
|
||||
public:
|
||||
/// file this was read from. blank, if none
|
||||
QString original_file;
|
||||
/// the ID - determines which jar to use! ACTUALLY IMPORTANT!
|
||||
QString id;
|
||||
/// Last updated time - as a string
|
||||
@ -81,7 +84,7 @@ public:
|
||||
QString mainClass;
|
||||
|
||||
/// the list of libs - both active and inactive, native and java
|
||||
QList<std::shared_ptr<DerpLibrary>> libraries;
|
||||
QList<std::shared_ptr<OneSixLibrary>> libraries;
|
||||
|
||||
/*
|
||||
FIXME: add support for those rules here? Looks like a pile of quick hacks to me though.
|
||||
@ -103,4 +106,10 @@ public:
|
||||
}
|
||||
*/
|
||||
// QList<Rule> rules;
|
||||
|
||||
private:
|
||||
OneSixInstance *m_instance;
|
||||
};
|
||||
|
||||
QDebug operator<<(QDebug &dbg, const OneSixVersion *version);
|
||||
QDebug operator<<(QDebug &dbg, const OneSixLibrary *library);
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "DerpVersionBuilder.h"
|
||||
#include "OneSixVersionBuilder.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QJsonObject>
|
||||
@ -26,35 +26,35 @@
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
|
||||
#include "DerpVersion.h"
|
||||
#include "DerpInstance.h"
|
||||
#include "DerpRule.h"
|
||||
#include "OneSixVersion.h"
|
||||
#include "OneSixInstance.h"
|
||||
#include "OneSixRule.h"
|
||||
#include "logger/QsLog.h"
|
||||
|
||||
DerpVersionBuilder::DerpVersionBuilder()
|
||||
OneSixVersionBuilder::OneSixVersionBuilder()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool DerpVersionBuilder::build(DerpVersion *version, DerpInstance *instance, QWidget *widgetParent)
|
||||
bool OneSixVersionBuilder::build(OneSixVersion *version, OneSixInstance *instance, QWidget *widgetParent)
|
||||
{
|
||||
DerpVersionBuilder builder;
|
||||
OneSixVersionBuilder builder;
|
||||
builder.m_version = version;
|
||||
builder.m_instance = instance;
|
||||
builder.m_widgetParent = widgetParent;
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
bool DerpVersionBuilder::read(DerpVersion *version, const QJsonObject &obj)
|
||||
bool OneSixVersionBuilder::read(OneSixVersion *version, const QJsonObject &obj)
|
||||
{
|
||||
DerpVersionBuilder builder;
|
||||
OneSixVersionBuilder builder;
|
||||
builder.m_version = version;
|
||||
builder.m_instance = 0;
|
||||
builder.m_widgetParent = 0;
|
||||
return builder.read(obj);
|
||||
}
|
||||
|
||||
bool DerpVersionBuilder::build()
|
||||
bool OneSixVersionBuilder::build()
|
||||
{
|
||||
m_version->clear();
|
||||
|
||||
@ -127,7 +127,7 @@ bool DerpVersionBuilder::build()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DerpVersionBuilder::read(const QJsonObject &obj)
|
||||
bool OneSixVersionBuilder::read(const QJsonObject &obj)
|
||||
{
|
||||
m_version->clear();
|
||||
|
||||
@ -152,14 +152,14 @@ void applyString(const QJsonObject &obj, const QString &key, QString &out, const
|
||||
}
|
||||
}
|
||||
}
|
||||
void applyString(const QJsonObject &obj, const QString &key, std::shared_ptr<DerpLibrary> lib, void(DerpLibrary::*func)(const QString &val))
|
||||
void applyString(const QJsonObject &obj, const QString &key, std::shared_ptr<OneSixLibrary> lib, void(OneSixLibrary::*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)
|
||||
bool OneSixVersionBuilder::apply(const QJsonObject &object)
|
||||
{
|
||||
applyString(object, "id", m_version->id);
|
||||
applyString(object, "mainClass", m_version->mainClass);
|
||||
@ -265,7 +265,7 @@ bool DerpVersionBuilder::apply(const QJsonObject &object)
|
||||
return true;
|
||||
}
|
||||
|
||||
int findLibrary(QList<std::shared_ptr<DerpLibrary> > haystack, const QString &needle)
|
||||
int findLibrary(QList<std::shared_ptr<OneSixLibrary> > haystack, const QString &needle)
|
||||
{
|
||||
for (int i = 0; i < haystack.size(); ++i)
|
||||
{
|
||||
@ -277,7 +277,7 @@ int findLibrary(QList<std::shared_ptr<DerpLibrary> > haystack, const QString &ne
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool DerpVersionBuilder::applyLibrary(const QJsonObject &lib, const DerpVersionBuilder::Type type)
|
||||
bool OneSixVersionBuilder::applyLibrary(const QJsonObject &lib, const OneSixVersionBuilder::Type type)
|
||||
{
|
||||
// Library name
|
||||
auto nameVal = lib.value("name");
|
||||
@ -302,11 +302,11 @@ bool DerpVersionBuilder::applyLibrary(const QJsonObject &lib, const DerpVersionB
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<DerpLibrary> library;
|
||||
std::shared_ptr<OneSixLibrary> library;
|
||||
|
||||
if (lib.value("insert").toString() != "apply" && type == Add)
|
||||
{
|
||||
QMutableListIterator<std::shared_ptr<DerpLibrary> > it(m_version->libraries);
|
||||
QMutableListIterator<std::shared_ptr<OneSixLibrary> > it(m_version->libraries);
|
||||
while (it.hasNext())
|
||||
{
|
||||
if (it.next()->rawName() == name)
|
||||
@ -322,13 +322,13 @@ bool DerpVersionBuilder::applyLibrary(const QJsonObject &lib, const DerpVersionB
|
||||
}
|
||||
else
|
||||
{
|
||||
library.reset(new DerpLibrary(nameVal.toString()));
|
||||
library.reset(new OneSixLibrary(nameVal.toString()));
|
||||
}
|
||||
|
||||
applyString(lib, "url", library, &DerpLibrary::setBaseUrl);
|
||||
applyString(lib, "MMC-hint", library, &DerpLibrary::setHint);
|
||||
applyString(lib, "MMC-absulute_url", library, &DerpLibrary::setAbsoluteUrl);
|
||||
applyString(lib, "MMC-absoluteUrl", library, &DerpLibrary::setAbsoluteUrl);
|
||||
applyString(lib, "url", library, &OneSixLibrary::setBaseUrl);
|
||||
applyString(lib, "MMC-hint", library, &OneSixLibrary::setHint);
|
||||
applyString(lib, "MMC-absulute_url", library, &OneSixLibrary::setAbsoluteUrl);
|
||||
applyString(lib, "MMC-absoluteUrl", library, &OneSixLibrary::setAbsoluteUrl);
|
||||
|
||||
auto extractVal = lib.value("extract");
|
||||
if (extractVal.isObject())
|
||||
@ -426,7 +426,7 @@ bool DerpVersionBuilder::applyLibrary(const QJsonObject &lib, const DerpVersionB
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DerpVersionBuilder::read(const QFileInfo &fileInfo, QJsonObject *out)
|
||||
bool OneSixVersionBuilder::read(const QFileInfo &fileInfo, QJsonObject *out)
|
||||
{
|
||||
QFile file(fileInfo.absoluteFilePath());
|
||||
if (!file.open(QFile::ReadOnly))
|
@ -17,22 +17,22 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
class DerpVersion;
|
||||
class DerpInstance;
|
||||
class OneSixVersion;
|
||||
class OneSixInstance;
|
||||
class QWidget;
|
||||
class QJsonObject;
|
||||
class QFileInfo;
|
||||
|
||||
class DerpVersionBuilder
|
||||
class OneSixVersionBuilder
|
||||
{
|
||||
DerpVersionBuilder();
|
||||
OneSixVersionBuilder();
|
||||
public:
|
||||
static bool build(DerpVersion *version, DerpInstance *instance, QWidget *widgetParent);
|
||||
static bool read(DerpVersion *version, const QJsonObject &obj);
|
||||
static bool build(OneSixVersion *version, OneSixInstance *instance, QWidget *widgetParent);
|
||||
static bool read(OneSixVersion *version, const QJsonObject &obj);
|
||||
|
||||
private:
|
||||
DerpVersion *m_version;
|
||||
DerpInstance *m_instance;
|
||||
OneSixVersion *m_version;
|
||||
OneSixInstance *m_instance;
|
||||
QWidget *m_widgetParent;
|
||||
|
||||
enum Type
|
@ -234,18 +234,18 @@ void MCVListLoadTask::list_downloaded()
|
||||
}
|
||||
// Parse the type.
|
||||
MinecraftVersion::VersionType versionType;
|
||||
// Derp or Legacy. use filter to determine type
|
||||
// OneSix or Legacy. use filter to determine type
|
||||
if (versionTypeStr == "release")
|
||||
{
|
||||
versionType = legacyWhitelist.contains(versionID) ? MinecraftVersion::Legacy
|
||||
: MinecraftVersion::Derp;
|
||||
: MinecraftVersion::OneSix;
|
||||
is_latest = (versionID == latestReleaseID);
|
||||
is_snapshot = false;
|
||||
}
|
||||
else if (versionTypeStr == "snapshot") // It's a snapshot... yay
|
||||
{
|
||||
versionType = legacyWhitelist.contains(versionID) ? MinecraftVersion::Legacy
|
||||
: MinecraftVersion::Derp;
|
||||
: MinecraftVersion::OneSix;
|
||||
is_latest = (versionID == latestSnapshotID);
|
||||
is_snapshot = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user