MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / configureSelfFromXml

Method configureSelfFromXml

forms/control.cpp:595–819  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

593}
594
595void Control::configureSelfFromXml(pugi::xml_node *node)
596{
597 UString specialpositionx = "";
598 UString specialpositiony = "";
599
600 if (node->attribute("id"))
601 {
602 this->Name = node->attribute("id").as_string();
603 }
604 if (node->attribute("visible"))
605 {
606 this->Visible = node->attribute("visible").as_bool();
607 }
608 if (node->attribute("border"))
609 {
610 this->showBounds = node->attribute("border").as_bool();
611 }
612 if (node->attribute("isclickable"))
613 {
614 this->isClickable = node->attribute("isclickable").as_bool();
615 }
616
617 auto parentControl = this->getParent();
618 for (auto child = node->first_child(); child; child = child.next_sibling())
619 {
620 UString childName = child.name();
621
622 if (childName == "palette")
623 {
624 auto pal = fw().data->loadPalette(child.text().get());
625 if (!pal)
626 {
627 LogError("Control referenced palette \"%s\" that cannot be loaded",
628 child.text().get());
629 }
630 this->palette = pal;
631 }
632
633 else if (childName == "backcolour")
634 {
635 uint8_t r = child.attribute("r").as_uint();
636 uint8_t g = child.attribute("g").as_uint();
637 uint8_t b = child.attribute("b").as_uint();
638 uint8_t a = child.attribute("a").as_uint(255);
639 this->BackgroundColour = Colour{r, g, b, a};
640 }
641 else if (childName == "position")
642 {
643 UString xAttr = child.attribute("x").as_string();
644 if (Strings::isInteger(xAttr))
645 {
646 Location.x = child.attribute("x").as_int();
647 }
648 else
649 {
650 specialpositionx = xAttr;
651 }
652 UString yAttr = child.attribute("y").as_string();

Callers 1

Calls 9

getParentMethod · 0.95
ends_withFunction · 0.85
trFunction · 0.85
loadPaletteMethod · 0.80
emptyMethod · 0.80
getMethod · 0.45
getFontMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected