mirror of
https://github.com/arabine/open-story-teller.git
synced 2025-12-06 17:09:06 +01:00
Multiple fixes on project management, fix resource copy bugs
This commit is contained in:
parent
c23176796f
commit
59921fe9fd
7 changed files with 33 additions and 10 deletions
|
|
@ -104,7 +104,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
int OutputsCount(const std::string &nodeId) const
|
int OutputsCount(const std::string &nodeId) const
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (const auto & l : m_links)
|
for (const auto & l : m_links)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,8 @@ void StoryProject::New(const std::string &uuid, const std::string &library_path)
|
||||||
|
|
||||||
std::filesystem::create_directories(m_assetsPath);
|
std::filesystem::create_directories(m_assetsPath);
|
||||||
|
|
||||||
|
CreatePage(MainUuid());
|
||||||
|
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -422,7 +424,7 @@ bool StoryProject::Load(ResourceManager &manager)
|
||||||
|
|
||||||
if (j.contains("pages"))
|
if (j.contains("pages"))
|
||||||
{
|
{
|
||||||
ModelFromJson(j["pages"]);
|
ModelFromJson(j);
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -433,6 +435,11 @@ bool StoryProject::Load(ResourceManager &manager)
|
||||||
std::cout << e.what() << std::endl;
|
std::cout << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_pages.size() == 0)
|
||||||
|
{
|
||||||
|
CreatePage(MainUuid());
|
||||||
|
}
|
||||||
|
|
||||||
return m_initialized;
|
return m_initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,11 @@ public:
|
||||||
|
|
||||||
StoryNode *m_tree;
|
StoryNode *m_tree;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
std::string MainUuid() const {
|
||||||
|
return "490745ab-df4d-476d-ae27-027e94b8ee0a";
|
||||||
|
}
|
||||||
|
|
||||||
void New(const std::string &uuid, const std::string &library_path);
|
void New(const std::string &uuid, const std::string &library_path);
|
||||||
std::filesystem::path BinaryFileName() const;
|
std::filesystem::path BinaryFileName() const;
|
||||||
bool GenerateScript(std::string &codeStr);
|
bool GenerateScript(std::string &codeStr);
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ $MyArray DV8 10 ; array of 10 bytes
|
||||||
StoryProject proj(m_log);
|
StoryProject proj(m_log);
|
||||||
ResourceManager res(m_log);
|
ResourceManager res(m_log);
|
||||||
|
|
||||||
std::shared_ptr<StoryPage> page = proj.CreatePage("main");
|
std::shared_ptr<StoryPage> page = proj.CreatePage(proj.MainUuid());
|
||||||
|
|
||||||
|
|
||||||
proj.New(uuid, outputDir);
|
proj.New(uuid, outputDir);
|
||||||
|
|
@ -396,7 +396,7 @@ bool PackArchive::ConvertJsonStudioToOst(const std::string &basePath, const std:
|
||||||
StoryProject proj(m_log);
|
StoryProject proj(m_log);
|
||||||
ResourceManager res(m_log);
|
ResourceManager res(m_log);
|
||||||
|
|
||||||
std::shared_ptr<StoryPage> page = proj.CreatePage("main");
|
std::shared_ptr<StoryPage> page = proj.CreatePage(proj.MainUuid());
|
||||||
|
|
||||||
if (j.contains("title"))
|
if (j.contains("title"))
|
||||||
{
|
{
|
||||||
|
|
@ -428,7 +428,7 @@ bool PackArchive::ConvertJsonStudioToOst(const std::string &basePath, const std:
|
||||||
|
|
||||||
for (const auto & n : j["stageNodes"])
|
for (const auto & n : j["stageNodes"])
|
||||||
{
|
{
|
||||||
auto node = proj.CreateNode("main", "media-node");
|
auto node = proj.CreateNode(proj.MainUuid(), "media-node");
|
||||||
|
|
||||||
if (node)
|
if (node)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -37,14 +37,14 @@ NodeEditorWindow::~NodeEditorWindow()
|
||||||
m_story.reset();
|
m_story.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
static const std::string gMainUuid = "490745ab-df4d-476d-ae27-027e94b8ee0a";
|
|
||||||
|
|
||||||
void NodeEditorWindow::Initialize()
|
void NodeEditorWindow::Initialize()
|
||||||
{
|
{
|
||||||
m_pages.clear();
|
m_pages.clear();
|
||||||
m_callStack.clear();
|
m_callStack.clear();
|
||||||
|
|
||||||
m_currentPage = std::make_shared<NodeEditorPage>(gMainUuid, "Main");
|
m_currentPage = std::make_shared<NodeEditorPage>(m_story->MainUuid(), "Main");
|
||||||
m_pages.push_back(m_currentPage);
|
m_pages.push_back(m_currentPage);
|
||||||
m_callStack.push_back(m_currentPage);
|
m_callStack.push_back(m_currentPage);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ private:
|
||||||
|
|
||||||
bool m_loaded{false};
|
bool m_loaded{false};
|
||||||
|
|
||||||
// "main" is the entry point editor context. You always need to create one.
|
// "MainUuid" is the entry point editor context. You always need to create one.
|
||||||
// Then each function can have its own editor context, for example if you want to create multiple graphs.
|
// Then each function can have its own editor context, for example if you want to create multiple graphs.
|
||||||
// the key is main, or the UUID of the function
|
// the key is main, or the UUID of the function
|
||||||
std::list<std::shared_ptr<NodeEditorPage>> m_pages;
|
std::list<std::shared_ptr<NodeEditorPage>> m_pages;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ void ResourcesWindow::ChooseFile()
|
||||||
m_showImportDialog = false;
|
m_showImportDialog = false;
|
||||||
// open Dialog Simple
|
// open Dialog Simple
|
||||||
IGFD::FileDialogConfig config;
|
IGFD::FileDialogConfig config;
|
||||||
config.path = ".";
|
config.path = m_story.BuildFullAssetsPath("");
|
||||||
config.countSelectionMax = 1;
|
config.countSelectionMax = 1;
|
||||||
config.sidePaneWidth = 350.0f;
|
config.sidePaneWidth = 350.0f;
|
||||||
config.flags = ImGuiFileDialogFlags_Modal;
|
config.flags = ImGuiFileDialogFlags_Modal;
|
||||||
|
|
@ -50,7 +50,18 @@ void ResourcesWindow::ChooseFile()
|
||||||
|
|
||||||
std::filesystem::path p(filePathName);
|
std::filesystem::path p(filePathName);
|
||||||
std::filesystem::path p2 = m_story.BuildFullAssetsPath( p.filename().generic_string());
|
std::filesystem::path p2 = m_story.BuildFullAssetsPath( p.filename().generic_string());
|
||||||
std::filesystem::copy(p, p2, std::filesystem::copy_options::overwrite_existing);
|
|
||||||
|
bool allowCopy = true;
|
||||||
|
// On ne copie pas le fichier sur lui-même
|
||||||
|
if (std::filesystem::exists(p) && std::filesystem::exists(p2))
|
||||||
|
{
|
||||||
|
allowCopy = !std::filesystem::equivalent(p, p2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allowCopy)
|
||||||
|
{
|
||||||
|
std::filesystem::copy(p, p2, std::filesystem::copy_options::overwrite_existing);
|
||||||
|
}
|
||||||
|
|
||||||
auto res = std::make_shared<Resource>();
|
auto res = std::make_shared<Resource>();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue