diff --git a/Core/Contents/Source/PolyWinCore.cpp b/Core/Contents/Source/PolyWinCore.cpp index 4f06a0a35..a52c3eac5 100644 --- a/Core/Contents/Source/PolyWinCore.cpp +++ b/Core/Contents/Source/PolyWinCore.cpp @@ -1137,7 +1137,7 @@ std::vector Win32Core::openFilePicker(std::vector ext ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir=NULL; - if(allowMultiple) { + if(!allowMultiple) { ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_EXPLORER; } else { ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT|OFN_EXPLORER; @@ -1147,7 +1147,23 @@ std::vector Win32Core::openFilePicker(std::vector ext if(GetOpenFileName(&ofn)) { if(allowMultiple) { - + String dir = fBuffer; + size_t pos = dir.length(), last = 0; + while (true){ + if (fBuffer[pos + 1] == NULL){ + if (retVec.size() == 0){ + retVec.push_back(dir); + } + break; + } else { + String fileName; + for (last = pos + 1; fBuffer[pos + 1] != NULL; pos++){ + fileName.append(fBuffer[pos + 1]); + } + retVec.push_back(dir + "/" + fileName); + pos++; + } + } } else { retVec.push_back(String(fBuffer)); } diff --git a/IDE/Build/Windows2013/Polycode.rc b/IDE/Build/Windows2013/Polycode.rc index d73e4349e..8f4b134a1 100644 Binary files a/IDE/Build/Windows2013/Polycode.rc and b/IDE/Build/Windows2013/Polycode.rc differ diff --git a/IDE/Build/Windows2013/Polycode.sln b/IDE/Build/Windows2013/Polycode.sln index 02b3dad1f..67ae375fa 100644 --- a/IDE/Build/Windows2013/Polycode.sln +++ b/IDE/Build/Windows2013/Polycode.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 2013 for Windows Desktop -VisualStudioVersion = 12.0.21005.1 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30723.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Polycode", "Polycode.vcxproj", "{D6C2171B-9167-4FB6-851A-DC1CEDCFC43D}" EndProject @@ -18,8 +18,8 @@ Global Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D6C2171B-9167-4FB6-851A-DC1CEDCFC43D}.Debug|Win32.ActiveCfg = Debug|x64 - {D6C2171B-9167-4FB6-851A-DC1CEDCFC43D}.Debug|Win32.Build.0 = Debug|x64 + {D6C2171B-9167-4FB6-851A-DC1CEDCFC43D}.Debug|Win32.ActiveCfg = Debug|Win32 + {D6C2171B-9167-4FB6-851A-DC1CEDCFC43D}.Debug|Win32.Build.0 = Debug|Win32 {D6C2171B-9167-4FB6-851A-DC1CEDCFC43D}.Debug|x64.ActiveCfg = Debug|x64 {D6C2171B-9167-4FB6-851A-DC1CEDCFC43D}.Debug|x64.Build.0 = Debug|x64 {D6C2171B-9167-4FB6-851A-DC1CEDCFC43D}.Release|Win32.ActiveCfg = Release|Win32 diff --git a/IDE/Build/Windows2013/resource.h b/IDE/Build/Windows2013/resource.h index de8ce9694..e1e0b7a7f 100644 Binary files a/IDE/Build/Windows2013/resource.h and b/IDE/Build/Windows2013/resource.h differ diff --git a/IDE/Build/WindowsShared/PolycodeWinIDEView.cpp b/IDE/Build/WindowsShared/PolycodeWinIDEView.cpp index c6f06ab8e..3504734a8 100644 --- a/IDE/Build/WindowsShared/PolycodeWinIDEView.cpp +++ b/IDE/Build/WindowsShared/PolycodeWinIDEView.cpp @@ -70,6 +70,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case ID_FILE_OPEN_PROJECT: globalApp->openProject(); break; + case ID_FILE_OPEN_FILE: + globalApp->openFilePicker(); + break; case ID_FILE_CLOSE_FILE: globalApp->closeFile(); break; diff --git a/IDE/Contents/Include/PolycodeEditor.h b/IDE/Contents/Include/PolycodeEditor.h index c02b6fac8..8261c03a5 100644 --- a/IDE/Contents/Include/PolycodeEditor.h +++ b/IDE/Contents/Include/PolycodeEditor.h @@ -127,7 +127,9 @@ class PolycodeEditorFactory { bool canHandleExtension(String extension); + std::vector getExtensions(); + protected: - std::vector extensions; + std::vector extensions; }; diff --git a/IDE/Contents/Include/PolycodeEditorManager.h b/IDE/Contents/Include/PolycodeEditorManager.h index 5854b1d52..f93ec3794 100644 --- a/IDE/Contents/Include/PolycodeEditorManager.h +++ b/IDE/Contents/Include/PolycodeEditorManager.h @@ -38,6 +38,8 @@ class PolycodeEditorManager : public EventDispatcher { void registerEditorFactory(PolycodeEditorFactory *editorFactory); PolycodeEditorFactory *getEditorFactoryForExtension(String extension); + + std::vector getExtensionsWithEditor(); void handleEvent(Event *event); diff --git a/IDE/Contents/Include/PolycodeIDEApp.h b/IDE/Contents/Include/PolycodeIDEApp.h index e90347d44..5c64cb8ef 100644 --- a/IDE/Contents/Include/PolycodeIDEApp.h +++ b/IDE/Contents/Include/PolycodeIDEApp.h @@ -68,6 +68,7 @@ class PolycodeIDEApp : public EventDispatcher { void openFileInProject(PolycodeProject *project, String filePath); void openFile(OSFileEntry file); + void openFilePicker(); void stopProject(); diff --git a/IDE/Contents/Source/PolycodeEditor.cpp b/IDE/Contents/Source/PolycodeEditor.cpp index 37e33b679..4afe3f086 100644 --- a/IDE/Contents/Source/PolycodeEditor.cpp +++ b/IDE/Contents/Source/PolycodeEditor.cpp @@ -42,6 +42,10 @@ bool PolycodeEditorFactory::canHandleExtension(String extension) { return false; } +std::vector PolycodeEditorFactory::getExtensions(){ + return extensions; +} + void PolycodeEditor::setFilePath(String newPath) { filePath = newPath; } diff --git a/IDE/Contents/Source/PolycodeEditorManager.cpp b/IDE/Contents/Source/PolycodeEditorManager.cpp index bddfc7241..066f9d197 100644 --- a/IDE/Contents/Source/PolycodeEditorManager.cpp +++ b/IDE/Contents/Source/PolycodeEditorManager.cpp @@ -45,6 +45,17 @@ PolycodeEditorFactory *PolycodeEditorManager::getEditorFactoryForExtension(Strin return NULL; } +std::vector PolycodeEditorManager::getExtensionsWithEditor(){ + std::vector extensions; + for (int i = 0; i < editorFactories.size(); i++) { + PolycodeEditorFactory *factory = editorFactories[i]; + for (int e = 0; e < factory->getExtensions().size(); e++){ + extensions.push_back(CoreFileExtension(factory->getExtensions()[e], factory->getExtensions()[e])); + } + } + return extensions; +} + PolycodeEditor *PolycodeEditorManager::createEditorForExtension(String extension) { for(int i=0;i < editorFactories.size(); i++) { PolycodeEditorFactory *factory = editorFactories[i]; diff --git a/IDE/Contents/Source/PolycodeEntityEditor.cpp b/IDE/Contents/Source/PolycodeEntityEditor.cpp index 4a2795cfa..e7aea4580 100644 --- a/IDE/Contents/Source/PolycodeEntityEditor.cpp +++ b/IDE/Contents/Source/PolycodeEntityEditor.cpp @@ -2517,4 +2517,3 @@ void PolycodeEntityEditor::Resize(int x, int y) { mainSizer->Resize(x, y); PolycodeEditor::Resize(x,y); } - diff --git a/IDE/Contents/Source/PolycodeIDEApp.cpp b/IDE/Contents/Source/PolycodeIDEApp.cpp index c57cff82f..c2e6b9404 100644 --- a/IDE/Contents/Source/PolycodeIDEApp.cpp +++ b/IDE/Contents/Source/PolycodeIDEApp.cpp @@ -703,6 +703,15 @@ void PolycodeIDEApp::openFile(OSFileEntry file) { } } +void PolycodeIDEApp::openFilePicker() { + std::vector extensions = editorManager->getExtensionsWithEditor(); + extensions.insert(extensions.begin(), CoreFileExtension("All Types", "*")); + std::vector filePaths = core->openFilePicker(extensions, true); + for (int f = 0; f < filePaths.size(); f++){ + openFile(OSFileEntry(filePaths[f], OSFileEntry::TYPE_FILE)); + } +} + void PolycodeIDEApp::handleEvent(Event *event) { if(event->getDispatcher() == frame->assetImporterWindow) {