public static Rectangle loadRectangleFromXmlOptSize(Node node) { Rectangle rect = new Rectangle(); rect.setX(Integer.parseInt(XmlHelper.loadAttribute(node, "X"))); rect.setY(Integer.parseInt(XmlHelper.loadAttribute(node, "Y"))); rect.setWidth(Integer.parseInt(XmlHelper.loadAttribute(node, "Width", "0"))); rect.setHeight(Integer.parseInt(XmlHelper.loadAttribute(node, "Height", "0"))); return rect; }
@Override public void loadXml(NodeList nodes) { for (int i = 0; i < nodes.getLength(); ++i) { Node n = nodes.item(i); if (n.getNodeName().equals("Background")) { background = new Texture( Gdx.files.external( ArchitectureCommandFrame.DATA_PATH + XmlHelper.loadAttribute(n, "FileName"))); backgroundPos = Point.fromXml(n); } else if (n.getNodeName().equals("MilitaryTable")) { militaryTablePos = XmlHelper.loadRectangleFromXml(n); NodeList child = n.getChildNodes(); for (int j = 0; j < child.getLength(); ++j) { Node n2 = child.item(j); if (n2.getNodeName().equals("Portrait")) { militaryTablePortraitSize = Point.fromXmlAsSize(n2); militaryTablePortraitColor = XmlHelper.loadColorFromXml( Integer.parseUnsignedInt(XmlHelper.loadAttribute(n2, "BorderColor"))); } else if (n2.getNodeName().equals("Caption")) { militaryTableCaptionSize = Point.fromXmlAsSize(n2); militaryTableCaptionTemplate = new TextWidget<>(TextWidget.Setting.fromXml(n2)); } else if (n2.getNodeName().equals("Detail")) { militaryTableDetailSize = Point.fromXmlAsSize(n2); militaryTableDetailTemplate = new TextWidget<>(TextWidget.Setting.fromXml(n2)); } } } else if (n.getNodeName().equals("Reorganize")) { reorganize = StateTexture.fromXml(ArchitectureCommandFrame.DATA_PATH, n); reorganizePos = XmlHelper.loadRectangleFromXml(n); } else if (n.getNodeName().equals("New")) { newMilitary = StateTexture.fromXml(ArchitectureCommandFrame.DATA_PATH, n); newMilitaryPos = XmlHelper.loadRectangleFromXml(n); } else if (n.getNodeName().equals("Recruit")) { recruit = StateTexture.fromXml(ArchitectureCommandFrame.DATA_PATH, n); recruitPos = XmlHelper.loadRectangleFromXml(n); } else if (n.getNodeName().equals("Training")) { training = StateTexture.fromXml(ArchitectureCommandFrame.DATA_PATH, n); trainingPos = XmlHelper.loadRectangleFromXml(n); } else if (n.getNodeName().equals("Merge")) { merge = StateTexture.fromXml(ArchitectureCommandFrame.DATA_PATH, n); mergePos = XmlHelper.loadRectangleFromXml(n); } else if (n.getNodeName().equals("Disband")) { disband = StateTexture.fromXml(ArchitectureCommandFrame.DATA_PATH, n); disbandPos = XmlHelper.loadRectangleFromXml(n); } else if (n.getNodeName().equals("Upgrade")) { upgrade = StateTexture.fromXml(ArchitectureCommandFrame.DATA_PATH, n); upgradePos = XmlHelper.loadRectangleFromXml(n); } else if (n.getNodeName().equals("MilitaryList")) { militaryListPos = XmlHelper.loadRectangleFromXml(n); listNameWidth = Integer.parseInt(XmlHelper.loadAttribute(n, "NameWidth")); listRecruitWidth = Integer.parseInt(XmlHelper.loadAttribute(n, "RecruitWidth")); listTrainWidth = Integer.parseInt(XmlHelper.loadAttribute(n, "TrainWidth")); listQuantityWidth = Integer.parseInt(XmlHelper.loadAttribute(n, "QuantityWidth")); listRowHeight = Integer.parseInt(XmlHelper.loadAttribute(n, "RowHeight")); militaryListTextTemplate = new TextWidget<>(TextWidget.Setting.fromXml(n)); } else if (n.getNodeName().equals("SelectedBorderColor")) { selectedBorderColor = XmlHelper.loadColorFromXml( Integer.parseUnsignedInt(XmlHelper.loadAttribute(n, "BorderColor"))); } else { ArchitectureCommandFrame.loadText(n, textWidgets); } } }