fix iOS save picker
This commit is contained in:
@@ -121,6 +121,13 @@ std::recursive_mutex lock_mutex;
|
|||||||
{
|
{
|
||||||
LOG("error creating rec path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
LOG("error creating rec path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
||||||
}
|
}
|
||||||
|
// tmp
|
||||||
|
NSString* tmppath = [docpath stringByAppendingString:@"/tmp"];
|
||||||
|
App::I->tmp_path = [tmppath cStringUsingEncoding:NSASCIIStringEncoding];
|
||||||
|
if (![[NSFileManager defaultManager] createDirectoryAtPath:tmppath withIntermediateDirectories:YES attributes:nil error:&err])
|
||||||
|
{
|
||||||
|
LOG("error creating rec path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
||||||
|
}
|
||||||
// brushes
|
// brushes
|
||||||
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/brushes"] withIntermediateDirectories:YES attributes:nil error:&err])
|
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/brushes"] withIntermediateDirectories:YES attributes:nil error:&err])
|
||||||
{
|
{
|
||||||
@@ -189,7 +196,7 @@ std::recursive_mutex lock_mutex;
|
|||||||
- (void)pick_file_save:(std::string)path
|
- (void)pick_file_save:(std::string)path
|
||||||
{
|
{
|
||||||
NSURL* url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:path.c_str()]];
|
NSURL* url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:path.c_str()]];
|
||||||
GameFilePicker *picker = [[GameFilePicker alloc] initWithURL:url inMode:UIDocumentPickerModeMoveToService];
|
GameFilePicker *picker = [[GameFilePicker alloc] initWithURL:url inMode:UIDocumentPickerModeExportToService];
|
||||||
picker.delegate = self;
|
picker.delegate = self;
|
||||||
[self presentViewController:picker animated:YES completion:NULL];
|
[self presentViewController:picker animated:YES completion:NULL];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -781,7 +781,7 @@ void App::rec_export(std::string path)
|
|||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
Canvas::I->m_encoder->write_mp4(data_path + "/export.mp4");
|
Canvas::I->m_encoder->write_mp4(path);
|
||||||
|
|
||||||
pb->destroy();
|
pb->destroy();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ public:
|
|||||||
std::string data_path{ "." };
|
std::string data_path{ "." };
|
||||||
std::string work_path{ "." };
|
std::string work_path{ "." };
|
||||||
std::string rec_path{ "." };
|
std::string rec_path{ "." };
|
||||||
|
std::string tmp_path{ "." };
|
||||||
std::thread rec_thread;
|
std::thread rec_thread;
|
||||||
bool rec_running = false;
|
bool rec_running = false;
|
||||||
int rec_count = 0;
|
int rec_count = 0;
|
||||||
@@ -174,8 +175,8 @@ public:
|
|||||||
void pick_image(std::function<void(std::string path)> callback);
|
void pick_image(std::function<void(std::string path)> callback);
|
||||||
void pick_file(std::vector<std::string> types, std::function<void(std::string path)> callback);
|
void pick_file(std::vector<std::string> types, std::function<void(std::string path)> callback);
|
||||||
#if __IOS__ || __WEB__
|
#if __IOS__ || __WEB__
|
||||||
void pick_file_save(const std::string& type, std::function<void(std::string path)> writer,
|
void pick_file_save(const std::string& type, const std::string& default_name,
|
||||||
std::function<void(bool saved)> callback);
|
std::function<void(std::string path)> writer, std::function<void(const std::string& path, bool saved)> callback);
|
||||||
#else
|
#else
|
||||||
void pick_file_save(std::vector<std::string> types, std::function<void(std::string path)> callback);
|
void pick_file_save(std::vector<std::string> types, std::function<void(std::string path)> callback);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -624,11 +624,11 @@ void App::dialog_ppbr_export()
|
|||||||
if (dialog->export_check)
|
if (dialog->export_check)
|
||||||
info.export_data = dialog->export_check->checked;
|
info.export_data = dialog->export_check->checked;
|
||||||
#if __IOS__ || __WEB__
|
#if __IOS__ || __WEB__
|
||||||
App::I->pick_file_save("ppbr",
|
App::I->pick_file_save("ppbr", "exported-brushes",
|
||||||
[this, dialog, info] (std::string path) {
|
[this, dialog, info] (std::string path) {
|
||||||
presets->export_ppbr(path, info);
|
presets->export_ppbr(path, info);
|
||||||
},
|
},
|
||||||
[dialog] (bool saved) {
|
[dialog] (const std::string& path, bool saved) {
|
||||||
if (saved)
|
if (saved)
|
||||||
dialog->destroy();
|
dialog->destroy();
|
||||||
}
|
}
|
||||||
@@ -649,11 +649,11 @@ void App::dialog_ppbr_export()
|
|||||||
void App::dialog_timelapse_export()
|
void App::dialog_timelapse_export()
|
||||||
{
|
{
|
||||||
#if __IOS__ || __WEB__
|
#if __IOS__ || __WEB__
|
||||||
pick_file_save("mp4",
|
pick_file_save("mp4", doc_name + "-timelapse",
|
||||||
[this](std::string path) {
|
[this](std::string path) {
|
||||||
rec_export(path);
|
rec_export(path);
|
||||||
},
|
},
|
||||||
[this](bool saved) {
|
[this](const std::string& path, bool saved) {
|
||||||
message_box("Export Timelapse", "Timelapse exported succesfully.");
|
message_box("Export Timelapse", "Timelapse exported succesfully.");
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -236,41 +236,29 @@ void App::pick_file(std::vector<std::string> types, std::function<void (std::str
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if __IOS__
|
#if __IOS__
|
||||||
void App::pick_file_save(const std::string& type, std::function<void(std::string)> writer,
|
void App::pick_file_save(const std::string& type, const std::string& default_name,
|
||||||
std::function<void(bool saved)> callback)
|
std::function<void(std::string)> writer, std::function<void(const std::string& path, bool saved)> callback)
|
||||||
{
|
{
|
||||||
redraw = true;
|
redraw = true;
|
||||||
auto mb = input_box("Insert", "File name");
|
std::string ext = "." + type;
|
||||||
std::string placeholder = "name." + type;
|
std::string path = tmp_path + "/" + default_name + ext;
|
||||||
mb->m_field_text->set_text(placeholder.c_str());
|
std::thread([=]{
|
||||||
mb->on_submit = [this, writer, type, callback, mb] (Node* target, std::string name) {
|
writer(path);
|
||||||
std::string ext = "." + type;
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
std::string path = data_path + "/" + name;
|
[ios_view pick_file_save:path];
|
||||||
if (name.find(ext) == std::string::npos)
|
});
|
||||||
path += ext;
|
callback(path, true);
|
||||||
std::thread([=]{
|
}).detach();
|
||||||
writer(path);
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
|
||||||
[ios_view pick_file_save:path];
|
|
||||||
});
|
|
||||||
mb->destroy();
|
|
||||||
callback(true);
|
|
||||||
}).detach();
|
|
||||||
};
|
|
||||||
mb->btn_cancel->on_click = [=] (Node* target) {
|
|
||||||
callback(false);
|
|
||||||
mb->destroy();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
#elif __WEB__
|
#elif __WEB__
|
||||||
void App::pick_file_save(const std::string& type, std::function<void(std::string)> writer,
|
void App::pick_file_save(const std::string& type, const std::string& default_name,
|
||||||
std::function<void(bool saved)> callback)
|
std::function<void(std::string)> writer, std::function<void(const std::string& path, bool saved)> callback)
|
||||||
{
|
{
|
||||||
redraw = true;
|
redraw = true;
|
||||||
auto path = data_path + "/file-save." + type;
|
auto path = data_path + "/" + default_name + "." + type;
|
||||||
LOG("App::pick_file_save %s", path.c_str());
|
LOG("App::pick_file_save %s", path.c_str());
|
||||||
writer(path);
|
writer(path);
|
||||||
webgl_pick_file_save(path, "file." + type, callback);
|
webgl_pick_file_save(path, default_name + "." + type, callback);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void App::pick_file_save(std::vector<std::string> types, std::function<void(std::string)> callback)
|
void App::pick_file_save(std::vector<std::string> types, std::function<void(std::string)> callback)
|
||||||
|
|||||||
Reference in New Issue
Block a user