summaryrefslogtreecommitdiffstats
path: root/logic
diff options
context:
space:
mode:
Diffstat (limited to 'logic')
-rw-r--r--logic/BaseInstance.h2
-rw-r--r--logic/OneSixUpdate.cpp8
-rw-r--r--logic/auth/MojangAccountList.cpp10
-rw-r--r--logic/auth/MojangAccountList.h5
-rw-r--r--logic/lists/InstanceList.cpp14
-rw-r--r--logic/lists/InstanceList.h5
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