NOISSUE Fixed code for PR

This commit is contained in:
Janrupf 2018-03-12 15:09:07 +01:00
parent b8ca36372b
commit 0812e3a87b
3 changed files with 17 additions and 76 deletions

View File

@ -7,6 +7,7 @@
#include "settings/INISettingsObject.h"
#include "minecraft/MinecraftInstance.h"
#include "minecraft/ComponentList.h"
#include "minecraft/GradleSpecifier.h"
FtbPackInstallTask::FtbPackInstallTask(FtbPackDownloader *downloader, SettingsObjectPtr settings,
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");
if(unzipMcDir.exists()) {
//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");
@ -111,13 +115,9 @@ void FtbPackInstallTask::install() {
continue;
}
//It is always maven like
//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);
GradleSpecifier forgeVersion(nameValue);
//1.7.10-10.13.4.1448-1.7.10 => 10.13.4.1448
forgeVersion = forgeVersion.replace(toInstall.mcVersion, "").replace("-", "");
components->setComponentVersion("net.minecraftforge", forgeVersion);
components->setComponentVersion("net.minecraftforge", forgeVersion.version().replace(toInstall.mcVersion, "").replace("-", ""));
packJson.remove();
fallback = false;
break;
@ -164,43 +164,8 @@ void FtbPackInstallTask::install() {
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) {
return m_downloader->getNetJob()->abort();
}

View File

@ -2,6 +2,7 @@
#include "MultiMC.h"
#include <MMCStrings.h>
#include <Version.h>
#include <QtMath>
@ -18,33 +19,9 @@ bool FtbFilterModel::lessThan(const QModelIndex &left, const QModelIndex &right)
FtbModpack rightPack = sourceModel()->data(right, Qt::UserRole).value<FtbModpack>();
if(currentSorting == Sorting::ByGameVersion) {
QStringList leftList = leftPack.mcVersion.split(".");
QStringList rightList = rightPack.mcVersion.split(".");
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;
}
Version lv(leftPack.mcVersion);
Version rv(rightPack.mcVersion);
return lv < rv;
} else if(currentSorting == Sorting::ByName) {
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
{
int pos = index.row();
if(modpacks.size() < pos || pos < 0) {
if(modpacks.size() <= pos || pos < 0) {
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
} else if(role == Qt::TextColorRole) {
if(pack.broken) {
//FIXME: Hardcoded color
return QColor(255, 0, 50);
} else if(pack.bugged) {
//FIXME: Hardcoded color
//bugged pack, currently only indicates bugged xml
return QColor(244, 229, 66);
}

View File

@ -315,14 +315,11 @@ void NewInstanceDialog::on_btnChooseFtbPack_clicked() {
}
void NewInstanceDialog::ftbPackDataDownloadSuccessfully() {
ui->packDataDownloadStatus->setText(tr("(Pack data download complete)"));
// ui->labelFtbPack->setText(tr("Disabled for now... not completed!"));
// Disable for PR
ui->packDataDownloadStatus->setText(tr("(Data download complete)"));
ui->ftbBox->setEnabled(true);
}
void NewInstanceDialog::ftbPackDataDownloadFailed() {
ui->packDataDownloadStatus->setText(tr("(Pack data download failed)"));
ui->packDataDownloadStatus->setText(tr("(Data download failed)"));
}