NOISSUE rearrange global initialization
This commit is contained in:
@ -10,17 +10,18 @@
|
||||
#include "tasks/Task.h"
|
||||
#include "meta/Index.h"
|
||||
#include "FileSystem.h"
|
||||
#include "minecraft/legacy/LwjglVersionList.h"
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
class Env::Private
|
||||
struct Env::Private
|
||||
{
|
||||
public:
|
||||
QNetworkAccessManager m_qnam;
|
||||
shared_qobject_ptr<HttpMetaCache> m_metacache;
|
||||
std::shared_ptr<IIconList> m_iconlist;
|
||||
QMap<QString, std::shared_ptr<BaseVersionList>> m_versionLists;
|
||||
shared_qobject_ptr<Meta::Index> m_metadataIndex;
|
||||
// FIXME: replace with mojang format LWJGL in meta store
|
||||
std::shared_ptr<LWJGLVersionList> m_lwjgllist;
|
||||
QString m_jarsPath;
|
||||
};
|
||||
|
||||
@ -75,32 +76,6 @@ void Env::registerIconList(std::shared_ptr<IIconList> iconlist)
|
||||
d->m_iconlist = iconlist;
|
||||
}
|
||||
|
||||
BaseVersionPtr Env::getVersion(QString component, QString version)
|
||||
{
|
||||
auto list = getVersionList(component);
|
||||
if(!list)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return list->findVersion(version);
|
||||
}
|
||||
|
||||
std::shared_ptr< BaseVersionList > Env::getVersionList(QString component)
|
||||
{
|
||||
auto iter = d->m_versionLists.find(component);
|
||||
if(iter != d->m_versionLists.end())
|
||||
{
|
||||
return *iter;
|
||||
}
|
||||
//return std::make_shared<NullVersionList>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Env::registerVersionList(QString name, std::shared_ptr< BaseVersionList > vlist)
|
||||
{
|
||||
d->m_versionLists[name] = vlist;
|
||||
}
|
||||
|
||||
shared_qobject_ptr<Meta::Index> Env::metadataIndex()
|
||||
{
|
||||
if (!d->m_metadataIndex)
|
||||
@ -207,4 +182,13 @@ void Env::setJarsPath(const QString& path)
|
||||
d->m_jarsPath = path;
|
||||
}
|
||||
|
||||
LWJGLVersionList *Env::getLegacyLWJGL()
|
||||
{
|
||||
if(!d->m_lwjgllist)
|
||||
{
|
||||
d->m_lwjgllist.reset(new LWJGLVersionList());
|
||||
}
|
||||
return d->m_lwjgllist.get();
|
||||
}
|
||||
|
||||
#include "Env.moc"
|
||||
|
@ -13,6 +13,7 @@ class QNetworkAccessManager;
|
||||
class HttpMetaCache;
|
||||
class BaseVersionList;
|
||||
class BaseVersion;
|
||||
class LWJGLVersionList;
|
||||
|
||||
namespace Meta
|
||||
{
|
||||
@ -24,11 +25,12 @@ class Index;
|
||||
#endif
|
||||
#define ENV (Env::getInstance())
|
||||
|
||||
|
||||
class MULTIMC_LOGIC_EXPORT Env
|
||||
{
|
||||
friend class MultiMC;
|
||||
private:
|
||||
class Private;
|
||||
struct Private;
|
||||
Env();
|
||||
~Env();
|
||||
static void dispose();
|
||||
@ -47,18 +49,12 @@ public:
|
||||
/// Updates the application proxy settings from the settings object.
|
||||
void updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password);
|
||||
|
||||
/// get a version list by name
|
||||
std::shared_ptr<BaseVersionList> getVersionList(QString component);
|
||||
|
||||
/// get a version by list name and version name
|
||||
std::shared_ptr<BaseVersion> getVersion(QString component, QString version);
|
||||
|
||||
void registerVersionList(QString name, std::shared_ptr<BaseVersionList> vlist);
|
||||
|
||||
void registerIconList(std::shared_ptr<IIconList> iconlist);
|
||||
|
||||
shared_qobject_ptr<Meta::Index> metadataIndex();
|
||||
|
||||
LWJGLVersionList *getLegacyLWJGL();
|
||||
|
||||
QString getJarsPath();
|
||||
void setJarsPath(const QString & path);
|
||||
protected:
|
||||
|
@ -164,7 +164,7 @@ void LegacyUpdate::lwjglStart()
|
||||
{
|
||||
LegacyInstance *inst = (LegacyInstance *)m_inst;
|
||||
|
||||
auto list = std::dynamic_pointer_cast<LWJGLVersionList>(ENV.getVersionList("org.lwjgl.legacy"));
|
||||
auto list = ENV.getLegacyLWJGL();
|
||||
if (!list->isLoaded())
|
||||
{
|
||||
setStatus(tr("Checking the LWJGL version list..."));
|
||||
|
Reference in New Issue
Block a user