mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-22 22:13:35 +02:00
Merge pull request #5099 from IvanSavenko/bugfixing_beta_3
Fixes for beta bugs reported on Discord
This commit is contained in:
commit
a9dfd9b7f4
@ -27,12 +27,13 @@
|
|||||||
#include "../vcmiqt/jsonutils.h"
|
#include "../vcmiqt/jsonutils.h"
|
||||||
#include "../helper.h"
|
#include "../helper.h"
|
||||||
|
|
||||||
#include "../../lib/VCMIDirs.h"
|
|
||||||
#include "../../lib/CConfigHandler.h"
|
#include "../../lib/CConfigHandler.h"
|
||||||
#include "../../lib/texts/Languages.h"
|
#include "../../lib/VCMIDirs.h"
|
||||||
#include "../../lib/modding/CModVersion.h"
|
|
||||||
#include "../../lib/filesystem/Filesystem.h"
|
#include "../../lib/filesystem/Filesystem.h"
|
||||||
|
#include "../../lib/json/JsonUtils.h"
|
||||||
|
#include "../../lib/modding/CModVersion.h"
|
||||||
#include "../../lib/texts/CGeneralTextHandler.h"
|
#include "../../lib/texts/CGeneralTextHandler.h"
|
||||||
|
#include "../../lib/texts/Languages.h"
|
||||||
|
|
||||||
#include <future>
|
#include <future>
|
||||||
|
|
||||||
@ -747,7 +748,7 @@ void CModListView::installFiles(QStringList files)
|
|||||||
else if(filename.endsWith(".json", Qt::CaseInsensitive))
|
else if(filename.endsWith(".json", Qt::CaseInsensitive))
|
||||||
{
|
{
|
||||||
//download and merge additional files
|
//download and merge additional files
|
||||||
const auto &repoData = JsonUtils::jsonFromFile(filename);
|
JsonNode repoData = JsonUtils::jsonFromFile(filename);
|
||||||
if(repoData["name"].isNull())
|
if(repoData["name"].isNull())
|
||||||
{
|
{
|
||||||
// This is main repository index. Download all referenced mods
|
// This is main repository index. Download all referenced mods
|
||||||
@ -769,7 +770,7 @@ void CModListView::installFiles(QStringList files)
|
|||||||
// This is json of a single mod. Extract name of mod and add it to repo
|
// This is json of a single mod. Extract name of mod and add it to repo
|
||||||
auto modName = QFileInfo(filename).baseName().toStdString();
|
auto modName = QFileInfo(filename).baseName().toStdString();
|
||||||
auto modNameLower = boost::algorithm::to_lower_copy(modName);
|
auto modNameLower = boost::algorithm::to_lower_copy(modName);
|
||||||
accumulatedRepositoryData[modNameLower] = repoData;
|
JsonUtils::merge(accumulatedRepositoryData[modNameLower], repoData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(filename.endsWith(".png", Qt::CaseInsensitive))
|
else if(filename.endsWith(".png", Qt::CaseInsensitive))
|
||||||
@ -778,25 +779,34 @@ void CModListView::installFiles(QStringList files)
|
|||||||
|
|
||||||
if (!accumulatedRepositoryData.isNull() && !repositoryFilesEnqueued)
|
if (!accumulatedRepositoryData.isNull() && !repositoryFilesEnqueued)
|
||||||
{
|
{
|
||||||
|
logGlobal->info("Installing repository: started");
|
||||||
manager->setRepositoryData(accumulatedRepositoryData);
|
manager->setRepositoryData(accumulatedRepositoryData);
|
||||||
modModel->reloadRepositories();
|
modModel->reloadRepositories();
|
||||||
|
|
||||||
static const QString repositoryCachePath = CLauncherDirs::downloadsPath() + "/repositoryCache.json";
|
static const QString repositoryCachePath = CLauncherDirs::downloadsPath() + "/repositoryCache.json";
|
||||||
JsonUtils::jsonToFile(repositoryCachePath, modStateModel->getRepositoryData());
|
JsonUtils::jsonToFile(repositoryCachePath, modStateModel->getRepositoryData());
|
||||||
|
logGlobal->info("Installing repository: ended");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mods.empty())
|
if(!mods.empty())
|
||||||
{
|
{
|
||||||
|
logGlobal->info("Installing mods: started");
|
||||||
installMods(mods);
|
installMods(mods);
|
||||||
modStateModel->reloadLocalState();
|
modStateModel->reloadLocalState();
|
||||||
modModel->reloadRepositories();
|
modModel->reloadRepositories();
|
||||||
|
logGlobal->info("Installing mods: ended");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!maps.empty())
|
if(!maps.empty())
|
||||||
|
{
|
||||||
|
logGlobal->info("Installing maps: started");
|
||||||
installMaps(maps);
|
installMaps(maps);
|
||||||
|
logGlobal->info("Installing maps: ended");
|
||||||
|
}
|
||||||
|
|
||||||
if(!exe.empty())
|
if(!exe.empty())
|
||||||
{
|
{
|
||||||
|
logGlobal->info("Installing chronicles: started");
|
||||||
ui->progressBar->setFormat(tr("Installing Heroes Chronicles"));
|
ui->progressBar->setFormat(tr("Installing Heroes Chronicles"));
|
||||||
ui->progressWidget->setVisible(true);
|
ui->progressWidget->setVisible(true);
|
||||||
ui->pushButton->setEnabled(false);
|
ui->pushButton->setEnabled(false);
|
||||||
@ -826,6 +836,7 @@ void CModListView::installFiles(QStringList files)
|
|||||||
modStateModel->reloadLocalState();
|
modStateModel->reloadLocalState();
|
||||||
modModel->reloadRepositories();
|
modModel->reloadRepositories();
|
||||||
}
|
}
|
||||||
|
logGlobal->info("Installing chronicles: ended");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!images.empty())
|
if(!images.empty())
|
||||||
@ -849,8 +860,9 @@ void CModListView::installMods(QStringList archives)
|
|||||||
// uninstall old version of mod, if installed
|
// uninstall old version of mod, if installed
|
||||||
for(QString mod : modNames)
|
for(QString mod : modNames)
|
||||||
{
|
{
|
||||||
if(modStateModel->getMod(mod).isInstalled())
|
if(modStateModel->isModExists(mod) && modStateModel->getMod(mod).isInstalled())
|
||||||
{
|
{
|
||||||
|
logGlobal->info("Uninstalling old version of mod '%s'", mod.toStdString());
|
||||||
if (modStateModel->isModEnabled(mod))
|
if (modStateModel->isModEnabled(mod))
|
||||||
modsToEnable.push_back(mod);
|
modsToEnable.push_back(mod);
|
||||||
|
|
||||||
@ -865,17 +877,23 @@ void CModListView::installMods(QStringList archives)
|
|||||||
|
|
||||||
for(int i = 0; i < modNames.size(); i++)
|
for(int i = 0; i < modNames.size(); i++)
|
||||||
{
|
{
|
||||||
|
logGlobal->info("Installing mod '%s'", modNames[i].toStdString());
|
||||||
ui->progressBar->setFormat(tr("Installing mod %1").arg(modNames[i]));
|
ui->progressBar->setFormat(tr("Installing mod %1").arg(modNames[i]));
|
||||||
manager->installMod(modNames[i], archives[i]);
|
manager->installMod(modNames[i], archives[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!modsToEnable.empty())
|
if (!modsToEnable.empty())
|
||||||
|
{
|
||||||
manager->enableMods(modsToEnable);
|
manager->enableMods(modsToEnable);
|
||||||
|
}
|
||||||
|
|
||||||
checkManagerErrors();
|
checkManagerErrors();
|
||||||
|
|
||||||
for(QString archive : archives)
|
for(QString archive : archives)
|
||||||
|
{
|
||||||
|
logGlobal->info("Erasing archive '%s'", archive.toStdString());
|
||||||
QFile::remove(archive);
|
QFile::remove(archive);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CModListView::installMaps(QStringList maps)
|
void CModListView::installMaps(QStringList maps)
|
||||||
@ -884,6 +902,7 @@ void CModListView::installMaps(QStringList maps)
|
|||||||
|
|
||||||
for(QString map : maps)
|
for(QString map : maps)
|
||||||
{
|
{
|
||||||
|
logGlobal->info("Importing map '%s'", map.toStdString());
|
||||||
QFile(map).rename(destDir + map.section('/', -1, -1));
|
QFile(map).rename(destDir + map.section('/', -1, -1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,6 +120,9 @@ bool ModStateController::disableMod(QString modname)
|
|||||||
|
|
||||||
bool ModStateController::canInstallMod(QString modname)
|
bool ModStateController::canInstallMod(QString modname)
|
||||||
{
|
{
|
||||||
|
if (!modList->isModExists(modname))
|
||||||
|
return true; // for installation of unknown mods, e.g. via "Install from file" option
|
||||||
|
|
||||||
auto mod = modList->getMod(modname);
|
auto mod = modList->getMod(modname);
|
||||||
|
|
||||||
if(mod.isSubmod())
|
if(mod.isSubmod())
|
||||||
|
@ -23,7 +23,10 @@
|
|||||||
void StartGameTab::changeEvent(QEvent *event)
|
void StartGameTab::changeEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
if(event->type() == QEvent::LanguageChange)
|
if(event->type() == QEvent::LanguageChange)
|
||||||
|
{
|
||||||
ui->retranslateUi(this);
|
ui->retranslateUi(this);
|
||||||
|
refreshState();
|
||||||
|
}
|
||||||
|
|
||||||
QWidget::changeEvent(event);
|
QWidget::changeEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ ModsPresetState::ModsPresetState()
|
|||||||
CResourceHandler::get("local")->createResource(settingsPath.getOriginalName() + ".json");
|
CResourceHandler::get("local")->createResource(settingsPath.getOriginalName() + ".json");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(modConfig["presets"].isNull())
|
if(modConfig["presets"].isNull() || modConfig["presets"].Struct().empty())
|
||||||
{
|
{
|
||||||
modConfig["activePreset"] = JsonNode("default");
|
modConfig["activePreset"] = JsonNode("default");
|
||||||
if(modConfig["activeMods"].isNull())
|
if(modConfig["activeMods"].isNull())
|
||||||
@ -171,6 +171,10 @@ ModsPresetState::ModsPresetState()
|
|||||||
else
|
else
|
||||||
importInitialPreset(); // 1.5 format import
|
importInitialPreset(); // 1.5 format import
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto allPresets = getAllPresets();
|
||||||
|
if (!vstd::contains(allPresets, modConfig["activePreset"].String()))
|
||||||
|
modConfig["activePreset"] = JsonNode(allPresets.front());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModsPresetState::createInitialPreset()
|
void ModsPresetState::createInitialPreset()
|
||||||
|
Loading…
Reference in New Issue
Block a user