summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanrupf <werbung.janrupf@t-online.de>2018-03-12 15:09:07 +0100
committerJanrupf <werbung.janrupf@t-online.de>2018-03-12 15:09:07 +0100
commit0812e3a87b2c05a5f9c89d53cda931e6fa71402f (patch)
tree31c5c4f4082206dea5f3155a1cc0b626fad84e87
parentb8ca36372be11b9ddddb3daa3d32583d286f19e2 (diff)
downloadMultiMC-0812e3a87b2c05a5f9c89d53cda931e6fa71402f.tar
MultiMC-0812e3a87b2c05a5f9c89d53cda931e6fa71402f.tar.gz
MultiMC-0812e3a87b2c05a5f9c89d53cda931e6fa71402f.tar.lz
MultiMC-0812e3a87b2c05a5f9c89d53cda931e6fa71402f.tar.xz
MultiMC-0812e3a87b2c05a5f9c89d53cda931e6fa71402f.zip
NOISSUE Fixed code for PR
-rw-r--r--api/logic/modplatform/FtbPackInstallTask.cpp51
-rw-r--r--application/FtbListModel.cpp35
-rw-r--r--application/dialogs/NewInstanceDialog.cpp7
3 files changed, 17 insertions, 76 deletions
diff --git a/api/logic/modplatform/FtbPackInstallTask.cpp b/api/logic/modplatform/FtbPackInstallTask.cpp
index 8c0bc70c..530f72ca 100644
--- a/api/logic/modplatform/FtbPackInstallTask.cpp
+++ b/api/logic/modplatform/FtbPackInstallTask.cpp
@@ -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();
}
diff --git a/application/FtbListModel.cpp b/application/FtbListModel.cpp
index 290767ff..68a68794 100644
--- a/application/FtbListModel.cpp
+++ b/application/FtbListModel.cpp
@@ -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);
}
diff --git a/application/dialogs/NewInstanceDialog.cpp b/application/dialogs/NewInstanceDialog.cpp
index 5faf57ac..eee3991c 100644
--- a/application/dialogs/NewInstanceDialog.cpp
+++ b/application/dialogs/NewInstanceDialog.cpp
@@ -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)"));
}