mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
InventoryView::readXML
This commit is contained in:
parent
8dbbea7b6d
commit
23705e065e
4 changed files with 91 additions and 10 deletions
|
|
@ -20,7 +20,7 @@ static Align align_from_string(const std::string& str, Align def) {
|
|||
}
|
||||
|
||||
/* Read basic UINode properties */
|
||||
static void readUINode(xml::xmlelement element, UINode& node) {
|
||||
static void _readUINode(xml::xmlelement element, UINode& node) {
|
||||
if (element->has("coord")) {
|
||||
node.setCoord(element->attr("coord").asVec2());
|
||||
}
|
||||
|
|
@ -37,8 +37,9 @@ static void readUINode(xml::xmlelement element, UINode& node) {
|
|||
node.setAlign(align_from_string(alignName, node.getAlign()));
|
||||
}
|
||||
|
||||
|
||||
static void _readContainer(UiXmlReader& reader, xml::xmlelement element, Container& container) {
|
||||
readUINode(element, container);
|
||||
_readUINode(element, container);
|
||||
|
||||
if (element->has("scrollable")) {
|
||||
container.setScrollable(element->attr("scrollable").asBool());
|
||||
|
|
@ -50,8 +51,16 @@ static void _readContainer(UiXmlReader& reader, xml::xmlelement element, Contain
|
|||
}
|
||||
}
|
||||
|
||||
void UiXmlReader::readUINode(UiXmlReader& reader, xml::xmlelement element, Container& container) {
|
||||
_readContainer(reader, element, container);
|
||||
}
|
||||
|
||||
void UiXmlReader::readUINode(UiXmlReader& reader, xml::xmlelement element, UINode& node) {
|
||||
_readUINode(element, node);
|
||||
}
|
||||
|
||||
static void _readPanel(UiXmlReader& reader, xml::xmlelement element, Panel& panel) {
|
||||
readUINode(element, panel);
|
||||
_readUINode(element, panel);
|
||||
|
||||
if (element->has("padding")) {
|
||||
panel.setPadding(element->attr("padding").asVec4());
|
||||
|
|
@ -86,7 +95,7 @@ static std::wstring readAndProcessInnerText(xml::xmlelement element) {
|
|||
static std::shared_ptr<UINode> readLabel(UiXmlReader& reader, xml::xmlelement element) {
|
||||
std::wstring text = readAndProcessInnerText(element);
|
||||
auto label = std::make_shared<Label>(text);
|
||||
readUINode(element, *label);
|
||||
_readUINode(element, *label);
|
||||
return label;
|
||||
}
|
||||
|
||||
|
|
@ -161,6 +170,14 @@ std::shared_ptr<UINode> UiXmlReader::readXML(
|
|||
return readUINode(root);
|
||||
}
|
||||
|
||||
std::shared_ptr<UINode> UiXmlReader::readXML(
|
||||
const std::string& filename,
|
||||
xml::xmlelement root
|
||||
) {
|
||||
this->filename = filename;
|
||||
return readUINode(root);
|
||||
}
|
||||
|
||||
const std::string& UiXmlReader::getFilename() const {
|
||||
return filename;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue