Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions Core/Contents/Source/PolyWinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ std::vector<String> Win32Core::openFilePicker(std::vector<CoreFileExtension> 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;
Expand All @@ -1147,7 +1147,23 @@ std::vector<String> Win32Core::openFilePicker(std::vector<CoreFileExtension> 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));
}
Expand Down
Binary file modified IDE/Build/Windows2013/Polycode.rc
Binary file not shown.
8 changes: 4 additions & 4 deletions IDE/Build/Windows2013/Polycode.sln
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
Binary file modified IDE/Build/Windows2013/resource.h
Binary file not shown.
3 changes: 3 additions & 0 deletions IDE/Build/WindowsShared/PolycodeWinIDEView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion IDE/Contents/Include/PolycodeEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ class PolycodeEditorFactory {

bool canHandleExtension(String extension);

std::vector<String> getExtensions();

protected:
std::vector<std::string> extensions;
std::vector<String> extensions;

};
2 changes: 2 additions & 0 deletions IDE/Contents/Include/PolycodeEditorManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class PolycodeEditorManager : public EventDispatcher {
void registerEditorFactory(PolycodeEditorFactory *editorFactory);

PolycodeEditorFactory *getEditorFactoryForExtension(String extension);

std::vector<CoreFileExtension> getExtensionsWithEditor();

void handleEvent(Event *event);

Expand Down
1 change: 1 addition & 0 deletions IDE/Contents/Include/PolycodeIDEApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class PolycodeIDEApp : public EventDispatcher {
void openFileInProject(PolycodeProject *project, String filePath);

void openFile(OSFileEntry file);
void openFilePicker();

void stopProject();

Expand Down
4 changes: 4 additions & 0 deletions IDE/Contents/Source/PolycodeEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ bool PolycodeEditorFactory::canHandleExtension(String extension) {
return false;
}

std::vector<String> PolycodeEditorFactory::getExtensions(){
return extensions;
}

void PolycodeEditor::setFilePath(String newPath) {
filePath = newPath;
}
Expand Down
11 changes: 11 additions & 0 deletions IDE/Contents/Source/PolycodeEditorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ PolycodeEditorFactory *PolycodeEditorManager::getEditorFactoryForExtension(Strin
return NULL;
}

std::vector<CoreFileExtension> PolycodeEditorManager::getExtensionsWithEditor(){
std::vector<CoreFileExtension> 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];
Expand Down
3 changes: 1 addition & 2 deletions IDE/Contents/Source/PolycodeEntityEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2535,5 +2535,4 @@ void PolycodeEntityEditor::saveFile() {
void PolycodeEntityEditor::Resize(int x, int y) {
mainSizer->Resize(x, y);
PolycodeEditor::Resize(x,y);
}

}
26 changes: 25 additions & 1 deletion IDE/Contents/Source/PolycodeIDEApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ PolycodeIDEApp::PolycodeIDEApp(PolycodeView *view) : EventDispatcher() {
fileEntry->addItem("New File", "new_file", KEY_n);
fileEntry->addItem("New Project", "new_project", KEY_LSHIFT, KEY_n);
fileEntry->addItem("New Folder", "new_folder", KEY_LSHIFT, KEY_f);
fileEntry->addItem("Open File", "open_file", KEY_o);
fileEntry->addItem("Open Project", "open_project", KEY_LSHIFT, KEY_o);
fileEntry->addItem("Close Project", "close_project", KEY_LSHIFT, KEY_w);
fileEntry->addItem("Close File", "close_file", KEY_w);
Expand Down Expand Up @@ -703,6 +704,25 @@ void PolycodeIDEApp::openFile(OSFileEntry file) {
}
}

void PolycodeIDEApp::openFilePicker() {
std::vector<CoreFileExtension> extensions = editorManager->getExtensionsWithEditor();
#ifdef USE_POLYCODEUI_FILE_DIALOGS
std::vector<String> exts;
for(int e = 0; e < extensions.size(); e++){
exts.push_back((extensions[e].extension));
}
frame->showFileBrowser(CoreServices::getInstance()->getCore()->getUserHomeDirectory(), false, exts, false);
frame->fileDialog->addEventListener(this, UIEvent::OK_EVENT);
frame->fileDialog->action = "openFile";
#else
extensions.insert(extensions.begin(), CoreFileExtension("All Types", "*"));
std::vector<String> filePaths = core->openFilePicker(extensions, true);
for (int f = 0; f < filePaths.size(); f++){
openFile(OSFileEntry(filePaths[f], OSFileEntry::TYPE_FILE));
}
#endif
}

void PolycodeIDEApp::handleEvent(Event *event) {

if(event->getDispatcher() == frame->assetImporterWindow) {
Expand Down Expand Up @@ -758,6 +778,8 @@ void PolycodeIDEApp::handleEvent(Event *event) {
frame->assetImporterWindow->setSourceFileAndTargetFolder(path, projectManager->activeFolder, projectManager->activeFolder.replace(projectManager->getActiveProject()->getRootFolder(), ""));
frame->showModal(frame->assetImporterWindow);
frame->assetImporterWindow->addEventListener(this, UIEvent::OK_EVENT);
} else if(frame->fileDialog->action == "openFile") {
openFile(OSFileEntry(path, OSFileEntry::TYPE_FILE));
}
}
}
Expand All @@ -772,7 +794,9 @@ void PolycodeIDEApp::handleEvent(Event *event) {
newProject();
} else if(action == "new_folder") {
newGroup();
} else if(action == "open_project") {
} else if (action == "open_file") {
openFilePicker();
} else if (action == "open_project") {
openProject();
} else if(action == "close_project") {
closeProject();
Expand Down