Change naming from Derp -> OneSix until the new instance type supports legacy

This commit is contained in:
Jan Dalheimer 2014-01-24 18:12:02 +01:00
parent 156bc8f276
commit 7d5787025a
35 changed files with 375 additions and 821 deletions

View File

@ -297,8 +297,8 @@ gui/dialogs/IconPickerDialog.h
gui/dialogs/IconPickerDialog.cpp gui/dialogs/IconPickerDialog.cpp
gui/dialogs/LegacyModEditDialog.h gui/dialogs/LegacyModEditDialog.h
gui/dialogs/LegacyModEditDialog.cpp gui/dialogs/LegacyModEditDialog.cpp
gui/dialogs/DerpModEditDialog.h gui/dialogs/OneSixModEditDialog.h
gui/dialogs/DerpModEditDialog.cpp gui/dialogs/OneSixModEditDialog.cpp
gui/dialogs/ModEditDialogCommon.h gui/dialogs/ModEditDialogCommon.h
gui/dialogs/ModEditDialogCommon.cpp gui/dialogs/ModEditDialogCommon.cpp
gui/dialogs/EditNotesDialog.h gui/dialogs/EditNotesDialog.h
@ -405,15 +405,15 @@ logic/LegacyUpdate.cpp
logic/LegacyForge.h logic/LegacyForge.h
logic/LegacyForge.cpp logic/LegacyForge.cpp
# Derp instances # OneSix instances
logic/DerpUpdate.h logic/OneSixUpdate.h
logic/DerpUpdate.cpp logic/OneSixUpdate.cpp
logic/DerpVersion.h logic/OneSixVersion.h
logic/DerpVersion.cpp logic/OneSixVersion.cpp
logic/DerpLibrary.h logic/OneSixLibrary.h
logic/DerpLibrary.cpp logic/OneSixLibrary.cpp
logic/DerpRule.h logic/OneSixRule.h
logic/DerpRule.cpp logic/OneSixRule.cpp
logic/OpSys.h logic/OpSys.h
logic/OpSys.cpp logic/OpSys.cpp
logic/BaseInstaller.h logic/BaseInstaller.h
@ -422,19 +422,19 @@ logic/ForgeInstaller.h
logic/ForgeInstaller.cpp logic/ForgeInstaller.cpp
logic/LiteLoaderInstaller.h logic/LiteLoaderInstaller.h
logic/LiteLoaderInstaller.cpp logic/LiteLoaderInstaller.cpp
logic/DerpInstance.h logic/OneSixInstance.h
logic/DerpInstance.cpp logic/OneSixInstance.cpp
logic/DerpInstance_p.h logic/OneSixInstance_p.h
logic/DerpVersionBuilder.h logic/OneSixVersionBuilder.h
logic/DerpVersionBuilder.cpp logic/OneSixVersionBuilder.cpp
# Nostalgia # Nostalgia
logic/NostalgiaInstance.h logic/NostalgiaInstance.h
logic/NostalgiaInstance.cpp logic/NostalgiaInstance.cpp
# FTB # FTB
logic/DerpFTBInstance.h logic/OneSixFTBInstance.h
logic/DerpFTBInstance.cpp logic/OneSixFTBInstance.cpp
logic/LegacyFTBInstance.h logic/LegacyFTBInstance.h
logic/LegacyFTBInstance.cpp logic/LegacyFTBInstance.cpp
@ -510,7 +510,7 @@ gui/dialogs/InstanceSettings.ui
gui/dialogs/ProgressDialog.ui gui/dialogs/ProgressDialog.ui
gui/dialogs/IconPickerDialog.ui gui/dialogs/IconPickerDialog.ui
gui/dialogs/LegacyModEditDialog.ui gui/dialogs/LegacyModEditDialog.ui
gui/dialogs/DerpModEditDialog.ui gui/dialogs/OneSixModEditDialog.ui
gui/dialogs/EditNotesDialog.ui gui/dialogs/EditNotesDialog.ui
gui/dialogs/AccountListDialog.ui gui/dialogs/AccountListDialog.ui
gui/dialogs/AccountSelectDialog.ui gui/dialogs/AccountSelectDialog.ui

View File

@ -84,7 +84,7 @@
#include "logic/BaseInstance.h" #include "logic/BaseInstance.h"
#include "logic/InstanceFactory.h" #include "logic/InstanceFactory.h"
#include "logic/MinecraftProcess.h" #include "logic/MinecraftProcess.h"
#include "logic/DerpUpdate.h" #include "logic/OneSixUpdate.h"
#include "logic/JavaUtils.h" #include "logic/JavaUtils.h"
#include "logic/NagUtils.h" #include "logic/NagUtils.h"
#include "logic/SkinUtils.h" #include "logic/SkinUtils.h"
@ -1257,7 +1257,7 @@ void MainWindow::on_actionChangeInstMCVersion_triggered()
VersionSelectDialog vselect(m_selectedInstance->versionList().get(), VersionSelectDialog vselect(m_selectedInstance->versionList().get(),
tr("Change Minecraft version"), this); tr("Change Minecraft version"), this);
vselect.setFilter(1, "Derp"); vselect.setFilter(1, "OneSix");
if(!vselect.exec() || !vselect.selectedVersion()) if(!vselect.exec() || !vselect.selectedVersion())
return; return;

View File

