Просмотр исходного кода

Updated Windows to use the latest fixed update code, added a save file dialog to core (only windows implementation for now)

Ivan Safrin 11 лет назад
Родитель
Сommit
b6663d29ce

+ 4 - 1
Core/Contents/Include/PolyCore.h

@@ -278,7 +278,10 @@ namespace Polycode {
 		* @return An STL vector of the selected file paths.
 		*/																							
 		virtual std::vector<String> openFilePicker(std::vector<CoreFileExtension> extensions, bool allowMultiple) = 0;
-				
+		
+		virtual String saveFilePicker(std::vector<CoreFileExtension> extensions) = 0;
+
+		
 		/**
 		* Sets a new video mode.
 		* @param xRes New horizontal resolution of the renderer.

+ 4 - 2
Core/Contents/Include/PolyWinCore.h

@@ -182,7 +182,7 @@ public:
 		void captureMouse(bool newval);
 		void warpCursor(int x, int y);
 		unsigned int getTicks();		
-		bool Update();
+		bool systemUpdate();
 		void Render();
 		void setVSync(bool vSyncVal);
 
@@ -196,7 +196,7 @@ public:
 
 		bool isMultiTouchEnabled() { return hasMultiTouch; }
 
-		void setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel);
+		void setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, bool retinaSupport = true);
 		
 		void initContext(bool usePixelFormat, unsigned int pixelFormat);
 		void destroyContext();
@@ -231,6 +231,8 @@ public:
 		
 		String executeExternalCommand(String command,  String args, String inDirectory);
 		std::vector<String> openFilePicker(std::vector<CoreFileExtension> extensions, bool allowMultiple);
+		String saveFilePicker(std::vector<CoreFileExtension> extensions);
+
 		void createFolder(const String& folderPath);
 		void openURL(String url);
 		String openFolderPicker();

+ 62 - 2
Core/Contents/Source/PolyWinCore.cpp

@@ -190,7 +190,7 @@ void Win32Core::Render() {
 	SwapBuffers(hDC);
 }
 
-bool Win32Core::Update() {
+bool Win32Core::systemUpdate() {
 	if(!running)
 		return false;
 	doSleep();
@@ -210,7 +210,7 @@ void Win32Core::setVSync(bool vSyncVal) {
 	}
 }
 
-void Win32Core::setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel) {
+void Win32Core::setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, bool retinaSupport) {
 
 	bool resetContext = false;
 
@@ -1141,6 +1141,66 @@ std::vector<String> Win32Core::openFilePicker(std::vector<CoreFileExtension> ext
 	return retVec;
 }
 
+String Win32Core::saveFilePicker(std::vector<CoreFileExtension> extensions) {
+	OPENFILENAME ofn;
+	wchar_t fBuffer[2048];
+
+	wchar_t filterString[2048];
+
+	ZeroMemory(&ofn, sizeof(OPENFILENAME));
+
+	ofn.lStructSize = sizeof (ofn);
+	ofn.hwndOwner = hWnd;
+	ofn.lpstrFile = fBuffer;
+	ofn.lpstrFile[0] = '\0';
+	ofn.nMaxFile = sizeof(fBuffer);
+
+	if (extensions.size() > 0) {
+		int offset = 0;
+		for (int i = 0; i < extensions.size(); i++) {
+			//	filterString += extensions[i].description+"\0*."+extensions[i].extension+"\0";
+			memcpy(filterString + offset, extensions[i].description.getWDataWithEncoding(String::ENCODING_UTF8), extensions[i].description.length() * sizeof(wchar_t));
+			offset += extensions[i].description.length();
+			filterString[offset] = '\0';
+			offset++;
+			filterString[offset] = '*';
+			offset++;
+			filterString[offset] = '.';
+			offset++;
+			memcpy(filterString + offset, extensions[i].extension.getWDataWithEncoding(String::ENCODING_UTF8), extensions[i].extension.length() * sizeof(wchar_t));
+			offset += extensions[i].extension.length();
+			filterString[offset] = '\0';
+			offset++;
+		}
+		filterString[offset] = '\0';
+		ofn.lpstrFilter = filterString;
+
+		ofn.nFilterIndex = 1;
+	}
+	else {
+		ofn.lpstrFilter = NULL;
+	}
+
+	ofn.lpstrFileTitle = NULL;
+	ofn.nMaxFileTitle = 0;
+	ofn.lpstrInitialDir = NULL;
+
+	ofn.Flags = OFN_PATHMUSTEXIST  | OFN_EXPLORER;
+
+	std::vector<String> retVec;
+
+	String retPath = "";
+
+	if (GetSaveFileName(&ofn)) {
+		retPath = String(fBuffer);
+	}
+
+	SetCurrentDirectory(defaultWorkingDirectory.getWDataWithEncoding(String::ENCODING_UTF8));
+
+	retPath = retPath.replace("\\", "/");
+	return retPath;
+}
+
 void Win32Core::createFolder(const String& folderPath) {
 	String path = folderPath;
 	CreateDirectory(path.getWDataWithEncoding(String::ENCODING_UTF8), NULL);		

+ 4 - 0
IDE/Build/Windows2013/Polycode.vcxproj.user

@@ -8,4 +8,8 @@
     <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
     <LocalDebuggerWorkingDirectory>..</LocalDebuggerWorkingDirectory>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <LocalDebuggerWorkingDirectory>.</LocalDebuggerWorkingDirectory>
+    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+  </PropertyGroup>
 </Project>

+ 1 - 1
IDE/Build/Windows2013/main.cpp

@@ -75,7 +75,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
 	PathRemoveFileSpec( FilePath );    
 	SetCurrentDirectory( FilePath );
 
-	PolycodeWinIDEView *view = new PolycodeWinIDEView(hInstance, nCmdShow, L"Polycode", true, false);
+	PolycodeWinIDEView *view = new PolycodeWinIDEView(hInstance, nCmdShow, L"Polycode", true, true);
 	PolycodeIDEApp *app = new PolycodeIDEApp(view);
 
 	globalApp = app;