bool GUITabbedPanel::loadXMLSettings(XMLElement *element) { if(!element || element->getName() != "TabbedPanel") { LOG_PRINT("Need a TabbedPanel node in the xml file"); return false; } XMLElement *child = 0, *subChild = 0; D3DXFROMWINEVECTOR3 bordersColor = upperPanel->getBordersColor(); D3DXFROMWINEVECTOR4 bgColor = upperPanel->getBGColor(); int count = 0; if(child = element->getChildByName("hScale")) fontScales.y = child->getValuef(); if(child = element->getChildByName("wScale")) fontScales.x = child->getValuef(); if(child = element->getChildByName("TabButtonsBordersColor")) XMLElement::loadRX_GY_BZf(*child, tabButtonsBordersColor); if(child = element->getChildByName("TabButtonsColor")) XMLElement::loadRX_GY_BZf(*child, tabButtonsColor); if(child = element->getChildByName("BordersColor")) XMLElement::loadRX_GY_BZf(*child, bordersColor); if(child = element->getChildByName("BGColor")) XMLElement::loadRX_GY_BZ_AWf(*child, bgColor); if(child = element->getChildByName("fontIndex")) fontIndex = clampNS(child->getValuei(), 0, 50); setFontScales(fontScales); for(size_t i = 0; i < element->getChildrenCount(); i++) { if(!(child = element->getChild(i))) continue; const NSString &childName = child->getName(); if(childName == "Panel") { GUIPanel *panel = new GUIPanel(); if(!panel->loadXMLSettings(child) || !addPanel(panel)) deleteObject(panel); continue; } } mainPanel->setBordersColor(bordersColor); mainPanel->setBGColor(bgColor); return GUIRectangle::loadXMLSettings(element) && lowerPanel->getWidgets().size(); }
bool GUIPanel::loadXMLSettings(const TiXmlElement *element) { if(!XMLArbiter::inspectElementInfo(element, "Panel")) return Logger::writeErrorLog("Need a Panel node in the xml file"); const char *description = element->Attribute("description"); std::string type = element->Attribute("layout") ? element->Attribute("layout") : "UNKNOWN"; if(description) return loadXMLSettings(description); layout = (type == "CEN_YAXIS") ? PL_YAXIS_CEN_LAYOUT : (type == "YAXIS" ) ? PL_YAXIS_LAYOUT : (type == "XAXIS" ) ? PL_XAXIS_LAYOUT : (type == "GRID" ) ? PL_GRID_LAYOUT : PL_FREE_LAYOUT; for(const TiXmlElement *child = element->FirstChildElement(); child; child = child->NextSiblingElement() ) { std::string childName = child->Value(); if(!childName.size()) continue; if(childName == "CheckBox") { GUICheckBox *newCheckBox = new GUICheckBox(); if(!newCheckBox->loadXMLSettings(child) || !addWidget(newCheckBox)) deleteObject(newCheckBox); continue; } if(childName == "TabbedPanel") { GUITabbedPanel *newTabbedPanel = new GUITabbedPanel(); if(!newTabbedPanel->loadXMLSettings(child) || !addWidget(newTabbedPanel)) deleteObject(newTabbedPanel); continue; } if(childName == "RadioButton") { GUIRadioButton *newRadioButton = new GUIRadioButton(); if(!newRadioButton->loadXMLSettings(child) || !addWidget(newRadioButton)) { deleteObject(newRadioButton); } else { if(newRadioButton->isChecked()) notify(newRadioButton); } continue; } if(childName == "ComboBox") { GUIComboBox *newComboBox = new GUIComboBox(); if(!newComboBox->loadXMLSettings(child) || !addWidget(newComboBox)) deleteObject(newComboBox); continue; } if(childName == "TextBox") { GUITextBox *newTextBox = new GUITextBox(); if(!newTextBox->loadXMLSettings(child) || !addWidget(newTextBox)) deleteObject(newTextBox); continue; } if(childName == "Slider") { GUISlider *newSlider = new GUISlider(); if(!newSlider->loadXMLSettings(child) || !addWidget(newSlider)) deleteObject(newSlider); continue; } if(childName == "Separator") { GUISeparator *newSeparator = new GUISeparator(); if((layout != PL_YAXIS_LAYOUT && layout != PL_XAXIS_LAYOUT && layout != PL_YAXIS_CEN_LAYOUT) || (!newSeparator->loadXMLSettings(child))) { deleteObject(newSeparator); } else { newSeparator->setParent(this); newSeparator->setOrientation((layout != PL_YAXIS_LAYOUT && layout != PL_YAXIS_CEN_LAYOUT)); elements.push_back(newSeparator); } continue; } if(childName == "Button") { GUIButton *newButton = new GUIButton(); if(!newButton->loadXMLSettings(child) || !addWidget(newButton)) deleteObject(newButton); continue; } if(childName == "Label") { GUILabel *newLabel = new GUILabel(); if(!newLabel->loadXMLSettings(child) || !addWidget(newLabel)) deleteObject(newLabel); continue; } if(childName == "Interval") setInterval(XMLArbiter::fillComponents2i(child, interval)); if(childName == "Panel") { GUIPanel *panel = new GUIPanel(); if(!panel->loadXMLSettings(child) || !addWidget(panel)) deleteObject(panel); continue; } } return GUIRectangle::loadXMLSettings(element) && GUIClippedRectangle::loadXMLClippedRectangleInfo(element); }