diff options
author | Sky <git@bunnies.cc> | 2013-11-27 18:45:29 +0000 |
---|---|---|
committer | Sky <git@bunnies.cc> | 2013-11-27 18:45:29 +0000 |
commit | 38732636d3c1f1563c2dceeae723fd51f7b5fda6 (patch) | |
tree | ee59e304a5aa93ff9a47c98ab69db21b4e671434 /logic/SkinUtils.cpp | |
parent | 7d7579d7f04f88013d7e4d064b2becec28cced61 (diff) | |
download | MultiMC-38732636d3c1f1563c2dceeae723fd51f7b5fda6.tar MultiMC-38732636d3c1f1563c2dceeae723fd51f7b5fda6.tar.gz MultiMC-38732636d3c1f1563c2dceeae723fd51f7b5fda6.tar.lz MultiMC-38732636d3c1f1563c2dceeae723fd51f7b5fda6.tar.xz MultiMC-38732636d3c1f1563c2dceeae723fd51f7b5fda6.zip |
Nuke skins.json, use nice yggdrasil implementation instead. Grabs all Mojang account skins on addition, active on startup
Diffstat (limited to 'logic/SkinUtils.cpp')
-rw-r--r-- | logic/SkinUtils.cpp | 50 |
1 files changed, 11 insertions, 39 deletions
diff --git a/logic/SkinUtils.cpp b/logic/SkinUtils.cpp index f00ce98d..c6c80006 100644 --- a/logic/SkinUtils.cpp +++ b/logic/SkinUtils.cpp @@ -24,52 +24,24 @@ namespace SkinUtils { +/* + * Given a username, return a pixmap of the cached skin (if it exists), QPixmap() otherwise + */ QPixmap getFaceFromCache(QString username, int height, int width) { - bool gotFace = false; - - QByteArray data; - { - auto filename = - MMC->metacache()->resolveEntry("skins", "skins.json")->getFullPath(); - QFile listFile(filename); - if (!listFile.open(QIODevice::ReadOnly)) - return QPixmap(); - data = listFile.readAll(); - } + QFile fskin(MMC->metacache() + ->resolveEntry("skins", username + ".png") + ->getFullPath()); - QJsonParseError jsonError; - QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError); - QJsonObject root = jsonDoc.object(); - QJsonObject mappings = root.value("mappings").toObject(); - - if (!mappings[username].isUndefined()) + if (fskin.exists()) { - QJsonArray usernames = mappings.value(username).toArray(); - if (!usernames.isEmpty()) + QPixmap skin(fskin.fileName()); + if(!skin.isNull()) { - 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(height, width, Qt::KeepAspectRatio); - - return face; - } - } + return skin.copy(8, 8, 8, 8).scaled(height, width, Qt::KeepAspectRatio); } } - if(!gotFace) return QPixmap(); + return QPixmap(); } } |