2013-05-03 19:41:37 +00:00
|
|
|
/* Copyright 2013 Andrew Okin
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2013-07-28 22:59:35 +00:00
|
|
|
#pragma once
|
2013-05-03 19:41:37 +00:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QList>
|
2013-08-11 16:58:24 +00:00
|
|
|
#include <QSet>
|
|
|
|
#include <QSharedPointer>
|
2013-05-03 19:41:37 +00:00
|
|
|
|
2013-07-28 22:59:35 +00:00
|
|
|
#include "InstVersionList.h"
|
2013-08-17 11:40:51 +00:00
|
|
|
#include "logic/tasks/Task.h"
|
|
|
|
#include "logic/MinecraftVersion.h"
|
2013-05-03 19:41:37 +00:00
|
|
|
|
|
|
|
class MCVListLoadTask;
|
2013-08-04 12:46:33 +00:00
|
|
|
class QNetworkReply;
|
2013-05-03 19:41:37 +00:00
|
|
|
|
2013-08-17 11:40:51 +00:00
|
|
|
class MinecraftVersionList : public InstVersionList
|
2013-05-03 19:41:37 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
friend class MCVListLoadTask;
|
|
|
|
|
|
|
|
explicit MinecraftVersionList(QObject *parent = 0);
|
|
|
|
|
|
|
|
virtual Task *getLoadTask();
|
|
|
|
virtual bool isLoaded();
|
2013-08-11 16:58:24 +00:00
|
|
|
virtual const InstVersionPtr at(int i) const;
|
2013-05-03 19:41:37 +00:00
|
|
|
virtual int count() const;
|
2013-05-04 01:14:38 +00:00
|
|
|
virtual void sort();
|
2013-05-03 19:41:37 +00:00
|
|
|
|
2013-08-11 16:58:24 +00:00
|
|
|
virtual InstVersionPtr getLatestStable() const;
|
2013-05-07 02:08:31 +00:00
|
|
|
|
2013-05-03 19:41:37 +00:00
|
|
|
/*!
|
|
|
|
* Gets the main version list instance.
|
|
|
|
*/
|
|
|
|
static MinecraftVersionList &getMainList();
|
|
|
|
|
2013-05-04 01:14:38 +00:00
|
|
|
|
2013-05-03 19:41:37 +00:00
|
|
|
protected:
|
2013-08-11 16:58:24 +00:00
|
|
|
QList<InstVersionPtr > m_vlist;
|
2013-05-03 19:41:37 +00:00
|
|
|
|
|
|
|
bool m_loaded;
|
|
|
|
|
|
|
|
protected slots:
|
2013-08-11 16:58:24 +00:00
|
|
|
virtual void updateListData(QList<InstVersionPtr > versions);
|
2013-05-03 19:41:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class MCVListLoadTask : public Task
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit MCVListLoadTask(MinecraftVersionList *vlist);
|
|
|
|
~MCVListLoadTask();
|
|
|
|
|
|
|
|
virtual void executeTask();
|
|
|
|
|
2013-08-04 12:46:33 +00:00
|
|
|
protected slots:
|
|
|
|
void list_downloaded();
|
2013-05-03 19:41:37 +00:00
|
|
|
|
2013-08-04 12:46:33 +00:00
|
|
|
protected:
|
2013-05-03 19:41:37 +00:00
|
|
|
//! Loads versions from Mojang's official version list.
|
|
|
|
bool loadFromVList();
|
|
|
|
|
2013-08-04 12:46:33 +00:00
|
|
|
QNetworkReply *vlistReply;
|
2013-05-03 19:41:37 +00:00
|
|
|
MinecraftVersionList *m_list;
|
|
|
|
MinecraftVersion *m_currentStable;
|
2013-08-11 16:58:24 +00:00
|
|
|
QSet<QString> legacyWhitelist;
|
2013-05-03 19:41:37 +00:00
|
|
|
};
|
|
|
|
|