Extract brush package import targets
This commit is contained in:
@@ -126,4 +126,34 @@ pp::foundation::Result<PpbrExportPaths> plan_ppbr_export_paths(
|
||||
return pp::foundation::Result<PpbrExportPaths>::success(std::move(paths));
|
||||
}
|
||||
|
||||
pp::foundation::Result<BrushPackageImageTargetPaths> plan_brush_package_image_target_paths(
|
||||
std::string_view data_path,
|
||||
BrushPackageImageKind kind,
|
||||
std::string_view image_name,
|
||||
std::string_view image_extension)
|
||||
{
|
||||
if (data_path.empty()) {
|
||||
return pp::foundation::Result<BrushPackageImageTargetPaths>::failure(
|
||||
pp::foundation::Status::invalid_argument("brush package data path must not be empty"));
|
||||
}
|
||||
if (image_name.empty()) {
|
||||
return pp::foundation::Result<BrushPackageImageTargetPaths>::failure(
|
||||
pp::foundation::Status::invalid_argument("brush package image name must not be empty"));
|
||||
}
|
||||
if (!is_word_extension(image_extension)) {
|
||||
return pp::foundation::Result<BrushPackageImageTargetPaths>::failure(
|
||||
pp::foundation::Status::invalid_argument("brush package image extension contains unsupported characters"));
|
||||
}
|
||||
|
||||
const auto directory = kind == BrushPackageImageKind::brush_tip ? "brushes" : "patterns";
|
||||
const std::string base_path = std::string(data_path) + "/" + directory + "/" + std::string(image_name)
|
||||
+ "." + std::string(image_extension);
|
||||
|
||||
return pp::foundation::Result<BrushPackageImageTargetPaths>::success(BrushPackageImageTargetPaths {
|
||||
.image_path = base_path,
|
||||
.thumbnail_path = std::string(data_path) + "/" + directory + "/thumbs/" + std::string(image_name)
|
||||
+ "." + std::string(image_extension),
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace pp::assets
|
||||
|
||||
@@ -19,11 +19,21 @@ enum class PpbrDataDirectoryPolicy {
|
||||
override_directory,
|
||||
};
|
||||
|
||||
enum class BrushPackageImageKind {
|
||||
brush_tip,
|
||||
pattern,
|
||||
};
|
||||
|
||||
struct PpbrHeader {
|
||||
std::uint16_t major = 0;
|
||||
std::uint16_t minor = 0;
|
||||
};
|
||||
|
||||
struct BrushPackageImageTargetPaths {
|
||||
std::string image_path;
|
||||
std::string thumbnail_path;
|
||||
};
|
||||
|
||||
struct PpbrExportPaths {
|
||||
std::string package_path;
|
||||
std::string directory;
|
||||
@@ -50,4 +60,10 @@ struct PpbrExportPaths {
|
||||
bool export_data,
|
||||
PpbrDataDirectoryPolicy data_directory_policy);
|
||||
|
||||
[[nodiscard]] pp::foundation::Result<BrushPackageImageTargetPaths> plan_brush_package_image_target_paths(
|
||||
std::string_view data_path,
|
||||
BrushPackageImageKind kind,
|
||||
std::string_view image_name,
|
||||
std::string_view image_extension);
|
||||
|
||||
} // namespace pp::assets
|
||||
|
||||
Reference in New Issue
Block a user