diff options
author | Sky <git@bunnies.cc> | 2013-10-19 06:40:46 +0100 |
---|---|---|
committer | Sky <git@bunnies.cc> | 2013-10-19 06:40:46 +0100 |
commit | 681d36b23251993a8678db8e72859d4018396b63 (patch) | |
tree | 9082d1bc7107c1b1d0bc7b72fb486bd84cd21560 /gui/mainwindow.cpp | |
parent | be2c7f451541647899478d0197d3e9500d63c833 (diff) | |
download | PrismLauncher-681d36b23251993a8678db8e72859d4018396b63.tar.gz PrismLauncher-681d36b23251993a8678db8e72859d4018396b63.tar.bz2 PrismLauncher-681d36b23251993a8678db8e72859d4018396b63.zip |
First draft of player faces in the login dialog
Diffstat (limited to 'gui/mainwindow.cpp')
-rw-r--r-- | gui/mainwindow.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 0bd6f651..b68af5fa 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -57,6 +57,8 @@ #include "logic/lists/JavaVersionList.h" #include "logic/net/LoginTask.h" +#include "logic/net/SkinDownload.h" + #include "logic/BaseInstance.h" #include "logic/InstanceFactory.h" #include "logic/MinecraftProcess.h" @@ -517,6 +519,42 @@ void MainWindow::onLoginComplete() tDialog.exec(updateTask); delete updateTask; } + + auto download = new SkinDownload(m_activeLogin.player_name); + download->start(); + + auto filename = MMC->metacache()->resolveEntry("skins", "skins.json")->getFullPath(); + QFile listFile(filename); + + // Add skin mapping + QByteArray data; + { + if(!listFile.open(QIODevice::ReadWrite)) + { + QLOG_ERROR() << "Failed to open/make skins list JSON"; + return; + } + + data = listFile.readAll(); + } + + QJsonParseError jsonError; + QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError); + QJsonObject root = jsonDoc.object(); + QJsonObject mappings = root.value("mappings").toObject(); + QJsonArray usernames = mappings.value(m_activeLogin.username).toArray(); + + if(!usernames.contains(m_activeLogin.player_name)) + { + usernames.prepend(m_activeLogin.player_name); + mappings[m_activeLogin.username] = usernames; + root["mappings"] = mappings; + jsonDoc.setObject(root); + + // QJson hack - shouldn't have to clear the file every time a save happens + listFile.resize(0); + listFile.write(jsonDoc.toJson()); + } } void MainWindow::onGameUpdateComplete() |