implement export/import ppbr
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user