summaryrefslogtreecommitdiffstats
path: root/gui/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'gui/dialogs')
-rw-r--r--gui/dialogs/AccountListDialog.cpp23
-rw-r--r--gui/dialogs/AccountListDialog.h3
-rw-r--r--gui/dialogs/LoginDialog.cpp44
3 files changed, 29 insertions, 41 deletions
diff --git a/gui/dialogs/AccountListDialog.cpp b/gui/dialogs/AccountListDialog.cpp
index c685c164..ea6861c6 100644
--- a/gui/dialogs/AccountListDialog.cpp
+++ b/gui/dialogs/AccountListDialog.cpp
@@ -21,6 +21,7 @@
#include <logger/QsLog.h>
#include <logic/auth/AuthenticateTask.h>
+#include <logic/net/NetJob.h>
#include <gui/dialogs/LoginDialog.h>
#include <gui/dialogs/ProgressDialog.h>
@@ -56,6 +57,8 @@ void AccountListDialog::on_rmAccountBtn_clicked()
{
QModelIndex selected = selection.first();
m_accounts->removeAccount(selected);
+
+ emit activeAccountChanged();
}
}
@@ -72,7 +75,9 @@ void AccountListDialog::on_setActiveBtn_clicked()
QModelIndex selected = selection.first();
MojangAccountPtr account = selected.data(MojangAccountList::PointerRole).value<MojangAccountPtr>();
m_accounts->setActiveAccount(account->username());
- }
+
+ emit activeAccountChanged();
+ }
}
void AccountListDialog::on_closeBtnBox_rejected()
@@ -108,5 +113,21 @@ void AccountListDialog::onLoginComplete()
MojangAccountPtr account = m_authTask->getMojangAccount();
m_accounts->addAccount(account);
//ui->listView->update();
+
+ // Grab associated player skins
+ auto job = new NetJob("Player skins: " + account->username());
+
+ for(AccountProfile profile : account->profiles())
+ {
+ auto meta = MMC->metacache()->resolveEntry("skins", profile.name() + ".png");
+ auto action = CacheDownload::make(
+ QUrl("http://skins.minecraft.net/MinecraftSkins/" + profile.name() + ".png"),
+ meta);
+ job->addNetAction(action);
+ meta->stale = true;
+ }
+
+ connect(job, SIGNAL(succeeded()), SIGNAL(activeAccountChanged()));
+ job->start();
}
diff --git a/gui/dialogs/AccountListDialog.h b/gui/dialogs/AccountListDialog.h
index 17a50bec..52666e3b 100644
--- a/gui/dialogs/AccountListDialog.h
+++ b/gui/dialogs/AccountListDialog.h
@@ -47,6 +47,9 @@ slots:
// This will be sent when the "close" button is clicked.
void on_closeBtnBox_rejected();
+signals:
+ void activeAccountChanged();
+
protected:
std::shared_ptr<MojangAccountList> m_accounts;
diff --git a/gui/dialogs/LoginDialog.cpp b/gui/dialogs/LoginDialog.cpp
index 19c6437d..28bbb1ee 100644
--- a/gui/dialogs/LoginDialog.cpp
+++ b/gui/dialogs/LoginDialog.cpp
@@ -18,6 +18,7 @@
#include "keyring.h"
#include "gui/Platform.h"
#include "MultiMC.h"
+#include "logic/SkinUtils.h"
#include <QFile>
#include <QJsonObject>
@@ -168,47 +169,10 @@ void LoginDialog::userTextChanged(const QString &user)
ui->rememberPasswordCheckbox->setChecked(!passwd.isEmpty());
ui->passwordTextBox->setText(passwd);
- QByteArray data;
- {
- auto filename =
- MMC->metacache()->resolveEntry("skins", "skins.json")->getFullPath();
- QFile listFile(filename);
- if (!listFile.open(QIODevice::ReadOnly))
- return;
- data = listFile.readAll();
- }
-
- QJsonParseError jsonError;
- QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
- QJsonObject root = jsonDoc.object();
- QJsonObject mappings = root.value("mappings").toObject();
+ QPixmap face = SkinUtils::getFaceFromCache(user);
+ gotFace = !face.isNull();
- if (!mappings[user].isUndefined())
- {
- QJsonArray usernames = mappings.value(user).toArray();
- if (!usernames.isEmpty())
- {
- QString mapped_username = usernames[0].toString();
-
- if (!mapped_username.isEmpty())
- {
- QFile fskin(MMC->metacache()
- ->resolveEntry("skins", mapped_username + ".png")
- ->getFullPath());
- if (fskin.exists())
- {
- QPixmap skin(MMC->metacache()
- ->resolveEntry("skins", mapped_username + ".png")
- ->getFullPath());
- QPixmap face =
- skin.copy(8, 8, 8, 8).scaled(48, 48, Qt::KeepAspectRatio);
-
- ui->lblFace->setPixmap(face);
- gotFace = true;
- }
- }
- }
- }
+ if(gotFace) ui->lblFace->setPixmap(face);
}
ui->lblFace->setVisible(gotFace);