1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

template search

This commit is contained in:
Laserlicht
2025-10-08 01:12:57 +02:00
parent da79b27547
commit 64c44ce887
5 changed files with 23 additions and 2 deletions

View File

@@ -43,7 +43,8 @@
#include "../../lib/serializer/JsonDeserializer.h"
RandomMapTab::RandomMapTab():
InterfaceObjectConfigurable()
InterfaceObjectConfigurable(),
templateIndex(0)
{
recActions = 0;
mapGenOptions = std::make_shared<CMapGenOptions>();
@@ -164,6 +165,20 @@ RandomMapTab::RandomMapTab():
return readText(variables["randomTemplate"]);
return std::string("");
};
w->addCallback([this]()
{
std::vector<std::string> texts;
texts.push_back(readText(variables["randomTemplate"]));
for(auto & t : LIBRARY->tplh->getTemplates())
texts.push_back(t->getName());
ENGINE->windows().popWindows(1); // no real dropdown...
ENGINE->windows().createAndPushWindow<CObjectListWindow>(texts, nullptr, LIBRARY->generaltexth->translate("vcmi.lobby.templatesSelect.hover"), LIBRARY->generaltexth->translate("vcmi.lobby.templatesSelect.help"), [this](int index){
widget<ComboBox>("templateList")->setItem(index);
templateIndex = index;
}, templateIndex, std::vector<std::shared_ptr<IImage>>(), true);
});
}
loadOptions();