From 65c21064b5620fe72caa8e1c7c7c2e19e8209c9c Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Sun, 1 Oct 2023 00:18:25 +0200 Subject: [PATCH] added var --- client/windows/CMapOverview.cpp | 46 ++++++++++++++++----------------- client/windows/CMapOverview.h | 1 - config/widgets/mapOverview.json | 7 ++++- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/client/windows/CMapOverview.cpp b/client/windows/CMapOverview.cpp index 7fdad167e..1a154ac2b 100644 --- a/client/windows/CMapOverview.cpp +++ b/client/windows/CMapOverview.cpp @@ -148,32 +148,32 @@ CMapOverview::CMapOverviewWidget::CMapOverviewWidget(CMapOverview& parent): InterfaceObjectConfigurable(), p(parent) { drawPlayerElements = p.tabType == ESelectionScreen::newGame; - renderImage = settings["lobby"]["mapPreview"].Bool(); - // create minimaps - ResourcePath res = ResourcePath(p.resource.getName(), EResType::MAP); - std::unique_ptr campaignMap = nullptr; - if(p.tabType != ESelectionScreen::newGame) - { - CLoadFile lf(*CResourceHandler::get()->getResourceName(ResourcePath(p.resource.getName(), EResType::SAVEGAME)), MINIMAL_SERIALIZATION_VERSION); - lf.checkMagicBytes(SAVEGAME_MAGIC); - - std::unique_ptr mapHeader = std::make_unique(); - StartInfo * startInfo; - lf >> *(mapHeader) >> startInfo; - - if(startInfo->campState) - campaignMap = startInfo->campState->getMap(*startInfo->campState->currentScenario()); - res = ResourcePath(startInfo->fileURI, EResType::MAP); - } - if(!campaignMap) - minimaps = createMinimaps(res); - else - minimaps = createMinimaps(campaignMap); - - // config const JsonNode config(JsonPath::builtin("config/widgets/mapOverview.json")); + if(settings["lobby"]["mapPreview"].Bool()) + { + ResourcePath res = ResourcePath(p.resource.getName(), EResType::MAP); + std::unique_ptr campaignMap = nullptr; + if(p.tabType != ESelectionScreen::newGame && config["variables"]["mapPreviewForSaves"].Bool()) + { + CLoadFile lf(*CResourceHandler::get()->getResourceName(ResourcePath(p.resource.getName(), EResType::SAVEGAME)), MINIMAL_SERIALIZATION_VERSION); + lf.checkMagicBytes(SAVEGAME_MAGIC); + + std::unique_ptr mapHeader = std::make_unique(); + StartInfo * startInfo; + lf >> *(mapHeader) >> startInfo; + + if(startInfo->campState) + campaignMap = startInfo->campState->getMap(*startInfo->campState->currentScenario()); + res = ResourcePath(startInfo->fileURI, EResType::MAP); + } + if(!campaignMap) + minimaps = createMinimaps(res); + else + minimaps = createMinimaps(campaignMap); + } + REGISTER_BUILDER("drawMinimap", &CMapOverview::CMapOverviewWidget::buildDrawMinimap); build(config); diff --git a/client/windows/CMapOverview.h b/client/windows/CMapOverview.h index c9d4197f9..872e35292 100644 --- a/client/windows/CMapOverview.h +++ b/client/windows/CMapOverview.h @@ -33,7 +33,6 @@ class CMapOverview : public CWindowObject CMapOverview& p; bool drawPlayerElements; - bool renderImage; std::vector minimaps; Canvas createMinimapForLayer(std::unique_ptr & map, int layer) const; diff --git a/config/widgets/mapOverview.json b/config/widgets/mapOverview.json index bed9130f5..d28c2cfc2 100644 --- a/config/widgets/mapOverview.json +++ b/config/widgets/mapOverview.json @@ -130,5 +130,10 @@ "text": "", "rect": {"x": 10, "y": 334, "w": 408, "h": 35} } - ] + ], + + "variables": + { + "mapPreviewForSaves": true + } }