From 0f425069dcbeee22ff2ad2ea782024ab6d39a72d Mon Sep 17 00:00:00 2001 From: that Date: Wed, 4 Mar 2015 23:05:00 +0100 Subject: gui: allow specifying resource type in element name e.g. '' instead of '' Change-Id: I5ce04ae0845351c8a4640d12e36f1aaf32e1ebc9 --- gui/resources.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'gui') diff --git a/gui/resources.cpp b/gui/resources.cpp index 1e2e7f9c6..563dcc45c 100644 --- a/gui/resources.cpp +++ b/gui/resources.cpp @@ -288,17 +288,19 @@ ResourceManager::ResourceManager() void ResourceManager::LoadResources(xml_node<>* resList, ZipArchive* pZip) { - xml_node<>* child; - if (!resList) return; - child = resList->first_node("resource"); - while (child != NULL) + + for (xml_node<>* child = resList->first_node(); child; child = child->next_sibling()) { - xml_attribute<>* attr = child->first_attribute("type"); + std::string type = child->name(); + if (type == "resource") { + // legacy format : + xml_attribute<>* attr = child->first_attribute("type"); + type = attr ? attr->value() : "*unspecified*"; + } bool error = false; - std::string type = attr ? attr->value() : "*unspecified*"; if (type == "font") { FontResource* res = new FontResource(child, pZip); @@ -356,8 +358,6 @@ void ResourceManager::LoadResources(xml_node<>* resList, ZipArchive* pZip) } else LOGERR("Resource type (%s) failed to load\n", type.c_str()); } - - child = child->next_sibling("resource"); } } -- cgit v1.2.3