export data flag, fix android create dir

This commit is contained in:
2019-09-23 00:48:25 +02:00
parent 1d1aef4095
commit d91f730cbd
8 changed files with 21 additions and 12 deletions

View File

@@ -376,6 +376,7 @@ bool android_set_clipboard(const std::string& s)
bool android_create_dir(const std::string& path)
{
android_attach_jni();
jclass clazz = jni->GetObjectClass(g_engine.app->activity->clazz);
jmethodID method = jni->GetMethodID(clazz, "createDir", "(Ljava/lang/String;)Z");
jstring js = JniStringFromUTF8(path);

View File

@@ -59,28 +59,30 @@
<button id="header-open" text="Open" grow="1" height="100%"/>
<button id="header-clear" text="Clear" grow="1" height="100%"/>
</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">
<checkbox id="export-data" width="30" aspect-ratio="1" margin="0 5 0 0"/>
<text text="Export data"/>
<node grow="1"/>
<button os="mac" id="pick-dest" text="Pick dest." pad="5"/>
</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>
</node>
<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-input id="info-author" pad="5" grow="1" height="30" color=".3"/>
</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-input id="info-email" pad="5" grow="1" height="30" color=".3"/>
</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-input id="info-url" pad="5" grow="1" height="30" color=".3"/>
</node>
<node dir="row" height="80" align="center" grow="2">
<node dir="row" grow="1">
<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"/>
</node>

View File

@@ -615,6 +615,7 @@ void App::dialog_ppbr_export()
info.email = dialog->txt_email->m_text;
info.descr = dialog->txt_descr->m_text;
info.header_image = dialog->m_header_image;
info.export_data = dialog->export_check->checked;
#if __IOS__
App::I->pick_file_save("ppbr",
[this, dialog, info] (std::string path) {

View File

@@ -53,6 +53,7 @@ void NodeDialogExportPPBR::init_controls()
txt_email = find<NodeTextInput>("info-email");
txt_url = find<NodeTextInput>("info-url");
txt_descr = find<NodeTextInput>("info-descr");
export_check = find<NodeCheckBox>("export-data");
}
void NodeDialogExportPPBR::open_header()

View File

@@ -5,6 +5,7 @@
#include "node_text.h"
#include "node_text_input.h"
#include "node_image_texture.h"
#include "node_checkbox.h"
class NodeDialogExportPPBR : public NodeBorder
{
@@ -22,6 +23,7 @@ public:
NodeTextInput* txt_descr;
NodeTextInput* txt_url;
NodeTextInput* txt_email;
NodeCheckBox* export_check;
virtual Node* clone_instantiate() const override;
virtual void clone_finalize(Node* dest) const override;
virtual void init() override;

View File

@@ -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)
{
std::regex r(R"((.*)[\\/]([^\\/]+)\.(\w+)$)");
LOG("export ppbr to: %s", path.c_str());
std::regex r(R"((.*)[\\/]([^\\/]+)(\.\w+)?$)");
std::smatch m;
if (!std::regex_search(path, m, r))
return false;
@@ -695,7 +697,7 @@ bool NodePanelBrushPreset::export_ppbr(const std::string& path, const PPBRInfo&
auto ext = m[3].str();
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);
if (f.good())
@@ -805,6 +807,7 @@ bool NodePanelBrushPreset::export_ppbr(const std::string& path, const PPBRInfo&
return true;
}
LOG("export failed file creation");
return false;
}

View File

@@ -95,6 +95,7 @@ public:
std::string url;
std::string descr;
std::shared_ptr<Image> header_image;
bool export_data;
};
Node* m_container;

View File

@@ -579,8 +579,7 @@ std::wstring str2wstr(const std::string& str)
//return converted;
if (str.empty())
return {};
using convert_typeX = std::codecvt_utf8<wchar_t>;
std::wstring_convert<convert_typeX, wchar_t> converterX;
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converterX;
return converterX.from_bytes(str);
}
@@ -594,8 +593,7 @@ std::string wstr2str(const std::wstring & wstr)
//return converted;
if (wstr.empty())
return {};
using convert_typeX = std::codecvt_utf8<wchar_t>;
std::wstring_convert<convert_typeX, wchar_t> converterX;
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converterX;
return converterX.to_bytes(wstr);
}