mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
added var
This commit is contained in:
@@ -148,32 +148,32 @@ CMapOverview::CMapOverviewWidget::CMapOverviewWidget(CMapOverview& parent):
|
|||||||
InterfaceObjectConfigurable(), p(parent)
|
InterfaceObjectConfigurable(), p(parent)
|
||||||
{
|
{
|
||||||
drawPlayerElements = p.tabType == ESelectionScreen::newGame;
|
drawPlayerElements = p.tabType == ESelectionScreen::newGame;
|
||||||
renderImage = settings["lobby"]["mapPreview"].Bool();
|
|
||||||
|
|
||||||
// create minimaps
|
|
||||||
ResourcePath res = ResourcePath(p.resource.getName(), EResType::MAP);
|
|
||||||
std::unique_ptr<CMap> 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<CMapHeader> mapHeader = std::make_unique<CMapHeader>();
|
|
||||||
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"));
|
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<CMap> 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<CMapHeader> mapHeader = std::make_unique<CMapHeader>();
|
||||||
|
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);
|
REGISTER_BUILDER("drawMinimap", &CMapOverview::CMapOverviewWidget::buildDrawMinimap);
|
||||||
|
|
||||||
build(config);
|
build(config);
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ class CMapOverview : public CWindowObject
|
|||||||
CMapOverview& p;
|
CMapOverview& p;
|
||||||
|
|
||||||
bool drawPlayerElements;
|
bool drawPlayerElements;
|
||||||
bool renderImage;
|
|
||||||
std::vector<Canvas> minimaps;
|
std::vector<Canvas> minimaps;
|
||||||
|
|
||||||
Canvas createMinimapForLayer(std::unique_ptr<CMap> & map, int layer) const;
|
Canvas createMinimapForLayer(std::unique_ptr<CMap> & map, int layer) const;
|
||||||
|
|||||||
@@ -130,5 +130,10 @@
|
|||||||
"text": "",
|
"text": "",
|
||||||
"rect": {"x": 10, "y": 334, "w": 408, "h": 35}
|
"rect": {"x": 10, "y": 334, "w": 408, "h": 35}
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
|
||||||
|
"variables":
|
||||||
|
{
|
||||||
|
"mapPreviewForSaves": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user