refactor(test): fix loading mod metadata setting
This commit is contained in:
parent
e843b8e188
commit
8856c8cd62
@ -21,12 +21,14 @@
|
||||
#include "Application.h"
|
||||
#include "minecraft/mod/ModFolderModel.h"
|
||||
|
||||
ModDownloadTask::ModDownloadTask(ModPlatform::IndexedPack mod, ModPlatform::IndexedVersion version, const std::shared_ptr<ModFolderModel> mods)
|
||||
ModDownloadTask::ModDownloadTask(ModPlatform::IndexedPack mod, ModPlatform::IndexedVersion version, const std::shared_ptr<ModFolderModel> mods, bool is_indexed)
|
||||
: m_mod(mod), m_mod_version(version), mods(mods)
|
||||
{
|
||||
if (is_indexed) {
|
||||
m_update_task.reset(new LocalModUpdateTask(mods->indexDir(), m_mod, m_mod_version));
|
||||
|
||||
addTask(m_update_task);
|
||||
}
|
||||
|
||||
m_filesNetJob.reset(new NetJob(tr("Mod download"), APPLICATION->network()));
|
||||
m_filesNetJob->setStatus(tr("Downloading mod:\n%1").arg(m_mod_version.downloadUrl));
|
||||
|
@ -29,7 +29,7 @@ class ModFolderModel;
|
||||
class ModDownloadTask : public SequentialTask {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ModDownloadTask(ModPlatform::IndexedPack mod, ModPlatform::IndexedVersion version, const std::shared_ptr<ModFolderModel> mods);
|
||||
explicit ModDownloadTask(ModPlatform::IndexedPack mod, ModPlatform::IndexedVersion version, const std::shared_ptr<ModFolderModel> mods, bool is_indexed);
|
||||
const QString& getFilename() const { return m_mod_version.fileName; }
|
||||
|
||||
private:
|
||||
|
@ -1015,7 +1015,8 @@ std::shared_ptr<ModFolderModel> MinecraftInstance::loaderModList() const
|
||||
{
|
||||
if (!m_loader_mod_list)
|
||||
{
|
||||
m_loader_mod_list.reset(new ModFolderModel(modsRoot()));
|
||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||
m_loader_mod_list.reset(new ModFolderModel(modsRoot(), is_indexed));
|
||||
m_loader_mod_list->disableInteraction(isRunning());
|
||||
connect(this, &BaseInstance::runningStatusChanged, m_loader_mod_list.get(), &ModFolderModel::disableInteraction);
|
||||
}
|
||||
@ -1026,7 +1027,8 @@ std::shared_ptr<ModFolderModel> MinecraftInstance::coreModList() const
|
||||
{
|
||||
if (!m_core_mod_list)
|
||||
{
|
||||
m_core_mod_list.reset(new ModFolderModel(coreModsDir()));
|
||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||
m_core_mod_list.reset(new ModFolderModel(coreModsDir(), is_indexed));
|
||||
m_core_mod_list->disableInteraction(isRunning());
|
||||
connect(this, &BaseInstance::runningStatusChanged, m_core_mod_list.get(), &ModFolderModel::disableInteraction);
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ auto Mod::destroy(QDir& index_dir) -> bool
|
||||
{
|
||||
auto n = name();
|
||||
// FIXME: This can fail to remove the metadata if the
|
||||
// "DontUseModMetadata" setting is on, since there could
|
||||
// "ModMetadataDisabled" setting is on, since there could
|
||||
// be a name mismatch!
|
||||
Metadata::remove(index_dir, n);
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "minecraft/mod/tasks/LocalModParseTask.h"
|
||||
#include "minecraft/mod/tasks/ModFolderLoadTask.h"
|
||||
|
||||
ModFolderModel::ModFolderModel(const QString &dir) : QAbstractListModel(), m_dir(dir)
|
||||
ModFolderModel::ModFolderModel(const QString &dir, bool is_indexed) : QAbstractListModel(), m_dir(dir), m_is_indexed(is_indexed)
|
||||
{
|
||||
FS::ensureFolderPathExists(m_dir.absolutePath());
|
||||
m_dir.setFilter(QDir::Readable | QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs);
|
||||
@ -82,7 +82,7 @@ bool ModFolderModel::update()
|
||||
}
|
||||
|
||||
auto index_dir = indexDir();
|
||||
auto task = new ModFolderLoadTask(dir(), index_dir);
|
||||
auto task = new ModFolderLoadTask(dir(), index_dir, m_is_indexed);
|
||||
|
||||
m_update = task->result();
|
||||
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
Enable,
|
||||
Toggle
|
||||
};
|
||||
ModFolderModel(const QString &dir);
|
||||
ModFolderModel(const QString &dir, bool is_indexed);
|
||||
|
||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
@ -146,6 +146,7 @@ protected:
|
||||
bool scheduled_update = false;
|
||||
bool interaction_disabled = false;
|
||||
QDir m_dir;
|
||||
bool m_is_indexed;
|
||||
QMap<QString, int> modsIndex;
|
||||
QMap<int, LocalModParseTask::ResultPtr> activeTickets;
|
||||
int nextResolutionTicket = 0;
|
||||
|
@ -32,7 +32,7 @@ slots:
|
||||
{
|
||||
QString folder = source;
|
||||
QTemporaryDir tempDir;
|
||||
ModFolderModel m(tempDir.path());
|
||||
ModFolderModel m(tempDir.path(), true);
|
||||
m.installMod(folder);
|
||||
verify(tempDir.path());
|
||||
}
|
||||
@ -41,7 +41,7 @@ slots:
|
||||
{
|
||||
QString folder = source + '/';
|
||||
QTemporaryDir tempDir;
|
||||
ModFolderModel m(tempDir.path());
|
||||
ModFolderModel m(tempDir.path(), true);
|
||||
m.installMod(folder);
|
||||
verify(tempDir.path());
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "ResourcePackFolderModel.h"
|
||||
|
||||
ResourcePackFolderModel::ResourcePackFolderModel(const QString &dir) : ModFolderModel(dir) {
|
||||
ResourcePackFolderModel::ResourcePackFolderModel(const QString &dir) : ModFolderModel(dir, false) {
|
||||
}
|
||||
|
||||
QVariant ResourcePackFolderModel::headerData(int section, Qt::Orientation orientation, int role) const {
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "TexturePackFolderModel.h"
|
||||
|
||||
TexturePackFolderModel::TexturePackFolderModel(const QString &dir) : ModFolderModel(dir) {
|
||||
TexturePackFolderModel::TexturePackFolderModel(const QString &dir) : ModFolderModel(dir, false) {
|
||||
}
|
||||
|
||||
QVariant TexturePackFolderModel::headerData(int section, Qt::Orientation orientation, int role) const {
|
||||
|
@ -35,11 +35,6 @@ void LocalModUpdateTask::executeTask()
|
||||
{
|
||||
setStatus(tr("Updating index for mod:\n%1").arg(m_mod.name));
|
||||
|
||||
if(APPLICATION->settings()->get("DontUseModMetadata").toBool()){
|
||||
emitSucceeded();
|
||||
return;
|
||||
}
|
||||
|
||||
auto pw_mod = Metadata::create(m_index_dir, m_mod, m_mod_version);
|
||||
Metadata::update(m_index_dir, pw_mod);
|
||||
|
||||
|
@ -38,13 +38,13 @@
|
||||
#include "Application.h"
|
||||
#include "minecraft/mod/MetadataHandler.h"
|
||||
|
||||
ModFolderLoadTask::ModFolderLoadTask(QDir& mods_dir, QDir& index_dir)
|
||||
: m_mods_dir(mods_dir), m_index_dir(index_dir), m_result(new Result())
|
||||
ModFolderLoadTask::ModFolderLoadTask(QDir& mods_dir, QDir& index_dir, bool is_indexed)
|
||||
: m_mods_dir(mods_dir), m_index_dir(index_dir), m_is_indexed(is_indexed), m_result(new Result())
|
||||
{}
|
||||
|
||||
void ModFolderLoadTask::run()
|
||||
{
|
||||
if (!APPLICATION->settings()->get("ModMetadataDisabled").toBool()) {
|
||||
if (m_is_indexed) {
|
||||
// Read metadata first
|
||||
getFromMetadata();
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ModFolderLoadTask(QDir& mods_dir, QDir& index_dir);
|
||||
ModFolderLoadTask(QDir& mods_dir, QDir& index_dir, bool is_indexed);
|
||||
void run();
|
||||
signals:
|
||||
void succeeded();
|
||||
@ -65,5 +65,6 @@ private:
|
||||
|
||||
private:
|
||||
QDir& m_mods_dir, m_index_dir;
|
||||
bool m_is_indexed;
|
||||
ResultPtr m_result;
|
||||
};
|
||||
|
@ -450,7 +450,7 @@ void LauncherPage::loadSettings()
|
||||
}
|
||||
|
||||
// Mods
|
||||
ui->metadataDisableBtn->setChecked(s->get("DontUseModMetadata").toBool());
|
||||
ui->metadataDisableBtn->setChecked(s->get("ModMetadataDisabled").toBool());
|
||||
ui->metadataWarningLabel->setHidden(!ui->metadataDisableBtn->isChecked());
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "ModPage.h"
|
||||
#include "Application.h"
|
||||
#include "ui_ModPage.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
@ -150,7 +151,8 @@ void ModPage::onModSelected()
|
||||
if (dialog->isModSelected(current.name, version.fileName)) {
|
||||
dialog->removeSelectedMod(current.name);
|
||||
} else {
|
||||
dialog->addSelectedMod(current.name, new ModDownloadTask(current, version, dialog->mods));
|
||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||
dialog->addSelectedMod(current.name, new ModDownloadTask(current, version, dialog->mods, is_indexed));
|
||||
}
|
||||
|
||||
updateSelectionButton();
|
||||
|
Loading…
Reference in New Issue
Block a user