mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-12-16 00:47:14 +00:00
NOISSUE Add a skeleton of the wonko system
This commit is contained in:
committed by
Petr Mrázek
parent
5ae3b2c114
commit
00e5968bd2
74
application/WonkoGui.cpp
Normal file
74
application/WonkoGui.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
#include "WonkoGui.h"
|
||||
|
||||
#include "dialogs/ProgressDialog.h"
|
||||
#include "wonko/WonkoIndex.h"
|
||||
#include "wonko/WonkoVersionList.h"
|
||||
#include "wonko/WonkoVersion.h"
|
||||
#include "Env.h"
|
||||
|
||||
WonkoIndexPtr Wonko::ensureIndexLoaded(QWidget *parent)
|
||||
{
|
||||
if (!ENV.wonkoIndex()->isLocalLoaded())
|
||||
{
|
||||
ProgressDialog(parent).execWithTask(ENV.wonkoIndex()->localUpdateTask());
|
||||
if (!ENV.wonkoIndex()->isRemoteLoaded() && ENV.wonkoIndex()->lists().size() == 0)
|
||||
{
|
||||
ProgressDialog(parent).execWithTask(ENV.wonkoIndex()->remoteUpdateTask());
|
||||
}
|
||||
}
|
||||
return ENV.wonkoIndex();
|
||||
}
|
||||
|
||||
WonkoVersionListPtr Wonko::ensureVersionListExists(const QString &uid, QWidget *parent)
|
||||
{
|
||||
ensureIndexLoaded(parent);
|
||||
if (!ENV.wonkoIndex()->isRemoteLoaded() && !ENV.wonkoIndex()->hasUid(uid))
|
||||
{
|
||||
ProgressDialog(parent).execWithTask(ENV.wonkoIndex()->remoteUpdateTask());
|
||||
}
|
||||
return ENV.wonkoIndex()->getList(uid);
|
||||
}
|
||||
WonkoVersionListPtr Wonko::ensureVersionListLoaded(const QString &uid, QWidget *parent)
|
||||
{
|
||||
WonkoVersionListPtr list = ensureVersionListExists(uid, parent);
|
||||
if (!list)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
if (!list->isLocalLoaded())
|
||||
{
|
||||
ProgressDialog(parent).execWithTask(list->localUpdateTask());
|
||||
if (!list->isLocalLoaded())
|
||||
{
|
||||
ProgressDialog(parent).execWithTask(list->remoteUpdateTask());
|
||||
}
|
||||
}
|
||||
return list->isComplete() ? list : nullptr;
|
||||
}
|
||||
|
||||
WonkoVersionPtr Wonko::ensureVersionExists(const QString &uid, const QString &version, QWidget *parent)
|
||||
{
|
||||
WonkoVersionListPtr list = ensureVersionListLoaded(uid, parent);
|
||||
if (!list)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return list->getVersion(version);
|
||||
}
|
||||
WonkoVersionPtr Wonko::ensureVersionLoaded(const QString &uid, const QString &version, QWidget *parent, const UpdateType update)
|
||||
{
|
||||
WonkoVersionPtr vptr = ensureVersionExists(uid, version, parent);
|
||||
if (!vptr)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
if (!vptr->isLocalLoaded() || update == AlwaysUpdate)
|
||||
{
|
||||
ProgressDialog(parent).execWithTask(vptr->localUpdateTask());
|
||||
if (!vptr->isLocalLoaded() || update == AlwaysUpdate)
|
||||
{
|
||||
ProgressDialog(parent).execWithTask(vptr->remoteUpdateTask());
|
||||
}
|
||||
}
|
||||
return vptr->isComplete() ? vptr : nullptr;
|
||||
}
|
||||
Reference in New Issue
Block a user