export data flag, fix android create dir
This commit is contained in:
@@ -376,6 +376,7 @@ bool android_set_clipboard(const std::string& s)
|
|||||||
|
|
||||||
bool android_create_dir(const std::string& path)
|
bool android_create_dir(const std::string& path)
|
||||||
{
|
{
|
||||||
|
android_attach_jni();
|
||||||
jclass clazz = jni->GetObjectClass(g_engine.app->activity->clazz);
|
jclass clazz = jni->GetObjectClass(g_engine.app->activity->clazz);
|
||||||
jmethodID method = jni->GetMethodID(clazz, "createDir", "(Ljava/lang/String;)Z");
|
jmethodID method = jni->GetMethodID(clazz, "createDir", "(Ljava/lang/String;)Z");
|
||||||
jstring js = JniStringFromUTF8(path);
|
jstring js = JniStringFromUTF8(path);
|
||||||
|
|||||||
@@ -59,28 +59,30 @@
|
|||||||
<button id="header-open" text="Open" grow="1" height="100%"/>
|
<button id="header-open" text="Open" grow="1" height="100%"/>
|
||||||
<button id="header-clear" text="Clear" grow="1" height="100%"/>
|
<button id="header-clear" text="Clear" grow="1" height="100%"/>
|
||||||
</node>
|
</node>
|
||||||
<border color=".4" grow="1" pad="5" margin="10 0 0 0" justify="center">
|
<border os="win,mac,android" color=".4" grow="1" pad="5" margin="10 0 0 0" justify="center">
|
||||||
<node dir="row" align="center">
|
<node dir="row" align="center">
|
||||||
<checkbox id="export-data" width="30" aspect-ratio="1" margin="0 5 0 0"/>
|
<checkbox id="export-data" width="30" aspect-ratio="1" margin="0 5 0 0"/>
|
||||||
<text text="Export data"/>
|
<text text="Export data"/>
|
||||||
|
<node grow="1"/>
|
||||||
|
<button os="mac" id="pick-dest" text="Pick dest." pad="5"/>
|
||||||
</node>
|
</node>
|
||||||
<text color=".7" text-wrap-width="256" text="Note: exports the data into..."/>
|
<text color=".7" text-wrap-width="256" text="Save the generated preview images to a separete folder."/>
|
||||||
</border>
|
</border>
|
||||||
</node>
|
</node>
|
||||||
<node grow="1" dir="col">
|
<node grow="1" dir="col">
|
||||||
<node dir="row" height="30" align="center" grow="1" margin="0 0 4 0">
|
<node dir="row" height="30" align="center" margin="0 0 4 0">
|
||||||
<text text="Author" margin="0 5 0 0"/>
|
<text text="Author" margin="0 5 0 0"/>
|
||||||
<text-input id="info-author" pad="5" grow="1" height="30" color=".3"/>
|
<text-input id="info-author" pad="5" grow="1" height="30" color=".3"/>
|
||||||
</node>
|
</node>
|
||||||
<node dir="row" height="30" align="center" grow="1" margin="0 0 4 0">
|
<node dir="row" height="30" align="center" margin="0 0 4 0">
|
||||||
<text text="Email" margin="0 5 0 0"/>
|
<text text="Email" margin="0 5 0 0"/>
|
||||||
<text-input id="info-email" pad="5" grow="1" height="30" color=".3"/>
|
<text-input id="info-email" pad="5" grow="1" height="30" color=".3"/>
|
||||||
</node>
|
</node>
|
||||||
<node dir="row" height="30" align="center" grow="1" margin="0 0 4 0">
|
<node dir="row" height="30" align="center" margin="0 0 4 0">
|
||||||
<text text="URL" margin="0 5 0 0"/>
|
<text text="URL" margin="0 5 0 0"/>
|
||||||
<text-input id="info-url" pad="5" grow="1" height="30" color=".3"/>
|
<text-input id="info-url" pad="5" grow="1" height="30" color=".3"/>
|
||||||
</node>
|
</node>
|
||||||
<node dir="row" height="80" align="center" grow="2">
|
<node dir="row" grow="1">
|
||||||
<text text="Description" margin="0 5 0 0"/>
|
<text text="Description" margin="0 5 0 0"/>
|
||||||
<text-input id="info-descr" text-vertical-align="top" pad="5" grow="1" height="100%" color=".3" multiline="1"/>
|
<text-input id="info-descr" text-vertical-align="top" pad="5" grow="1" height="100%" color=".3" multiline="1"/>
|
||||||
</node>
|
</node>
|
||||||
|
|||||||
@@ -615,6 +615,7 @@ void App::dialog_ppbr_export()
|
|||||||
info.email = dialog->txt_email->m_text;
|
info.email = dialog->txt_email->m_text;
|
||||||
info.descr = dialog->txt_descr->m_text;
|
info.descr = dialog->txt_descr->m_text;
|
||||||
info.header_image = dialog->m_header_image;
|
info.header_image = dialog->m_header_image;
|
||||||
|
info.export_data = dialog->export_check->checked;
|
||||||
#if __IOS__
|
#if __IOS__
|
||||||
App::I->pick_file_save("ppbr",
|
App::I->pick_file_save("ppbr",
|
||||||
[this, dialog, info] (std::string path) {
|
[this, dialog, info] (std::string path) {
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ void NodeDialogExportPPBR::init_controls()
|
|||||||
txt_email = find<NodeTextInput>("info-email");
|
txt_email = find<NodeTextInput>("info-email");
|
||||||
txt_url = find<NodeTextInput>("info-url");
|
txt_url = find<NodeTextInput>("info-url");
|
||||||
txt_descr = find<NodeTextInput>("info-descr");
|
txt_descr = find<NodeTextInput>("info-descr");
|
||||||
|
export_check = find<NodeCheckBox>("export-data");
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeDialogExportPPBR::open_header()
|
void NodeDialogExportPPBR::open_header()
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "node_text.h"
|
#include "node_text.h"
|
||||||
#include "node_text_input.h"
|
#include "node_text_input.h"
|
||||||
#include "node_image_texture.h"
|
#include "node_image_texture.h"
|
||||||
|
#include "node_checkbox.h"
|
||||||
|
|
||||||
class NodeDialogExportPPBR : public NodeBorder
|
class NodeDialogExportPPBR : public NodeBorder
|
||||||
{
|
{
|
||||||
@@ -22,6 +23,7 @@ public:
|
|||||||
NodeTextInput* txt_descr;
|
NodeTextInput* txt_descr;
|
||||||
NodeTextInput* txt_url;
|
NodeTextInput* txt_url;
|
||||||
NodeTextInput* txt_email;
|
NodeTextInput* txt_email;
|
||||||
|
NodeCheckBox* export_check;
|
||||||
virtual Node* clone_instantiate() const override;
|
virtual Node* clone_instantiate() const override;
|
||||||
virtual void clone_finalize(Node* dest) const override;
|
virtual void clone_finalize(Node* dest) const override;
|
||||||
virtual void init() override;
|
virtual void init() override;
|
||||||
|
|||||||
@@ -686,7 +686,9 @@ void NodePanelBrushPreset::add_brush(std::shared_ptr<Brush> brush)
|
|||||||
|
|
||||||
bool NodePanelBrushPreset::export_ppbr(const std::string& path, const PPBRInfo& info_data)
|
bool NodePanelBrushPreset::export_ppbr(const std::string& path, const PPBRInfo& info_data)
|
||||||
{
|
{
|
||||||
std::regex r(R"((.*)[\\/]([^\\/]+)\.(\w+)$)");
|
LOG("export ppbr to: %s", path.c_str());
|
||||||
|
|
||||||
|
std::regex r(R"((.*)[\\/]([^\\/]+)(\.\w+)?$)");
|
||||||
std::smatch m;
|
std::smatch m;
|
||||||
if (!std::regex_search(path, m, r))
|
if (!std::regex_search(path, m, r))
|
||||||
return false;
|
return false;
|
||||||
@@ -695,7 +697,7 @@ bool NodePanelBrushPreset::export_ppbr(const std::string& path, const PPBRInfo&
|
|||||||
auto ext = m[3].str();
|
auto ext = m[3].str();
|
||||||
std::string out_path = base + "/" + name + "_data";
|
std::string out_path = base + "/" + name + "_data";
|
||||||
|
|
||||||
bool path_created = Asset::create_dir(out_path);
|
bool path_created = info_data.export_data ? Asset::create_dir(out_path) : false;
|
||||||
|
|
||||||
std::ofstream f(path, std::ios::binary);
|
std::ofstream f(path, std::ios::binary);
|
||||||
if (f.good())
|
if (f.good())
|
||||||
@@ -805,6 +807,7 @@ bool NodePanelBrushPreset::export_ppbr(const std::string& path, const PPBRInfo&
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
LOG("export failed file creation");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ public:
|
|||||||
std::string url;
|
std::string url;
|
||||||
std::string descr;
|
std::string descr;
|
||||||
std::shared_ptr<Image> header_image;
|
std::shared_ptr<Image> header_image;
|
||||||
|
bool export_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
Node* m_container;
|
Node* m_container;
|
||||||
|
|||||||
@@ -579,8 +579,7 @@ std::wstring str2wstr(const std::string& str)
|
|||||||
//return converted;
|
//return converted;
|
||||||
if (str.empty())
|
if (str.empty())
|
||||||
return {};
|
return {};
|
||||||
using convert_typeX = std::codecvt_utf8<wchar_t>;
|
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converterX;
|
||||||
std::wstring_convert<convert_typeX, wchar_t> converterX;
|
|
||||||
return converterX.from_bytes(str);
|
return converterX.from_bytes(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -594,8 +593,7 @@ std::string wstr2str(const std::wstring & wstr)
|
|||||||
//return converted;
|
//return converted;
|
||||||
if (wstr.empty())
|
if (wstr.empty())
|
||||||
return {};
|
return {};
|
||||||
using convert_typeX = std::codecvt_utf8<wchar_t>;
|
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converterX;
|
||||||
std::wstring_convert<convert_typeX, wchar_t> converterX;
|
|
||||||
return converterX.to_bytes(wstr);
|
return converterX.to_bytes(wstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user