diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-12-15 18:10:51 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-12-15 18:13:46 +0100 |
commit | dd9e04000ccd02a868138de9276f8fb93b855550 (patch) | |
tree | 496985ef1c0d0d1ba724948b87aaf641a78c624b /logic | |
parent | 5a3043398e45cbe39455609a42463f2e6e5d3fd2 (diff) | |
download | MultiMC-dd9e04000ccd02a868138de9276f8fb93b855550.tar MultiMC-dd9e04000ccd02a868138de9276f8fb93b855550.tar.gz MultiMC-dd9e04000ccd02a868138de9276f8fb93b855550.tar.lz MultiMC-dd9e04000ccd02a868138de9276f8fb93b855550.tar.xz MultiMC-dd9e04000ccd02a868138de9276f8fb93b855550.zip |
Improve group changing, update instance on version change
Gives a list of existing groups to choose from.
Instances are updated as long as there is at least one valid account.
Diffstat (limited to 'logic')
-rw-r--r-- | logic/BaseInstance.h | 2 | ||||
-rw-r--r-- | logic/OneSixUpdate.cpp | 8 | ||||
-rw-r--r-- | logic/auth/MojangAccountList.cpp | 10 | ||||
-rw-r--r-- | logic/auth/MojangAccountList.h | 5 | ||||
-rw-r--r-- | logic/lists/InstanceList.cpp | 14 | ||||
-rw-r--r-- | logic/lists/InstanceList.h | 5 |
6 files changed, 37 insertions, 7 deletions
diff --git a/logic/BaseInstance.h b/logic/BaseInstance.h index 93e57414..5f426676 100644 --- a/logic/BaseInstance.h +++ b/logic/BaseInstance.h @@ -149,7 +149,7 @@ public: */ virtual SettingsObject &settings() const; - /// returns a valid update task if update is needed, NULL otherwise + /// returns a valid update task virtual std::shared_ptr<Task> doUpdate(bool only_prepare) = 0; /// returns a valid minecraft process, ready for launch with the given account. diff --git a/logic/OneSixUpdate.cpp b/logic/OneSixUpdate.cpp index 62332267..696eeff0 100644 --- a/logic/OneSixUpdate.cpp +++ b/logic/OneSixUpdate.cpp @@ -54,11 +54,9 @@ void OneSixUpdate::executeTask() if (m_only_prepare) { - if (m_inst->shouldUpdate()) - { - emitFailed("Unable to update instance in offline mode."); - return; - } + /* + * FIXME: in offline mode, do not proceed! + */ setStatus("Testing the Java installation."); QString java_path = m_inst->settings().get("JavaPath").toString(); diff --git a/logic/auth/MojangAccountList.cpp b/logic/auth/MojangAccountList.cpp index 937b4721..70bc0cf2 100644 --- a/logic/auth/MojangAccountList.cpp +++ b/logic/auth/MojangAccountList.cpp @@ -414,3 +414,13 @@ void MojangAccountList::setListFilePath(QString path, bool autosave) m_listFilePath = path; m_autosave = autosave; } + +bool MojangAccountList::anyAccountIsValid() +{ + for(auto account:m_accounts) + { + if(account->accountStatus() != NotVerified) + return true; + } + return false; +} diff --git a/logic/auth/MojangAccountList.h b/logic/auth/MojangAccountList.h index c7e30958..6f4fbb17 100644 --- a/logic/auth/MojangAccountList.h +++ b/logic/auth/MojangAccountList.h @@ -126,6 +126,11 @@ public: * If the username given is an empty string, sets the active account to nothing. */ virtual void setActiveAccount(const QString &username); + + /*! + * Returns true if any of the account is at least Validated + */ + bool anyAccountIsValid(); signals: /*! diff --git a/logic/lists/InstanceList.cpp b/logic/lists/InstanceList.cpp index 94481fb9..15fd10ba 100644 --- a/logic/lists/InstanceList.cpp +++ b/logic/lists/InstanceList.cpp @@ -117,6 +117,11 @@ void InstanceList::groupChanged() saveGroupList(); } +QStringList InstanceList::getGroups() +{ + return m_groups.toList(); +} + void InstanceList::saveGroupList() { QString groupFileName = m_instDir + "/instgroups.json"; @@ -126,7 +131,7 @@ void InstanceList::saveGroupList() if (!groupFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { // An error occurred. Ignore it. - QLOG_ERROR() << "Failed to read instance group file."; + QLOG_ERROR() << "Failed to save instance group file."; return; } QTextStream out(&groupFile); @@ -137,6 +142,10 @@ void InstanceList::saveGroupList() QString group = instance->group(); if (group.isEmpty()) continue; + + // keep a list/set of groups for choosing + m_groups.insert(group); + if (!groupMap.count(group)) { QSet<QString> set; @@ -253,6 +262,9 @@ void InstanceList::loadGroupList(QMap<QString, QString> &groupMap) continue; } + // keep a list/set of groups for choosing + m_groups.insert(groupName); + // Iterate through the list of instances in the group. QJsonArray instancesArray = groupObj.value("instances").toArray(); diff --git a/logic/lists/InstanceList.h b/logic/lists/InstanceList.h index c3bb74cd..f23b7763 100644 --- a/logic/lists/InstanceList.h +++ b/logic/lists/InstanceList.h @@ -17,6 +17,7 @@ #include <QObject> #include <QAbstractListModel> +#include <QSet> #include "categorizedsortfilterproxymodel.h" #include <QIcon> @@ -97,6 +98,9 @@ public: InstancePtr getInstanceById(QString id) const; QModelIndex getInstanceIndexById(const QString &id) const; + + // FIXME: instead of iterating through all instances and forming a set, keep the set around + QStringList getGroups(); signals: void dataIsInvalid(); @@ -116,6 +120,7 @@ private: protected: QString m_instDir; QList<InstancePtr> m_instances; + QSet<QString> m_groups; }; class InstanceProxyModel : public KCategorizedSortFilterProxyModel |