@ -23,9 +23,9 @@
#include <QKeyEvent> #include <QKeyEvent>
#include <QDesktopServices> #include <QDesktopServices>
#include "DerpModEditDialog.h" #include "OneSixModEditDialog.h"
#include "ModEditDialogCommon.h" #include "ModEditDialogCommon.h"
#include "ui_DerpModEditDialog.h" #include "ui_OneSixModEditDialog.h"
#include "gui/Platform.h" #include "gui/Platform.h"
#include "gui/dialogs/CustomMessageBox.h" #include "gui/dialogs/CustomMessageBox.h"
@ -34,14 +34,14 @@
#include "gui/dialogs/ProgressDialog.h" #include "gui/dialogs/ProgressDialog.h"
#include "logic/ModList.h" #include "logic/ModList.h"
#include "logic/DerpVersion.h" #include "logic/OneSixVersion.h"
#include "logic/EnabledItemFilter.h" #include "logic/EnabledItemFilter.h"
#include "logic/lists/ForgeVersionList.h" #include "logic/lists/ForgeVersionList.h"
#include "logic/ForgeInstaller.h" #include "logic/ForgeInstaller.h"
#include "logic/LiteLoaderInstaller.h" #include "logic/LiteLoaderInstaller.h"
DerpModEditDialog::DerpModEditDialog(DerpInstance *inst, QWidget *parent) OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent)
: QDialog(parent), ui(new Ui::DerpModEditDialog), m_inst(inst) : QDialog(parent), ui(new Ui::OneSixModEditDialog), m_inst(inst)
{ {
MultiMCPlatform::fixWM_CLASS(this); MultiMCPlatform::fixWM_CLASS(this);
ui->setupUi(this); ui->setupUi(this);
@ -81,17 +81,17 @@ DerpModEditDialog::DerpModEditDialog(DerpInstance *inst, QWidget *parent)
m_resourcepacks->startWatching(); 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_mods->stopWatching();
m_resourcepacks->stopWatching(); m_resourcepacks->stopWatching();
delete ui; delete ui;
} }
void DerpModEditDialog::updateVersionControls() void OneSixModEditDialog::updateVersionControls()
{ {
bool customVersion = m_inst->versionIsCustom(); bool customVersion = m_inst->versionIsCustom();
ui->forgeBtn->setEnabled(true); ui->forgeBtn->setEnabled(true);
@ -100,7 +100,7 @@ void DerpModEditDialog::updateVersionControls()
ui->mainClassEdit->setText(m_version->mainClass); ui->mainClassEdit->setText(m_version->mainClass);
} }
void DerpModEditDialog::disableVersionControls() void OneSixModEditDialog::disableVersionControls()
{ {
ui->forgeBtn->setEnabled(false); ui->forgeBtn->setEnabled(false);
ui->liteloaderBtn->setEnabled(false); ui->liteloaderBtn->setEnabled(false);
@ -108,7 +108,7 @@ void DerpModEditDialog::disableVersionControls()
ui->mainClassEdit->setText(""); ui->mainClassEdit->setText("");
} }
void DerpModEditDialog::on_customEditorBtn_clicked() void OneSixModEditDialog::on_customEditorBtn_clicked()
{ {
if (QDir(m_inst->instanceRoot()).exists("custom.json")) 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); VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this);
vselect.setFilter(1, m_inst->currentVersionId()); vselect.setFilter(1, m_inst->currentVersionId());
@ -165,7 +165,7 @@ void DerpModEditDialog::on_forgeBtn_clicked()
m_inst->reloadFullVersion(this); m_inst->reloadFullVersion(this);
} }
void DerpModEditDialog::on_liteloaderBtn_clicked() void OneSixModEditDialog::on_liteloaderBtn_clicked()
{ {
LiteLoaderInstaller liteloader; LiteLoaderInstaller liteloader;
if (!liteloader.canApply(m_inst)) 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()) switch (keyEvent->key())
{ {
@ -204,7 +204,7 @@ bool DerpModEditDialog::loaderListFilter(QKeyEvent *keyEvent)
return QDialog::eventFilter(ui->loaderModTreeView, keyEvent); return QDialog::eventFilter(ui->loaderModTreeView, keyEvent);
} }
bool DerpModEditDialog::resourcePackListFilter(QKeyEvent *keyEvent) bool OneSixModEditDialog::resourcePackListFilter(QKeyEvent *keyEvent)
{ {
switch (keyEvent->key()) switch (keyEvent->key())
{ {
@ -220,7 +220,7 @@ bool DerpModEditDialog::resourcePackListFilter(QKeyEvent *keyEvent)
return QDialog::eventFilter(ui->resPackTreeView, 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) if (ev->type() != QEvent::KeyPress)
{ {
@ -234,12 +234,12 @@ bool DerpModEditDialog::eventFilter(QObject *obj, QEvent *ev)
return QDialog::eventFilter(obj, ev); return QDialog::eventFilter(obj, ev);
} }
void DerpModEditDialog::on_buttonBox_rejected() void OneSixModEditDialog::on_buttonBox_rejected()
{ {
close(); close();
} }
void DerpModEditDialog::on_addModBtn_clicked() void OneSixModEditDialog::on_addModBtn_clicked()
{ {
QStringList fileNames = QFileDialog::getOpenFileNames( QStringList fileNames = QFileDialog::getOpenFileNames(
this, QApplication::translate("LegacyModEditDialog", "Select Loader Mods")); this, QApplication::translate("LegacyModEditDialog", "Select Loader Mods"));
@ -250,7 +250,7 @@ void DerpModEditDialog::on_addModBtn_clicked()
m_mods->startWatching(); m_mods->startWatching();
} }
} }
void DerpModEditDialog::on_rmModBtn_clicked() void OneSixModEditDialog::on_rmModBtn_clicked()
{ {
int first, last; int first, last;
auto list = ui->loaderModTreeView->selectionModel()->selectedRows(); auto list = ui->loaderModTreeView->selectionModel()->selectedRows();
@ -261,12 +261,12 @@ void DerpModEditDialog::on_rmModBtn_clicked()
m_mods->deleteMods(first, last); m_mods->deleteMods(first, last);
m_mods->startWatching(); m_mods->startWatching();
} }
void DerpModEditDialog::on_viewModBtn_clicked() void OneSixModEditDialog::on_viewModBtn_clicked()
{ {
openDirInDefaultProgram(m_inst->loaderModsDir(), true); openDirInDefaultProgram(m_inst->loaderModsDir(), true);
} }
void DerpModEditDialog::on_addResPackBtn_clicked() void OneSixModEditDialog::on_addResPackBtn_clicked()
{ {
QStringList fileNames = QFileDialog::getOpenFileNames( QStringList fileNames = QFileDialog::getOpenFileNames(
this, QApplication::translate("LegacyModEditDialog", "Select Resource Packs")); this, QApplication::translate("LegacyModEditDialog", "Select Resource Packs"));
@ -277,7 +277,7 @@ void DerpModEditDialog::on_addResPackBtn_clicked()
m_resourcepacks->startWatching(); m_resourcepacks->startWatching();
} }
} }
void DerpModEditDialog::on_rmResPackBtn_clicked() void OneSixModEditDialog::on_rmResPackBtn_clicked()
{ {
int first, last; int first, last;
auto list = ui->resPackTreeView->selectionModel()->selectedRows(); auto list = ui->resPackTreeView->selectionModel()->selectedRows();
@ -288,12 +288,12 @@ void DerpModEditDialog::on_rmResPackBtn_clicked()
m_resourcepacks->deleteMods(first, last); m_resourcepacks->deleteMods(first, last);
m_resourcepacks->startWatching(); m_resourcepacks->startWatching();
} }
void DerpModEditDialog::on_viewResPackBtn_clicked() void OneSixModEditDialog::on_viewResPackBtn_clicked()
{ {
openDirInDefaultProgram(m_inst->resourcePacksDir(), true); openDirInDefaultProgram(m_inst->resourcePacksDir(), true);
} }
void DerpModEditDialog::loaderCurrent(QModelIndex current, QModelIndex previous) void OneSixModEditDialog::loaderCurrent(QModelIndex current, QModelIndex previous)
{ {
if (!current.isValid()) if (!current.isValid())
{ {

View File

@ -16,21 +16,21 @@
#pragma once #pragma once
#include <QDialog> #include <QDialog>
#include <logic/DerpInstance.h> #include <logic/OneSixInstance.h>
class EnabledItemFilter; class EnabledItemFilter;
namespace Ui namespace Ui
{ {
class DerpModEditDialog; class OneSixModEditDialog;
} }
class DerpModEditDialog : public QDialog class OneSixModEditDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DerpModEditDialog(DerpInstance *inst, QWidget *parent = 0); explicit OneSixModEditDialog(OneSixInstance *inst, QWidget *parent = 0);
virtual ~DerpModEditDialog(); virtual ~OneSixModEditDialog();
private private
slots: slots:
@ -55,12 +55,12 @@ protected:
bool resourcePackListFilter(QKeyEvent *ev); bool resourcePackListFilter(QKeyEvent *ev);
private: private:
Ui::DerpModEditDialog *ui; Ui::OneSixModEditDialog *ui;
std::shared_ptr<DerpVersion> m_version; std::shared_ptr<OneSixVersion> m_version;
std::shared_ptr<ModList> m_mods; std::shared_ptr<ModList> m_mods;
std::shared_ptr<ModList> m_resourcepacks; std::shared_ptr<ModList> m_resourcepacks;
EnabledItemFilter *main_model; EnabledItemFilter *main_model;
DerpInstance *m_inst; OneSixInstance *m_inst;
public public
slots: slots:
void loaderCurrent(QModelIndex current, QModelIndex previous); void loaderCurrent(QModelIndex current, QModelIndex previous);

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>DerpModEditDialog</class> <class>OneSixModEditDialog</class>
<widget class="QDialog" name="DerpModEditDialog"> <widget class="QDialog" name="OneSixModEditDialog">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>

View File

@ -17,9 +17,9 @@
#include <QFile> #include <QFile>
#include "DerpVersion.h" #include "OneSixVersion.h"
#include "DerpLibrary.h" #include "OneSixLibrary.h"
#include "DerpInstance.h" #include "OneSixInstance.h"
#include "cmdutils.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())); return QFile::exists(filename(on->instanceRoot()));
} }
bool BaseInstaller::add(DerpInstance *to) bool BaseInstaller::add(OneSixInstance *to)
{ {
if (!patchesDir(to->instanceRoot()).exists()) if (!patchesDir(to->instanceRoot()).exists())
{ {
@ -51,7 +51,7 @@ bool BaseInstaller::add(DerpInstance *to)
return true; return true;
} }
bool BaseInstaller::remove(DerpInstance *from) bool BaseInstaller::remove(OneSixInstance *from)
{ {
return QFile::remove(filename(from->instanceRoot())); return QFile::remove(filename(from->instanceRoot()));
} }

View File

@ -17,7 +17,7 @@
#include <memory> #include <memory>
class DerpInstance; class OneSixInstance;
class QDir; class QDir;
class QString; class QString;
@ -26,11 +26,11 @@ class BaseInstaller
public: public:
BaseInstaller(); BaseInstaller();
virtual bool canApply(DerpInstance *instance) const { return true; } virtual bool canApply(OneSixInstance *instance) const { return true; }
bool isApplied(DerpInstance *on); bool isApplied(OneSixInstance *on);
virtual bool add(DerpInstance *to); virtual bool add(OneSixInstance *to);
virtual bool remove(DerpInstance *from); virtual bool remove(OneSixInstance *from);
protected: protected:
virtual QString id() const = 0; virtual QString id() const = 0;

View File

@ -27,7 +27,7 @@
class QDialog; class QDialog;
class Task; class Task;
class MinecraftProcess; class MinecraftProcess;
class DerpUpdate; class OneSixUpdate;
class InstanceList; class InstanceList;
class BaseInstancePrivate; class BaseInstancePrivate;

View File

@ -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();
}

View File

@ -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);

View File

@ -14,15 +14,15 @@
*/ */
#include "ForgeInstaller.h" #include "ForgeInstaller.h"
#include "DerpVersion.h" #include "OneSixVersion.h"
#include "DerpLibrary.h" #include "OneSixLibrary.h"
#include "net/HttpMetaCache.h" #include "net/HttpMetaCache.h"
#include <quazip.h> #include <quazip.h>
#include <quazipfile.h> #include <quazipfile.h>
#include <pathutils.h> #include <pathutils.h>
#include <QStringList> #include <QStringList>
#include "MultiMC.h" #include "MultiMC.h"
#include "DerpInstance.h" #include "OneSixInstance.h"
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonArray> #include <QJsonArray>
@ -31,7 +31,7 @@
ForgeInstaller::ForgeInstaller(QString filename, QString universal_url) ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
{ {
std::shared_ptr<DerpVersion> newVersion; std::shared_ptr<OneSixVersion> newVersion;
m_universal_url = universal_url; m_universal_url = universal_url;
QuaZip zip(filename); QuaZip zip(filename);
@ -64,7 +64,7 @@ ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
// read the forge version info // read the forge version info
{ {
newVersion = DerpVersion::fromJson(versionInfoVal.toObject()); newVersion = OneSixVersion::fromJson(versionInfoVal.toObject());
if (!newVersion) if (!newVersion)
return; return;
} }
@ -74,7 +74,7 @@ ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
internalPath = installObj.value("filePath").toString(); internalPath = installObj.value("filePath").toString();
// where do we put the library? decode the mojang path // where do we put the library? decode the mojang path
DerpLibrary lib(libraryName); OneSixLibrary lib(libraryName);
lib.finalize(); lib.finalize();
auto cacheentry = MMC->metacache()->resolveEntry("libraries", lib.storagePath()); 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(); realVersionId = m_forge_version->id = installObj.value("minecraft").toString();
} }
bool ForgeInstaller::add(DerpInstance *to) bool ForgeInstaller::add(OneSixInstance *to)
{ {
if (!BaseInstaller::add(to)) if (!BaseInstaller::add(to))
{ {

View File

@ -20,20 +20,20 @@
#include <QString> #include <QString>
#include <memory> #include <memory>
class DerpVersion; class OneSixVersion;
class ForgeInstaller : public BaseInstaller class ForgeInstaller : public BaseInstaller
{ {
public: public:
ForgeInstaller(QString filename, QString universal_url); ForgeInstaller(QString filename, QString universal_url);
bool add(DerpInstance *to) override; bool add(OneSixInstance *to) override;
QString id() const override { return "net.minecraftforge"; } QString id() const override { return "net.minecraftforge"; }
private: private:
// the version, read from the installer // the version, read from the installer
std::shared_ptr<DerpVersion> m_forge_version; std::shared_ptr<OneSixVersion> m_forge_version;
QString internalPath; QString internalPath;
QString finalPath; QString finalPath;
QString realVersionId; QString realVersionId;

View File

@ -21,10 +21,10 @@
#include "BaseInstance.h" #include "BaseInstance.h"
#include "LegacyInstance.h" #include "LegacyInstance.h"
#include "LegacyFTBInstance.h" #include "LegacyFTBInstance.h"
#include "DerpInstance.h" #include "OneSixInstance.h"
#include "DerpFTBInstance.h" #include "OneSixFTBInstance.h"
#include "NostalgiaInstance.h" #include "NostalgiaInstance.h"
#include "DerpInstance.h" #include "OneSixInstance.h"
#include "BaseVersion.h" #include "BaseVersion.h"
#include "MinecraftVersion.h" #include "MinecraftVersion.h"
@ -51,9 +51,9 @@ InstanceFactory::InstLoadError InstanceFactory::loadInstance(BaseInstance *&inst
QString inst_type = m_settings->get("InstanceType").toString(); QString inst_type = m_settings->get("InstanceType").toString();
// FIXME: replace with a map lookup, where instance classes register their types // 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") else if (inst_type == "Legacy")
{ {
@ -67,9 +67,9 @@ InstanceFactory::InstLoadError InstanceFactory::loadInstance(BaseInstance *&inst
{ {
inst = new LegacyFTBInstance(instDir, m_settings, this); 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 else
{ {
@ -102,15 +102,15 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *&
switch (mcVer->type) switch (mcVer->type)
{ {
case MinecraftVersion::Legacy: case MinecraftVersion::Legacy:
// TODO derp // TODO OneSix
m_settings->set("InstanceType", "Legacy"); m_settings->set("InstanceType", "Legacy");
inst = new LegacyInstance(instDir, m_settings, this); inst = new LegacyInstance(instDir, m_settings, this);
inst->setIntendedVersionId(version->descriptor()); inst->setIntendedVersionId(version->descriptor());
inst->setShouldUseCustomBaseJar(false); inst->setShouldUseCustomBaseJar(false);
break; break;
case MinecraftVersion::Derp: case MinecraftVersion::OneSix:
m_settings->set("InstanceType", "Derp"); m_settings->set("InstanceType", "OneSix");
inst = new DerpInstance(instDir, m_settings, this); inst = new OneSixInstance(instDir, m_settings, this);
inst->setIntendedVersionId(version->descriptor()); inst->setIntendedVersionId(version->descriptor());
inst->setShouldUseCustomBaseJar(false); inst->setShouldUseCustomBaseJar(false);
break; break;
@ -137,9 +137,9 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *&
inst->setIntendedVersionId(version->descriptor()); inst->setIntendedVersionId(version->descriptor());
inst->setShouldUseCustomBaseJar(false); inst->setShouldUseCustomBaseJar(false);
break; break;
case MinecraftVersion::Derp: case MinecraftVersion::OneSix:
m_settings->set("InstanceType", "DerpFTB"); m_settings->set("InstanceType", "OneSixFTB");
inst = new DerpFTBInstance(instDir, m_settings, this); inst = new OneSixFTBInstance(instDir, m_settings, this);
inst->setIntendedVersionId(version->descriptor()); inst->setIntendedVersionId(version->descriptor());
inst->setShouldUseCustomBaseJar(false); inst->setShouldUseCustomBaseJar(false);
break; break;
@ -176,8 +176,8 @@ InstanceFactory::InstCreateError InstanceFactory::copyInstance(BaseInstance *&ne
m_settings->registerSetting("InstanceType", "Legacy"); m_settings->registerSetting("InstanceType", "Legacy");
QString inst_type = m_settings->get("InstanceType").toString(); QString inst_type = m_settings->get("InstanceType").toString();
if(inst_type == "OneSixFTB" || inst_type == "DerpFTB") if(inst_type == "OneSixFTB" || inst_type == "OneSixFTB")
m_settings->set("InstanceType", "Derp"); m_settings->set("InstanceType", "OneSix");
if(inst_type == "LegacyFTB") if(inst_type == "LegacyFTB")
m_settings->set("InstanceType", "Legacy"); m_settings->set("InstanceType", "Legacy");

View File

@ -68,7 +68,7 @@ public:
virtual QString intendedVersionId() const override; virtual QString intendedVersionId() const override;
virtual bool setIntendedVersionId(QString version) override; virtual bool setIntendedVersionId(QString version) override;
// the `version' of Legacy instances is defined by the launcher code. // 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 virtual bool versionIsCustom() override
{ {
return false; return false;

View File

@ -20,9 +20,9 @@
#include "logger/QsLog.h" #include "logger/QsLog.h"
#include "DerpVersion.h" #include "OneSixVersion.h"
#include "DerpLibrary.h" #include "OneSixLibrary.h"
#include "DerpInstance.h" #include "OneSixInstance.h"
QMap<QString, QString> LiteLoaderInstaller::m_launcherWrapperVersionMapping; 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()); return m_launcherWrapperVersionMapping.contains(instance->intendedVersionId());
} }
bool LiteLoaderInstaller::add(DerpInstance *to) bool LiteLoaderInstaller::add(OneSixInstance *to)
{ {
if (!BaseInstaller::add(to)) if (!BaseInstaller::add(to))
{ {
@ -60,7 +60,7 @@ bool LiteLoaderInstaller::add(DerpInstance *to)
// launchwrapper // launchwrapper
{ {
DerpLibrary launchwrapperLib("net.minecraft:launchwrapper:" + m_launcherWrapperVersionMapping[to->intendedVersionId()]); OneSixLibrary launchwrapperLib("net.minecraft:launchwrapper:" + m_launcherWrapperVersionMapping[to->intendedVersionId()]);
launchwrapperLib.finalize(); launchwrapperLib.finalize();
QJsonObject lwLibObj = launchwrapperLib.toJson(); QJsonObject lwLibObj = launchwrapperLib.toJson();
lwLibObj.insert("insert", QString("prepend")); lwLibObj.insert("insert", QString("prepend"));
@ -69,7 +69,7 @@ bool LiteLoaderInstaller::add(DerpInstance *to)
// liteloader // liteloader
{ {
DerpLibrary liteloaderLib("com.mumfrey:liteloader:" + to->intendedVersionId()); OneSixLibrary liteloaderLib("com.mumfrey:liteloader:" + to->intendedVersionId());
liteloaderLib.setBaseUrl("http://dl.liteloader.com/versions/"); liteloaderLib.setBaseUrl("http://dl.liteloader.com/versions/");
liteloaderLib.finalize(); liteloaderLib.finalize();
QJsonObject llLibObj = liteloaderLib.toJson(); QJsonObject llLibObj = liteloaderLib.toJson();

View File

@ -25,8 +25,8 @@ class LiteLoaderInstaller : public BaseInstaller
public: public:
LiteLoaderInstaller(); LiteLoaderInstaller();
bool canApply(DerpInstance *instance) const override; bool canApply(OneSixInstance *instance) const override;
bool add(DerpInstance *to) override; bool add(OneSixInstance *to) override;
private: private:
virtual QString id() const override { return "com.mumfrey.liteloader"; } virtual QString id() const override { return "com.mumfrey.liteloader"; }

View File

@ -32,7 +32,7 @@ struct MinecraftVersion : public BaseVersion
/// This version's type. Used internally to identify what kind of version this is. /// This version's type. Used internally to identify what kind of version this is.
enum VersionType enum VersionType
{ {
Derp, OneSix,
Legacy, Legacy,
Nostalgia Nostalgia
} type; } type;
@ -66,8 +66,8 @@ struct MinecraftVersion : public BaseVersion
} }
switch (type) switch (type)
{ {
case Derp: case OneSix:
pre_final.append("Derp"); pre_final.append("OneSix");
break; break;
case Legacy: case Legacy:
pre_final.append("Legacy"); pre_final.append("Legacy");

View File

@ -17,7 +17,7 @@
NostalgiaInstance::NostalgiaInstance(const QString &rootDir, SettingsObject *settings, NostalgiaInstance::NostalgiaInstance(const QString &rootDir, SettingsObject *settings,
QObject *parent) QObject *parent)
: DerpInstance(rootDir, settings, parent) : OneSixInstance(rootDir, settings, parent)
{ {
} }

View File

@ -15,9 +15,9 @@
#pragma once #pragma once
#include "DerpInstance.h" #include "OneSixInstance.h"
class NostalgiaInstance : public DerpInstance class NostalgiaInstance : public OneSixInstance
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -1,17 +1,17 @@
#include "DerpFTBInstance.h" #include "OneSixFTBInstance.h"
#include "DerpVersion.h" #include "OneSixVersion.h"
#include "DerpLibrary.h" #include "OneSixLibrary.h"
#include "tasks/SequentialTask.h" #include "tasks/SequentialTask.h"
#include "ForgeInstaller.h" #include "ForgeInstaller.h"
#include "lists/ForgeVersionList.h" #include "lists/ForgeVersionList.h"
#include "MultiMC.h" #include "MultiMC.h"
class DerpFTBInstanceForge : public Task class OneSixFTBInstanceForge : public Task
{ {
Q_OBJECT Q_OBJECT
public: 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) Task(parent), instance(inst), version("Forge " + version)
{ {
} }
@ -38,7 +38,7 @@ public:
fjob = new NetJob("Forge download"); fjob = new NetJob("Forge download");
fjob->addNetAction(CacheDownload::make(forgeVersion->installer_url, entry)); fjob->addNetAction(CacheDownload::make(forgeVersion->installer_url, entry));
connect(fjob, &NetJob::failed, [this](){emitFailed(m_failReason);}); 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); }); connect(fjob, &NetJob::progress, [this](qint64 c, qint64 total){ setProgress(100 * c / total); });
fjob->start(); fjob->start();
} }
@ -70,41 +70,41 @@ slots:
} }
private: private:
DerpFTBInstance *instance; OneSixFTBInstance *instance;
QString version; QString version;
ForgeVersionPtr forgeVersion; ForgeVersionPtr forgeVersion;
MetaEntryPtr entry; MetaEntryPtr entry;
NetJob *fjob; NetJob *fjob;
}; };
DerpFTBInstance::DerpFTBInstance(const QString &rootDir, SettingsObject *settings, QObject *parent) : OneSixFTBInstance::OneSixFTBInstance(const QString &rootDir, SettingsObject *settings, QObject *parent) :
DerpInstance(rootDir, settings, parent) OneSixInstance(rootDir, settings, parent)
{ {
QFile f(QDir(minecraftRoot()).absoluteFilePath("pack.json")); QFile f(QDir(minecraftRoot()).absoluteFilePath("pack.json"));
if (f.open(QFile::ReadOnly)) if (f.open(QFile::ReadOnly))
{ {
QString data = QString::fromUtf8(f.readAll()); QString data = QString::fromUtf8(f.readAll());
QRegularExpressionMatch match = QRegularExpression("net.minecraftforge:minecraftforge:[\\.\\d]*").match(data); 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(); m_forge->finalize();
} }
} }
QString DerpFTBInstance::id() const QString OneSixFTBInstance::id() const
{ {
return "FTB/" + BaseInstance::id(); 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; 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; std::shared_ptr<SequentialTask> task;
task.reset(new SequentialTask(this)); 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(std::shared_ptr<Task>(MMC->forgelist()->getLoadTask()));
} }
task->addTask(DerpInstance::doUpdate(only_prepare)); task->addTask(OneSixInstance::doUpdate(only_prepare));
task->addTask(std::shared_ptr<Task>(new DerpFTBInstanceForge(m_forge->version(), this, this))); 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. //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. //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; return task;
} }
#include "DerpFTBInstance.moc" #include "OneSixFTBInstance.moc"

View File

@ -1,14 +1,14 @@
#pragma once #pragma once
#include "DerpInstance.h" #include "OneSixInstance.h"
class DerpLibrary; class OneSixLibrary;
class DerpFTBInstance : public DerpInstance class OneSixFTBInstance : public OneSixInstance
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DerpFTBInstance(const QString &rootDir, SettingsObject *settings, explicit OneSixFTBInstance(const QString &rootDir, SettingsObject *settings,
QObject *parent = 0); QObject *parent = 0);
virtual QString getStatusbarDescription(); virtual QString getStatusbarDescription();
virtual bool menuActionEnabled(QString action_name) const; virtual bool menuActionEnabled(QString action_name) const;
@ -18,5 +18,5 @@ public:
virtual QString id() const; virtual QString id() const;
private: private:
std::shared_ptr<DerpLibrary> m_forge; std::shared_ptr<OneSixLibrary> m_forge;
}; };

View File

@ -13,28 +13,28 @@
* limitations under the License. * limitations under the License.
*/ */
#include "DerpInstance.h" #include "OneSixInstance.h"
#include <QIcon> #include <QIcon>
#include "DerpInstance_p.h" #include "OneSixInstance_p.h"
#include "DerpUpdate.h" #include "OneSixUpdate.h"
#include "DerpVersion.h" #include "OneSixVersion.h"
#include "pathutils.h" #include "pathutils.h"
#include "logger/QsLog.h" #include "logger/QsLog.h"
#include "assets/AssetsUtils.h" #include "assets/AssetsUtils.h"
#include "MultiMC.h" #include "MultiMC.h"
#include "icons/IconList.h" #include "icons/IconList.h"
#include "MinecraftProcess.h" #include "MinecraftProcess.h"
#include "gui/dialogs/DerpModEditDialog.h" #include "gui/dialogs/OneSixModEditDialog.h"
DerpInstance::DerpInstance(const QString &rootDir, SettingsObject *settings, QObject *parent) OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *settings, QObject *parent)
: BaseInstance(new DerpInstancePrivate(), rootDir, settings, parent) : BaseInstance(new OneSixInstancePrivate(), rootDir, settings, parent)
{ {
I_D(DerpInstance); I_D(OneSixInstance);
d->m_settings->registerSetting("IntendedVersion", ""); d->m_settings->registerSetting("IntendedVersion", "");
d->m_settings->registerSetting("ShouldUpdate", false); 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")) if (QDir(instanceRoot()).exists("version.json"))
{ {
reloadFullVersion(); 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) QString replaceTokensIn(QString text, QMap<QString, QString> with)
@ -74,7 +74,7 @@ QString replaceTokensIn(QString text, QMap<QString, QString> with)
return result; return result;
} }
QDir DerpInstance::reconstructAssets(std::shared_ptr<DerpVersion> version) QDir OneSixInstance::reconstructAssets(std::shared_ptr<OneSixVersion> version)
{ {
QDir assetsDir = QDir("assets/"); QDir assetsDir = QDir("assets/");
QDir indexDir = QDir(PathCombine(assetsDir.path(), "indexes")); QDir indexDir = QDir(PathCombine(assetsDir.path(), "indexes"));
@ -134,9 +134,9 @@ QDir DerpInstance::reconstructAssets(std::shared_ptr<DerpVersion> version)
return virtualRoot; return virtualRoot;
} }
QStringList DerpInstance::processMinecraftArgs(MojangAccountPtr account) QStringList OneSixInstance::processMinecraftArgs(MojangAccountPtr account)
{ {
I_D(DerpInstance); I_D(OneSixInstance);
auto version = d->version; auto version = d->version;
QString args_pattern = version->minecraftArguments; QString args_pattern = version->minecraftArguments;
@ -186,9 +186,9 @@ QStringList DerpInstance::processMinecraftArgs(MojangAccountPtr account)
return parts; return parts;
} }
MinecraftProcess *DerpInstance::prepareForLaunch(MojangAccountPtr account) MinecraftProcess *OneSixInstance::prepareForLaunch(MojangAccountPtr account)
{ {
I_D(DerpInstance); I_D(OneSixInstance);
QIcon icon = MMC->icons()->getIcon(iconKey()); QIcon icon = MMC->icons()->getIcon(iconKey());
auto pixmap = icon.pixmap(128, 128); auto pixmap = icon.pixmap(128, 128);
@ -248,16 +248,16 @@ MinecraftProcess *DerpInstance::prepareForLaunch(MojangAccountPtr account)
return proc; return proc;
} }
void DerpInstance::cleanupAfterRun() void OneSixInstance::cleanupAfterRun()
{ {
QString target_dir = PathCombine(instanceRoot(), "natives/"); QString target_dir = PathCombine(instanceRoot(), "natives/");
QDir dir(target_dir); QDir dir(target_dir);
dir.removeRecursively(); 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) if (!d->loader_mod_list)
{ {
d->loader_mod_list.reset(new ModList(loaderModsDir())); d->loader_mod_list.reset(new ModList(loaderModsDir()));
@ -266,9 +266,9 @@ std::shared_ptr<ModList> DerpInstance::loaderModList()
return d->loader_mod_list; 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) if (!d->resource_pack_list)
{ {
d->resource_pack_list.reset(new ModList(resourcePacksDir())); d->resource_pack_list.reset(new ModList(resourcePacksDir()));
@ -277,12 +277,12 @@ std::shared_ptr<ModList> DerpInstance::resourcePackList()
return d->resource_pack_list; 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); settings().set("IntendedVersion", version);
setShouldUpdate(true); setShouldUpdate(true);
@ -291,17 +291,17 @@ bool DerpInstance::setIntendedVersionId(QString version)
return true; return true;
} }
QString DerpInstance::intendedVersionId() const QString OneSixInstance::intendedVersionId() const
{ {
return settings().get("IntendedVersion").toString(); return settings().get("IntendedVersion").toString();
} }
void DerpInstance::setShouldUpdate(bool val) void OneSixInstance::setShouldUpdate(bool val)
{ {
settings().set("ShouldUpdate", val); settings().set("ShouldUpdate", val);
} }
bool DerpInstance::shouldUpdate() const bool OneSixInstance::shouldUpdate() const
{ {
QVariant var = settings().get("ShouldUpdate"); QVariant var = settings().get("ShouldUpdate");
if (!var.isValid() || var.toBool() == false) if (!var.isValid() || var.toBool() == false)
@ -311,60 +311,60 @@ bool DerpInstance::shouldUpdate() const
return true; return true;
} }
bool DerpInstance::versionIsCustom() bool OneSixInstance::versionIsCustom()
{ {
QDir patches(PathCombine(instanceRoot(), "patches/")); QDir patches(PathCombine(instanceRoot(), "patches/"));
return QFile::exists(PathCombine(instanceRoot(), "custom.json")) return QFile::exists(PathCombine(instanceRoot(), "custom.json"))
|| (patches.exists() && patches.count() >= 0); || (patches.exists() && patches.count() >= 0);
} }
QString DerpInstance::currentVersionId() const QString OneSixInstance::currentVersionId() const
{ {
return intendedVersionId(); return intendedVersionId();
} }
bool DerpInstance::reloadFullVersion(QWidget *widgetParent) bool OneSixInstance::reloadFullVersion(QWidget *widgetParent)
{ {
I_D(DerpInstance); I_D(OneSixInstance);
bool ret = d->version->reload(widgetParent); bool ret = d->version->reload(widgetParent);
emit versionReloaded(); emit versionReloaded();
return ret; return ret;
} }
void DerpInstance::clearFullVersion() void OneSixInstance::clearFullVersion()
{ {
I_D(DerpInstance); I_D(OneSixInstance);
d->version->clear(); d->version->clear();
emit versionReloaded(); emit versionReloaded();
} }
std::shared_ptr<DerpVersion> DerpInstance::getFullVersion() std::shared_ptr<OneSixVersion> OneSixInstance::getFullVersion()
{ {
I_D(DerpInstance); I_D(OneSixInstance);
return d->version; return d->version;
} }
QString DerpInstance::defaultBaseJar() const QString OneSixInstance::defaultBaseJar() const
{ {
return "versions/" + intendedVersionId() + "/" + intendedVersionId() + ".jar"; return "versions/" + intendedVersionId() + "/" + intendedVersionId() + ".jar";
} }
QString DerpInstance::defaultCustomBaseJar() const QString OneSixInstance::defaultCustomBaseJar() const
{ {
return PathCombine(instanceRoot(), "custom.jar"); return PathCombine(instanceRoot(), "custom.jar");
} }
bool DerpInstance::menuActionEnabled(QString action_name) const bool OneSixInstance::menuActionEnabled(QString action_name) const
{ {
if (action_name == "actionChangeInstLWJGLVersion") if (action_name == "actionChangeInstLWJGLVersion")
return false; return false;
return true; return true;
} }
QString DerpInstance::getStatusbarDescription() QString OneSixInstance::getStatusbarDescription()
{ {
QString descr = "Derp : " + intendedVersionId(); QString descr = "OneSix : " + intendedVersionId();
if (versionIsCustom()) if (versionIsCustom())
{ {
descr + " (custom)"; descr + " (custom)";
@ -372,17 +372,17 @@ QString DerpInstance::getStatusbarDescription()
return descr; return descr;
} }
QString DerpInstance::loaderModsDir() const QString OneSixInstance::loaderModsDir() const
{ {
return PathCombine(minecraftRoot(), "mods"); return PathCombine(minecraftRoot(), "mods");
} }
QString DerpInstance::resourcePacksDir() const QString OneSixInstance::resourcePacksDir() const
{ {
return PathCombine(minecraftRoot(), "resourcepacks"); return PathCombine(minecraftRoot(), "resourcepacks");
} }
QString DerpInstance::instanceConfigFolder() const QString OneSixInstance::instanceConfigFolder() const
{ {
return PathCombine(minecraftRoot(), "config"); return PathCombine(minecraftRoot(), "config");
} }

View File

@ -17,14 +17,14 @@
#include "BaseInstance.h" #include "BaseInstance.h"
#include "DerpVersion.h" #include "OneSixVersion.h"
#include "ModList.h" #include "ModList.h"
class DerpInstance : public BaseInstance class OneSixInstance : public BaseInstance
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DerpInstance(const QString &rootDir, SettingsObject *settings, explicit OneSixInstance(const QString &rootDir, SettingsObject *settings,
QObject *parent = 0); QObject *parent = 0);
////// Mod Lists ////// ////// Mod Lists //////
@ -56,7 +56,7 @@ public:
/// clears all version information in preparation for an update /// clears all version information in preparation for an update
void clearFullVersion(); void clearFullVersion();
/// get the current full version info /// get the current full version info
std::shared_ptr<DerpVersion> getFullVersion(); std::shared_ptr<OneSixVersion> getFullVersion();
/// is the current version original, or custom? /// is the current version original, or custom?
virtual bool versionIsCustom() override; virtual bool versionIsCustom() override;
@ -71,5 +71,5 @@ signals:
private: private:
QStringList processMinecraftArgs(MojangAccountPtr account); QStringList processMinecraftArgs(MojangAccountPtr account);
QDir reconstructAssets(std::shared_ptr<DerpVersion> version); QDir reconstructAssets(std::shared_ptr<OneSixVersion> version);
}; };

View File

@ -16,12 +16,12 @@
#pragma once #pragma once
#include "BaseInstance_p.h" #include "BaseInstance_p.h"
#include "DerpVersion.h" #include "OneSixVersion.h"
#include "ModList.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> loader_mod_list;
std::shared_ptr<ModList> resource_pack_list; std::shared_ptr<ModList> resource_pack_list;
}; };

View File

@ -15,15 +15,15 @@
#include <QJsonArray> #include <QJsonArray>
#include "DerpLibrary.h" #include "OneSixLibrary.h"
#include "DerpRule.h" #include "OneSixRule.h"
#include "OpSys.h" #include "OpSys.h"
#include "logic/net/URLConstants.h" #include "logic/net/URLConstants.h"
#include <pathutils.h> #include <pathutils.h>
#include <JlCompress.h> #include <JlCompress.h>
#include "logger/QsLog.h" #include "logger/QsLog.h"
void DerpLibrary::finalize() void OneSixLibrary::finalize()
{ {
QStringList parts = m_name.split(':'); QStringList parts = m_name.split(':');
QString relative = parts[0]; 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; m_name = name;
} }
void DerpLibrary::setBaseUrl(const QString &base_url) void OneSixLibrary::setBaseUrl(const QString &base_url)
{ {
m_base_url = base_url; m_base_url = base_url;
} }
void DerpLibrary::setIsNative() void OneSixLibrary::setIsNative()
{ {
m_is_native = true; 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_is_native = true;
m_native_suffixes[os] = suffix; 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; m_rules = rules;
} }
bool DerpLibrary::isActive() const bool OneSixLibrary::isActive() const
{ {
return m_is_active; return m_is_active;
} }
bool DerpLibrary::isNative() const bool OneSixLibrary::isNative() const
{ {
return m_is_native; return m_is_native;
} }
QString DerpLibrary::downloadUrl() const QString OneSixLibrary::downloadUrl() const
{ {
if (m_absolute_url.size()) if (m_absolute_url.size())
return m_absolute_url; return m_absolute_url;
return m_download_url; return m_download_url;
} }
QString DerpLibrary::storagePath() const QString OneSixLibrary::storagePath() const
{ {
return m_storage_path; return m_storage_path;
} }
void DerpLibrary::setAbsoluteUrl(const QString &absolute_url) void OneSixLibrary::setAbsoluteUrl(const QString &absolute_url)
{ {
m_absolute_url = absolute_url; m_absolute_url = absolute_url;
} }
QString DerpLibrary::absoluteUrl() const QString OneSixLibrary::absoluteUrl() const
{ {
return m_absolute_url; return m_absolute_url;
} }
void DerpLibrary::setHint(const QString &hint) void OneSixLibrary::setHint(const QString &hint)
{ {
m_hint = hint; m_hint = hint;
} }
QString DerpLibrary::hint() const QString OneSixLibrary::hint() const
{ {
return m_hint; return m_hint;
} }
bool DerpLibrary::filesExist() bool OneSixLibrary::filesExist()
{ {
QString storage = storagePath(); QString storage = storagePath();
if (storage.contains("${arch}")) if (storage.contains("${arch}"))
@ -167,7 +167,7 @@ bool DerpLibrary::filesExist()
return true; return true;
} }
bool DerpLibrary::extractTo(QString target_dir) bool OneSixLibrary::extractTo(QString target_dir)
{ {
QString storage = storagePath(); QString storage = storagePath();
if (storage.contains("${arch}")) if (storage.contains("${arch}"))
@ -220,7 +220,7 @@ bool DerpLibrary::extractTo(QString target_dir)
return true; return true;
} }
QJsonObject DerpLibrary::toJson() QJsonObject OneSixLibrary::toJson()
{ {
QJsonObject libRoot; QJsonObject libRoot;
libRoot.insert("name", m_name); libRoot.insert("name", m_name);

View File

@ -26,7 +26,7 @@
class Rule; class Rule;
class DerpLibrary class OneSixLibrary
{ {
private: private:
// basic values used internally (so far) // basic values used internally (so far)
@ -63,7 +63,7 @@ public:
public: public:
/// Constructor /// Constructor
DerpLibrary(const QString &name) OneSixLibrary(const QString &name)
{ {
m_name = name; m_name = name;
} }

View File

@ -16,7 +16,7 @@
#include <QJsonObject> #include <QJsonObject>
#include <QJsonArray> #include <QJsonArray>
#include "DerpRule.h" #include "OneSixRule.h"
QList<std::shared_ptr<Rule>> rulesFromJsonV4(const QJsonObject &objectWithRules) QList<std::shared_ptr<Rule>> rulesFromJsonV4(const QJsonObject &objectWithRules)
{ {

View File

@ -17,7 +17,7 @@
#include <QString> #include <QString>
#include "logic/DerpLibrary.h" #include "logic/OneSixLibrary.h"
enum RuleAction enum RuleAction
{ {
@ -33,7 +33,7 @@ class Rule
{ {
protected: protected:
RuleAction m_result; RuleAction m_result;
virtual bool applies(DerpLibrary *parent) = 0; virtual bool applies(OneSixLibrary *parent) = 0;
public: public:
Rule(RuleAction result) : m_result(result) Rule(RuleAction result) : m_result(result)
@ -41,7 +41,7 @@ public:
} }
virtual ~Rule() {}; virtual ~Rule() {};
virtual QJsonObject toJson() = 0; virtual QJsonObject toJson() = 0;
RuleAction apply(DerpLibrary *parent) RuleAction apply(OneSixLibrary *parent)
{ {
if (applies(parent)) if (applies(parent))
return m_result; return m_result;
@ -60,7 +60,7 @@ private:
QString m_version_regexp; QString m_version_regexp;
protected: protected:
virtual bool applies(DerpLibrary *) virtual bool applies(OneSixLibrary *)
{ {
return (m_system == currentSystem); return (m_system == currentSystem);
} }
@ -81,7 +81,7 @@ public:
class ImplicitRule : public Rule class ImplicitRule : public Rule
{ {
protected: protected:
virtual bool applies(DerpLibrary *) virtual bool applies(OneSixLibrary *)
{ {
return true; return true;
} }

View File

@ -14,7 +14,7 @@
*/ */
#include "MultiMC.h" #include "MultiMC.h"
#include "DerpUpdate.h" #include "OneSixUpdate.h"
#include <QtNetwork> #include <QtNetwork>
@ -25,9 +25,9 @@
#include "BaseInstance.h" #include "BaseInstance.h"
#include "lists/MinecraftVersionList.h" #include "lists/MinecraftVersionList.h"
#include "DerpVersion.h" #include "OneSixVersion.h"
#include "DerpLibrary.h" #include "OneSixLibrary.h"
#include "DerpInstance.h" #include "OneSixInstance.h"
#include "net/ForgeMirrors.h" #include "net/ForgeMirrors.h"
#include "net/URLConstants.h" #include "net/URLConstants.h"
#include "assets/AssetsUtils.h" #include "assets/AssetsUtils.h"
@ -35,12 +35,12 @@
#include "pathutils.h" #include "pathutils.h"
#include <JlCompress.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) : Task(parent), m_inst(inst), m_only_prepare(only_prepare)
{ {
} }
void DerpUpdate::executeTask() void OneSixUpdate::executeTask()
{ {
QString intendedVersion = m_inst->intendedVersionId(); 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."; QLOG_INFO() << m_inst->name() << ": getting version file.";
setStatus(tr("Getting the version files from Mojang...")); setStatus(tr("Getting the version files from Mojang..."));
@ -94,10 +94,10 @@ void DerpUpdate::versionFileStart()
specificVersionDownloadJob->start(); specificVersionDownloadJob->start();
} }
void DerpUpdate::versionFileFinished() void OneSixUpdate::versionFileFinished()
{ {
NetActionPtr DlJob = specificVersionDownloadJob->first(); NetActionPtr DlJob = specificVersionDownloadJob->first();
DerpInstance *inst = (DerpInstance *)m_inst; OneSixInstance *inst = (OneSixInstance *)m_inst;
QString version_id = targetVersion->descriptor(); QString version_id = targetVersion->descriptor();
QString inst_dir = m_inst->instanceRoot(); QString inst_dir = m_inst->instanceRoot();
@ -142,16 +142,16 @@ void DerpUpdate::versionFileFinished()
jarlibStart(); jarlibStart();
} }
void DerpUpdate::versionFileFailed() void OneSixUpdate::versionFileFailed()
{ {
emitFailed("Failed to download the version description. Try again."); emitFailed("Failed to download the version description. Try again.");
} }
void DerpUpdate::assetIndexStart() void OneSixUpdate::assetIndexStart()
{ {
setStatus(tr("Updating assets index...")); setStatus(tr("Updating assets index..."));
DerpInstance *inst = (DerpInstance *)m_inst; OneSixInstance *inst = (OneSixInstance *)m_inst;
std::shared_ptr<DerpVersion> version = inst->getFullVersion(); std::shared_ptr<OneSixVersion> version = inst->getFullVersion();
QString assetName = version->assets; QString assetName = version->assets;
QUrl indexUrl = "http://" + URLConstants::AWS_DOWNLOAD_INDEXES + assetName + ".json"; QUrl indexUrl = "http://" + URLConstants::AWS_DOWNLOAD_INDEXES + assetName + ".json";
QString localPath = assetName + ".json"; QString localPath = assetName + ".json";
@ -170,12 +170,12 @@ void DerpUpdate::assetIndexStart()
jarlibDownloadJob->start(); jarlibDownloadJob->start();
} }
void DerpUpdate::assetIndexFinished() void OneSixUpdate::assetIndexFinished()
{ {
AssetsIndex index; AssetsIndex index;
DerpInstance *inst = (DerpInstance *)m_inst; OneSixInstance *inst = (OneSixInstance *)m_inst;
std::shared_ptr<DerpVersion> version = inst->getFullVersion(); std::shared_ptr<OneSixVersion> version = inst->getFullVersion();
QString assetName = version->assets; QString assetName = version->assets;
QString asset_fname = "assets/indexes/" + assetName + ".json"; QString asset_fname = "assets/indexes/" + assetName + ".json";
@ -215,26 +215,26 @@ void DerpUpdate::assetIndexFinished()
assetsFinished(); assetsFinished();
} }
void DerpUpdate::assetIndexFailed() void OneSixUpdate::assetIndexFailed()
{ {
emitFailed("Failed to download the assets index!"); emitFailed("Failed to download the assets index!");
} }
void DerpUpdate::assetsFinished() void OneSixUpdate::assetsFinished()
{ {
prepareForLaunch(); prepareForLaunch();
} }
void DerpUpdate::assetsFailed() void OneSixUpdate::assetsFailed()
{ {
emitFailed("Failed to download assets!"); emitFailed("Failed to download assets!");
} }
void DerpUpdate::jarlibStart() void OneSixUpdate::jarlibStart()
{ {
setStatus(tr("Getting the library files from Mojang...")); setStatus(tr("Getting the library files from Mojang..."));
QLOG_INFO() << m_inst->name() << ": downloading libraries"; QLOG_INFO() << m_inst->name() << ": downloading libraries";
DerpInstance *inst = (DerpInstance *)m_inst; OneSixInstance *inst = (OneSixInstance *)m_inst;
bool successful = inst->reloadFullVersion(); bool successful = inst->reloadFullVersion();
if (!successful) if (!successful)
{ {
@ -244,7 +244,7 @@ void DerpUpdate::jarlibStart()
} }
// Build a list of URLs that will need to be downloaded. // 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 // minecraft.jar for this version
{ {
QString version_id = version->id; QString version_id = version->id;
@ -318,12 +318,12 @@ void DerpUpdate::jarlibStart()
jarlibDownloadJob->start(); jarlibDownloadJob->start();
} }
void DerpUpdate::jarlibFinished() void OneSixUpdate::jarlibFinished()
{ {
assetIndexStart(); assetIndexStart();
} }
void DerpUpdate::jarlibFailed() void OneSixUpdate::jarlibFailed()
{ {
QStringList failed = jarlibDownloadJob->getFailedFiles(); QStringList failed = jarlibDownloadJob->getFailedFiles();
QString failed_all = failed.join("\n"); QString failed_all = failed.join("\n");
@ -331,17 +331,17 @@ void DerpUpdate::jarlibFailed()
"\n\nPlease try again."); "\n\nPlease try again.");
} }
void DerpUpdate::prepareForLaunch() void OneSixUpdate::prepareForLaunch()
{ {
setStatus(tr("Preparing for launch...")); setStatus(tr("Preparing for launch..."));
QLOG_INFO() << m_inst->name() << ": 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. // delete any leftovers, if they are present.
derp_inst->cleanupAfterRun(); OneSix_inst->cleanupAfterRun();
QString natives_dir_raw = PathCombine(derp_inst->instanceRoot(), "natives/"); QString natives_dir_raw = PathCombine(OneSix_inst->instanceRoot(), "natives/");
auto version = derp_inst->getFullVersion(); auto version = OneSix_inst->getFullVersion();
if (!version) if (!version)
{ {
emitFailed("The version information for this instance is not complete. Try re-creating " emitFailed("The version information for this instance is not complete. Try re-creating "

View File

@ -25,11 +25,11 @@
class MinecraftVersion; class MinecraftVersion;
class BaseInstance; class BaseInstance;
class DerpUpdate : public Task class OneSixUpdate : public Task
{ {
Q_OBJECT Q_OBJECT
public: 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(); virtual void executeTask();
private private

View File

@ -13,228 +13,60 @@
* limitations under the License. * limitations under the License.
*/ */
#include "logic/DerpVersion.h" #include "OneSixVersion.h"
#include "logic/DerpLibrary.h"
#include "logic/DerpRule.h"
#include "logger/QsLog.h" #include <QDebug>
std::shared_ptr<DerpVersion> fromJsonV4(QJsonObject root, #include "OneSixVersionBuilder.h"
std::shared_ptr<DerpVersion> fullVersion)
OneSixVersion::OneSixVersion(OneSixInstance *instance, QObject *parent)
: QAbstractListModel(parent), m_instance(instance)
{ {
fullVersion->id = root.value("id").toString(); clear();
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;
} }
std::shared_ptr<DerpVersion> DerpVersion::fromJson(QJsonObject root) bool OneSixVersion::reload(QWidget *widgetParent)
{ {
std::shared_ptr<DerpVersion> readVersion(new DerpVersion()); return OneSixVersionBuilder::build(this, m_instance, widgetParent);
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>();
}
} }
std::shared_ptr<DerpVersion> DerpVersion::fromFile(QString filepath) void OneSixVersion::clear()
{ {
QFile file(filepath); id.clear();
if (!file.open(QIODevice::ReadOnly)) time.clear();
{ releaseTime.clear();
return std::shared_ptr<DerpVersion>(); type.clear();
} assets.clear();
processArguments.clear();
auto data = file.readAll(); minecraftArguments.clear();
QJsonParseError jsonError; minimumLauncherVersion = 0xDEADBEAF;
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError); mainClass.clear();
libraries.clear();
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;
} }
bool DerpVersion::toOriginalFile() void OneSixVersion::dump() const
{ {
if (original_file.isEmpty()) qDebug().nospace() << "OneSixVersion("
return false; << "\n\tid=" << id
QSaveFile file(original_file); << "\n\ttime=" << time
if (!file.open(QIODevice::WriteOnly)) << "\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) qDebug().nospace() << "\n)";
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();
} }
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) for (auto lib : libraries)
{ {
if (lib->isActive() && !lib->isNative()) if (lib->isActive() && !lib->isNative())
@ -245,9 +77,9 @@ QList<std::shared_ptr<DerpLibrary>> DerpVersion::getActiveNormalLibs()
return output; 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) for (auto lib : libraries)
{ {
if (lib->isActive() && lib->isNative()) if (lib->isActive() && lib->isNative())
@ -258,17 +90,17 @@ QList<std::shared_ptr<DerpLibrary>> DerpVersion::getActiveNativeLibs()
return output; 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() QVariant OneSixVersion::data(const QModelIndex &index, int role) const
{
endResetModel();
}
QVariant DerpVersion::data(const QModelIndex &index, int role) const
{ {
if (!index.isValid()) if (!index.isValid())
return QVariant(); return QVariant();
@ -296,7 +128,7 @@ QVariant DerpVersion::data(const QModelIndex &index, int role) const
return QVariant(); return QVariant();
} }
Qt::ItemFlags DerpVersion::flags(const QModelIndex &index) const Qt::ItemFlags OneSixVersion::flags(const QModelIndex &index) const
{ {
if (!index.isValid()) if (!index.isValid())
return Qt::NoItemFlags; return Qt::NoItemFlags;
@ -312,7 +144,7 @@ Qt::ItemFlags DerpVersion::flags(const QModelIndex &index) const
// return QAbstractListModel::flags(index); // 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) if (role != Qt::DisplayRole || orientation != Qt::Horizontal)
return QVariant(); 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(); return libraries.size();
} }
int DerpVersion::columnCount(const QModelIndex &parent) const int OneSixVersion::columnCount(const QModelIndex &parent) const
{ {
return 3; 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();
}

View File

@ -14,15 +14,23 @@
*/ */
#pragma once #pragma once
#include <QtCore>
#include <QAbstractListModel>
#include <QString>
#include <QList>
#include <memory> #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: public:
explicit OneSixVersion(OneSixInstance *instance, QObject *parent = 0);
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, virtual QVariant headerData(int section, Qt::Orientation orientation,
@ -30,24 +38,19 @@ public:
virtual int columnCount(const QModelIndex &parent) const; virtual int columnCount(const QModelIndex &parent) const;
virtual Qt::ItemFlags flags(const QModelIndex &index) const; virtual Qt::ItemFlags flags(const QModelIndex &index) const;
// serialization/deserialization bool reload(QWidget *widgetParent);
public: void clear();
bool toOriginalFile();
static std::shared_ptr<DerpVersion> fromJson(QJsonObject root); void dump() const;
static std::shared_ptr<DerpVersion> fromFile(QString filepath);
public: public:
QList<std::shared_ptr<DerpLibrary>> getActiveNormalLibs(); QList<std::shared_ptr<OneSixLibrary>> getActiveNormalLibs();
QList<std::shared_ptr<DerpLibrary>> getActiveNativeLibs(); QList<std::shared_ptr<OneSixLibrary>> getActiveNativeLibs();
// called when something starts/stops messing with the object
// FIXME: these are ugly in every possible way. static std::shared_ptr<OneSixVersion> fromJson(const QJsonObject &obj);
void externalUpdateStart();
void externalUpdateFinish();
// data members // data members
public: public:
/// file this was read from. blank, if none
QString original_file;
/// the ID - determines which jar to use! ACTUALLY IMPORTANT! /// the ID - determines which jar to use! ACTUALLY IMPORTANT!
QString id; QString id;
/// Last updated time - as a string /// Last updated time - as a string
@ -81,7 +84,7 @@ public:
QString mainClass; QString mainClass;
/// the list of libs - both active and inactive, native and java /// 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. 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; // QList<Rule> rules;
private:
OneSixInstance *m_instance;
}; };
QDebug operator<<(QDebug &dbg, const OneSixVersion *version);
QDebug operator<<(QDebug &dbg, const OneSixLibrary *library);

View File

@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "DerpVersionBuilder.h" #include "OneSixVersionBuilder.h"
#include <QList> #include <QList>
#include <QJsonObject> #include <QJsonObject>
@ -26,35 +26,35 @@
#include <QDir> #include <QDir>
#include <QDebug> #include <QDebug>
#include "DerpVersion.h" #include "OneSixVersion.h"
#include "DerpInstance.h" #include "OneSixInstance.h"
#include "DerpRule.h" #include "OneSixRule.h"
#include "logger/QsLog.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_version = version;
builder.m_instance = instance; builder.m_instance = instance;
builder.m_widgetParent = widgetParent; builder.m_widgetParent = widgetParent;
return builder.build(); 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_version = version;
builder.m_instance = 0; builder.m_instance = 0;
builder.m_widgetParent = 0; builder.m_widgetParent = 0;
return builder.read(obj); return builder.read(obj);
} }
bool DerpVersionBuilder::build() bool OneSixVersionBuilder::build()
{ {
m_version->clear(); m_version->clear();
@ -127,7 +127,7 @@ bool DerpVersionBuilder::build()
return true; return true;
} }
bool DerpVersionBuilder::read(const QJsonObject &obj) bool OneSixVersionBuilder::read(const QJsonObject &obj)
{ {
m_version->clear(); 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()) if (obj.contains(key) && obj.value(key).isString())
{ {
(lib.get()->*func)(obj.value(key).toString()); (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, "id", m_version->id);
applyString(object, "mainClass", m_version->mainClass); applyString(object, "mainClass", m_version->mainClass);
@ -265,7 +265,7 @@ bool DerpVersionBuilder::apply(const QJsonObject &object)
return true; 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) 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; return -1;
} }
bool DerpVersionBuilder::applyLibrary(const QJsonObject &lib, const DerpVersionBuilder::Type type) bool OneSixVersionBuilder::applyLibrary(const QJsonObject &lib, const OneSixVersionBuilder::Type type)
{ {
// Library name // Library name
auto nameVal = lib.value("name"); auto nameVal = lib.value("name");
@ -302,11 +302,11 @@ bool DerpVersionBuilder::applyLibrary(const QJsonObject &lib, const DerpVersionB
return false; return false;
} }
std::shared_ptr<DerpLibrary> library; std::shared_ptr<OneSixLibrary> library;
if (lib.value("insert").toString() != "apply" && type == Add) 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()) while (it.hasNext())
{ {
if (it.next()->rawName() == name) if (it.next()->rawName() == name)
@ -322,13 +322,13 @@ bool DerpVersionBuilder::applyLibrary(const QJsonObject &lib, const DerpVersionB
} }
else else
{ {
library.reset(new DerpLibrary(nameVal.toString())); library.reset(new OneSixLibrary(nameVal.toString()));
} }
applyString(lib, "url", library, &DerpLibrary::setBaseUrl); applyString(lib, "url", library, &OneSixLibrary::setBaseUrl);
applyString(lib, "MMC-hint", library, &DerpLibrary::setHint); applyString(lib, "MMC-hint", library, &OneSixLibrary::setHint);
applyString(lib, "MMC-absulute_url", library, &DerpLibrary::setAbsoluteUrl); applyString(lib, "MMC-absulute_url", library, &OneSixLibrary::setAbsoluteUrl);
applyString(lib, "MMC-absoluteUrl", library, &DerpLibrary::setAbsoluteUrl); applyString(lib, "MMC-absoluteUrl", library, &OneSixLibrary::setAbsoluteUrl);
auto extractVal = lib.value("extract"); auto extractVal = lib.value("extract");
if (extractVal.isObject()) if (extractVal.isObject())
@ -426,7 +426,7 @@ bool DerpVersionBuilder::applyLibrary(const QJsonObject &lib, const DerpVersionB
return true; return true;
} }
bool DerpVersionBuilder::read(const QFileInfo &fileInfo, QJsonObject *out) bool OneSixVersionBuilder::read(const QFileInfo &fileInfo, QJsonObject *out)
{ {
QFile file(fileInfo.absoluteFilePath()); QFile file(fileInfo.absoluteFilePath());
if (!file.open(QFile::ReadOnly)) if (!file.open(QFile::ReadOnly))

View File

@ -17,22 +17,22 @@
#include <QString> #include <QString>
class DerpVersion; class OneSixVersion;
class DerpInstance; class OneSixInstance;
class QWidget; class QWidget;
class QJsonObject; class QJsonObject;
class QFileInfo; class QFileInfo;
class DerpVersionBuilder class OneSixVersionBuilder
{ {
DerpVersionBuilder(); OneSixVersionBuilder();
public: public:
static bool build(DerpVersion *version, DerpInstance *instance, QWidget *widgetParent); static bool build(OneSixVersion *version, OneSixInstance *instance, QWidget *widgetParent);
static bool read(DerpVersion *version, const QJsonObject &obj); static bool read(OneSixVersion *version, const QJsonObject &obj);
private: private:
DerpVersion *m_version; OneSixVersion *m_version;
DerpInstance *m_instance; OneSixInstance *m_instance;
QWidget *m_widgetParent; QWidget *m_widgetParent;
enum Type enum Type

View File

@ -234,18 +234,18 @@ void MCVListLoadTask::list_downloaded()
} }
// Parse the type. // Parse the type.
MinecraftVersion::VersionType versionType; MinecraftVersion::VersionType versionType;
// Derp or Legacy. use filter to determine type // OneSix or Legacy. use filter to determine type
if (versionTypeStr == "release") if (versionTypeStr == "release")
{ {
versionType = legacyWhitelist.contains(versionID) ? MinecraftVersion::Legacy versionType = legacyWhitelist.contains(versionID) ? MinecraftVersion::Legacy
: MinecraftVersion::Derp; : MinecraftVersion::OneSix;
is_latest = (versionID == latestReleaseID); is_latest = (versionID == latestReleaseID);
is_snapshot = false; is_snapshot = false;
} }
else if (versionTypeStr == "snapshot") // It's a snapshot... yay else if (versionTypeStr == "snapshot") // It's a snapshot... yay
{ {
versionType = legacyWhitelist.contains(versionID) ? MinecraftVersion::Legacy versionType = legacyWhitelist.contains(versionID) ? MinecraftVersion::Legacy
: MinecraftVersion::Derp; : MinecraftVersion::OneSix;
is_latest = (versionID == latestSnapshotID); is_latest = (versionID == latestSnapshotID);
is_snapshot = true; is_snapshot = true;
} }