implement export/import ppbr

This commit is contained in:
2019-09-03 11:56:34 +02:00
parent 568f20e5c9
commit 0353d323a4
11 changed files with 390 additions and 135 deletions

View File

@@ -373,6 +373,30 @@ bool Brush::valid()
return true;
}
void Brush::relocate_paths(std::string base)
{
if (!Asset::is_asset(m_brush_path))
m_brush_path = replace_path(m_brush_path, base + "/brushes/");
if (!Asset::is_asset(m_dual_path))
m_dual_path = replace_path(m_dual_path, base + "/brushes/");
if (!Asset::is_asset(m_pattern_path))
m_pattern_path = replace_path(m_pattern_path, base + "/patterns/");
}
std::string Brush::replace_path(std::string path, std::string new_base)
{
if (path.empty())
return path;
std::regex r(R"((.*)[\\/]([^\\/]+)\.(\w+)$)");
std::smatch m;
if (!std::regex_search(path, m, r))
return path;
std::string base = m[1].str();
std::string name = m[2].str();
std::string ext = m[3].str();
return new_base + "/" + name + "." + ext;
}
bool Brush::read(BinaryStreamReader& r)
{
Serializer::Descriptor d;