ATLauncher: Display mod colours in optional mod dialog
This commit is contained in:
parent
f5f59203a2
commit
7c251efc47
@ -556,7 +556,7 @@ void PackInstallTask::downloadMods()
|
|||||||
QVector<QString> selectedMods;
|
QVector<QString> selectedMods;
|
||||||
if (!optionalMods.isEmpty()) {
|
if (!optionalMods.isEmpty()) {
|
||||||
setStatus(tr("Selecting optional mods..."));
|
setStatus(tr("Selecting optional mods..."));
|
||||||
selectedMods = m_support->chooseOptionalMods(optionalMods);
|
selectedMods = m_support->chooseOptionalMods(m_version, optionalMods);
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatus(tr("Downloading mods..."));
|
setStatus(tr("Downloading mods..."));
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Requests a user interaction to select which optional mods should be installed.
|
* Requests a user interaction to select which optional mods should be installed.
|
||||||
*/
|
*/
|
||||||
virtual QVector<QString> chooseOptionalMods(QVector<ATLauncher::VersionMod> mods) = 0;
|
virtual QVector<QString> chooseOptionalMods(PackVersion version, QVector<ATLauncher::VersionMod> mods) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests a user interaction to select a component version from a given version list
|
* Requests a user interaction to select a component version from a given version list
|
||||||
|
@ -178,6 +178,7 @@ static void loadVersionMod(ATLauncher::VersionMod & p, QJsonObject & obj) {
|
|||||||
p.depends.append(Json::requireString(depends));
|
p.depends.append(Json::requireString(depends));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
p.colour = Json::ensureString(obj, QString("colour"), "");
|
||||||
|
|
||||||
p.client = Json::ensureBoolean(obj, QString("client"), false);
|
p.client = Json::ensureBoolean(obj, QString("client"), false);
|
||||||
|
|
||||||
@ -232,4 +233,9 @@ void ATLauncher::loadVersion(PackVersion & v, QJsonObject & obj)
|
|||||||
auto configsObj = Json::requireObject(obj, "configs");
|
auto configsObj = Json::requireObject(obj, "configs");
|
||||||
loadVersionConfigs(v.configs, configsObj);
|
loadVersionConfigs(v.configs, configsObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto colourObj = Json::ensureObject(obj, "colours");
|
||||||
|
for (const auto &key : colourObj.keys()) {
|
||||||
|
v.colours[key] = Json::requireString(colourObj.value(key), "colour");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QJsonObject>
|
|
||||||
|
|
||||||
namespace ATLauncher
|
namespace ATLauncher
|
||||||
{
|
{
|
||||||
@ -109,6 +110,7 @@ struct VersionMod
|
|||||||
bool library;
|
bool library;
|
||||||
QString group;
|
QString group;
|
||||||
QVector<QString> depends;
|
QVector<QString> depends;
|
||||||
|
QString colour;
|
||||||
|
|
||||||
bool client;
|
bool client;
|
||||||
|
|
||||||
@ -134,6 +136,8 @@ struct PackVersion
|
|||||||
QVector<VersionLibrary> libraries;
|
QVector<VersionLibrary> libraries;
|
||||||
QVector<VersionMod> mods;
|
QVector<VersionMod> mods;
|
||||||
VersionConfigs configs;
|
VersionConfigs configs;
|
||||||
|
|
||||||
|
QMap<QString, QString> colours;
|
||||||
};
|
};
|
||||||
|
|
||||||
void loadVersion(PackVersion & v, QJsonObject & obj);
|
void loadVersion(PackVersion & v, QJsonObject & obj);
|
||||||
|
@ -43,8 +43,11 @@
|
|||||||
#include "modplatform/atlauncher/ATLShareCode.h"
|
#include "modplatform/atlauncher/ATLShareCode.h"
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
|
||||||
AtlOptionalModListModel::AtlOptionalModListModel(QWidget *parent, QVector<ATLauncher::VersionMod> mods)
|
AtlOptionalModListModel::AtlOptionalModListModel(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
|
||||||
: QAbstractListModel(parent), m_mods(mods) {
|
: QAbstractListModel(parent)
|
||||||
|
, m_version(version)
|
||||||
|
, m_mods(mods)
|
||||||
|
{
|
||||||
// fill mod index
|
// fill mod index
|
||||||
for (int i = 0; i < m_mods.size(); i++) {
|
for (int i = 0; i < m_mods.size(); i++) {
|
||||||
auto mod = m_mods.at(i);
|
auto mod = m_mods.at(i);
|
||||||
@ -97,6 +100,11 @@ QVariant AtlOptionalModListModel::data(const QModelIndex &index, int role) const
|
|||||||
return mod.description;
|
return mod.description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (role == Qt::ForegroundRole) {
|
||||||
|
if (!mod.colour.isEmpty() && m_version.colours.contains(mod.colour)) {
|
||||||
|
return QColor(QString("#%1").arg(m_version.colours[mod.colour]));
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (role == Qt::CheckStateRole) {
|
else if (role == Qt::CheckStateRole) {
|
||||||
if (index.column() == EnabledColumn) {
|
if (index.column() == EnabledColumn) {
|
||||||
return m_selection[mod.name] ? Qt::Checked : Qt::Unchecked;
|
return m_selection[mod.name] ? Qt::Checked : Qt::Unchecked;
|
||||||
@ -287,12 +295,13 @@ void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AtlOptionalModDialog::AtlOptionalModDialog(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
|
||||||
AtlOptionalModDialog::AtlOptionalModDialog(QWidget *parent, QVector<ATLauncher::VersionMod> mods)
|
: QDialog(parent)
|
||||||
: QDialog(parent), ui(new Ui::AtlOptionalModDialog) {
|
, ui(new Ui::AtlOptionalModDialog)
|
||||||
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
listModel = new AtlOptionalModListModel(this, mods);
|
listModel = new AtlOptionalModListModel(this, version, mods);
|
||||||
ui->treeView->setModel(listModel);
|
ui->treeView->setModel(listModel);
|
||||||
|
|
||||||
ui->treeView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
ui->treeView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
@ -56,7 +56,7 @@ public:
|
|||||||
DescriptionColumn,
|
DescriptionColumn,
|
||||||
};
|
};
|
||||||
|
|
||||||
AtlOptionalModListModel(QWidget *parent, QVector<ATLauncher::VersionMod> mods);
|
AtlOptionalModListModel(QWidget *parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods);
|
||||||
|
|
||||||
QVector<QString> getResult();
|
QVector<QString> getResult();
|
||||||
|
|
||||||
@ -86,7 +86,9 @@ private:
|
|||||||
NetJob::Ptr m_jobPtr;
|
NetJob::Ptr m_jobPtr;
|
||||||
QByteArray m_response;
|
QByteArray m_response;
|
||||||
|
|
||||||
|
ATLauncher::PackVersion m_version;
|
||||||
QVector<ATLauncher::VersionMod> m_mods;
|
QVector<ATLauncher::VersionMod> m_mods;
|
||||||
|
|
||||||
QMap<QString, bool> m_selection;
|
QMap<QString, bool> m_selection;
|
||||||
QMap<QString, int> m_index;
|
QMap<QString, int> m_index;
|
||||||
QMap<QString, QVector<QString>> m_dependants;
|
QMap<QString, QVector<QString>> m_dependants;
|
||||||
@ -96,7 +98,7 @@ class AtlOptionalModDialog : public QDialog {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AtlOptionalModDialog(QWidget *parent, QVector<ATLauncher::VersionMod> mods);
|
AtlOptionalModDialog(QWidget *parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods);
|
||||||
~AtlOptionalModDialog() override;
|
~AtlOptionalModDialog() override;
|
||||||
|
|
||||||
QVector<QString> getResult() {
|
QVector<QString> getResult() {
|
||||||
|
@ -169,8 +169,9 @@ void AtlPage::onVersionSelectionChanged(QString data)
|
|||||||
suggestCurrent();
|
suggestCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<QString> AtlPage::chooseOptionalMods(QVector<ATLauncher::VersionMod> mods) {
|
QVector<QString> AtlPage::chooseOptionalMods(ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
|
||||||
AtlOptionalModDialog optionalModDialog(this, mods);
|
{
|
||||||
|
AtlOptionalModDialog optionalModDialog(this, version, mods);
|
||||||
optionalModDialog.exec();
|
optionalModDialog.exec();
|
||||||
return optionalModDialog.getResult();
|
return optionalModDialog.getResult();
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ private:
|
|||||||
void suggestCurrent();
|
void suggestCurrent();
|
||||||
|
|
||||||
QString chooseVersion(Meta::VersionListPtr vlist, QString minecraftVersion) override;
|
QString chooseVersion(Meta::VersionListPtr vlist, QString minecraftVersion) override;
|
||||||
QVector<QString> chooseOptionalMods(QVector<ATLauncher::VersionMod> mods) override;
|
QVector<QString> chooseOptionalMods(ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void triggerSearch();
|
void triggerSearch();
|
||||||
|
Loading…
Reference in New Issue
Block a user