add remote page loading

This commit is contained in:
2019-11-27 19:55:31 +01:00
parent 7701e6771b
commit 41579fa3c6
18 changed files with 373 additions and 41 deletions

View File

@@ -39,14 +39,28 @@ bool LayoutManager::load(const char* path)
m_path = path;
auto old = std::move(m_layouts);
Asset file;
if (!(file.open(path) && file.read_all()))
return false;
tinyxml2::XMLDocument xml;
auto ret = xml.Parse((char*)file.m_data, file.m_len);
auto xml_string = std::string((char*)file.m_data, (size_t)file.m_len);
file.close();
if (!parse(xml_string))
return false;
if (on_loaded)
on_loaded(m_loaded);
m_loaded = true;
return true;
}
bool LayoutManager::parse(const std::string& xml_string) noexcept
{
auto old = std::move(m_layouts);
tinyxml2::XMLDocument xml;
auto ret = xml.Parse(xml_string.c_str(), xml_string.size());
if (ret != tinyxml2::XMLError::XML_SUCCESS)
{
return false;
@@ -70,7 +84,7 @@ bool LayoutManager::load(const char* path)
if (std::find(osv.begin(), osv.end(), PP_OS) == osv.end())
{
LOG("Layout %s not for this os(%s), skipping", id_str, PP_OS)
current = current->NextSiblingElement("layout");
current = current->NextSiblingElement("layout");
continue;
}
}
@@ -105,11 +119,6 @@ bool LayoutManager::load(const char* path)
}
current = current->NextSiblingElement("layout");
}
if (on_loaded)
on_loaded(m_loaded);
m_loaded = true;
return true;
}