From 4901985db64c91e7cfafc3b9bf710423b90538cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Wed, 19 Mar 2014 23:23:59 +0100 Subject: [PATCH] Finalize version on reload. --- logic/OneSixVersionBuilder.cpp | 29 ++--------------------------- logic/OneSixVersionBuilder.h | 1 - logic/VersionFinal.cpp | 28 +++++++++++++++++++++++++++- logic/VersionFinal.h | 1 + 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/logic/OneSixVersionBuilder.cpp b/logic/OneSixVersionBuilder.cpp index 35d01a46..be3a7da4 100644 --- a/logic/OneSixVersionBuilder.cpp +++ b/logic/OneSixVersionBuilder.cpp @@ -137,35 +137,10 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi } while (0); // some final touches - finalizeVersion(); + m_version->finalize(); } -void OneSixVersionBuilder::finalizeVersion() -{ - if (m_version->assets.isEmpty()) - { - m_version->assets = "legacy"; - } - if (m_version->minecraftArguments.isEmpty()) - { - QString toCompare = m_version->processArguments.toLower(); - if (toCompare == "legacy") - { - m_version->minecraftArguments = " ${auth_player_name} ${auth_session}"; - } - else if (toCompare == "username_session") - { - m_version->minecraftArguments = - "--username ${auth_player_name} --session ${auth_session}"; - } - else if (toCompare == "username_session_version") - { - m_version->minecraftArguments = "--username ${auth_player_name} " - "--session ${auth_session} " - "--version ${profile_name}"; - } - } -} + void OneSixVersionBuilder::readJsonAndApply(const QJsonObject &obj) { diff --git a/logic/OneSixVersionBuilder.h b/logic/OneSixVersionBuilder.h index 8be3d9d3..7a799e5b 100644 --- a/logic/OneSixVersionBuilder.h +++ b/logic/OneSixVersionBuilder.h @@ -41,7 +41,6 @@ private: void buildInternal(const bool onlyVanilla, const QStringList &external); void readJsonAndApply(const QJsonObject &obj); - void finalizeVersion(); VersionFilePtr parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder, bool isFTB = false); diff --git a/logic/VersionFinal.cpp b/logic/VersionFinal.cpp index d0e85c15..b465df68 100644 --- a/logic/VersionFinal.cpp +++ b/logic/VersionFinal.cpp @@ -310,9 +310,35 @@ void VersionFinal::reapply(const bool alreadyReseting) file->applyTo(this); } versionFiles.swap(newVersionFiles); - + finalize(); if (!alreadyReseting) { endResetModel(); } } + +void VersionFinal::finalize() +{ + if (assets.isEmpty()) + { + assets = "legacy"; + } + if (minecraftArguments.isEmpty()) + { + QString toCompare = processArguments.toLower(); + if (toCompare == "legacy") + { + minecraftArguments = " ${auth_player_name} ${auth_session}"; + } + else if (toCompare == "username_session") + { + minecraftArguments = "--username ${auth_player_name} --session ${auth_session}"; + } + else if (toCompare == "username_session_version") + { + minecraftArguments = "--username ${auth_player_name} " + "--session ${auth_session} " + "--version ${profile_name}"; + } + } +} diff --git a/logic/VersionFinal.h b/logic/VersionFinal.h index fcffb3c3..4ddfe9f4 100644 --- a/logic/VersionFinal.h +++ b/logic/VersionFinal.h @@ -56,6 +56,7 @@ public: // clears and reapplies all version files void reapply(const bool alreadyReseting = false); + void finalize(); public slots: