implement work_path for documents and data_path for assets

This commit is contained in:
2018-10-07 16:20:05 +02:00
parent 05decb6a05
commit e2069fadca
16 changed files with 64 additions and 74 deletions

View File

@@ -90,12 +90,15 @@ void App::dialog_newdoc()
dialog->btn_ok->on_click = [this, dialog](Node*)
{
std::string name = dialog->input->m_string;
std::string path = data_path + "/" + name + ".ppi";
std::string path = work_path + "/" + name + ".ppi";
auto action = [this, dialog, name] {
auto action = [this, dialog, name, path] {
std::array<int, 4> resolutions{ 512, 1024, 1536, 2048 };
int res = resolutions[dialog->m_resolution->m_current_index];
doc_name = name;
doc_path = path;
doc_filename = name + ".ppi";
doc_dir = work_path;
layers->clear();
canvas->m_canvas->m_layers.clear();
@@ -176,7 +179,6 @@ void App::dialog_open()
// load thumbnail test
auto dialog = std::make_shared<NodeDialogOpen>();
dialog->m_manager = &layout;
dialog->data_path = data_path;
dialog->init();
dialog->create();
dialog->loaded();
@@ -237,7 +239,7 @@ void App::dialog_browse()
// load thumbnail test
auto dialog = std::make_shared<NodeDialogBrowse>();
dialog->m_manager = &layout;
dialog->data_path = data_path;
dialog->search_path = work_path;
dialog->init();
dialog->create();
dialog->loaded();
@@ -302,14 +304,15 @@ void App::dialog_save_ver()
static char tmp_name[256];
sprintf(tmp_name, "%s.%02d", base.c_str(), i);
next = tmp_name;
if (Asset::exist(data_path + "/" + next + ".ppi", false))
if (Asset::exist(doc_dir + "/" + next + ".ppi", false))
continue;
break;
}
doc_name = next;
doc_path = doc_dir + "/" + next + ".ppi";
title_update();
canvas->m_canvas->project_save(data_path + "/" + next + ".ppi");
canvas->m_canvas->project_save(doc_path);
}
void App::dialog_save()
@@ -328,7 +331,7 @@ void App::dialog_save()
dialog->btn_ok->on_click = [this, dialog](Node*)
{
std::string name = dialog->input->m_string;
std::string path = data_path + "/" + name + ".ppi";
std::string path = work_path + "/" + name + ".ppi";
if (name.empty())
{
@@ -343,6 +346,8 @@ void App::dialog_save()
auto action = [this, dialog, name, path] {
doc_name = name;
doc_path = path;
doc_dir = work_path;
title_update();
canvas->m_canvas->project_save(path);
dialog->destroy();
@@ -383,7 +388,8 @@ void App::dialog_export()
{
if (canvas)
{
canvas->m_canvas->export_equirectangular(data_path + "/" + doc_name + ".jpg", [this]{
// TODO: use picker
canvas->m_canvas->export_equirectangular(work_path + "/" + doc_name + ".jpg", [this]{
#if defined(__IOS__)
message_box("Export JPG", "Image exported to Photos");
#elif defined(__OSX__)
@@ -424,7 +430,7 @@ void App::dialog_export_cubes()
{
if (canvas)
{
canvas->m_canvas->export_cubes(data_path + "/" + doc_name);
canvas->m_canvas->export_cubes();
}
}
@@ -432,7 +438,6 @@ void App::dialog_layer_rename()
{
auto dialog = std::make_shared<NodeDialogLayerRename>();
dialog->m_manager = &layout;
dialog->data_path = data_path;
dialog->init();
dialog->create();
dialog->loaded();