65 lines
1.6 KiB
C++
65 lines
1.6 KiB
C++
#include "pch.h"
|
|
|
|
#include "legacy_brush_package_import_services.h"
|
|
|
|
#include "app.h"
|
|
#include "node_panel_brush.h"
|
|
|
|
#include <functional>
|
|
#include <string>
|
|
|
|
namespace pp::panopainter {
|
|
namespace {
|
|
|
|
void queue_legacy_brush_package_import_job(
|
|
App& app,
|
|
std::shared_ptr<NodePanelBrushPreset> presets,
|
|
pp::app::BrushPackageImportKind kind,
|
|
std::string path_string)
|
|
{
|
|
app.runtime().canvas_async_task([presets = std::move(presets),
|
|
kind,
|
|
path_string = std::move(path_string)]() mutable {
|
|
BT_SetTerminate();
|
|
if (!presets) {
|
|
return;
|
|
}
|
|
if (kind == pp::app::BrushPackageImportKind::abr) {
|
|
presets->import_abr(path_string);
|
|
return;
|
|
}
|
|
|
|
presets->import_ppbr(path_string);
|
|
});
|
|
}
|
|
|
|
class LegacyBrushPackageImportServices final : public pp::app::BrushPackageImportServices {
|
|
public:
|
|
explicit LegacyBrushPackageImportServices(App& app) noexcept
|
|
: app_(app)
|
|
{
|
|
}
|
|
|
|
void import_brush_package(pp::app::BrushPackageImportKind kind, std::string_view path) override
|
|
{
|
|
const auto path_string = std::string(path);
|
|
queue_legacy_brush_package_import_job(app_, app_.presets, kind, std::move(path_string));
|
|
}
|
|
|
|
private:
|
|
App& app_;
|
|
};
|
|
|
|
} // namespace
|
|
|
|
pp::foundation::Status execute_legacy_brush_package_import(
|
|
App& app,
|
|
pp::app::BrushPackageImportKind kind,
|
|
std::string_view path)
|
|
{
|
|
LegacyBrushPackageImportServices services(app);
|
|
return pp::app::execute_brush_package_import(kind, path, services);
|
|
}
|
|
|
|
} // namespace pp::panopainter
|