1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Read default template from config, named custom types

This commit is contained in:
nordsoft 2022-12-22 01:37:33 +04:00
parent 7e7071fc95
commit 8f7025328f
2 changed files with 14 additions and 13 deletions

View File

@ -405,13 +405,9 @@ std::shared_ptr<CIntObject> InterfaceObjectConfigurable::buildWidget(JsonNode co
{
return buildSlider(config);
}
if(type == "custom")
{
logGlobal->debug("Calling custom widget building function");
return const_cast<InterfaceObjectConfigurable*>(this)->buildCustomWidget(config);
}
logGlobal->error("Unknown type, nullptr will be returned");
return std::shared_ptr<CIntObject>(nullptr);
logGlobal->debug("Calling custom widget building function");
return const_cast<InterfaceObjectConfigurable*>(this)->buildCustomWidget(config);
}
std::shared_ptr<CIntObject> InterfaceObjectConfigurable::buildCustomWidget(const JsonNode & config)

View File

@ -281,7 +281,7 @@ void RandomMapTab::setMapGenOptions(std::shared_ptr<CMapGenOptions> opts)
if(tmpl)
w->addTextOverlay(tmpl->getName(), EFonts::FONT_SMALL);
else
w->addTextOverlay("default", EFonts::FONT_SMALL);
w->addTextOverlay(readText(variables["defaultTemplate"]), EFonts::FONT_SMALL);
}
for(auto r : VLC->terrainTypeHandler->roads())
{
@ -301,7 +301,7 @@ void RandomMapTab::setTemplate(const CRmgTemplate * tmpl)
if(tmpl)
w->addTextOverlay(tmpl->getName(), EFonts::FONT_SMALL);
else
w->addTextOverlay("default", EFonts::FONT_SMALL);
w->addTextOverlay(readText(variables["defaultTemplate"]), EFonts::FONT_SMALL);
}
updateMapInfoByHost();
}
@ -362,7 +362,7 @@ void TemplatesDropBox::ListItem::updateItem(int idx, const CRmgTemplate * _item)
if(idx)
w->setText("");
else
w->setText("default");
w->setText(readText(dropBox.variables["defaultTemplate"]));
}
}
}
@ -424,9 +424,14 @@ TemplatesDropBox::TemplatesDropBox(RandomMapTab & randomMapTab, int3 size):
std::shared_ptr<CIntObject> TemplatesDropBox::buildCustomWidget(const JsonNode & config)
{
auto position = readPosition(config["position"]);
listItems.push_back(std::make_shared<ListItem>(config, *this, position));
return listItems.back();
if(config["type"].String() == "templateListItem")
{
auto position = readPosition(config["position"]);
listItems.push_back(std::make_shared<ListItem>(config, *this, position));
return listItems.back();
}
return InterfaceObjectConfigurable::buildCustomWidget(config);
}
void TemplatesDropBox::sliderMove(int slidPos)