Clean up skins, remove wrapper, save to accounts/skins

This commit is contained in:
Sky 2013-10-21 17:50:45 +01:00
parent 681d36b232
commit ce512e1cf2
6 changed files with 8 additions and 106 deletions

View File

@ -256,8 +256,6 @@ logic/net/HttpMetaCache.h
logic/net/HttpMetaCache.cpp logic/net/HttpMetaCache.cpp
logic/net/LoginTask.h logic/net/LoginTask.h
logic/net/LoginTask.cpp logic/net/LoginTask.cpp
logic/net/SkinDownload.h
logic/net/SkinDownload.cpp
# legacy instances # legacy instances
logic/LegacyInstance.h logic/LegacyInstance.h

View File

@ -294,7 +294,7 @@ void MultiMC::initHttpMetaCache()
m_metacache->addBase("versions", QDir("versions").absolutePath()); m_metacache->addBase("versions", QDir("versions").absolutePath());
m_metacache->addBase("libraries", QDir("libraries").absolutePath()); m_metacache->addBase("libraries", QDir("libraries").absolutePath());
m_metacache->addBase("minecraftforge", QDir("mods/minecraftforge").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(); m_metacache->Load();
} }

View File

@ -206,8 +206,7 @@ void LoginDialog::userTextChanged ( const QString& user )
} }
} }
if(gotFace) ui->lblFace->setVisible(true); ui->lblFace->setVisible(gotFace);
else ui->lblFace->setVisible(false);
blockToggles = false; blockToggles = false;
} }

View File

@ -57,7 +57,6 @@
#include "logic/lists/JavaVersionList.h" #include "logic/lists/JavaVersionList.h"
#include "logic/net/LoginTask.h" #include "logic/net/LoginTask.h"
#include "logic/net/SkinDownload.h"
#include "logic/BaseInstance.h" #include "logic/BaseInstance.h"
#include "logic/InstanceFactory.h" #include "logic/InstanceFactory.h"
@ -520,9 +519,13 @@ void MainWindow::onLoginComplete()
delete updateTask; delete updateTask;
} }
auto download = new SkinDownload(m_activeLogin.player_name); auto job = new DownloadJob("Player skin: " + m_activeLogin.player_name);
download->start();
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(); auto filename = MMC->metacache()->resolveEntry("skins", "skins.json")->getFullPath();
QFile listFile(filename); QFile listFile(filename);

View File

@ -1,60 +0,0 @@
#include "MultiMC.h"
#include "SkinDownload.h"
#include "DownloadJob.h"
#include <pathutils.h>
#include <QImage>
#include <QPainter>
#include <QCryptographicHash>
#include <QFileInfo>
#include <QDateTime>
#include <logger/QsLog.h>
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();
}

View File

@ -1,38 +0,0 @@
#pragma once
#include "Download.h"
#include "HttpMetaCache.h"
#include "DownloadJob.h"
#include <QFile>
#include <QTemporaryFile>
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<SkinDownload> SkinDownloadPtr;