1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

Added non-linear slider for better simturn duration selection

This commit is contained in:
Ivan Savenko
2023-11-10 17:18:49 +02:00
parent 7d54f6a9c0
commit c5eeaa6526
6 changed files with 114 additions and 26 deletions

View File

@ -501,12 +501,25 @@ std::shared_ptr<CSlider> InterfaceObjectConfigurable::buildSlider(const JsonNode
auto position = readPosition(config["position"]);
int length = config["size"].Integer();
auto style = config["style"].String() == "brown" ? CSlider::BROWN : CSlider::BLUE;
auto itemsVisible = config["itemsVisible"].Integer();
auto itemsTotal = config["itemsTotal"].Integer();
auto value = config["selected"].Integer();
bool horizontal = config["orientation"].String() == "horizontal";
const auto & result =
std::make_shared<CSlider>(position, length, callbacks_int.at(config["callback"].String()), itemsVisible, itemsTotal, value, horizontal ? Orientation::HORIZONTAL : Orientation::VERTICAL, style);
auto orientation = horizontal ? Orientation::HORIZONTAL : Orientation::VERTICAL;
std::shared_ptr<CSlider> result;
if (config["items"].isNull())
{
auto itemsVisible = config["itemsVisible"].Integer();
auto itemsTotal = config["itemsTotal"].Integer();
result = std::make_shared<CSlider>(position, length, callbacks_int.at(config["callback"].String()), itemsVisible, itemsTotal, value, orientation, style);
}
else
{
auto items = config["items"].convertTo<std::vector<int>>();
result = std::make_shared<SliderNonlinear>(position, length, callbacks_int.at(config["callback"].String()), items, value, orientation, style);
}
if(!config["scrollBounds"].isNull())
{