From ce512e1cf228584336353acbcacbdc30e21f5c4a Mon Sep 17 00:00:00 2001 From: Sky Date: Mon, 21 Oct 2013 17:50:45 +0100 Subject: [PATCH] Clean up skins, remove wrapper, save to accounts/skins --- CMakeLists.txt | 2 -- MultiMC.cpp | 2 +- gui/logindialog.cpp | 3 +- gui/mainwindow.cpp | 9 ++++-- logic/net/SkinDownload.cpp | 60 -------------------------------------- logic/net/SkinDownload.h | 38 ------------------------ 6 files changed, 8 insertions(+), 106 deletions(-) delete mode 100644 logic/net/SkinDownload.cpp delete mode 100644 logic/net/SkinDownload.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d00fbd5e..b7dd6ea3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -256,8 +256,6 @@ logic/net/HttpMetaCache.h logic/net/HttpMetaCache.cpp logic/net/LoginTask.h logic/net/LoginTask.cpp -logic/net/SkinDownload.h -logic/net/SkinDownload.cpp # legacy instances logic/LegacyInstance.h diff --git a/MultiMC.cpp b/MultiMC.cpp index e38733a1..50ae3d3d 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -294,7 +294,7 @@ void MultiMC::initHttpMetaCache() m_metacache->addBase("versions", QDir("versions").absolutePath()); m_metacache->addBase("libraries", QDir("libraries").absolutePath()); m_metacache->addBase("minecraftforge", QDir("mods/minecraftforge").absolutePath()); - m_metacache->addBase("skins", QDir("playerdata/skins").absolutePath()); + m_metacache->addBase("skins", QDir("accounts/skins").absolutePath()); m_metacache->Load(); } diff --git a/gui/logindialog.cpp b/gui/logindialog.cpp index 332b5d38..aeaaaa9e 100644 --- a/gui/logindialog.cpp +++ b/gui/logindialog.cpp @@ -206,8 +206,7 @@ void LoginDialog::userTextChanged ( const QString& user ) } } - if(gotFace) ui->lblFace->setVisible(true); - else ui->lblFace->setVisible(false); + ui->lblFace->setVisible(gotFace); blockToggles = false; } diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index b68af5fa..f5503754 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -57,7 +57,6 @@ #include "logic/lists/JavaVersionList.h" #include "logic/net/LoginTask.h" -#include "logic/net/SkinDownload.h" #include "logic/BaseInstance.h" #include "logic/InstanceFactory.h" @@ -520,9 +519,13 @@ void MainWindow::onLoginComplete() delete updateTask; } - auto download = new SkinDownload(m_activeLogin.player_name); - download->start(); + auto job = new DownloadJob("Player skin: " + m_activeLogin.player_name); + auto meta = MMC->metacache()->resolveEntry("skins", m_activeLogin.player_name + ".png"); + job->addCacheDownload(QUrl("http://skins.minecraft.net/MinecraftSkins/" + m_activeLogin.player_name + ".png"), meta); + meta->stale = true; + + job->start(); auto filename = MMC->metacache()->resolveEntry("skins", "skins.json")->getFullPath(); QFile listFile(filename); diff --git a/logic/net/SkinDownload.cpp b/logic/net/SkinDownload.cpp deleted file mode 100644 index fa7be2b5..00000000 --- a/logic/net/SkinDownload.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "MultiMC.h" -#include "SkinDownload.h" -#include "DownloadJob.h" -#include - -#include -#include -#include -#include -#include -#include - -SkinDownload::SkinDownload(QString name) -{ - m_name = name; - m_entry = MMC->metacache()->resolveEntry("skins", name + ".png"); - m_entry->stale = true; - m_url = QUrl("http://skins.minecraft.net/MinecraftSkins/" + name + ".png"); -} - -void SkinDownload::start() -{ - auto job = new DownloadJob("Player skin: " + m_name); - - job->addCacheDownload(m_url, m_entry); - m_job.reset(job); - - connect(m_job.get(), SIGNAL(started()), SLOT(downloadStarted())); - connect(m_job.get(), SIGNAL(progress(qint64, qint64)), SLOT(downloadProgress(qint64, qint64))); - connect(m_job.get(), SIGNAL(succeeded()), SLOT(downloadSucceeded())); - connect(m_job.get(), SIGNAL(failed()), SLOT(downloadFailed())); - - m_job->start(); -} - -void SkinDownload::downloadStarted() -{ - //QLOG_INFO() << "Started skin download for " << m_name << "."; - - emit started(); -} - -void SkinDownload::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) -{ - emit progress(bytesReceived, bytesTotal); -} - -void SkinDownload::downloadSucceeded() -{ - //QLOG_INFO() << "Got skin for " << m_name << ", cropping."; - - emit succeeded(); -} - -void SkinDownload::downloadFailed() -{ - //QLOG_ERROR() << "Failed to download skin for: " << m_name; - - emit failed(); -} diff --git a/logic/net/SkinDownload.h b/logic/net/SkinDownload.h deleted file mode 100644 index 56e5c01d..00000000 --- a/logic/net/SkinDownload.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include "Download.h" -#include "HttpMetaCache.h" -#include "DownloadJob.h" -#include -#include - -class SkinDownload : public QObject -{ - Q_OBJECT - -public: - explicit SkinDownload(QString name); - QString m_name; - QUrl m_url; - MetaEntryPtr m_entry; - DownloadJobPtr m_job; - - void start(); - -protected slots: - void downloadStarted(); - void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); - void downloadSucceeded(); - void downloadFailed(); - -signals: - void started(); - void progress(qint64 current, qint64 total); - void succeeded(); - void failed(); - -protected: - -}; - -typedef std::shared_ptr SkinDownloadPtr;