| 558 | } |
| 559 | |
| 560 | inline void LoadAsText(const std::string &text) { |
| 561 | this->el_text.text = text; |
| 562 | this->el_text.font_size = static_cast<int>(ul::design::FontSize::Medium); |
| 563 | |
| 564 | const auto text_json = this->GetSettings(); |
| 565 | if(text_json.count("font_size")) { |
| 566 | const auto raw_font_size = text_json["font_size"].get<std::string>(); |
| 567 | |
| 568 | if(raw_font_size == "small") { |
| 569 | this->el_text.font_size = static_cast<int>(ul::design::FontSize::Small); |
| 570 | } |
| 571 | else if(raw_font_size == "medium") { |
| 572 | this->el_text.font_size = static_cast<int>(ul::design::FontSize::Medium); |
| 573 | } |
| 574 | else if(raw_font_size == "medium-large") { |
| 575 | this->el_text.font_size = static_cast<int>(ul::design::FontSize::MediumLarge); |
| 576 | } |
| 577 | else if(raw_font_size == "large") { |
| 578 | this->el_text.font_size = static_cast<int>(ul::design::FontSize::Large); |
| 579 | } |
| 580 | else { |
| 581 | emscripten_log(EM_LOG_CONSOLE, "Unknown font size value '%s' for text element '%s'...", raw_font_size.c_str(), this->ui_name.c_str()); |
| 582 | } |
| 583 | } |
| 584 | this->el_text.clamp_width = text_json.value("clamp_width", 0); |
| 585 | this->el_text.clamp_speed = text_json.value("clamp_speed", 0); |
| 586 | this->el_text.clamp_delay = text_json.value("clamp_delay", 0); |
| 587 | } |
| 588 | |
| 589 | inline void LoadAsDefault() { |
| 590 | // ... |