MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / sliderHandler

Method sliderHandler

source/windowing/StarWidgetParsing.cpp:577–607  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

575}
576
577WidgetConstructResult WidgetParser::sliderHandler(String const& name, Json const& config) {
578 try {
579 auto grid = config.getString("gridImage");
580 auto slider = make_shared<SliderBarWidget>(grid, config.getBool("showSpinner", true));
581 common(slider, config);
582
583 if (auto callback = m_callbacks.value(config.getString("callback", name)))
584 slider->setCallback(callback);
585
586 if (config.contains("range")) {
587 auto rangeConfig = config.getArray("range");
588 slider->setRange(rangeConfig.get(0).toInt(), rangeConfig.get(1).toInt(), rangeConfig.get(2).toInt());
589 }
590
591 if (config.contains("jogImages")) {
592 auto jogConfig = config.get("jogImages");
593 slider->setJogImages(jogConfig.getString("baseImage"),
594 jogConfig.getString("hoverImage", ""),
595 jogConfig.getString("pressedImage", ""),
596 jogConfig.getString("disabledImage", ""));
597 }
598
599 if (config.contains("disabled"))
600 slider->setEnabled(!config.getBool("disabled"));
601
602 return WidgetConstructResult(slider, name, config.getFloat("zlevel", 0));
603 } catch (MapException const& e) {
604 throw WidgetParserException::format(
605 "Malformed gui json, missing a required value in the map. {}", outputException(e, false));
606 }
607}
608
609WidgetConstructResult WidgetParser::largeCharPlateHandler(String const& name, Json const& config) {
610 String callback = config.getString("callback", name);

Callers

nothing calls this directly

Calls 15

getStringMethod · 0.80
getBoolMethod · 0.80
getArrayMethod · 0.80
toIntMethod · 0.80
setJogImagesMethod · 0.80
getFloatMethod · 0.80
formatFunction · 0.50
outputExceptionFunction · 0.50
valueMethod · 0.45
setCallbackMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected