NOISSUE make liteloader version list pretty and usable
This commit is contained in:
parent
6ecfe8546f
commit
969418f01f
@ -106,17 +106,23 @@ QVariant LiteLoaderVersionList::data(const QModelIndex &index, int role) const
|
|||||||
case ParentGameVersionRole:
|
case ParentGameVersionRole:
|
||||||
return version->mcVersion;
|
return version->mcVersion;
|
||||||
|
|
||||||
case RecommendedRole:
|
case LatestRole:
|
||||||
return version->isLatest;
|
return version->isLatest;
|
||||||
|
|
||||||
|
case RecommendedRole:
|
||||||
|
return version->isRecommended;
|
||||||
|
|
||||||
|
case TypeRole:
|
||||||
|
return version->isSnapshot ? tr("Snapshot") : tr("Release");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<BaseVersionList::ModelRoles> LiteLoaderVersionList::providesRoles()
|
BaseVersionList::RoleList LiteLoaderVersionList::providesRoles() const
|
||||||
{
|
{
|
||||||
return {VersionPointerRole, VersionRole, VersionIdRole, ParentGameVersionRole, RecommendedRole};
|
return {VersionPointerRole, VersionRole, VersionIdRole, ParentGameVersionRole, RecommendedRole, LatestRole, TypeRole};
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseVersionPtr LiteLoaderVersionList::getLatestStable() const
|
BaseVersionPtr LiteLoaderVersionList::getLatestStable() const
|
||||||
@ -124,7 +130,7 @@ BaseVersionPtr LiteLoaderVersionList::getLatestStable() const
|
|||||||
for (int i = 0; i < m_vlist.length(); i++)
|
for (int i = 0; i < m_vlist.length(); i++)
|
||||||
{
|
{
|
||||||
auto ver = std::dynamic_pointer_cast<LiteLoaderVersion>(m_vlist.at(i));
|
auto ver = std::dynamic_pointer_cast<LiteLoaderVersion>(m_vlist.at(i));
|
||||||
if (ver->isLatest)
|
if (ver->isRecommended)
|
||||||
{
|
{
|
||||||
return m_vlist.at(i);
|
return m_vlist.at(i);
|
||||||
}
|
}
|
||||||
@ -228,9 +234,9 @@ void LLListLoadTask::listDownloaded()
|
|||||||
const QString mcVersion = vIt.key();
|
const QString mcVersion = vIt.key();
|
||||||
const QJsonObject versionObject = vIt.value().toObject();
|
const QJsonObject versionObject = vIt.value().toObject();
|
||||||
|
|
||||||
auto processArtefacts = [&](QJsonObject artefacts, bool notSnapshots)
|
auto processArtefacts = [&](QJsonObject artefacts, bool notSnapshots, std::shared_ptr<LiteLoaderVersion> &latest)
|
||||||
{
|
{
|
||||||
QString latest;
|
QString latestVersion;
|
||||||
QList<BaseVersionPtr> perMcVersionList;
|
QList<BaseVersionPtr> perMcVersionList;
|
||||||
for (auto aIt = artefacts.begin(); aIt != artefacts.end(); ++aIt)
|
for (auto aIt = artefacts.begin(); aIt != artefacts.end(); ++aIt)
|
||||||
{
|
{
|
||||||
@ -238,18 +244,19 @@ void LLListLoadTask::listDownloaded()
|
|||||||
const QJsonObject artefact = aIt.value().toObject();
|
const QJsonObject artefact = aIt.value().toObject();
|
||||||
if (identifier == "latest")
|
if (identifier == "latest")
|
||||||
{
|
{
|
||||||
latest = artefact.value("version").toString();
|
latestVersion = artefact.value("version").toString();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
LiteLoaderVersionPtr version(new LiteLoaderVersion());
|
LiteLoaderVersionPtr version(new LiteLoaderVersion());
|
||||||
version->version = artefact.value("version").toString();
|
version->version = artefact.value("version").toString();
|
||||||
version->mcVersion = mcVersion;
|
version->mcVersion = mcVersion;
|
||||||
version->md5 = artefact.value("md5").toString();
|
version->md5 = artefact.value("md5").toString();
|
||||||
version->timestamp = artefact.value("timestamp").toString().toInt();
|
version->timestamp = artefact.value("timestamp").toString().toLong();
|
||||||
version->tweakClass = artefact.value("tweakClass").toString();
|
version->tweakClass = artefact.value("tweakClass").toString();
|
||||||
version->authors = authors;
|
version->authors = authors;
|
||||||
version->description = description;
|
version->description = description;
|
||||||
version->defaultUrl = defaultUrl;
|
version->defaultUrl = defaultUrl;
|
||||||
|
version->isSnapshot = !notSnapshots;
|
||||||
const QJsonArray libs = artefact.value("libraries").toArray();
|
const QJsonArray libs = artefact.value("libraries").toArray();
|
||||||
for (auto lIt = libs.begin(); lIt != libs.end(); ++lIt)
|
for (auto lIt = libs.begin(); lIt != libs.end(); ++lIt)
|
||||||
{
|
{
|
||||||
@ -284,58 +291,39 @@ void LLListLoadTask::listDownloaded()
|
|||||||
for (auto version : perMcVersionList)
|
for (auto version : perMcVersionList)
|
||||||
{
|
{
|
||||||
auto v = std::dynamic_pointer_cast<LiteLoaderVersion>(version);
|
auto v = std::dynamic_pointer_cast<LiteLoaderVersion>(version);
|
||||||
v->isLatest = v->version == latest;
|
if(v->version == latestVersion)
|
||||||
|
{
|
||||||
|
latest = v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tempList.append(perMcVersionList);
|
tempList.append(perMcVersionList);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::shared_ptr<LiteLoaderVersion> latestSnapshot;
|
||||||
|
std::shared_ptr<LiteLoaderVersion> latestRelease;
|
||||||
// are there actually released versions for this mc version?
|
// are there actually released versions for this mc version?
|
||||||
if(versionObject.contains("artefacts"))
|
if(versionObject.contains("artefacts"))
|
||||||
{
|
{
|
||||||
const QJsonObject artefacts = versionObject.value("artefacts").toObject().value("com.mumfrey:liteloader").toObject();
|
const QJsonObject artefacts = versionObject.value("artefacts").toObject().value("com.mumfrey:liteloader").toObject();
|
||||||
processArtefacts(artefacts, true);
|
processArtefacts(artefacts, true, latestRelease);
|
||||||
}
|
}
|
||||||
if(versionObject.contains("snapshots"))
|
if(versionObject.contains("snapshots"))
|
||||||
{
|
{
|
||||||
QJsonObject artefacts = versionObject.value("snapshots").toObject().value("com.mumfrey:liteloader").toObject();
|
QJsonObject artefacts = versionObject.value("snapshots").toObject().value("com.mumfrey:liteloader").toObject();
|
||||||
processArtefacts(artefacts, false);
|
processArtefacts(artefacts, false, latestSnapshot);
|
||||||
/*
|
}
|
||||||
LiteLoaderVersionPtr version(new LiteLoaderVersion());
|
if(latestSnapshot)
|
||||||
version->version = mcVersion + "-SNAPSHOT";
|
{
|
||||||
version->mcVersion = mcVersion;
|
latestSnapshot->isLatest = true;
|
||||||
version->md5 = QString(); // FIXME: not available, unable to check
|
}
|
||||||
version->timestamp = QDateTime::currentMSecsSinceEpoch() / 1000LL;
|
else if(latestRelease)
|
||||||
version->tweakClass = "com.mumfrey.liteloader.launch.LiteLoaderTweaker"; // FIXME: guessing here, no data available
|
{
|
||||||
version->authors = authors;
|
latestRelease->isLatest = true;
|
||||||
version->description = description;
|
}
|
||||||
version->defaultUrl = defaultUrl;
|
if(latestRelease)
|
||||||
const QJsonArray libs = snapshots.value("libraries").toArray();
|
{
|
||||||
for (auto lIt = libs.begin(); lIt != libs.end(); ++lIt)
|
latestRelease->isRecommended = true;
|
||||||
{
|
|
||||||
auto libobject = (*lIt).toObject();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
auto lib = OneSixVersionFormat::libraryFromJson(libobject, "versions.json");
|
|
||||||
// hack to make liteloader 1.7.10_00 work
|
|
||||||
if(lib->rawName() == GradleSpecifier("org.ow2.asm:asm-all:5.0.3"))
|
|
||||||
{
|
|
||||||
lib->setRepositoryURL("http://repo.maven.apache.org/maven2/");
|
|
||||||
}
|
|
||||||
version->libraries.append(lib);
|
|
||||||
}
|
|
||||||
catch (Exception &e)
|
|
||||||
{
|
|
||||||
qCritical() << "Couldn't read JSON object:";
|
|
||||||
continue; // FIXME: ignores bad libraries and continues loading
|
|
||||||
}
|
|
||||||
}
|
|
||||||
auto liteloaderLib = std::make_shared<Library>("com.mumfrey:liteloader:" + version->version);
|
|
||||||
liteloaderLib->setHint("always-stale");
|
|
||||||
liteloaderLib->setRepositoryURL("http://dl.liteloader.com/versions/");
|
|
||||||
version->libraries.append(liteloaderLib);
|
|
||||||
tempList.append(version);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_list->updateListData(tempList);
|
m_list->updateListData(tempList);
|
||||||
|
@ -56,8 +56,11 @@ public:
|
|||||||
QString version;
|
QString version;
|
||||||
QString mcVersion;
|
QString mcVersion;
|
||||||
QString md5;
|
QString md5;
|
||||||
int timestamp;
|
long timestamp = 0;
|
||||||
bool isLatest;
|
bool isLatest = false;
|
||||||
|
bool isRecommended = false;
|
||||||
|
bool isSnapshot = false;
|
||||||
|
|
||||||
QString tweakClass;
|
QString tweakClass;
|
||||||
QList<LibraryPtr> libraries;
|
QList<LibraryPtr> libraries;
|
||||||
|
|
||||||
@ -76,15 +79,15 @@ public:
|
|||||||
|
|
||||||
explicit LiteLoaderVersionList(QObject *parent = 0);
|
explicit LiteLoaderVersionList(QObject *parent = 0);
|
||||||
|
|
||||||
virtual Task *getLoadTask();
|
Task *getLoadTask() override;
|
||||||
virtual bool isLoaded();
|
bool isLoaded() override;
|
||||||
virtual const BaseVersionPtr at(int i) const;
|
const BaseVersionPtr at(int i) const override;
|
||||||
virtual int count() const;
|
int count() const override;
|
||||||
virtual void sortVersions();
|
void sortVersions() override;
|
||||||
virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
|
QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const override;
|
||||||
virtual QList< ModelRoles > providesRoles();
|
RoleList providesRoles() const override;
|
||||||
|
|
||||||
virtual BaseVersionPtr getLatestStable() const;
|
virtual BaseVersionPtr getLatestStable() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QList<BaseVersionPtr> m_vlist;
|
QList<BaseVersionPtr> m_vlist;
|
||||||
@ -93,7 +96,7 @@ protected:
|
|||||||
|
|
||||||
protected
|
protected
|
||||||
slots:
|
slots:
|
||||||
virtual void updateListData(QList<BaseVersionPtr> versions);
|
void updateListData(QList<BaseVersionPtr> versions) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LLListLoadTask : public Task
|
class LLListLoadTask : public Task
|
||||||
|
Loading…
Reference in New Issue
Block a user