mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
Read default template from config, named custom types
This commit is contained in:
@@ -405,13 +405,9 @@ std::shared_ptr<CIntObject> InterfaceObjectConfigurable::buildWidget(JsonNode co
|
|||||||
{
|
{
|
||||||
return buildSlider(config);
|
return buildSlider(config);
|
||||||
}
|
}
|
||||||
if(type == "custom")
|
|
||||||
{
|
logGlobal->debug("Calling custom widget building function");
|
||||||
logGlobal->debug("Calling custom widget building function");
|
return const_cast<InterfaceObjectConfigurable*>(this)->buildCustomWidget(config);
|
||||||
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)
|
std::shared_ptr<CIntObject> InterfaceObjectConfigurable::buildCustomWidget(const JsonNode & config)
|
||||||
|
@@ -281,7 +281,7 @@ void RandomMapTab::setMapGenOptions(std::shared_ptr<CMapGenOptions> opts)
|
|||||||
if(tmpl)
|
if(tmpl)
|
||||||
w->addTextOverlay(tmpl->getName(), EFonts::FONT_SMALL);
|
w->addTextOverlay(tmpl->getName(), EFonts::FONT_SMALL);
|
||||||
else
|
else
|
||||||
w->addTextOverlay("default", EFonts::FONT_SMALL);
|
w->addTextOverlay(readText(variables["defaultTemplate"]), EFonts::FONT_SMALL);
|
||||||
}
|
}
|
||||||
for(auto r : VLC->terrainTypeHandler->roads())
|
for(auto r : VLC->terrainTypeHandler->roads())
|
||||||
{
|
{
|
||||||
@@ -301,7 +301,7 @@ void RandomMapTab::setTemplate(const CRmgTemplate * tmpl)
|
|||||||
if(tmpl)
|
if(tmpl)
|
||||||
w->addTextOverlay(tmpl->getName(), EFonts::FONT_SMALL);
|
w->addTextOverlay(tmpl->getName(), EFonts::FONT_SMALL);
|
||||||
else
|
else
|
||||||
w->addTextOverlay("default", EFonts::FONT_SMALL);
|
w->addTextOverlay(readText(variables["defaultTemplate"]), EFonts::FONT_SMALL);
|
||||||
}
|
}
|
||||||
updateMapInfoByHost();
|
updateMapInfoByHost();
|
||||||
}
|
}
|
||||||
@@ -362,7 +362,7 @@ void TemplatesDropBox::ListItem::updateItem(int idx, const CRmgTemplate * _item)
|
|||||||
if(idx)
|
if(idx)
|
||||||
w->setText("");
|
w->setText("");
|
||||||
else
|
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)
|
std::shared_ptr<CIntObject> TemplatesDropBox::buildCustomWidget(const JsonNode & config)
|
||||||
{
|
{
|
||||||
auto position = readPosition(config["position"]);
|
if(config["type"].String() == "templateListItem")
|
||||||
listItems.push_back(std::make_shared<ListItem>(config, *this, position));
|
{
|
||||||
return listItems.back();
|
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)
|
void TemplatesDropBox::sliderMove(int slidPos)
|
||||||
|
Reference in New Issue
Block a user