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

Method labelHandler

source/windowing/StarWidgetParsing.cpp:445–468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

443}
444
445WidgetConstructResult WidgetParser::labelHandler(String const& name, Json const& config) {
446 String text = config.getString("value", "");
447
448 Color color = Color::White;
449 if (config.contains("color"))
450 color = jsonToColor(config.get("color"));
451 HorizontalAnchor hAnchor = HorizontalAnchorNames.getLeft(config.getString("hAnchor", "left"));
452 VerticalAnchor vAnchor = VerticalAnchorNames.getLeft(config.getString("vAnchor", "bottom"));
453
454 auto label = make_shared<LabelWidget>(text, color, hAnchor, vAnchor);
455 common(label, config);
456 if (config.contains("fontSize"))
457 label->setFontSize(config.getInt("fontSize"));
458 if (config.contains("wrapWidth"))
459 label->setWrapWidth(config.getInt("wrapWidth"));
460 if (config.contains("charLimit"))
461 label->setTextCharLimit(config.getInt("charLimit"));
462 if (config.contains("lineSpacing"))
463 label->setLineSpacing(config.getFloat("lineSpacing"));
464 if (config.contains("directives"))
465 label->setDirectives(config.getString("directives"));
466
467 return WidgetConstructResult(label, name, config.getFloat("zlevel", 0));
468}
469
470WidgetConstructResult WidgetParser::itemSlotHandler(String const& name, Json const& config) {
471 String backingImage = config.getString("backingImage", "");

Callers

nothing calls this directly

Calls 12

jsonToColorFunction · 0.85
getStringMethod · 0.80
getIntMethod · 0.80
setWrapWidthMethod · 0.80
setTextCharLimitMethod · 0.80
getFloatMethod · 0.80
containsMethod · 0.45
getMethod · 0.45
setFontSizeMethod · 0.45
setLineSpacingMethod · 0.45
setDirectivesMethod · 0.45

Tested by

no test coverage detected