add remote page loading
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user