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:
parent
7e7071fc95
commit
8f7025328f
@ -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);
|
||||
}
|
||||
|
||||
std::shared_ptr<CIntObject> InterfaceObjectConfigurable::buildCustomWidget(const JsonNode & config)
|
||||
|
@ -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)
|
||||
{
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user