add ppbr info data
This commit is contained in:
@@ -610,7 +610,12 @@ void App::dialog_ppbr_export()
|
||||
App::I->pick_file_save({ "ppbr" }, [this, dialog] (std::string path) {
|
||||
std::thread([this, path, dialog] {
|
||||
BT_SetTerminate();
|
||||
presets->export_ppbr(path, dialog->m_header_image);
|
||||
NodePanelBrushPreset::PPBRInfo info;
|
||||
info.author = dialog->txt_author->m_text;
|
||||
info.url = dialog->txt_url->m_text;
|
||||
info.email = dialog->txt_email->m_text;
|
||||
info.descr = dialog->txt_descr->m_text;
|
||||
presets->export_ppbr(path, info);
|
||||
dialog->destroy();
|
||||
App::I->message_box("Export PPBR", "Brushes exported to:\n" + path);
|
||||
}).detach();
|
||||
|
||||
@@ -48,6 +48,10 @@ void NodeDialogExportPPBR::init_controls()
|
||||
};
|
||||
img_header = find<NodeImageTexture>("header-tex");
|
||||
txt_header_descr = find<NodeText>("header-descr");
|
||||
txt_author = find<NodeText>("info-author");
|
||||
txt_email = find<NodeText>("info-email");
|
||||
txt_url = find<NodeText>("info-url");
|
||||
txt_descr = find<NodeText>("info-descr");
|
||||
}
|
||||
|
||||
void NodeDialogExportPPBR::open_header()
|
||||
|
||||
@@ -16,6 +16,10 @@ public:
|
||||
NodeImageTexture* img_header;
|
||||
Image m_header_image;
|
||||
NodeText* txt_header_descr;
|
||||
NodeText* txt_author;
|
||||
NodeText* txt_descr;
|
||||
NodeText* txt_url;
|
||||
NodeText* txt_email;
|
||||
virtual Node* clone_instantiate() const override;
|
||||
virtual void clone_finalize(Node* dest) const override;
|
||||
virtual void init() override;
|
||||
|
||||
@@ -684,7 +684,7 @@ void NodePanelBrushPreset::add_brush(std::shared_ptr<Brush> brush)
|
||||
m_notification->SetVisibility(m_container->m_children.size() == 0);
|
||||
}
|
||||
|
||||
bool NodePanelBrushPreset::export_ppbr(const std::string& path, const Image& header_image)
|
||||
bool NodePanelBrushPreset::export_ppbr(const std::string& path, const PPBRInfo& info_data)
|
||||
{
|
||||
std::regex r(R"((.*)[\\/]([^\\/]+)\.(\w+)$)");
|
||||
std::smatch m;
|
||||
@@ -724,8 +724,12 @@ bool NodePanelBrushPreset::export_ppbr(const std::string& path, const Image& hea
|
||||
info.class_id = "ppbr_info";
|
||||
info.name = L"info header";
|
||||
|
||||
bool has_header_image = header_image.m_data != nullptr;
|
||||
bool has_header_image = info_data.header_image.m_data != nullptr;
|
||||
|
||||
info.props["author"] = std::make_shared<Serializer::String>(info_data.author);
|
||||
info.props["email"] = std::make_shared<Serializer::String>(info_data.email);
|
||||
info.props["url"] = std::make_shared<Serializer::String>(info_data.url);
|
||||
info.props["descr"] = std::make_shared<Serializer::String>(info_data.descr);
|
||||
info.props["has_header_image"] = std::make_shared<Serializer::Boolean>(has_header_image);
|
||||
info.props["num_brush_tips"] = std::make_shared<Serializer::Integer>(img_brushes.size());
|
||||
info.props["num_brush_patt"] = std::make_shared<Serializer::Integer>(img_patterns.size());
|
||||
@@ -739,8 +743,8 @@ bool NodePanelBrushPreset::export_ppbr(const std::string& path, const Image& hea
|
||||
// header image
|
||||
if (has_header_image)
|
||||
{
|
||||
sw << header_image;
|
||||
header_image.save_jpg(out_path + "/header.jpg", 75);
|
||||
sw << info_data.header_image;
|
||||
info_data.header_image.save_jpg(out_path + "/header.jpg", 75);
|
||||
}
|
||||
|
||||
pb->increment();
|
||||
|
||||
@@ -88,20 +88,32 @@ class NodePanelBrushPreset : public Node
|
||||
NodeButton* m_btn_download;
|
||||
Node* m_notification;
|
||||
public:
|
||||
struct PPBRInfo
|
||||
{
|
||||
std::string author;
|
||||
std::string email;
|
||||
std::string url;
|
||||
std::string descr;
|
||||
Image header_image;
|
||||
};
|
||||
|
||||
Node* m_container;
|
||||
std::function<void(Node* target, std::shared_ptr<Brush>& brush)> on_brush_changed;
|
||||
std::function<void(Node* target)> on_popup_close;
|
||||
|
||||
NodePanelBrushPreset();
|
||||
~NodePanelBrushPreset();
|
||||
|
||||
virtual Node* clone_instantiate() const override;
|
||||
virtual void init() override;
|
||||
virtual kEventResult handle_event(Event* e) override;
|
||||
virtual void added(Node* parent) override;
|
||||
|
||||
void handle_click(Node* target);
|
||||
bool save();
|
||||
bool restore();
|
||||
void add_brush(std::shared_ptr<Brush> brush);
|
||||
bool export_ppbr(const std::string& path, const Image& header_image);
|
||||
bool export_ppbr(const std::string& path, const PPBRInfo& info);
|
||||
bool import_ppbr(const std::string& path);
|
||||
bool import_abr(const std::string& path);
|
||||
bool import_brush(const std::string& path);
|
||||
|
||||
@@ -744,7 +744,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("Error image with %ld channels\n", channels.size());
|
||||
LOG("Error image with %zd channels\n", channels.size());
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user