NOISSUE Fixed code for PR
This commit is contained in:
parent
b8ca36372b
commit
0812e3a87b
@ -7,6 +7,7 @@
|
|||||||
#include "settings/INISettingsObject.h"
|
#include "settings/INISettingsObject.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
#include "minecraft/ComponentList.h"
|
#include "minecraft/ComponentList.h"
|
||||||
|
#include "minecraft/GradleSpecifier.h"
|
||||||
|
|
||||||
FtbPackInstallTask::FtbPackInstallTask(FtbPackDownloader *downloader, SettingsObjectPtr settings,
|
FtbPackInstallTask::FtbPackInstallTask(FtbPackDownloader *downloader, SettingsObjectPtr settings,
|
||||||
const QString &stagingPath, const QString &instName, const QString &instIcon, const QString &instGroup) :
|
const QString &stagingPath, const QString &instName, const QString &instIcon, const QString &instGroup) :
|
||||||
@ -79,7 +80,10 @@ void FtbPackInstallTask::install() {
|
|||||||
QDir unzipMcDir(m_stagingPath + "/unzip/minecraft");
|
QDir unzipMcDir(m_stagingPath + "/unzip/minecraft");
|
||||||
if(unzipMcDir.exists()) {
|
if(unzipMcDir.exists()) {
|
||||||
//ok, found minecraft dir, move contents to instance dir
|
//ok, found minecraft dir, move contents to instance dir
|
||||||
moveRecursively(m_stagingPath + "/unzip/minecraft", m_stagingPath + "/.minecraft");
|
if(!QDir().rename(m_stagingPath + "/unzip/minecraft", m_stagingPath + "/.minecraft")) {
|
||||||
|
emitFailed(tr("Failed to move unzipped minecraft!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
QString instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
||||||
@ -111,13 +115,9 @@ void FtbPackInstallTask::install() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//It is always maven like
|
GradleSpecifier forgeVersion(nameValue);
|
||||||
//net.minecraftforge:forge:1.7.10-10.13.4.1448-1.7.10:universal => 1.7.10-10.13.4.1448-1.7.10
|
|
||||||
QString forgeVersion = nameValue.split(":").at(2);
|
|
||||||
|
|
||||||
//1.7.10-10.13.4.1448-1.7.10 => 10.13.4.1448
|
components->setComponentVersion("net.minecraftforge", forgeVersion.version().replace(toInstall.mcVersion, "").replace("-", ""));
|
||||||
forgeVersion = forgeVersion.replace(toInstall.mcVersion, "").replace("-", "");
|
|
||||||
components->setComponentVersion("net.minecraftforge", forgeVersion);
|
|
||||||
packJson.remove();
|
packJson.remove();
|
||||||
fallback = false;
|
fallback = false;
|
||||||
break;
|
break;
|
||||||
@ -164,43 +164,8 @@ void FtbPackInstallTask::install() {
|
|||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FtbPackInstallTask::moveRecursively(QString sourceFolder, QString destFolder)
|
bool FtbPackInstallTask::abort()
|
||||||
{
|
{
|
||||||
bool success = false;
|
|
||||||
QDir sourceDir(sourceFolder);
|
|
||||||
|
|
||||||
if(!sourceDir.exists())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
QDir destDir(destFolder);
|
|
||||||
if(!destDir.exists())
|
|
||||||
destDir.mkdir(destFolder);
|
|
||||||
|
|
||||||
QStringList files = sourceDir.entryList(QDir::Files);
|
|
||||||
for(int i = 0; i< files.count(); i++) {
|
|
||||||
QString srcName = sourceFolder + QDir::separator() + files[i];
|
|
||||||
QString destName = destFolder + QDir::separator() + files[i];
|
|
||||||
success = QFile::copy(srcName, destName);
|
|
||||||
if(!success)
|
|
||||||
return false;
|
|
||||||
QFile::remove(srcName);
|
|
||||||
}
|
|
||||||
|
|
||||||
files.clear();
|
|
||||||
files = sourceDir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
|
|
||||||
for(int i = 0; i< files.count(); i++)
|
|
||||||
{
|
|
||||||
QString srcName = sourceFolder + QDir::separator() + files[i];
|
|
||||||
QString destName = destFolder + QDir::separator() + files[i];
|
|
||||||
success = moveRecursively(srcName, destName);
|
|
||||||
if(!success)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QDir(sourceFolder).rmdir(sourceFolder);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FtbPackInstallTask::abort() {
|
|
||||||
if(abortable) {
|
if(abortable) {
|
||||||
return m_downloader->getNetJob()->abort();
|
return m_downloader->getNetJob()->abort();
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
|
|
||||||
#include <MMCStrings.h>
|
#include <MMCStrings.h>
|
||||||
|
#include <Version.h>
|
||||||
|
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
|
|
||||||
@ -18,33 +19,9 @@ bool FtbFilterModel::lessThan(const QModelIndex &left, const QModelIndex &right)
|
|||||||
FtbModpack rightPack = sourceModel()->data(right, Qt::UserRole).value<FtbModpack>();
|
FtbModpack rightPack = sourceModel()->data(right, Qt::UserRole).value<FtbModpack>();
|
||||||
|
|
||||||
if(currentSorting == Sorting::ByGameVersion) {
|
if(currentSorting == Sorting::ByGameVersion) {
|
||||||
QStringList leftList = leftPack.mcVersion.split(".");
|
Version lv(leftPack.mcVersion);
|
||||||
QStringList rightList = rightPack.mcVersion.split(".");
|
Version rv(rightPack.mcVersion);
|
||||||
|
return lv < rv;
|
||||||
if(leftList.size() < 1) {
|
|
||||||
return true;
|
|
||||||
} else if(rightList.size() < 1) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
for(int i = 0; i < qMax(leftList.size(), rightList.size()); i++) {
|
|
||||||
if(leftList.size() -1 < i) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(rightList.size() -1 < i) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int leftV = leftList.at(i).toInt();
|
|
||||||
int rightV = rightList.at(i).toInt();
|
|
||||||
|
|
||||||
if(leftV != rightV) {
|
|
||||||
return leftV < rightV;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if(currentSorting == Sorting::ByName) {
|
} else if(currentSorting == Sorting::ByName) {
|
||||||
return Strings::naturalCompare(leftPack.name, rightPack.name, Qt::CaseSensitive) >= 0;
|
return Strings::naturalCompare(leftPack.name, rightPack.name, Qt::CaseSensitive) >= 0;
|
||||||
@ -93,7 +70,7 @@ int FtbListModel::columnCount(const QModelIndex &parent) const
|
|||||||
QVariant FtbListModel::data(const QModelIndex &index, int role) const
|
QVariant FtbListModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
int pos = index.row();
|
int pos = index.row();
|
||||||
if(modpacks.size() < pos || pos < 0) {
|
if(modpacks.size() <= pos || pos < 0) {
|
||||||
return QString("INVALID INDEX %1").arg(pos);
|
return QString("INVALID INDEX %1").arg(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,8 +91,10 @@ QVariant FtbListModel::data(const QModelIndex &index, int role) const
|
|||||||
//TODO: Add pack logos or something... but they have a weird size. This needs some design hacks
|
//TODO: Add pack logos or something... but they have a weird size. This needs some design hacks
|
||||||
} else if(role == Qt::TextColorRole) {
|
} else if(role == Qt::TextColorRole) {
|
||||||
if(pack.broken) {
|
if(pack.broken) {
|
||||||
|
//FIXME: Hardcoded color
|
||||||
return QColor(255, 0, 50);
|
return QColor(255, 0, 50);
|
||||||
} else if(pack.bugged) {
|
} else if(pack.bugged) {
|
||||||
|
//FIXME: Hardcoded color
|
||||||
//bugged pack, currently only indicates bugged xml
|
//bugged pack, currently only indicates bugged xml
|
||||||
return QColor(244, 229, 66);
|
return QColor(244, 229, 66);
|
||||||
}
|
}
|
||||||
|
@ -315,14 +315,11 @@ void NewInstanceDialog::on_btnChooseFtbPack_clicked() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NewInstanceDialog::ftbPackDataDownloadSuccessfully() {
|
void NewInstanceDialog::ftbPackDataDownloadSuccessfully() {
|
||||||
ui->packDataDownloadStatus->setText(tr("(Pack data download complete)"));
|
ui->packDataDownloadStatus->setText(tr("(Data download complete)"));
|
||||||
// ui->labelFtbPack->setText(tr("Disabled for now... not completed!"));
|
|
||||||
|
|
||||||
// Disable for PR
|
|
||||||
ui->ftbBox->setEnabled(true);
|
ui->ftbBox->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewInstanceDialog::ftbPackDataDownloadFailed() {
|
void NewInstanceDialog::ftbPackDataDownloadFailed() {
|
||||||
ui->packDataDownloadStatus->setText(tr("(Pack data download failed)"));
|
ui->packDataDownloadStatus->setText(tr("(Data download failed)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user