summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gui/mainwindow.cpp42
-rw-r--r--gui/mainwindow.h9
-rw-r--r--logic/OneSixAssets.cpp6
-rw-r--r--logic/OneSixAssets.h3
-rw-r--r--logic/net/DownloadJob.cpp3
-rw-r--r--logic/net/DownloadJob.h4
6 files changed, 63 insertions, 4 deletions
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index 8e43a3b1..ff1ac68a 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -155,6 +155,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
// FIXME: stop using POINTERS everywhere
connect(MMC->instances().get(), SIGNAL(dataIsInvalid()), SLOT(selectionBad()));
+ m_statusLeft = new QLabel(tr("Instance type"), this);
+ m_statusRight = new QLabel(tr("Assets information"), this);
+ m_statusRight->setAlignment(Qt::AlignRight);
+ statusBar()->addPermanentWidget(m_statusLeft, 1);
+ statusBar()->addPermanentWidget(m_statusRight, 0);
+
// run the things that load and download other things... FIXME: this is NOT the place
// FIXME: invisible actions in the background = NOPE.
{
@@ -168,6 +174,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
MMC->lwjgllist()->loadList();
}
assets_downloader = new OneSixAssets();
+ connect(assets_downloader, SIGNAL(indexStarted()), SLOT(assetsIndexStarted()));
+ connect(assets_downloader, SIGNAL(filesStarted()), SLOT(assetsFilesStarted()));
+ connect(assets_downloader, SIGNAL(filesProgress(int, int, int)), SLOT(assetsFilesProgress(int, int, int)));
+ connect(assets_downloader, SIGNAL(failed()), SLOT(assetsFailed()));
+ connect(assets_downloader, SIGNAL(finished()), SLOT(assetsFinished()));
assets_downloader->start();
}
}
@@ -754,8 +765,7 @@ void MainWindow::instanceChanged(const QModelIndex &current, const QModelIndex &
m_selectedInstance->menuActionEnabled("actionEditInstMods"));
ui->actionChangeInstMCVersion->setEnabled(
m_selectedInstance->menuActionEnabled("actionChangeInstMCVersion"));
- statusBar()->clearMessage();
- statusBar()->showMessage(m_selectedInstance->getStatusbarDescription());
+ m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
auto ico = MMC->icons()->getIcon(iconKey);
ui->actionChangeInstIcon->setIcon(ico);
}
@@ -851,3 +861,31 @@ void MainWindow::checkSetDefaultJava()
MMC->settings()->set("JavaPath", QString("java"));
}
}
+
+void MainWindow::assetsIndexStarted()
+{
+ m_statusRight->setText(tr("Checking assets..."));
+}
+
+void MainWindow::assetsFilesStarted()
+{
+ m_statusRight->setText(tr("Downloading assets..."));
+}
+
+void MainWindow::assetsFilesProgress(int succeeded, int failed, int total)
+{
+ QString status = tr("Downloading assets: %1 / %2").arg(succeeded + failed).arg(total);
+ if(failed > 0) status += tr(" (%1 failed)").arg(failed);
+ status += tr("...");
+ m_statusRight->setText(status);
+}
+
+void MainWindow::assetsFailed()
+{
+ m_statusRight->setText(tr("Failed to update assets."));
+}
+
+void MainWindow::assetsFinished()
+{
+ m_statusRight->setText(tr("Assets up to date."));
+}
diff --git a/gui/mainwindow.h b/gui/mainwindow.h
index 941fbcca..6715acbb 100644
--- a/gui/mainwindow.h
+++ b/gui/mainwindow.h
@@ -116,6 +116,12 @@ private slots:
void on_actionInstanceSettings_triggered();
+ void assetsIndexStarted();
+ void assetsFilesStarted();
+ void assetsFilesProgress(int, int, int);
+ void assetsFailed();
+ void assetsFinished();
+
public slots:
void instanceActivated(QModelIndex);
@@ -150,6 +156,9 @@ private:
LoginResponse m_activeLogin;
Task *m_versionLoadTask;
+
+ QLabel *m_statusLeft;
+ QLabel *m_statusRight;
};
#endif // MAINWINDOW_H
diff --git a/logic/OneSixAssets.cpp b/logic/OneSixAssets.cpp
index 6aa0a207..ff19a86b 100644
--- a/logic/OneSixAssets.cpp
+++ b/logic/OneSixAssets.cpp
@@ -67,6 +67,8 @@ void OneSixAssets::fetchXMLFinished()
QString fprefix ( "assets/" );
nuke_whitelist.clear();
+ emit filesStarted();
+
auto firstJob = index_job->first();
QByteArray ba = std::dynamic_pointer_cast<ByteArrayDownload>(firstJob)->m_data;
@@ -84,6 +86,7 @@ void OneSixAssets::fetchXMLFinished()
DownloadJob *job = new DownloadJob("Assets");
connect ( job, SIGNAL(succeeded()), SLOT(downloadFinished()) );
connect ( job, SIGNAL(failed()), SIGNAL(failed()) );
+ connect ( job, SIGNAL(filesProgress(int, int, int)), SIGNAL(filesProgress(int, int, int)) );
auto metacache = MMC->metacache();
@@ -130,14 +133,15 @@ void OneSixAssets::fetchXMLFinished()
emit finished();
}
}
+
void OneSixAssets::start()
{
auto job = new DownloadJob("Assets index");
job->addByteArrayDownload(QUrl ( "http://s3.amazonaws.com/Minecraft.Resources/" ));
connect ( job, SIGNAL(succeeded()), SLOT ( fetchXMLFinished() ) );
+ emit indexStarted();
index_job.reset ( job );
job->start();
}
-
#include "OneSixAssets.moc"
diff --git a/logic/OneSixAssets.h b/logic/OneSixAssets.h
index 58618c88..6c6f2c36 100644
--- a/logic/OneSixAssets.h
+++ b/logic/OneSixAssets.h
@@ -10,6 +10,9 @@ class OneSixAssets : public QObject
signals:
void failed();
void finished();
+ void indexStarted();
+ void filesStarted();
+ void filesProgress(int, int, int);
public slots:
void fetchXMLFinished();
diff --git a/logic/net/DownloadJob.cpp b/logic/net/DownloadJob.cpp
index fa3e655e..38716a02 100644
--- a/logic/net/DownloadJob.cpp
+++ b/logic/net/DownloadJob.cpp
@@ -56,6 +56,8 @@ void DownloadJob::partSucceeded(int index)
num_succeeded++;
QLOG_INFO() << m_job_name.toLocal8Bit() << "progress:" << num_succeeded << "/"
<< downloads.size();
+ emit filesProgress(num_succeeded, num_failed, downloads.size());
+
if (num_failed + num_succeeded == downloads.size())
{
if (num_failed)
@@ -78,6 +80,7 @@ void DownloadJob::partFailed(int index)
{
QLOG_ERROR() << "Part" << index << "failed 3 times (" << downloads[index]->m_url << ")";
num_failed++;
+ emit filesProgress(num_succeeded, num_failed, downloads.size());
if (num_failed + num_succeeded == downloads.size())
{
QLOG_ERROR() << m_job_name.toLocal8Bit() << "failed.";
diff --git a/logic/net/DownloadJob.h b/logic/net/DownloadJob.h
index 91b014ad..cc2a1d59 100644
--- a/logic/net/DownloadJob.h
+++ b/logic/net/DownloadJob.h
@@ -1,5 +1,6 @@
#pragma once
#include <QtNetwork>
+#include <QLabel>
#include "Download.h"
#include "ByteArrayDownload.h"
#include "FileDownload.h"
@@ -57,12 +58,13 @@ public:
signals:
void started();
void progress(qint64 current, qint64 total);
+ void filesProgress(int, int, int);
void succeeded();
void failed();
public slots:
virtual void start();
private slots:
- void partProgress(int index, qint64 bytesReceived, qint64 bytesTotal);;
+ void partProgress(int index, qint64 bytesReceived, qint64 bytesTotal);
void partSucceeded(int index);
void partFailed(int index);
private: