Added FTB pack selection ad download, WIP
This commit is contained in:
parent
1a43f28297
commit
ab3fe74c97
@ -418,6 +418,20 @@ set(META_SOURCES
|
|||||||
meta/Index.h
|
meta/Index.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(MODPLATFORM_SOURCES
|
||||||
|
# Modplatform sources
|
||||||
|
modplatform/FtbPackDownloader.h
|
||||||
|
modplatform/FtbPackDownloader.cpp
|
||||||
|
|
||||||
|
modplatform/FtbPackFetchTask.h
|
||||||
|
modplatform/FtbPackFetchTask.cpp
|
||||||
|
modplatform/FtbPackInstallTask.h
|
||||||
|
modplatform/FtbPackInstallTask.cpp
|
||||||
|
|
||||||
|
modplatform/PackHelpers.h
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
add_unit_test(Index
|
add_unit_test(Index
|
||||||
SOURCES meta/Index_test.cpp
|
SOURCES meta/Index_test.cpp
|
||||||
LIBS MultiMC_logic
|
LIBS MultiMC_logic
|
||||||
@ -446,6 +460,7 @@ set(LOGIC_SOURCES
|
|||||||
${TOOLS_SOURCES}
|
${TOOLS_SOURCES}
|
||||||
${META_SOURCES}
|
${META_SOURCES}
|
||||||
${ICONS_SOURCES}
|
${ICONS_SOURCES}
|
||||||
|
${MODPLATFORM_SOURCES}
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(MultiMC_logic SHARED ${LOGIC_SOURCES})
|
add_library(MultiMC_logic SHARED ${LOGIC_SOURCES})
|
||||||
|
@ -428,6 +428,14 @@ Task * FolderInstanceProvider::creationTask(BaseVersionPtr version, const QStrin
|
|||||||
return new FolderInstanceStaging(this, task, stagingPath, instName, instGroup);
|
return new FolderInstanceStaging(this, task, stagingPath, instName, instGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <modplatform/FtbPackInstallTask.h>
|
||||||
|
Task * FolderInstanceProvider::ftbCreationTask(FtbPackDownloader *downloader, const QString& instName, const QString& instGroup, const QString& instIcon)
|
||||||
|
{
|
||||||
|
auto stagingPath = getStagedInstancePath();
|
||||||
|
auto task = new FtbPackInstallTask(downloader, m_globalSettings, stagingPath, instName, instIcon, instGroup);
|
||||||
|
return new FolderInstanceStaging(this, task, stagingPath, instName, instGroup);
|
||||||
|
}
|
||||||
|
|
||||||
#include "InstanceCopyTask.h"
|
#include "InstanceCopyTask.h"
|
||||||
Task * FolderInstanceProvider::copyTask(const InstancePtr& oldInstance, const QString& instName, const QString& instGroup, const QString& instIcon, bool copySaves)
|
Task * FolderInstanceProvider::copyTask(const InstancePtr& oldInstance, const QString& instName, const QString& instGroup, const QString& instIcon, bool copySaves)
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "BaseInstanceProvider.h"
|
#include "BaseInstanceProvider.h"
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <modplatform/FtbPackDownloader.h>
|
||||||
|
|
||||||
class QFileSystemWatcher;
|
class QFileSystemWatcher;
|
||||||
|
|
||||||
@ -28,6 +29,9 @@ public:
|
|||||||
// import zipped instance into this provider
|
// import zipped instance into this provider
|
||||||
Task * zipImportTask(const QUrl sourceUrl, const QString &instName, const QString &instGroup, const QString &instIcon);
|
Task * zipImportTask(const QUrl sourceUrl, const QString &instName, const QString &instGroup, const QString &instIcon);
|
||||||
|
|
||||||
|
//create FtbInstance
|
||||||
|
Task * ftbCreationTask(FtbPackDownloader *downloader, const QString &instName, const QString &instGroup, const QString &instIcon);
|
||||||
|
|
||||||
// migrate an instance to the current format
|
// migrate an instance to the current format
|
||||||
Task * legacyUpgradeTask(const InstancePtr& oldInstance);
|
Task * legacyUpgradeTask(const InstancePtr& oldInstance);
|
||||||
|
|
||||||
|
106
api/logic/modplatform/FtbPackDownloader.cpp
Normal file
106
api/logic/modplatform/FtbPackDownloader.cpp
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
#include "FtbPackDownloader.h"
|
||||||
|
#include "PackHelpers.h"
|
||||||
|
#include "FtbPackFetchTask.h"
|
||||||
|
#include "Env.h"
|
||||||
|
|
||||||
|
FtbPackDownloader::FtbPackDownloader() {
|
||||||
|
done = false;
|
||||||
|
fetching = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
FtbPackDownloader::~FtbPackDownloader(){
|
||||||
|
delete netJobContainer.get();
|
||||||
|
netJobContainer.reset(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FtbPackDownloader::isValidPackSelected(){
|
||||||
|
FtbModpack dummy;
|
||||||
|
dummy.name = "__INVALID__";
|
||||||
|
|
||||||
|
FtbModpack other = fetchedPacks.value(selected.name, dummy);
|
||||||
|
if(other.name == "__INVALID__") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return other.oldVersions.contains(selectedVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString FtbPackDownloader::getSuggestedInstanceName() {
|
||||||
|
return selected.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
FtbModpackList FtbPackDownloader::getModpacks() {
|
||||||
|
return static_cast<FtbModpackList>(fetchedPacks.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
void FtbPackDownloader::fetchModpacks(bool force = false){
|
||||||
|
if(fetching || (!force && done)) {
|
||||||
|
qDebug() << "Skipping modpack refetch because done or already fetching [done =>" << done << "| fetching =>" << fetching << "]";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fetching = true;
|
||||||
|
|
||||||
|
fetchTask = new FtbPackFetchTask();
|
||||||
|
connect(fetchTask, &FtbPackFetchTask::finished, this, &FtbPackDownloader::fetchSuccess);
|
||||||
|
connect(fetchTask, &FtbPackFetchTask::failed, this, &FtbPackDownloader::fetchFailed);
|
||||||
|
fetchTask->fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FtbPackDownloader::fetchSuccess(FtbModpackList modpacks) {
|
||||||
|
for(int i = 0; i < modpacks.size(); i++) {
|
||||||
|
fetchedPacks.insert(modpacks.at(i).name, modpacks.at(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
fetching = false;
|
||||||
|
done = true;
|
||||||
|
emit ready();
|
||||||
|
fetchTask->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FtbPackDownloader::fetchFailed(QString reason) {
|
||||||
|
qWarning() << "Failed to fetch FtbData" << reason;
|
||||||
|
fetching = false;
|
||||||
|
emit packFetchFailed();
|
||||||
|
fetchTask->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FtbPackDownloader::selectPack(FtbModpack modpack, QString version) {
|
||||||
|
selected = modpack;
|
||||||
|
selectedVersion = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
FtbModpack FtbPackDownloader::getSelectedPack() {
|
||||||
|
return selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FtbPackDownloader::downloadSelected(MetaEntryPtr cache) {
|
||||||
|
NetJob *job = new NetJob("Downlad FTB Pack");
|
||||||
|
|
||||||
|
cache->setStale(true);
|
||||||
|
QString url = QString("http://ftb.cursecdn.com/FTB2/modpacks/%1/%2/%3").arg(selected.dir, selectedVersion.replace(".", "_"), selected.file);
|
||||||
|
job->addNetAction(Net::Download::makeCached(url, cache));
|
||||||
|
downloadPath = cache->getFullPath();
|
||||||
|
|
||||||
|
netJobContainer.reset(job);
|
||||||
|
|
||||||
|
connect(job, &NetJob::succeeded, this, &FtbPackDownloader::_downloadSucceeded);
|
||||||
|
connect(job, &NetJob::failed, this, &FtbPackDownloader::_downloadFailed);
|
||||||
|
connect(job, &NetJob::progress, this, &FtbPackDownloader::_downloadProgress);
|
||||||
|
job->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FtbPackDownloader::_downloadSucceeded() {
|
||||||
|
netJobContainer.reset();
|
||||||
|
emit downloadSucceded(downloadPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FtbPackDownloader::_downloadProgress(qint64 current, qint64 total) {
|
||||||
|
emit downloadProgress(current, total);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FtbPackDownloader::_downloadFailed(QString reason) {
|
||||||
|
netJobContainer.reset();
|
||||||
|
emit downloadFailed(reason);
|
||||||
|
}
|
63
api/logic/modplatform/FtbPackDownloader.h
Normal file
63
api/logic/modplatform/FtbPackDownloader.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QList>
|
||||||
|
#include <QObject>
|
||||||
|
#include "FtbPackFetchTask.h"
|
||||||
|
#include "tasks/Task.h"
|
||||||
|
#include "net/NetJob.h"
|
||||||
|
|
||||||
|
#include "PackHelpers.h"
|
||||||
|
#include "Env.h"
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class FtbPackDownloader;
|
||||||
|
class MULTIMC_LOGIC_EXPORT FtbPackDownloader : public QObject {
|
||||||
|
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMap<QString, FtbModpack> fetchedPacks;
|
||||||
|
bool fetching;
|
||||||
|
bool done;
|
||||||
|
|
||||||
|
FtbModpack selected;
|
||||||
|
QString selectedVersion;
|
||||||
|
QString downloadPath;
|
||||||
|
|
||||||
|
FtbPackFetchTask *fetchTask = 0;
|
||||||
|
NetJobPtr netJobContainer;
|
||||||
|
|
||||||
|
void _downloadSucceeded();
|
||||||
|
void _downloadFailed(QString reason);
|
||||||
|
void _downloadProgress(qint64 current, qint64 total);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void fetchSuccess(FtbModpackList modlist);
|
||||||
|
void fetchFailed(QString reason);
|
||||||
|
|
||||||
|
public:
|
||||||
|
FtbPackDownloader();
|
||||||
|
~FtbPackDownloader();
|
||||||
|
|
||||||
|
bool isValidPackSelected();
|
||||||
|
void selectPack(FtbModpack modpack, QString version);
|
||||||
|
|
||||||
|
FtbModpack getSelectedPack();
|
||||||
|
|
||||||
|
void fetchModpacks(bool force);
|
||||||
|
void downloadSelected(MetaEntryPtr cache);
|
||||||
|
|
||||||
|
QString getSuggestedInstanceName();
|
||||||
|
|
||||||
|
FtbModpackList getModpacks();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void ready();
|
||||||
|
void packFetchFailed();
|
||||||
|
|
||||||
|
void downloadSucceded(QString archivePath);
|
||||||
|
void downloadFailed(QString reason);
|
||||||
|
void downloadProgress(qint64 current, qint64 total);
|
||||||
|
|
||||||
|
};
|
75
api/logic/modplatform/FtbPackFetchTask.cpp
Normal file
75
api/logic/modplatform/FtbPackFetchTask.cpp
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#include "FtbPackFetchTask.h"
|
||||||
|
#include <QDomDocument>
|
||||||
|
|
||||||
|
FtbPackFetchTask::FtbPackFetchTask() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FtbPackFetchTask::~FtbPackFetchTask() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void FtbPackFetchTask::fetch() {
|
||||||
|
NetJob *netJob = new NetJob("FtbModpackFetch");
|
||||||
|
|
||||||
|
QUrl url = QUrl("https://ftb.cursecdn.com/FTB2/static/modpacks.xml");
|
||||||
|
qDebug() << "Downloading version info from " << url.toString();
|
||||||
|
|
||||||
|
netJob->addNetAction(downloadPtr = Net::Download::makeByteArray(url, &modpacksXmlFileData));
|
||||||
|
|
||||||
|
QObject::connect(netJob, &NetJob::succeeded, this, &FtbPackFetchTask::fileDownloadFinished);
|
||||||
|
QObject::connect(netJob, &NetJob::failed, this, &FtbPackFetchTask::fileDownloadFailed);
|
||||||
|
|
||||||
|
jobPtr.reset(netJob);
|
||||||
|
netJob->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FtbPackFetchTask::fileDownloadFinished(){
|
||||||
|
|
||||||
|
jobPtr.reset();
|
||||||
|
|
||||||
|
QDomDocument doc;
|
||||||
|
|
||||||
|
QString errorMsg = "Unknown error.";
|
||||||
|
int errorLine = -1;
|
||||||
|
int errorCol = -1;
|
||||||
|
|
||||||
|
if(!doc.setContent(modpacksXmlFileData, false, &errorMsg, &errorLine, &errorCol)){
|
||||||
|
auto fullErrMsg = QString("Failed to fetch modpack data: %s %d:%d!").arg(errorMsg, errorLine, errorCol);
|
||||||
|
qWarning() << fullErrMsg;
|
||||||
|
emit failed(fullErrMsg);
|
||||||
|
modpacksXmlFileData.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
modpacksXmlFileData.clear();
|
||||||
|
|
||||||
|
FtbModpackList modpackList;
|
||||||
|
|
||||||
|
QDomNodeList nodes = doc.elementsByTagName("modpack");
|
||||||
|
for(int i = 0; i < nodes.length(); i++) {
|
||||||
|
QDomElement element = nodes.at(i).toElement();
|
||||||
|
|
||||||
|
FtbModpack modpack;
|
||||||
|
modpack.name = element.attribute("name");
|
||||||
|
modpack.currentVersion = element.attribute("version");
|
||||||
|
modpack.mcVersion = element.attribute("mcVersion");
|
||||||
|
modpack.description = element.attribute("description");
|
||||||
|
modpack.mods = element.attribute("mods");
|
||||||
|
modpack.image = element.attribute("image");
|
||||||
|
modpack.oldVersions = element.attribute("oldVersions").split(";");
|
||||||
|
modpack.author = element.attribute("author");
|
||||||
|
|
||||||
|
modpack.dir = element.attribute("dir");
|
||||||
|
modpack.file = element.attribute("url");
|
||||||
|
|
||||||
|
modpackList.append(modpack);
|
||||||
|
}
|
||||||
|
|
||||||
|
emit finished(modpackList);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FtbPackFetchTask::fileDownloadFailed(QString reason){
|
||||||
|
qWarning() << "Fetching FtbPacks failed: " << reason;
|
||||||
|
emit failed(reason);
|
||||||
|
}
|
34
api/logic/modplatform/FtbPackFetchTask.h
Normal file
34
api/logic/modplatform/FtbPackFetchTask.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "multimc_logic_export.h"
|
||||||
|
#include "net/NetJob.h"
|
||||||
|
#include <QTemporaryDir>
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QObject>
|
||||||
|
#include "PackHelpers.h"
|
||||||
|
|
||||||
|
class MULTIMC_LOGIC_EXPORT FtbPackFetchTask : public QObject {
|
||||||
|
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
FtbPackFetchTask();
|
||||||
|
~FtbPackFetchTask();
|
||||||
|
|
||||||
|
void fetch();
|
||||||
|
|
||||||
|
private:
|
||||||
|
NetJobPtr jobPtr;
|
||||||
|
Net::Download::Ptr downloadPtr;
|
||||||
|
|
||||||
|
QByteArray modpacksXmlFileData;
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void fileDownloadFinished();
|
||||||
|
void fileDownloadFailed(QString reason);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void finished(FtbModpackList list);
|
||||||
|
void failed(QString reason);
|
||||||
|
|
||||||
|
};
|
65
api/logic/modplatform/FtbPackInstallTask.cpp
Normal file
65
api/logic/modplatform/FtbPackInstallTask.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
#include "FtbPackInstallTask.h"
|
||||||
|
#include "Env.h"
|
||||||
|
#include "MMCZip.h"
|
||||||
|
#include "QtConcurrent"
|
||||||
|
|
||||||
|
FtbPackInstallTask::FtbPackInstallTask(FtbPackDownloader *downloader, SettingsObjectPtr settings,
|
||||||
|
const QString &stagingPath, const QString &instName, const QString &instIcon, const QString &instGroup) :
|
||||||
|
m_globalSettings(settings), m_stagingPath(stagingPath), m_instName(instName), m_instIcon(instIcon), m_instGroup(instGroup)
|
||||||
|
{
|
||||||
|
m_downloader = downloader;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FtbPackInstallTask::executeTask() {
|
||||||
|
downloadPack();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FtbPackInstallTask::downloadPack(){
|
||||||
|
FtbModpack toInstall = m_downloader->getSelectedPack();
|
||||||
|
setStatus(tr("Installing new FTB Pack %1").arg(toInstall.name));
|
||||||
|
|
||||||
|
auto entry = ENV.metacache()->resolveEntry("general", "FTBPack/" + toInstall.name);
|
||||||
|
m_downloader->downloadSelected(entry);
|
||||||
|
|
||||||
|
connect(m_downloader, &FtbPackDownloader::downloadSucceded, this, &FtbPackInstallTask::onDownloadSucceeded);
|
||||||
|
connect(m_downloader, &FtbPackDownloader::downloadProgress, this, &FtbPackInstallTask::onDownloadProgress);
|
||||||
|
connect(m_downloader, &FtbPackDownloader::downloadFailed, this,&FtbPackInstallTask::onDownloadFailed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FtbPackInstallTask::onDownloadSucceeded(QString archivePath){
|
||||||
|
qDebug() << "Download succeeded!";
|
||||||
|
unzip(archivePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FtbPackInstallTask::onDownloadFailed(QString reason) {
|
||||||
|
emitFailed(reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FtbPackInstallTask::onDownloadProgress(qint64 current, qint64 total){
|
||||||
|
progress(current, total);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FtbPackInstallTask::unzip(QString archivePath) {
|
||||||
|
setStatus(QString("Extracting modpack from %1").arg(archivePath));
|
||||||
|
QDir extractDir(m_stagingPath);
|
||||||
|
|
||||||
|
m_packZip.reset(new QuaZip(archivePath));
|
||||||
|
if(!m_packZip->open(QuaZip::mdUnzip)) {
|
||||||
|
emitFailed(tr("Failed to open modpack file %1!").arg(archivePath));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_extractFuture = QtConcurrent::run(QThreadPool::globalInstance(), MMCZip::extractSubDir, m_packZip.get(), QString("/"), extractDir.absolutePath());
|
||||||
|
connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::finished, this, &FtbPackInstallTask::onUnzipFinished);
|
||||||
|
connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::canceled, this, &FtbPackInstallTask::onUnzipCanceled);
|
||||||
|
m_extractFutureWatcher.setFuture(m_extractFuture);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FtbPackInstallTask::onUnzipFinished() {
|
||||||
|
qDebug() << "Unzipped:" << m_stagingPath;
|
||||||
|
emitSucceeded();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FtbPackInstallTask::onUnzipCanceled() {
|
||||||
|
emitAborted();
|
||||||
|
}
|
45
api/logic/modplatform/FtbPackInstallTask.h
Normal file
45
api/logic/modplatform/FtbPackInstallTask.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "tasks/Task.h"
|
||||||
|
#include "modplatform/FtbPackDownloader.h"
|
||||||
|
#include "BaseInstanceProvider.h"
|
||||||
|
#include "net/NetJob.h"
|
||||||
|
#include "quazip.h"
|
||||||
|
#include "quazipdir.h"
|
||||||
|
|
||||||
|
class MULTIMC_LOGIC_EXPORT FtbPackInstallTask : public Task {
|
||||||
|
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit FtbPackInstallTask(FtbPackDownloader *downloader, SettingsObjectPtr settings, const QString & stagingPath, const QString &instName,
|
||||||
|
const QString &instIcon, const QString &instGroup);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! Entry point for tasks.
|
||||||
|
virtual void executeTask() override;
|
||||||
|
|
||||||
|
private: /* data */
|
||||||
|
SettingsObjectPtr m_globalSettings;
|
||||||
|
QString m_stagingPath;
|
||||||
|
QString m_instName;
|
||||||
|
QString m_instIcon;
|
||||||
|
QString m_instGroup;
|
||||||
|
NetJobPtr m_netJobPtr;
|
||||||
|
FtbPackDownloader *m_downloader = nullptr;
|
||||||
|
|
||||||
|
std::unique_ptr<QuaZip> m_packZip;
|
||||||
|
QFuture<QStringList> m_extractFuture;
|
||||||
|
QFutureWatcher<QStringList> m_extractFutureWatcher;
|
||||||
|
|
||||||
|
void downloadPack();
|
||||||
|
void unzip(QString archivePath);
|
||||||
|
void install();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onDownloadSucceeded(QString archivePath);
|
||||||
|
void onDownloadFailed(QString reason);
|
||||||
|
void onDownloadProgress(qint64 current, qint64 total);
|
||||||
|
|
||||||
|
void onUnzipFinished();
|
||||||
|
void onUnzipCanceled();
|
||||||
|
};
|
21
api/logic/modplatform/PackHelpers.h
Normal file
21
api/logic/modplatform/PackHelpers.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
//Header for structs etc...
|
||||||
|
|
||||||
|
struct FtbModpack {
|
||||||
|
QString name;
|
||||||
|
QString description;
|
||||||
|
QString author;
|
||||||
|
QStringList oldVersions;
|
||||||
|
QString currentVersion;
|
||||||
|
QString mcVersion;
|
||||||
|
QString mods;
|
||||||
|
QString image;
|
||||||
|
|
||||||
|
//Technical data
|
||||||
|
QString dir;
|
||||||
|
QString file; //<- Url in the xml, but doesn't make much sense
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef QList<FtbModpack> FtbModpackList;
|
@ -153,6 +153,9 @@ SET(MULTIMC_SOURCES
|
|||||||
dialogs/VersionSelectDialog.h
|
dialogs/VersionSelectDialog.h
|
||||||
dialogs/SkinUploadDialog.cpp
|
dialogs/SkinUploadDialog.cpp
|
||||||
dialogs/SkinUploadDialog.h
|
dialogs/SkinUploadDialog.h
|
||||||
|
dialogs/ChooseFtbPackDialog.cpp
|
||||||
|
dialogs/ChooseFtbPackDialog.h
|
||||||
|
|
||||||
|
|
||||||
# GUI - widgets
|
# GUI - widgets
|
||||||
widgets/Common.cpp
|
widgets/Common.cpp
|
||||||
@ -186,7 +189,8 @@ SET(MULTIMC_SOURCES
|
|||||||
widgets/VersionSelectWidget.h
|
widgets/VersionSelectWidget.h
|
||||||
widgets/ProgressWidget.h
|
widgets/ProgressWidget.h
|
||||||
widgets/ProgressWidget.cpp
|
widgets/ProgressWidget.cpp
|
||||||
|
widgets/FtbModpackListItem.h
|
||||||
|
widgets/FtbModpackListItem.cpp
|
||||||
|
|
||||||
# GUI - instance group view
|
# GUI - instance group view
|
||||||
groupview/GroupedProxyModel.cpp
|
groupview/GroupedProxyModel.cpp
|
||||||
@ -236,6 +240,7 @@ SET(MULTIMC_UIS
|
|||||||
dialogs/UpdateDialog.ui
|
dialogs/UpdateDialog.ui
|
||||||
dialogs/NotificationDialog.ui
|
dialogs/NotificationDialog.ui
|
||||||
dialogs/SkinUploadDialog.ui
|
dialogs/SkinUploadDialog.ui
|
||||||
|
dialogs/ChooseFtbPackDialog.ui
|
||||||
|
|
||||||
# Widgets/other
|
# Widgets/other
|
||||||
widgets/CustomCommands.ui
|
widgets/CustomCommands.ui
|
||||||
|
@ -1272,6 +1272,14 @@ void MainWindow::instanceFromVersion(QString instName, QString instGroup, QStrin
|
|||||||
// finalizeInstance(newInstance);
|
// finalizeInstance(newInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::instanceFromFtbPack(FtbPackDownloader *downloader, QString instName, QString instGroup, QString instIcon) {
|
||||||
|
std::unique_ptr<Task> task(MMC->folderProvider()->ftbCreationTask(downloader, instName, instGroup, instIcon));
|
||||||
|
runModalTask(task.get());
|
||||||
|
|
||||||
|
// FIXME: handle instance selection after creation
|
||||||
|
// finalizeInstance(newInstance);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionCopyInstance_triggered()
|
void MainWindow::on_actionCopyInstance_triggered()
|
||||||
{
|
{
|
||||||
if (!m_selectedInstance)
|
if (!m_selectedInstance)
|
||||||
@ -1347,7 +1355,10 @@ void MainWindow::addInstance(QString url)
|
|||||||
|
|
||||||
const QUrl modpackUrl = newInstDlg.modpackUrl();
|
const QUrl modpackUrl = newInstDlg.modpackUrl();
|
||||||
|
|
||||||
if (modpackUrl.isValid())
|
if(newInstDlg.isFtbModpackRequested()) {
|
||||||
|
instanceFromFtbPack(newInstDlg.getFtbPackDownloader(), newInstDlg.instName(), newInstDlg.instGroup(), newInstDlg.iconKey());
|
||||||
|
}
|
||||||
|
else if (modpackUrl.isValid())
|
||||||
{
|
{
|
||||||
instanceFromZipPack(newInstDlg.instName(), newInstDlg.instGroup(), newInstDlg.iconKey(), modpackUrl);
|
instanceFromZipPack(newInstDlg.instName(), newInstDlg.instGroup(), newInstDlg.iconKey(), modpackUrl);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "minecraft/auth/MojangAccount.h"
|
#include "minecraft/auth/MojangAccount.h"
|
||||||
#include "net/NetJob.h"
|
#include "net/NetJob.h"
|
||||||
#include "updater/GoUpdate.h"
|
#include "updater/GoUpdate.h"
|
||||||
|
#include <modplatform/FtbPackDownloader.h>
|
||||||
|
|
||||||
class LaunchController;
|
class LaunchController;
|
||||||
class NewsChecker;
|
class NewsChecker;
|
||||||
@ -185,6 +186,7 @@ private:
|
|||||||
void runModalTask(Task *task);
|
void runModalTask(Task *task);
|
||||||
void instanceFromVersion(QString instName, QString instGroup, QString instIcon, BaseVersionPtr version);
|
void instanceFromVersion(QString instName, QString instGroup, QString instIcon, BaseVersionPtr version);
|
||||||
void instanceFromZipPack(QString instName, QString instGroup, QString instIcon, QUrl url);
|
void instanceFromZipPack(QString instName, QString instGroup, QString instIcon, QUrl url);
|
||||||
|
void instanceFromFtbPack(FtbPackDownloader *downloader, QString instName, QString instGroup, QString instIcon);
|
||||||
void finalizeInstance(InstancePtr inst);
|
void finalizeInstance(InstancePtr inst);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
64
application/dialogs/ChooseFtbPackDialog.cpp
Normal file
64
application/dialogs/ChooseFtbPackDialog.cpp
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#include "ChooseFtbPackDialog.h"
|
||||||
|
#include "widgets/FtbModpackListItem.h"
|
||||||
|
|
||||||
|
ChooseFtbPackDialog::ChooseFtbPackDialog(FtbModpackList modpacks) : ui(new Ui::ChooseFtbPackDialog) {
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
for(int i = 0; i < modpacks.size(); i++) {
|
||||||
|
FtbModpackListItem *item = new FtbModpackListItem(ui->packList, modpacks.at(i));
|
||||||
|
|
||||||
|
item->setText(modpacks.at(i).name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Use a model/view instead of a widget
|
||||||
|
connect(ui->packList, &QListWidget::itemClicked, this, &ChooseFtbPackDialog::onListItemClicked);
|
||||||
|
connect(ui->packVersionSelection, &QComboBox::currentTextChanged, this, &ChooseFtbPackDialog::onVersionSelectionItemChanged);
|
||||||
|
|
||||||
|
ui->modpackInfo->setOpenExternalLinks(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ChooseFtbPackDialog::~ChooseFtbPackDialog(){
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChooseFtbPackDialog::onListItemClicked(QListWidgetItem *item){
|
||||||
|
ui->packVersionSelection->clear();
|
||||||
|
FtbModpack selectedPack = static_cast<FtbModpackListItem*>(item)->getModpack();
|
||||||
|
|
||||||
|
ui->modpackInfo->setHtml("Pack by <b>" + selectedPack.author + "</b>" + "<br>Minecraft " + selectedPack.mcVersion + "<br>"
|
||||||
|
"<br>" + selectedPack.description + "<ul><li>" + selectedPack.mods.replace(";", "</li><li>") + "</li></ul>");
|
||||||
|
|
||||||
|
bool currentAdded = false;
|
||||||
|
|
||||||
|
for(int i = 0; i < selectedPack.oldVersions.size(); i++) {
|
||||||
|
if(selectedPack.currentVersion == selectedPack.oldVersions.at(i)) {
|
||||||
|
currentAdded = true;
|
||||||
|
}
|
||||||
|
ui->packVersionSelection->addItem(selectedPack.oldVersions.at(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!currentAdded) {
|
||||||
|
ui->packVersionSelection->addItem(selectedPack.currentVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
selected = selectedPack;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChooseFtbPackDialog::onVersionSelectionItemChanged(QString data) {
|
||||||
|
if(data.isNull() || data.isEmpty()) {
|
||||||
|
selectedVersion = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedVersion = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
FtbModpack ChooseFtbPackDialog::getSelectedModpack() {
|
||||||
|
return selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ChooseFtbPackDialog::getSelectedVersion() {
|
||||||
|
return selectedVersion;
|
||||||
|
}
|
32
application/dialogs/ChooseFtbPackDialog.h
Normal file
32
application/dialogs/ChooseFtbPackDialog.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <net/NetJob.h>
|
||||||
|
#include <modplatform/PackHelpers.h>
|
||||||
|
#include "ui_ChooseFtbPackDialog.h"
|
||||||
|
#include <modplatform/PackHelpers.h>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class ChooseFtbPackDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ChooseFtbPackDialog : public QDialog {
|
||||||
|
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::ChooseFtbPackDialog *ui;
|
||||||
|
FtbModpack selected;
|
||||||
|
QString selectedVersion;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onListItemClicked(QListWidgetItem *item);
|
||||||
|
void onVersionSelectionItemChanged(QString data);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ChooseFtbPackDialog(FtbModpackList packs);
|
||||||
|
~ChooseFtbPackDialog();
|
||||||
|
|
||||||
|
FtbModpack getSelectedModpack();
|
||||||
|
QString getSelectedVersion();
|
||||||
|
};
|
163
application/dialogs/ChooseFtbPackDialog.ui
Normal file
163
application/dialogs/ChooseFtbPackDialog.ui
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>ChooseFtbPackDialog</class>
|
||||||
|
<widget class="QDialog" name="ChooseFtbPackDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>730</width>
|
||||||
|
<height>437</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="sizeGripEnabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>540</x>
|
||||||
|
<y>400</y>
|
||||||
|
<width>176</width>
|
||||||
|
<height>25</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>261</width>
|
||||||
|
<height>381</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="widgetResizable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>259</width>
|
||||||
|
<height>379</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<widget class="QListWidget" name="packList">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>261</width>
|
||||||
|
<height>381</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<widget class="QScrollArea" name="scrollArea_2">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>280</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>441</width>
|
||||||
|
<height>381</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="widgetResizable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="scrollAreaWidgetContents_2">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>439</width>
|
||||||
|
<height>379</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<widget class="QTextBrowser" name="modpackInfo">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>441</width>
|
||||||
|
<height>381</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox" name="packVersionSelection">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>450</x>
|
||||||
|
<y>400</y>
|
||||||
|
<width>72</width>
|
||||||
|
<height>25</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="selectedVersionLabel">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>340</x>
|
||||||
|
<y>400</y>
|
||||||
|
<width>101</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Version selected:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>ChooseFtbPackDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>666</x>
|
||||||
|
<y>422</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>889</x>
|
||||||
|
<y>501</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>ChooseFtbPackDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>680</x>
|
||||||
|
<y>411</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>524</x>
|
||||||
|
<y>458</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
@ -25,6 +25,7 @@
|
|||||||
#include "VersionSelectDialog.h"
|
#include "VersionSelectDialog.h"
|
||||||
#include "ProgressDialog.h"
|
#include "ProgressDialog.h"
|
||||||
#include "IconPickerDialog.h"
|
#include "IconPickerDialog.h"
|
||||||
|
#include "ChooseFtbPackDialog.h"
|
||||||
|
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
@ -92,9 +93,12 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, const QString
|
|||||||
|
|
||||||
connect(ui->modpackEdit, &QLineEdit::textChanged, this, &NewInstanceDialog::updateDialogState);
|
connect(ui->modpackEdit, &QLineEdit::textChanged, this, &NewInstanceDialog::updateDialogState);
|
||||||
connect(ui->modpackBox, &QRadioButton::clicked, this, &NewInstanceDialog::updateDialogState);
|
connect(ui->modpackBox, &QRadioButton::clicked, this, &NewInstanceDialog::updateDialogState);
|
||||||
|
|
||||||
connect(ui->versionBox, &QRadioButton::clicked, this, &NewInstanceDialog::updateDialogState);
|
connect(ui->versionBox, &QRadioButton::clicked, this, &NewInstanceDialog::updateDialogState);
|
||||||
connect(ui->versionTextBox, &QLineEdit::textChanged, this, &NewInstanceDialog::updateDialogState);
|
connect(ui->versionTextBox, &QLineEdit::textChanged, this, &NewInstanceDialog::updateDialogState);
|
||||||
|
|
||||||
|
connect(ui->ftbBox, &QRadioButton::clicked, this, &NewInstanceDialog::updateDialogState);
|
||||||
|
|
||||||
auto groups = MMC->instances()->getGroups().toSet();
|
auto groups = MMC->instances()->getGroups().toSet();
|
||||||
auto groupList = QStringList(groups.toList());
|
auto groupList = QStringList(groups.toList());
|
||||||
groupList.sort(Qt::CaseInsensitive);
|
groupList.sort(Qt::CaseInsensitive);
|
||||||
@ -117,6 +121,14 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, const QString
|
|||||||
ui->modpackBox->setChecked(true);
|
ui->modpackBox->setChecked(true);
|
||||||
ui->modpackEdit->setText(url);
|
ui->modpackEdit->setText(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ftbPackDownloader = new FtbPackDownloader();
|
||||||
|
|
||||||
|
connect(ftbPackDownloader, &FtbPackDownloader::ready, this, &NewInstanceDialog::ftbPackDataDownloadSuccessfully);
|
||||||
|
connect(ftbPackDownloader, &FtbPackDownloader::packFetchFailed, this, &NewInstanceDialog::ftbPackDataDownloadFailed);
|
||||||
|
|
||||||
|
ftbPackDownloader->fetchModpacks(false);
|
||||||
|
|
||||||
updateDialogState();
|
updateDialogState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,6 +159,17 @@ void NewInstanceDialog::updateDialogState()
|
|||||||
QFileInfo fi(url.fileName());
|
QFileInfo fi(url.fileName());
|
||||||
suggestedName = fi.completeBaseName();
|
suggestedName = fi.completeBaseName();
|
||||||
}
|
}
|
||||||
|
else if (ui->ftbBox->isChecked())
|
||||||
|
{
|
||||||
|
if(ftbPackDownloader->isValidPackSelected()) {
|
||||||
|
suggestedName = ftbPackDownloader->getSuggestedInstanceName();
|
||||||
|
ui->labelFtbPack->setText(selectedPack.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ftbModpackRequested = ui->ftbBox->isChecked();
|
||||||
|
|
||||||
if(suggestedName.isEmpty())
|
if(suggestedName.isEmpty())
|
||||||
{
|
{
|
||||||
ui->instNameTextBox->setPlaceholderText(originalPlaceholderText);
|
ui->instNameTextBox->setPlaceholderText(originalPlaceholderText);
|
||||||
@ -157,7 +180,8 @@ void NewInstanceDialog::updateDialogState()
|
|||||||
}
|
}
|
||||||
bool allowOK = !instName().isEmpty() && (
|
bool allowOK = !instName().isEmpty() && (
|
||||||
(ui->versionBox->isChecked() && m_selectedVersion) ||
|
(ui->versionBox->isChecked() && m_selectedVersion) ||
|
||||||
(ui->modpackBox->isChecked() && ui->modpackEdit->hasAcceptableInput())
|
(ui->modpackBox->isChecked() && ui->modpackEdit->hasAcceptableInput()) ||
|
||||||
|
(ui->ftbBox->isChecked() && ftbPackDownloader && ftbPackDownloader->isValidPackSelected() )
|
||||||
);
|
);
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(allowOK);
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(allowOK);
|
||||||
}
|
}
|
||||||
@ -271,3 +295,34 @@ void NewInstanceDialog::on_modpackBtn_clicked()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NewInstanceDialog::isFtbModpackRequested() {
|
||||||
|
return ftbModpackRequested;
|
||||||
|
}
|
||||||
|
|
||||||
|
FtbPackDownloader *NewInstanceDialog::getFtbPackDownloader() {
|
||||||
|
return ftbPackDownloader;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewInstanceDialog::on_btnChooseFtbPack_clicked() {
|
||||||
|
ChooseFtbPackDialog dl(ftbPackDownloader->getModpacks());
|
||||||
|
dl.exec();
|
||||||
|
if(dl.result() == QDialog::Accepted) {
|
||||||
|
selectedPack = dl.getSelectedModpack();
|
||||||
|
ftbPackDownloader->selectPack(selectedPack, dl.getSelectedVersion());
|
||||||
|
}
|
||||||
|
updateDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewInstanceDialog::ftbPackDataDownloadSuccessfully() {
|
||||||
|
ui->packDataDownloadStatus->setText(tr("(Pack data download complete)"));
|
||||||
|
// ui->labelFtbPack->setText(tr("Disabled for now... not completed!"));
|
||||||
|
|
||||||
|
// Disable for PR
|
||||||
|
ui->ftbBox->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewInstanceDialog::ftbPackDataDownloadFailed() {
|
||||||
|
ui->packDataDownloadStatus->setText(tr("(Pack data download failed)"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
#include "BaseVersion.h"
|
#include "BaseVersion.h"
|
||||||
|
#include "modplatform/FtbPackDownloader.h"
|
||||||
|
#include "modplatform/PackHelpers.h"
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
@ -42,19 +44,31 @@ public:
|
|||||||
QUrl modpackUrl() const;
|
QUrl modpackUrl() const;
|
||||||
BaseVersionPtr selectedVersion() const;
|
BaseVersionPtr selectedVersion() const;
|
||||||
|
|
||||||
|
bool isFtbModpackRequested();
|
||||||
|
FtbPackDownloader* getFtbPackDownloader();
|
||||||
|
|
||||||
private
|
private
|
||||||
slots:
|
slots:
|
||||||
void on_btnChangeVersion_clicked();
|
void on_btnChangeVersion_clicked();
|
||||||
void on_iconButton_clicked();
|
void on_iconButton_clicked();
|
||||||
void on_modpackBtn_clicked();
|
void on_modpackBtn_clicked();
|
||||||
|
void on_btnChooseFtbPack_clicked();
|
||||||
void on_instNameTextBox_textChanged(const QString &arg1);
|
void on_instNameTextBox_textChanged(const QString &arg1);
|
||||||
void versionListUpdated();
|
void versionListUpdated();
|
||||||
|
|
||||||
|
void ftbPackDataDownloadSuccessfully();
|
||||||
|
void ftbPackDataDownloadFailed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::NewInstanceDialog *ui;
|
Ui::NewInstanceDialog *ui;
|
||||||
|
|
||||||
bool m_versionSetByUser = false;
|
bool m_versionSetByUser = false;
|
||||||
|
bool ftbModpackRequested = false;
|
||||||
|
|
||||||
BaseVersionPtr m_selectedVersion;
|
BaseVersionPtr m_selectedVersion;
|
||||||
QString InstIconKey;
|
QString InstIconKey;
|
||||||
QString originalPlaceholderText;
|
QString originalPlaceholderText;
|
||||||
|
|
||||||
|
FtbPackDownloader* ftbPackDownloader;
|
||||||
|
FtbModpack selectedPack;
|
||||||
};
|
};
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>281</width>
|
<width>281</width>
|
||||||
<height>404</height>
|
<height>407</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -107,6 +107,33 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QRadioButton" name="ftbBox">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Install FTB Pack</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QToolButton" name="btnChangeVersion">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="2">
|
||||||
|
<widget class="QToolButton" name="btnChooseFtbPack">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="4" column="2">
|
<item row="4" column="2">
|
||||||
<widget class="QToolButton" name="modpackBtn">
|
<widget class="QToolButton" name="modpackBtn">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
@ -117,27 +144,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0" colspan="2">
|
<item row="7" column="0" colspan="2">
|
||||||
<widget class="FocusLineEdit" name="modpackEdit">
|
<widget class="QLabel" name="labelFtbPack">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">http://</string>
|
<string> No Pack choosen</string>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0" colspan="2">
|
|
||||||
<widget class="QLineEdit" name="versionTextBox">
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="2">
|
|
||||||
<widget class="QToolButton" name="btnChangeVersion">
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">...</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -158,6 +171,30 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0" colspan="2">
|
||||||
|
<widget class="QLineEdit" name="versionTextBox">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0" colspan="2">
|
||||||
|
<widget class="FocusLineEdit" name="modpackEdit">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">http://</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1" colspan="2">
|
||||||
|
<widget class="QLabel" name="packDataDownloadStatus">
|
||||||
|
<property name="text">
|
||||||
|
<string>(Loading Pack data...)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -219,8 +256,8 @@
|
|||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>257</x>
|
<x>266</x>
|
||||||
<y>333</y>
|
<y>378</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>157</x>
|
<x>157</x>
|
||||||
@ -235,11 +272,11 @@
|
|||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>325</x>
|
<x>271</x>
|
||||||
<y>333</y>
|
<y>378</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>286</x>
|
<x>280</x>
|
||||||
<y>274</y>
|
<y>274</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
@ -251,12 +288,12 @@
|
|||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>81</x>
|
<x>91</x>
|
||||||
<y>229</y>
|
<y>251</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>236</x>
|
<x>240</x>
|
||||||
<y>221</y>
|
<y>278</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
@ -267,12 +304,12 @@
|
|||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>129</x>
|
<x>139</x>
|
||||||
<y>225</y>
|
<y>251</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>328</x>
|
<x>270</x>
|
||||||
<y>229</y>
|
<y>278</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
@ -287,8 +324,8 @@
|
|||||||
<y>195</y>
|
<y>195</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>213</x>
|
<x>223</x>
|
||||||
<y>191</y>
|
<y>224</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
@ -303,8 +340,40 @@
|
|||||||
<y>198</y>
|
<y>198</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>322</x>
|
<x>270</x>
|
||||||
<y>192</y>
|
<y>224</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>ftbBox</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>btnChooseFtbPack</receiver>
|
||||||
|
<slot>setEnabled(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>67</x>
|
||||||
|
<y>301</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>254</x>
|
||||||
|
<y>327</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>ftbBox</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>labelFtbPack</receiver>
|
||||||
|
<slot>setEnabled(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>81</x>
|
||||||
|
<y>310</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>73</x>
|
||||||
|
<y>334</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
8
application/widgets/FtbModpackListItem.cpp
Normal file
8
application/widgets/FtbModpackListItem.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "FtbModpackListItem.h"
|
||||||
|
|
||||||
|
FtbModpackListItem::FtbModpackListItem(QListWidget *list, FtbModpack modpack) : QListWidgetItem(list), modpack(modpack) {
|
||||||
|
}
|
||||||
|
|
||||||
|
FtbModpack FtbModpackListItem::getModpack(){
|
||||||
|
return modpack;
|
||||||
|
}
|
15
application/widgets/FtbModpackListItem.h
Normal file
15
application/widgets/FtbModpackListItem.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "QListWidget"
|
||||||
|
#include <modplatform/PackHelpers.h>
|
||||||
|
|
||||||
|
class FtbModpackListItem : public QListWidgetItem {
|
||||||
|
|
||||||
|
private:
|
||||||
|
FtbModpack modpack;
|
||||||
|
|
||||||
|
public:
|
||||||
|
FtbModpackListItem(QListWidget *list, FtbModpack modpack);
|
||||||
|
FtbModpack getModpack();
|
||||||
|
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user