diff --git a/editor/src/editor/Editor.cpp b/editor/src/editor/Editor.cpp index ba16d43f..43b012bb 100644 --- a/editor/src/editor/Editor.cpp +++ b/editor/src/editor/Editor.cpp @@ -11,6 +11,7 @@ #include "NativeHelpers.h" #include #include +#include #include #include #include @@ -30,6 +31,7 @@ struct Editor::Impl : EditorController::Receiver, IControlListener { SharedPointer mainView_; std::string currentSfzFile_; + std::string currentScalaFile_; enum { kPanelGeneral, @@ -226,6 +228,7 @@ void Editor::Impl::uiReceiveValue(EditId id, const EditValue& v) case EditId::ScalaFile: { const std::string& value = v.to_string(); + currentScalaFile_ = value; updateScalaFileLabel(value); } break; @@ -663,6 +666,10 @@ void Editor::Impl::chooseSfzFile() fs->setTitle("Load SFZ file"); fs->setDefaultExtension(CFileExtension("SFZ", "sfz")); + if (!currentSfzFile_.empty()) { + std::string initialDir = fs::path(currentSfzFile_).parent_path().u8string() + '/'; + fs->setInitialDirectory(initialDir.c_str()); + } if (fs->runModal()) { UTF8StringPtr file = fs->getSelectedFile(0); @@ -684,6 +691,10 @@ void Editor::Impl::chooseScalaFile() fs->setTitle("Load Scala file"); fs->setDefaultExtension(CFileExtension("SCL", "scl")); + if (!currentScalaFile_.empty()) { + std::string initialDir = fs::path(currentScalaFile_).parent_path().u8string() + '/'; + fs->setInitialDirectory(initialDir.c_str()); + } if (fs->runModal()) { UTF8StringPtr file = fs->getSelectedFile(0); @@ -695,6 +706,7 @@ void Editor::Impl::chooseScalaFile() void Editor::Impl::changeScalaFile(const std::string& filePath) { ctrl_->uiSendValue(EditId::ScalaFile, filePath); + currentScalaFile_ = filePath; updateScalaFileLabel(filePath); }