mirror of
https://github.com/arabine/open-story-teller.git
synced 2025-12-06 17:09:06 +01:00
media node fixes + (WIP) open project
This commit is contained in:
parent
3f3e589fde
commit
3c01a29c66
6 changed files with 112 additions and 6 deletions
|
|
@ -75,12 +75,13 @@ void BaseNode::DrawPins()
|
|||
ed::EndPin();
|
||||
}
|
||||
|
||||
int i = 1;
|
||||
for (auto& output : m_node->Outputs)
|
||||
{
|
||||
ImGui::Dummy(ImVec2(320 - textWidth * 2, 0)); // Hacky magic number to space out the output pin.
|
||||
ImGui::SameLine();
|
||||
ed::BeginPin(output.ID, ed::PinKind::Output);
|
||||
ImGui::Text( "#1 " ICON_MDI_OCTAGON_OUTLINE );
|
||||
ImGui::Text( "#%d " ICON_MDI_OCTAGON_OUTLINE, i++);
|
||||
ed::EndPin();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ void MainWindow::SetupMainMenuBar()
|
|||
bool showAboutPopup = false;
|
||||
bool showParameters = false;
|
||||
bool showNewProject = false;
|
||||
bool showOpenProject = false;
|
||||
|
||||
if (ImGui::BeginMainMenuBar())
|
||||
{
|
||||
|
|
@ -41,6 +42,11 @@ void MainWindow::SetupMainMenuBar()
|
|||
showNewProject = true;
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("Open project"))
|
||||
{
|
||||
showOpenProject = true;
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("Close project"))
|
||||
{
|
||||
CloseProject();
|
||||
|
|
@ -81,6 +87,11 @@ void MainWindow::SetupMainMenuBar()
|
|||
ImGui::OpenPopup("NewProjectPopup");
|
||||
}
|
||||
|
||||
if (showOpenProject)
|
||||
{
|
||||
ImGuiFileDialog::Instance()->OpenDialog("OpenProjectDlgKey", "Choose File", "project.json", ".", 1, nullptr, ImGuiFileDialogFlags_Modal);
|
||||
}
|
||||
|
||||
// Always center this window when appearing
|
||||
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
|
||||
//ImVec2 parent_pos = ImGui::GetWindowPos();
|
||||
|
|
@ -247,6 +258,89 @@ bool MainWindow::ShowQuitConfirm()
|
|||
}
|
||||
|
||||
|
||||
void MainWindow::OpenProjectDialog()
|
||||
{
|
||||
if (ImGuiFileDialog::Instance()->Display("OpenProjectDlgKey"))
|
||||
{
|
||||
// action if OK
|
||||
if (ImGuiFileDialog::Instance()->IsOk())
|
||||
{
|
||||
std::string filePathName = ImGuiFileDialog::Instance()->GetFilePathName();
|
||||
std::string filePath = ImGuiFileDialog::Instance()->GetCurrentPath();
|
||||
|
||||
bool success = false;
|
||||
|
||||
m_project.Initialize(filePathName);
|
||||
|
||||
nlohmann::json model;
|
||||
|
||||
if (m_project.Load(filePathName, model))
|
||||
{
|
||||
m_model.Load(model);
|
||||
EnableProject();
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << errorMsg;
|
||||
QMessageBox::critical(this, tr("Open project error"), errorMsg);
|
||||
}
|
||||
|
||||
m_resourceModel.EndChange();
|
||||
RefreshProjectInformation();
|
||||
|
||||
/*
|
||||
|
||||
// action
|
||||
|
||||
|
||||
std::filesystem::path p(filePathName);
|
||||
std::filesystem::path p2 = m_project.AssetsPath() / p.filename().generic_string();
|
||||
std::filesystem::copy(p, p2, std::filesystem::copy_options::overwrite_existing);
|
||||
|
||||
Resource res;
|
||||
|
||||
std::string ext = p.extension().string();
|
||||
ext.erase(ext.begin()); // remove '.' dot sign
|
||||
std::transform(ext.begin(), ext.end(), ext.begin(), ::toupper);
|
||||
|
||||
res.format = ext;
|
||||
res.type = m_soundFile ? "sound" : "image";
|
||||
res.file = p.filename().generic_string();
|
||||
m_project.AppendResource(res);
|
||||
*/
|
||||
}
|
||||
|
||||
// close
|
||||
ImGuiFileDialog::Instance()->Close();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::EnableProject()
|
||||
{
|
||||
// Add to recent if not exists
|
||||
if (!m_recentProjects.contains(m_project.GetProjectFilePath().c_str()))
|
||||
{
|
||||
m_recentProjects.push_front(m_project.GetProjectFilePath().c_str());
|
||||
// Limit to 10 recent projects
|
||||
if (m_recentProjects.size() > 10) {
|
||||
m_recentProjects.pop_back();
|
||||
}
|
||||
m_toolbar->GenerateRecentProjectsMenu(m_recentProjects);
|
||||
}
|
||||
|
||||
m_ostHmiDock->Open();
|
||||
m_resourcesDock->Open();
|
||||
m_scriptEditorDock->Open();
|
||||
m_vmDock->Open();
|
||||
m_ramView->Open();
|
||||
m_romView->Open();
|
||||
m_logDock->Open();
|
||||
|
||||
m_toolbar->SetActionsActive(true);
|
||||
m_view->setEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::NewProjectPopup()
|
||||
{
|
||||
static std::string projdir;
|
||||
|
|
@ -443,14 +537,10 @@ void MainWindow::SaveProject()
|
|||
m_project.Save(model);
|
||||
}
|
||||
|
||||
void MainWindow::EnableProject()
|
||||
{
|
||||
// FIXME
|
||||
}
|
||||
|
||||
void MainWindow::CloseProject()
|
||||
{
|
||||
m_project.Clear();
|
||||
m_nodeEditorWindow.Clear();
|
||||
|
||||
// m_model.Clear();
|
||||
|
||||
|
|
@ -491,6 +581,7 @@ void MainWindow::Loop()
|
|||
ShowOptionsWindow();
|
||||
|
||||
NewProjectPopup();
|
||||
OpenProjectDialog();
|
||||
|
||||
if (aboutToClose)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ private:
|
|||
void SaveProject();
|
||||
void EnableProject();
|
||||
void CloseProject();
|
||||
void OpenProjectDialog();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
|||
|
|
@ -107,6 +107,13 @@ void MediaNode::Draw()
|
|||
AddOutput();
|
||||
}
|
||||
}
|
||||
else if (counter < Outputs())
|
||||
{
|
||||
for (int i = 0; i < (Outputs() - counter); i++)
|
||||
{
|
||||
DeleteOutput();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DrawPins();
|
||||
|
|
|
|||
|
|
@ -35,6 +35,11 @@ void NodeEditorWindow::Initialize()
|
|||
|
||||
}
|
||||
|
||||
void NodeEditorWindow::Clear()
|
||||
{
|
||||
m_nodes.clear();
|
||||
}
|
||||
|
||||
void NodeEditorWindow::Draw(const char *title, bool *p_open)
|
||||
{
|
||||
static bool resetDockspace = true;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public:
|
|||
void Draw(const char *title, bool *p_open);
|
||||
|
||||
void Initialize();
|
||||
void Clear();
|
||||
private:
|
||||
ed::EditorContext* m_context = nullptr;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue