mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-14 10:12:59 +02:00
Cleanup
This commit is contained in:
parent
06ce71087e
commit
67fdd14dca
@ -206,11 +206,6 @@ void MainWindow::on_startEditorButton_clicked()
|
|||||||
startEditor({});
|
startEditor({});
|
||||||
}
|
}
|
||||||
|
|
||||||
//const CModList & MainWindow::getModList() const
|
|
||||||
//{
|
|
||||||
// return ui->modlistView->getModList();
|
|
||||||
//}
|
|
||||||
|
|
||||||
CModListView * MainWindow::getModView()
|
CModListView * MainWindow::getModView()
|
||||||
{
|
{
|
||||||
return ui->modlistView;
|
return ui->modlistView;
|
||||||
|
@ -46,7 +46,6 @@ public:
|
|||||||
explicit MainWindow(QWidget * parent = nullptr);
|
explicit MainWindow(QWidget * parent = nullptr);
|
||||||
~MainWindow() override;
|
~MainWindow() override;
|
||||||
|
|
||||||
// const CModList & getModList() const;
|
|
||||||
CModListView * getModView();
|
CModListView * getModView();
|
||||||
|
|
||||||
void updateTranslation();
|
void updateTranslation();
|
||||||
|
@ -176,7 +176,7 @@ void CModListView::loadRepositories()
|
|||||||
if (settings["launcher"]["extraRepositoryEnabled"].Bool())
|
if (settings["launcher"]["extraRepositoryEnabled"].Bool())
|
||||||
repositories.push_back(QString::fromStdString(settings["launcher"]["extraRepositoryURL"].String()));
|
repositories.push_back(QString::fromStdString(settings["launcher"]["extraRepositoryURL"].String()));
|
||||||
|
|
||||||
for(auto entry : repositories)
|
for(const auto & entry : repositories)
|
||||||
{
|
{
|
||||||
if (entry.isEmpty())
|
if (entry.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
@ -218,7 +218,7 @@ static QString replaceIfNotEmpty(QStringList value, QString pattern)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CModListView::genChangelogText(ModState & mod)
|
QString CModListView::genChangelogText(const ModState & mod)
|
||||||
{
|
{
|
||||||
QString headerTemplate = "<p><span style=\" font-weight:600;\">%1: </span></p>";
|
QString headerTemplate = "<p><span style=\" font-weight:600;\">%1: </span></p>";
|
||||||
QString entryBegin = "<p align=\"justify\"><ul>";
|
QString entryBegin = "<p align=\"justify\"><ul>";
|
||||||
@ -237,11 +237,11 @@ QString CModListView::genChangelogText(ModState & mod)
|
|||||||
});
|
});
|
||||||
std::reverse(versions.begin(), versions.end());
|
std::reverse(versions.begin(), versions.end());
|
||||||
|
|
||||||
for(auto & version : versions)
|
for(const auto & version : versions)
|
||||||
{
|
{
|
||||||
result += headerTemplate.arg(version);
|
result += headerTemplate.arg(version);
|
||||||
result += entryBegin;
|
result += entryBegin;
|
||||||
for(auto & line : changelog.value(version))
|
for(const auto & line : changelog.value(version))
|
||||||
result += entryLine.arg(line);
|
result += entryLine.arg(line);
|
||||||
result += entryEnd;
|
result += entryEnd;
|
||||||
}
|
}
|
||||||
@ -286,7 +286,7 @@ QStringList CModListView::getModNames(QStringList input)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CModListView::genModInfoText(ModState & mod)
|
QString CModListView::genModInfoText(const ModState & mod)
|
||||||
{
|
{
|
||||||
QString prefix = "<p><span style=\" font-weight:600;\">%1: </span>"; // shared prefix
|
QString prefix = "<p><span style=\" font-weight:600;\">%1: </span>"; // shared prefix
|
||||||
QString redPrefix = "<p><span style=\" font-weight:600; color:red\">%1: </span>"; // shared prefix
|
QString redPrefix = "<p><span style=\" font-weight:600; color:red\">%1: </span>"; // shared prefix
|
||||||
@ -495,7 +495,7 @@ QStringList CModListView::findBlockingMods(QString modUnderTest)
|
|||||||
if(mod.isEnabled())
|
if(mod.isEnabled())
|
||||||
{
|
{
|
||||||
// one of enabled mods have requirement (or this mod) marked as conflict
|
// one of enabled mods have requirement (or this mod) marked as conflict
|
||||||
for(auto conflict : mod.getConflicts())
|
for(const auto & conflict : mod.getConflicts())
|
||||||
{
|
{
|
||||||
if(required.contains(conflict))
|
if(required.contains(conflict))
|
||||||
ret.push_back(name);
|
ret.push_back(name);
|
||||||
@ -541,12 +541,11 @@ void CModListView::enableModByName(QString modName)
|
|||||||
|
|
||||||
auto mod = modStateModel->getMod(modName);
|
auto mod = modStateModel->getMod(modName);
|
||||||
|
|
||||||
for(auto & name : mod.getDependencies())
|
for(const auto & name : mod.getDependencies())
|
||||||
{
|
{
|
||||||
if(modStateModel->getMod(name).isDisabled())
|
if(modStateModel->getMod(name).isDisabled())
|
||||||
manager->enableMod(name);
|
manager->enableMod(name);
|
||||||
}
|
}
|
||||||
emit modsChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CModListView::on_disableButton_clicked()
|
void CModListView::on_disableButton_clicked()
|
||||||
@ -562,8 +561,6 @@ void CModListView::disableModByName(QString modName)
|
|||||||
{
|
{
|
||||||
if(modStateModel->isModExists(modName) && modStateModel->getMod(modName).isEnabled())
|
if(modStateModel->isModExists(modName) && modStateModel->getMod(modName).isEnabled())
|
||||||
manager->disableMod(modName);
|
manager->disableMod(modName);
|
||||||
|
|
||||||
emit modsChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CModListView::on_updateButton_clicked()
|
void CModListView::on_updateButton_clicked()
|
||||||
@ -572,7 +569,7 @@ void CModListView::on_updateButton_clicked()
|
|||||||
|
|
||||||
assert(findInvalidDependencies(modName).empty());
|
assert(findInvalidDependencies(modName).empty());
|
||||||
|
|
||||||
for(auto & name : modStateModel->getMod(modName).getDependencies())
|
for(const auto & name : modStateModel->getMod(modName).getDependencies())
|
||||||
{
|
{
|
||||||
auto mod = modStateModel->getMod(name);
|
auto mod = modStateModel->getMod(name);
|
||||||
// update required mod, install missing (can be new dependency)
|
// update required mod, install missing (can be new dependency)
|
||||||
@ -593,7 +590,6 @@ void CModListView::on_uninstallButton_clicked()
|
|||||||
manager->uninstallMod(modName);
|
manager->uninstallMod(modName);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit modsChanged();
|
|
||||||
checkManagerErrors();
|
checkManagerErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -603,7 +599,7 @@ void CModListView::on_installButton_clicked()
|
|||||||
|
|
||||||
assert(findInvalidDependencies(modName).empty());
|
assert(findInvalidDependencies(modName).empty());
|
||||||
|
|
||||||
for(auto & name : modStateModel->getMod(modName).getDependencies())
|
for(const auto & name : modStateModel->getMod(modName).getDependencies())
|
||||||
{
|
{
|
||||||
auto mod = modStateModel->getMod(name);
|
auto mod = modStateModel->getMod(name);
|
||||||
if(mod.isAvailable())
|
if(mod.isAvailable())
|
||||||
@ -612,7 +608,7 @@ void CModListView::on_installButton_clicked()
|
|||||||
enableModByName(name);
|
enableModByName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto & name : modStateModel->getMod(modName).getConflicts())
|
for(const auto & name : modStateModel->getMod(modName).getConflicts())
|
||||||
{
|
{
|
||||||
auto mod = modStateModel->getMod(name);
|
auto mod = modStateModel->getMod(name);
|
||||||
if(mod.isEnabled())
|
if(mod.isEnabled())
|
||||||
@ -674,11 +670,10 @@ void CModListView::manualInstallFile(QString filePath)
|
|||||||
|
|
||||||
// reload settings
|
// reload settings
|
||||||
Helper::loadSettings();
|
Helper::loadSettings();
|
||||||
for(auto widget : qApp->allWidgets())
|
for(const auto widget : qApp->allWidgets())
|
||||||
if(auto settingsView = qobject_cast<CSettingsView *>(widget))
|
if(auto settingsView = qobject_cast<CSettingsView *>(widget))
|
||||||
settingsView->loadSettings();
|
settingsView->loadSettings();
|
||||||
// manager->loadMods();
|
// TODO: rescan local mods
|
||||||
// manager->loadModSettings();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -771,7 +766,6 @@ void CModListView::downloadFinished(QStringList savedFiles, QStringList failedFi
|
|||||||
installFiles(savedFiles);
|
installFiles(savedFiles);
|
||||||
|
|
||||||
hideProgressBar();
|
hideProgressBar();
|
||||||
emit modsChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CModListView::hideProgressBar()
|
void CModListView::hideProgressBar()
|
||||||
@ -868,9 +862,7 @@ void CModListView::installFiles(QStringList files)
|
|||||||
{
|
{
|
||||||
//update
|
//update
|
||||||
CResourceHandler::get("initial")->updateFilteredFiles([](const std::string &){ return true; });
|
CResourceHandler::get("initial")->updateFilteredFiles([](const std::string &){ return true; });
|
||||||
// manager->loadMods();
|
// TODO: rescan local mods
|
||||||
// modModel->reloadRepositories();
|
|
||||||
emit modsChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -931,7 +923,7 @@ void CModListView::installMods(QStringList archives)
|
|||||||
auto mod = modStateModel->getMod(modName);
|
auto mod = modStateModel->getMod(modName);
|
||||||
if(mod.isInstalled() && !mod.isKeptDisabled())
|
if(mod.isInstalled() && !mod.isKeptDisabled())
|
||||||
{
|
{
|
||||||
for (auto const & dependencyName : mod.getDependencies())
|
for(const auto & dependencyName : mod.getDependencies())
|
||||||
{
|
{
|
||||||
auto dependency = modStateModel->getMod(dependencyName);
|
auto dependency = modStateModel->getMod(dependencyName);
|
||||||
if(dependency.isDisabled())
|
if(dependency.isDisabled())
|
||||||
@ -1048,17 +1040,11 @@ void CModListView::on_screenshotsList_clicked(const QModelIndex & index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//const CModList & CModListView::getModList() const
|
|
||||||
//{
|
|
||||||
// assert(modModel);
|
|
||||||
// return *modModel;
|
|
||||||
//}
|
|
||||||
|
|
||||||
void CModListView::doInstallMod(const QString & modName)
|
void CModListView::doInstallMod(const QString & modName)
|
||||||
{
|
{
|
||||||
assert(findInvalidDependencies(modName).empty());
|
assert(findInvalidDependencies(modName).empty());
|
||||||
|
|
||||||
for(auto & name : modStateModel->getMod(modName).getDependencies())
|
for(const auto & name : modStateModel->getMod(modName).getDependencies())
|
||||||
{
|
{
|
||||||
auto mod = modStateModel->getMod(name);
|
auto mod = modStateModel->getMod(name);
|
||||||
if(!mod.isInstalled())
|
if(!mod.isInstalled())
|
||||||
|
@ -61,14 +61,12 @@ class CModListView : public QWidget
|
|||||||
void installMaps(QStringList maps);
|
void installMaps(QStringList maps);
|
||||||
void installFiles(QStringList mods);
|
void installFiles(QStringList mods);
|
||||||
|
|
||||||
QString genChangelogText(ModState & mod);
|
QString genChangelogText(const ModState & mod);
|
||||||
QString genModInfoText(ModState & mod);
|
QString genModInfoText(const ModState & mod);
|
||||||
|
|
||||||
void changeEvent(QEvent *event) override;
|
void changeEvent(QEvent *event) override;
|
||||||
void dragEnterEvent(QDragEnterEvent* event) override;
|
void dragEnterEvent(QDragEnterEvent* event) override;
|
||||||
void dropEvent(QDropEvent *event) override;
|
void dropEvent(QDropEvent *event) override;
|
||||||
signals:
|
|
||||||
void modsChanged();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CModListView(QWidget * parent = nullptr);
|
explicit CModListView(QWidget * parent = nullptr);
|
||||||
@ -81,8 +79,6 @@ public:
|
|||||||
|
|
||||||
void selectMod(const QModelIndex & index);
|
void selectMod(const QModelIndex & index);
|
||||||
|
|
||||||
//const CModList & getModList() const;
|
|
||||||
|
|
||||||
// First Launch View interface
|
// First Launch View interface
|
||||||
|
|
||||||
/// install mod by name
|
/// install mod by name
|
||||||
|
@ -198,7 +198,7 @@ bool ModState::isInstalled() const
|
|||||||
|
|
||||||
bool ModState::isUpdateAvailable() const
|
bool ModState::isUpdateAvailable() const
|
||||||
{
|
{
|
||||||
return getInstalledVersion() != getRepositoryVersion() && !getRepositoryVersion().isEmpty() && !getInstalledVersion().isEmpty();;
|
return getInstalledVersion() != getRepositoryVersion() && !getRepositoryVersion().isEmpty() && !getInstalledVersion().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModState::isCompatible() const
|
bool ModState::isCompatible() const
|
||||||
|
@ -42,7 +42,7 @@ QString detectModArchive(QString path, QString modName, std::vector<std::string>
|
|||||||
|
|
||||||
for(int folderLevel : {0, 1}) //search in subfolder if there is no mod.json in the root
|
for(int folderLevel : {0, 1}) //search in subfolder if there is no mod.json in the root
|
||||||
{
|
{
|
||||||
for(auto file : filesToExtract)
|
for(const auto & file : filesToExtract)
|
||||||
{
|
{
|
||||||
QString filename = QString::fromUtf8(file.c_str());
|
QString filename = QString::fromUtf8(file.c_str());
|
||||||
modDirName = filename.section('/', 0, folderLevel);
|
modDirName = filename.section('/', 0, folderLevel);
|
||||||
@ -56,7 +56,7 @@ QString detectModArchive(QString path, QString modName, std::vector<std::string>
|
|||||||
|
|
||||||
logGlobal->error("Failed to detect mod path in archive!");
|
logGlobal->error("Failed to detect mod path in archive!");
|
||||||
logGlobal->debug("List of file in archive:");
|
logGlobal->debug("List of file in archive:");
|
||||||
for(auto file : filesToExtract)
|
for(const auto & file : filesToExtract)
|
||||||
logGlobal->debug("%s", file.c_str());
|
logGlobal->debug("%s", file.c_str());
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
@ -180,7 +180,7 @@ bool ModStateController::canEnableMod(QString modname)
|
|||||||
if(!mod.isCompatible())
|
if(!mod.isCompatible())
|
||||||
return addError(modname, tr("Mod is not compatible, please update VCMI and checkout latest mod revisions"));
|
return addError(modname, tr("Mod is not compatible, please update VCMI and checkout latest mod revisions"));
|
||||||
|
|
||||||
for(auto modEntry : mod.getDependencies())
|
for(const auto & modEntry : mod.getDependencies())
|
||||||
{
|
{
|
||||||
if(!modList->isModExists(modEntry)) // required mod is not available
|
if(!modList->isModExists(modEntry)) // required mod is not available
|
||||||
return addError(modname, tr("Required mod %1 is missing").arg(modEntry));
|
return addError(modname, tr("Required mod %1 is missing").arg(modEntry));
|
||||||
@ -193,14 +193,14 @@ bool ModStateController::canEnableMod(QString modname)
|
|||||||
|
|
||||||
for(QString modEntry : modList->getAllMods())
|
for(QString modEntry : modList->getAllMods())
|
||||||
{
|
{
|
||||||
auto mod = modList->getMod(modEntry);
|
auto otherMod = modList->getMod(modEntry);
|
||||||
|
|
||||||
// "reverse conflict" - enabled mod has this one as conflict
|
// "reverse conflict" - enabled mod has this one as conflict
|
||||||
if(modList->isModEnabled(modname) && mod.getConflicts().contains(modname))
|
if(modList->isModEnabled(modname) && otherMod.getConflicts().contains(modname))
|
||||||
return addError(modname, tr("This mod conflicts with %1").arg(modEntry));
|
return addError(modname, tr("This mod conflicts with %1").arg(modEntry));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto modEntry : mod.getConflicts())
|
for(const auto & modEntry : mod.getConflicts())
|
||||||
{
|
{
|
||||||
// check if conflicting mod installed and enabled
|
// check if conflicting mod installed and enabled
|
||||||
if(modList->isModExists(modEntry) && modList->isModEnabled(modEntry))
|
if(modList->isModExists(modEntry) && modList->isModEnabled(modEntry))
|
||||||
@ -257,7 +257,7 @@ bool ModStateController::doInstallMod(QString modname, QString archivePath)
|
|||||||
{
|
{
|
||||||
const auto destDirFsPath = qstringToPath(destDir);
|
const auto destDirFsPath = qstringToPath(destDir);
|
||||||
ZipArchive archive(qstringToPath(archivePath));
|
ZipArchive archive(qstringToPath(archivePath));
|
||||||
for (auto const & file : filesToExtract)
|
for(const auto & file : filesToExtract)
|
||||||
{
|
{
|
||||||
if (!archive.extract(destDirFsPath, file))
|
if (!archive.extract(destDirFsPath, file))
|
||||||
return false;
|
return false;
|
||||||
|
@ -109,7 +109,6 @@ QVariant ModStateItemModel::getText(const ModState & mod, int field) const
|
|||||||
|
|
||||||
QVariant ModStateItemModel::getIcon(const ModState & mod, int field) const
|
QVariant ModStateItemModel::getIcon(const ModState & mod, int field) const
|
||||||
{
|
{
|
||||||
|
|
||||||
if (field == ModFields::STATUS_ENABLED)
|
if (field == ModFields::STATUS_ENABLED)
|
||||||
{
|
{
|
||||||
if (!model->isModInstalled(mod.getID()))
|
if (!model->isModInstalled(mod.getID()))
|
||||||
|
@ -46,7 +46,7 @@ enum EModRoles
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class ModStateItemModel : public QAbstractItemModel
|
class ModStateItemModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
friend class CModFilterModel;
|
friend class CModFilterModel;
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "../CConfigHandler.h"
|
#include "../CConfigHandler.h"
|
||||||
#include "../CCreatureHandler.h"
|
#include "../CCreatureHandler.h"
|
||||||
#include "../GameSettings.h"
|
#include "../GameSettings.h"
|
||||||
|
#include "../ScriptHandler.h"
|
||||||
#include "../VCMI_Lib.h"
|
#include "../VCMI_Lib.h"
|
||||||
#include "../filesystem/Filesystem.h"
|
#include "../filesystem/Filesystem.h"
|
||||||
#include "../json/JsonUtils.h"
|
#include "../json/JsonUtils.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user