1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-22 03:39:45 +02:00

Added an option to configure validation level in launcher

This commit is contained in:
Ivan Savenko 2024-10-06 19:21:18 +00:00
parent 3e3f842fbe
commit 66fdad145c
8 changed files with 1200 additions and 1034 deletions

View File

@ -3,7 +3,7 @@
{
"type" : "object",
"$schema" : "http://json-schema.org/draft-04/schema",
"required" : [ "general", "video", "adventure", "battle", "input", "server", "logging", "launcher", "lobby", "gameTweaks" ],
"required" : [ "general", "video", "adventure", "battle", "input", "server", "logging", "launcher", "lobby", "gameTweaks", "mods" ],
"definitions" : {
"logLevelEnum" : {
"type" : "string",
@ -149,6 +149,23 @@
}
}
},
"mods" : {
"type" : "object",
"additionalProperties" : false,
"default" : {},
"required" : [
"validation"
],
"properties" : {
"validation" : {
"type" : "string",
"enum" : [ "off", "basic", "full" ],
"default" : "basic"
}
}
},
"video" : {
"type" : "object",
"additionalProperties" : false,

View File

@ -182,6 +182,13 @@ void CSettingsView::loadSettings()
else
ui->buttonFontScalable->setChecked(true);
if (settings["mods"]["validation"].String() == "off")
ui->buttonValidationOff->setChecked(true);
else if (settings["mods"]["validation"].String() == "basic")
ui->buttonValidationBasic->setChecked(true);
else
ui->buttonValidationFull->setChecked(true);
loadToggleButtonSettings();
}
@ -791,3 +798,21 @@ void CSettingsView::on_buttonFontOriginal_clicked(bool checked)
Settings node = settings.write["video"]["fontsType"];
node->String() = "original";
}
void CSettingsView::on_buttonValidationOff_clicked(bool checked)
{
Settings node = settings.write["mods"]["validation"];
node->String() = "off";
}
void CSettingsView::on_buttonValidationBasic_clicked(bool checked)
{
Settings node = settings.write["mods"]["validation"];
node->String() = "basic";
}
void CSettingsView::on_buttonValidationFull_clicked(bool checked)
{
Settings node = settings.write["mods"]["validation"];
node->String() = "full";
}

View File

@ -83,19 +83,20 @@ private slots:
void on_sliderToleranceDistanceController_valueChanged(int value);
void on_lineEditGameLobbyHost_textChanged(const QString &arg1);
void on_spinBoxNetworkPortLobby_valueChanged(int arg1);
void on_sliderControllerSticksAcceleration_valueChanged(int value);
void on_sliderControllerSticksSensitivity_valueChanged(int value);
//void on_buttonTtfFont_toggled(bool value);
void on_sliderScalingFont_valueChanged(int value);
void on_buttonFontAuto_clicked(bool checked);
void on_buttonFontScalable_clicked(bool checked);
void on_buttonFontOriginal_clicked(bool checked);
void on_buttonValidationOff_clicked(bool checked);
void on_buttonValidationBasic_clicked(bool checked);
void on_buttonValidationFull_clicked(bool checked);
private:
Ui::CSettingsView * ui;

File diff suppressed because it is too large Load Diff

View File

@ -14,6 +14,7 @@
#include "../mapObjects/CRewardableObject.h"
#include "../texts/CGeneralTextHandler.h"
#include "../IGameCallback.h"
#include "../CConfigHandler.h"
VCMI_LIB_NAMESPACE_BEGIN
@ -25,6 +26,7 @@ void CRewardableConstructor::initTypeData(const JsonNode & config)
if (!config["name"].isNull())
VLC->generaltexth->registerString( config.getModScope(), getNameTextID(), config["name"].String());
if (settings["mods"]["validation"].String() != "off")
JsonUtils::validate(config, "vcmi:rewardable", getJsonKey());
}

View File

@ -17,6 +17,7 @@
#include "ModIncompatibility.h"
#include "../CCreatureHandler.h"
#include "../CConfigHandler.h"
#include "../CStopWatch.h"
#include "../GameSettings.h"
#include "../ScriptHandler.h"
@ -339,6 +340,8 @@ void CModHandler::loadModFilesystems()
for(std::string & modName : activeMods)
CResourceHandler::addFilesystem("data", modName, modFilesystems[modName]);
if (settings["mods"]["validation"].String() == "full")
{
for(std::string & leftModName : activeMods)
{
for(std::string & rightModName : activeMods)
@ -362,6 +365,7 @@ void CModHandler::loadModFilesystems()
}
}
}
}
TModID CModHandler::findResourceOrigin(const ResourcePath & name) const
{
@ -508,8 +512,8 @@ void CModHandler::load()
content->loadCustom();
// for(const TModID & modName : activeMods)
// loadTranslation(modName);
for(const TModID & modName : activeMods)
loadTranslation(modName);
#if 0
for(const TModID & modName : activeMods)

View File

@ -17,6 +17,7 @@
#include "../BattleFieldHandler.h"
#include "../CArtHandler.h"
#include "../CCreatureHandler.h"
#include "../CConfigHandler.h"
#include "../entities/faction/CTownHandler.h"
#include "../texts/CGeneralTextHandler.h"
#include "../CHeroHandler.h"
@ -79,7 +80,7 @@ bool ContentTypeHandler::preloadModData(const std::string & modName, const std::
logMod->trace("Patching object %s (%s) from %s", objectName, remoteName, modName);
JsonNode & remoteConf = modData[remoteName].patches[objectName];
if (!remoteConf.isNull())
if (!remoteConf.isNull() && settings["mods"]["validation"].String() != "off")
JsonUtils::detectConflicts(conflictList, remoteConf, entry.second, objectName);
JsonUtils::merge(remoteConf, entry.second);
@ -161,6 +162,8 @@ void ContentTypeHandler::loadCustom()
}
void ContentTypeHandler::afterLoadFinalization()
{
if (settings["mods"]["validation"].String() != "off")
{
for (auto const & data : modData)
{
@ -224,6 +227,7 @@ void ContentTypeHandler::afterLoadFinalization()
for (auto const & modID : conflictingMods)
logMod->warn("Mod '%s' - value set to %s", modID, conflictModData[modID].toCompactString());
}
}
handler->afterLoadFinalization();
}
@ -288,7 +292,7 @@ void CContentHandler::afterLoadFinalization()
void CContentHandler::preloadData(CModInfo & mod)
{
bool validate = (mod.validation != CModInfo::PASSED);
bool validate = validateMod(mod);
// print message in format [<8-symbols checksum>] <modname>
auto & info = mod.getVerificationInfo();
@ -305,7 +309,7 @@ void CContentHandler::preloadData(CModInfo & mod)
void CContentHandler::load(CModInfo & mod)
{
bool validate = (mod.validation != CModInfo::PASSED);
bool validate = validateMod(mod);
if (!loadMod(mod.identifier, validate))
mod.validation = CModInfo::FAILED;
@ -326,4 +330,18 @@ const ContentTypeHandler & CContentHandler::operator[](const std::string & name)
return handlers.at(name);
}
bool CContentHandler::validateMod(const CModInfo & mod) const
{
if (settings["mods"]["validation"].String() == "full")
return true;
if (mod.validation == CModInfo::PASSED)
return false;
if (settings["mods"]["validation"].String() == "off")
return false;
return true;
}
VCMI_LIB_NAMESPACE_END

View File

@ -58,6 +58,7 @@ class DLL_LINKAGE CContentHandler
std::map<std::string, ContentTypeHandler> handlers;
bool validateMod(const CModInfo & mod) const;
public:
void init();