Ivan Safrin 13 лет назад
Родитель
Сommit
134576cae7

+ 1 - 1
Core/Contents/Include/PolyCocoaCore.h

@@ -118,7 +118,7 @@ namespace Polycode {
 		String openFolderPicker();
 		vector<String> openFilePicker(vector<CoreFileExtension> extensions, bool allowMultiple);
 		
-		String executeExternalCommand(String command);
+		String executeExternalCommand(String command, String inDirectory="");
 		
 		void launchApplicationWithFile(String application, String file);
 		void openFileWithApplication(String file, String application);

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

@@ -311,7 +311,7 @@ namespace Polycode {
 		static const int EVENT_LOST_FOCUS = 1;
 		static const int EVENT_GAINED_FOCUS = 2;
 		
-		virtual String executeExternalCommand(String command) = 0;
+		virtual String executeExternalCommand(String command, String args, String inDirectory) = 0;
 		
 		/**
 		* Returns the default working path of the application.

+ 1 - 1
Core/Contents/Include/PolySDLCore.h

@@ -68,7 +68,7 @@ namespace Polycode {
 		std::vector<String> openFilePicker(std::vector<CoreFileExtension> extensions, bool allowMultiple);
 		void resizeTo(int xRes, int yRes);
 
-		String executeExternalCommand(String command);
+		String executeExternalCommand(String command, String inDirectory="");
 		void openURL(String url);
 
 	private:

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

@@ -226,22 +226,25 @@ public:
 		void initTouch();
 
 		void handleViewResize(int width, int height);
+		
+		String executeExternalCommand(String command,  String args, String inDirectory);
+		std::vector<String> openFilePicker(std::vector<CoreFileExtension> extensions, bool allowMultiple);
+		void createFolder(const String& folderPath);
+		void openURL(String url);
 
 		// NEED TO IMPLEMENT:
 
-		String executeExternalCommand(String command) { return "";}
 
-		void openURL(String url) {}
 		void setCursor(int cursorType){ }
 		void copyStringToClipboard(const String& str) { }
 		String getClipboardString() { return ""; }
 
-		void createFolder(const String& folderPath) {}
+
 		void copyDiskItem(const String& itemPath, const String& destItemPath) {}
 		void moveDiskItem(const String& itemPath, const String& destItemPath) {}
 		String openFolderPicker()  { return "";}
 		void removeDiskItem(const String& itemPath)  {}
-		std::vector<String> openFilePicker(std::vector<CoreFileExtension> extensions, bool allowMultiple) { std::vector<String> ret; return ret;}
+		
 		void resizeTo(int xRes, int yRes) { }
 		
 		std::vector<GamepadDeviceEntry*> gamepads;

+ 38 - 1
Core/Contents/PolycodeView/MSVC/PolycodeView.cpp

@@ -4,11 +4,44 @@
 #include "PolyCoreServices.h"
 #include "PolyCoreInput.h"
 #include "PolyRenderer.h"
+#include <io.h>
+#include <fcntl.h>
 
 using namespace Polycode;
 
 Win32Core *core = NULL;
 
+
+static void OpenConsole()
+{
+    int outHandle, errHandle, inHandle;
+    FILE *outFile, *errFile, *inFile;
+    AllocConsole();
+    CONSOLE_SCREEN_BUFFER_INFO coninfo;
+    GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
+    coninfo.dwSize.Y = 9999;
+    SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
+
+    outHandle = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
+    errHandle = _open_osfhandle((long)GetStdHandle(STD_ERROR_HANDLE),_O_TEXT);
+    inHandle = _open_osfhandle((long)GetStdHandle(STD_INPUT_HANDLE),_O_TEXT );
+
+    outFile = _fdopen(outHandle, "w" );
+    errFile = _fdopen(errHandle, "w");
+    inFile =  _fdopen(inHandle, "r");
+
+    *stdout = *outFile;
+    *stderr = *errFile;
+    *stdin = *inFile;
+
+    setvbuf( stdout, NULL, _IONBF, 0 );
+    setvbuf( stderr, NULL, _IONBF, 0 );
+    setvbuf( stdin, NULL, _IONBF, 0 );
+
+    std::ios::sync_with_stdio();
+
+}
+
 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
 	int wmId, wmEvent;
@@ -115,7 +148,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 }
 
 
-PolycodeView::PolycodeView(HINSTANCE hInstance, int nCmdShow, LPCTSTR windowTitle, bool resizable) : PolycodeViewBase() {
+PolycodeView::PolycodeView(HINSTANCE hInstance, int nCmdShow, LPCTSTR windowTitle, bool resizable, bool showDebugConsole) : PolycodeViewBase() {
 
 WNDCLASSEX wcex;
 
@@ -145,6 +178,10 @@ WNDCLASSEX wcex;
    ShowWindow(hwnd, nCmdShow);
    UpdateWindow(hwnd);
 
+   if(showDebugConsole) {
+		OpenConsole();
+   }
+
 }
 
 PolycodeView::~PolycodeView() {

+ 1 - 1
Core/Contents/PolycodeView/MSVC/PolycodeView.h

@@ -10,7 +10,7 @@ namespace Polycode {
 
 class _PolyExport PolycodeView : public PolycodeViewBase {
 public:
-	PolycodeView(HINSTANCE hInstance, int nCmdShow, LPCTSTR windowTitle, bool resizable=false);
+	PolycodeView(HINSTANCE hInstance, int nCmdShow, LPCTSTR windowTitle, bool resizable=false, bool showDebugConsole = false);
 	~PolycodeView();
 
 	HWND hwnd;

+ 10 - 0
Core/Contents/Source/OSBasics.cpp

@@ -280,8 +280,18 @@ vector<OSFileEntry> OSBasics::parseFolder(const String& pathString, bool showHid
 	WCHAR tmp[4096];
 	memset(tmp, 0, sizeof(WCHAR)*4096);
 	ctow(tmp, pathString.c_str());
+
+
+	DWORD dwAttrib = GetFileAttributes(tmp);
+  if(! (dwAttrib != INVALID_FILE_ATTRIBUTES && 
+         (dwAttrib & FILE_ATTRIBUTE_DIRECTORY))) {
+		return returnVector;
+  }
+
+
 	SetCurrentDirectory(tmp);
 
+
 	HANDLE hFind = FindFirstFile((LPCWSTR)"*", &findFileData);
 	if(hFind  == INVALID_HANDLE_VALUE) {
 		SetCurrentDirectory(curDir);

+ 1 - 1
Core/Contents/Source/PolyCocoaCore.mm

@@ -215,7 +215,7 @@ void CocoaCore::launchApplicationWithFile(String application, String file) {
 //Handle error
 }
 
-String CocoaCore::executeExternalCommand(String command) {
+String CocoaCore::executeExternalCommand(String command,  String inDirectory) {
 	FILE *fp = popen(command.c_str(), "r");
 	if(!fp) {
 		return "Unable to execute command";

+ 2 - 2
Core/Contents/Source/PolyColor.cpp

@@ -60,11 +60,11 @@ void Color::setColorHexRGB(unsigned int hex) {
 }
 
 void Color::setColorHexFromString(String hex) {
-	setColorHex(strtol(hex.c_str(), 0, 16));
+	setColorHex(strtoul(hex.c_str(), 0, 16));
 }
 
 void Color::setColorHexRGBFromString(String hex) {
-	setColorHexRGB(strtol(hex.c_str(), 0, 16));
+	setColorHexRGB(strtoul(hex.c_str(), 0, 16));
 }
 
 Color Color::blendColor(Color c2, int mode, Number amount, Color c3) {

+ 1 - 1
Core/Contents/Source/PolySDLCore.cpp

@@ -160,7 +160,7 @@ void SDLCore::openURL(String url) {
     }
 }
 
-String SDLCore::executeExternalCommand(String command) {
+String SDLCore::executeExternalCommand(String command,  String inDirectory) {
 	FILE *fp = popen(command.c_str(), "r");
 	if(!fp) {
 		return "Unable to execute command";

+ 109 - 0
Core/Contents/Source/PolyWinCore.cpp

@@ -35,6 +35,8 @@
 #include <stdio.h>
 
 #include <Shlobj.h>
+#include <Shellapi.h>
+#include <Commdlg.h>
 
 #include <GL/gl.h>
 #include <GL/glext.h>
@@ -949,3 +951,110 @@ std::vector<Polycode::Rectangle> Win32Core::getVideoModes() {
 	return retVector;
 }
 	
+
+String Win32Core::executeExternalCommand(String command,  String args, String inDirectory) {
+	String execInDirectory = inDirectory;
+	if(inDirectory == "") {
+		execInDirectory = defaultWorkingDirectory;
+	}
+
+	SHELLEXECUTEINFO lpExecInfo;
+      lpExecInfo.cbSize  = sizeof(SHELLEXECUTEINFO);
+      lpExecInfo.lpFile = command.getWDataWithEncoding(String::ENCODING_UTF8);
+	lpExecInfo.fMask=SEE_MASK_DOENVSUBST|SEE_MASK_NOCLOSEPROCESS ;     
+      lpExecInfo.hwnd = NULL;  
+      lpExecInfo.lpVerb = L"open"; // to open  program
+      lpExecInfo.lpParameters =  args.getWDataWithEncoding(String::ENCODING_UTF8); //  file name as an argument
+      lpExecInfo.lpDirectory = execInDirectory.getWDataWithEncoding(String::ENCODING_UTF8);   
+      lpExecInfo.nShow = SW_SHOW ;  // show command prompt with normal window size 
+      lpExecInfo.hInstApp = (HINSTANCE) SE_ERR_DDEFAIL ;   //WINSHELLAPI BOOL WINAPI result;
+      ShellExecuteEx(&lpExecInfo);
+    
+ 
+      //wait until a file is finished printing
+      if(lpExecInfo.hProcess !=NULL)
+      {
+        ::WaitForSingleObject(lpExecInfo.hProcess, INFINITE);
+        ::CloseHandle(lpExecInfo.hProcess);
+      }
+
+	  return "";
+}
+
+
+std::vector<String> Win32Core::openFilePicker(std::vector<CoreFileExtension> extensions, bool allowMultiple) {
+	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;
+
+	if(allowMultiple) {
+		ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_EXPLORER;
+	} else {
+		ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT|OFN_EXPLORER;
+	}
+
+	std::vector<String> retVec;
+
+	if(GetOpenFileName(&ofn)) {
+		if(allowMultiple) {
+
+		} else {
+			retVec.push_back(String(fBuffer));
+		}
+	}
+
+	SetCurrentDirectory(defaultWorkingDirectory.getWDataWithEncoding(String::ENCODING_UTF8));
+
+
+	for(int i=0; i < retVec.size(); i++) {
+		retVec[i] = retVec[i].replace("\\", "/");
+	}
+	return retVec;
+}
+
+void Win32Core::createFolder(const String& folderPath) {
+	String path = folderPath;
+	CreateDirectory(path.getWDataWithEncoding(String::ENCODING_UTF8), NULL);		
+}
+
+void Win32Core::openURL(String url) {
+	ShellExecute(NULL, L"open", url.getWDataWithEncoding(String::ENCODING_UTF8), NULL, NULL, SW_SHOWNORMAL);
+}

+ 1 - 1
IDE/Build/Windows/Polycode.vcxproj

@@ -119,7 +119,7 @@
       <Optimization>MaxSpeed</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>USE_POLYCODEUI_MENUBAR;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
       <GenerateDebugInformation>true</GenerateDebugInformation>

+ 3 - 1
IDE/Build/Windows/main.cpp

@@ -7,7 +7,7 @@ using namespace Polycode;
 
 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
 {
-	PolycodeView *view = new PolycodeView(hInstance, nCmdShow, L"Polycode", true);
+	PolycodeView *view = new PolycodeView(hInstance, nCmdShow, L"Polycode", true, true);
 	PolycodeIDEApp *app = new PolycodeIDEApp(view);
 
 	MSG Msg;
@@ -17,5 +17,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
 			DispatchMessage(&Msg);
 		}
 	} while(app->Update());
+
+	app->saveConfigFile();
 	return Msg.wParam;
 }

+ 2 - 0
IDE/Contents/Source/PolycodeIDEApp.cpp

@@ -231,9 +231,11 @@ void PolycodeIDEApp::openProject() {
 	ext.extension = "polyproject";
 	ext.description = "Polycode Project File";
 	extensions.push_back(ext);
+
 	std::vector<String> paths = core->openFilePicker(extensions, false);
 	if(paths.size() == 0) 
 		return;
+
 	if(paths[0] != "") {
 		PolycodeProject *project = projectManager->openProject(paths[0]);
 		if(project) {

+ 22 - 5
IDE/Contents/Source/PolycodeToolLauncher.cpp

@@ -34,13 +34,15 @@ void PolycodeRunner::runThread() {
 	String polycodeBasePath = CoreServices::getInstance()->getCore()->getDefaultWorkingDirectory();
 
 #if defined(__APPLE__) && defined(__MACH__)
-	String command = "cd "+polycodeBasePath+"/Standalone/Player/PolycodePlayer.app/Contents/Resources && ../MacOS/PolycodePlayer "+polyappPath;
-		;		
+	String command = "cd "+polycodeBasePath+"/Standalone/Player/PolycodePlayer.app/Contents/Resources && ../MacOS/PolycodePlayer "+polyappPath;	
+#elif defined _WINDOWS
+	String command = polycodeBasePath+"/Standalone/Player/PolycodePlayer.exe";
+	String args = polyappPath;
+	String inFolder = polycodeBasePath+"/Standalone/Player";
 #else
 	String command = "cd "+polycodeBasePath+"/Standalone/Player && ./PolycodePlayer "+polyappPath;
-
 #endif
-	String ret = CoreServices::getInstance()->getCore()->executeExternalCommand(command);
+	String ret = CoreServices::getInstance()->getCore()->executeExternalCommand(command, args, inFolder);
 	CoreServices::getInstance()->getCore()->removeDiskItem(polyappPath);	
 }
 
@@ -53,7 +55,15 @@ PolycodeToolLauncher::~PolycodeToolLauncher() {
 }
 
 String PolycodeToolLauncher::generateTempPath(PolycodeProject *project) {
+#ifdef _WINDOWS
+		wchar_t buf[2048];
+		GetTempPath(2048, buf);
+		String retString = String(buf)+project->getProjectName();
+		printf("TEMP_PATH: %s\n", retString.c_str());
+		return retString;
+#else
 	return "/tmp/"+project->getProjectName();
+#endif
 }
 
 void PolycodeToolLauncher::buildProject(PolycodeProject *project, String destinationPath) {
@@ -68,9 +78,16 @@ void PolycodeToolLauncher::buildProject(PolycodeProject *project, String destina
 	
 	String polycodeBasePath = CoreServices::getInstance()->getCore()->getDefaultWorkingDirectory();
 	
+#ifdef _WINDOWS
+	String targetFolder = projectBasePath;
+	String command = "\""+polycodeBasePath+"/Standalone/Bin/polybuild.exe\"";
+	String args =  "--config=\""+projectPath+"\" --out=\""+destinationPath+"\"";
+	String ret = CoreServices::getInstance()->getCore()->executeExternalCommand(command, args, targetFolder);
+#else
 	String command = "cd "+projectBasePath+" && "+polycodeBasePath+"/Standalone/Bin/polybuild  --config="+projectPath+" --out="+destinationPath;	
 	String ret = CoreServices::getInstance()->getCore()->executeExternalCommand(command);
 //	PolycodeConsole::print(ret);	
+#endif
 
 }
 
@@ -86,7 +103,7 @@ void PolycodeToolLauncher::runPolyapp(String polyappPath) {
 	CocoaCore *cocoaCore = (CocoaCore*) CoreServices::getInstance()->getCore();
 
 	String polycodeBasePath = CoreServices::getInstance()->getCore()->getDefaultWorkingDirectory();
-	String command = polycodeBasePath+"/Standalone/Player/PolycodePlayer.app";
+	String command = polycodeBasePath+"/Standalone/Player/PolycodePlayer.app"; 
 	
 //	cocoaCore->launchApplicationWithFile(command, polyappPath);
 	cocoaCore->openFileWithApplication(polyappPath, command);

+ 1 - 1
Modules/Contents/UI/Source/PolyUIButton.cpp

@@ -66,7 +66,7 @@ UIButton::UIButton(String text, Number width, Number height) : UIElement() {
 	pressedDown = false;
 	
 	buttonLabel = new ScreenLabel(text, fontSize, fontName, Label::ANTIALIAS_FULL);
-	buttonLabel->color.setColorHex(strtol(conf->getStringValue("Polycode", "uiButtonFontColor").c_str(), 0, 16));
+	buttonLabel->color.setColorHexFromString(conf->getStringValue("Polycode", "uiButtonFontColor"));
 	addChild(buttonLabel);
 	labelXPos = floor((width-buttonLabel->getWidth())/2.0f) + labelOffsetX;
 	labelYPos = labelOffsetY;

+ 1 - 1
Modules/Contents/UI/Source/PolyUICheckBox.cpp

@@ -55,7 +55,7 @@ UICheckBox::UICheckBox(String caption, bool checked) : UIElement() {
 	addChild(buttonImageUnchecked);	
 	addChild(buttonImageChecked);
 	
-	captionLabel->color.setColorHex(strtol(conf->getStringValue("Polycode", "uiDefaultFontColor").c_str(), 0, 16));
+	captionLabel->color.setColorHexFromString(conf->getStringValue("Polycode", "uiDefaultFontColor"));
 	
 	buttonImageUnchecked->addEventListener(this, InputEvent::EVENT_MOUSEOVER);
 	buttonImageUnchecked->addEventListener(this, InputEvent::EVENT_MOUSEOUT);

+ 1 - 1
Modules/Contents/UI/Source/PolyUIComboBox.cpp

@@ -78,7 +78,7 @@ UIComboBox::UIComboBox(UIGlobalMenu *globalMenu, Number comboWidth) : UIElement(
 	selectedLabel->setPosition(paddingX, floor(((dropDownImage->getHeight()/2.0) - selectedLabel->getLabel()->getTextHeight()/2.0) + paddingY));
 	addChild(selectedLabel);
 	
-	selectedLabel->color.setColorHex(strtol(conf->getStringValue("Polycode", "uiDefaultFontColor").c_str(), 0, 16));
+	selectedLabel->color.setColorHexFromString(conf->getStringValue("Polycode", "uiDefaultFontColor"));
 	
 	String selectorBgImage = conf->getStringValue("Polycode", "uiComboBoxSelectorBgImage");	
 	

+ 1 - 1
Modules/Contents/UI/Source/PolyUITree.cpp

@@ -53,7 +53,7 @@ UITree::UITree(String icon, String text, Number treeWidth, Number treeOffset) :
 								size,
 								fontName,
 								Label::ANTIALIAS_FULL);
-	textLabel->color.setColorHex(strtol(conf->getStringValue("Polycode", "uiTreeFontColor").c_str(), 0, 16));
+	textLabel->color.setColorHexFromString(conf->getStringValue("Polycode", "uiTreeFontColor"));
 	
 	bgBox = new ScreenShape(ScreenShape::SHAPE_RECT, treeWidth, cellHeight);	
 	bgBox->setPositionMode(ScreenEntity::POSITION_TOPLEFT);

+ 1 - 1
Modules/Contents/UI/Source/PolyUIWindow.cpp

@@ -71,7 +71,7 @@ UIWindow::UIWindow(String windowName, Number width, Number height) : ScreenEntit
 	titleLabel = new ScreenLabel(windowName, fontSize, fontName, Label::ANTIALIAS_FULL);
 	titleLabel->setPosition(conf->getNumericValue("Polycode", "uiWindowTitleX"),conf->getNumericValue("Polycode", "uiWindowTitleY"));
 	addChild(titleLabel);
-	titleLabel->color.setColorHex(strtol(conf->getStringValue("Polycode", "uiWindowFontColor").c_str(), 0, 16));
+	titleLabel->color.setColorHexFromString(conf->getStringValue("Polycode", "uiWindowFontColor"));
 		
 	closeBtn = new UIImageButton(conf->getStringValue("Polycode", "uiWindowCloseIcon"));
 	addChild(closeBtn);

+ 1 - 5
Player/Contents/CMakeLists.txt

@@ -25,26 +25,22 @@ INCLUDE_DIRECTORIES(
 SET(polycodeplayer_SRCS 
         Source/PolycodePlayer.cpp
         Source/PolycodeWindowsPlayer.cpp
-        Source/PolycodePlayerView.cpp
         Platform/Windows/main.cpp        
     )
 
     SET(polycodeplayer_HDRS 
         Include/PolycodePlayer.h
         Include/PolycodeWindowsPlayer.h
-        Include/PolycodePlayerView.h
     )
   
     SET(polycodeplayerstandalone_SRCS 
         Source/PolycodePlayer.cpp
         Source/PolycodeWindowsPlayer.cpp
-        Source/PolycodePlayerView.cpp
         Platform/Windows/Standalone/main.cpp
     )
     SET(polycodeplayerstandalone_HDRS 
         Include/PolycodePlayer.h
-        Include/PolycodeWindowsPlayer.h
-        Include/PolycodePlayerView.h        
+        Include/PolycodeWindowsPlayer.h   
     )
  
     ADD_EXECUTABLE(PolycodePlayer WIN32 ${polycodeplayer_SRCS} ${polycodeplayer_HDRS})

+ 3 - 3
Player/Contents/Include/PolycodeWindowsPlayer.h

@@ -22,19 +22,19 @@ THE SOFTWARE.
 
 #pragma once
 
-#include "PolycodePlayerView.h"
+#include "PolycodeView.h"
 
 #include "PolycodePlayer.h"
 #include "PolyWinCore.h"
 
 class PolycodeWindowsPlayer : public PolycodePlayer {
 	public:
-		PolycodeWindowsPlayer(PolycodePlayerView *view,String fileName, bool knownArchive);
+		PolycodeWindowsPlayer(PolycodeView *view,String fileName, bool knownArchive, bool useDebugger);
 		virtual ~PolycodeWindowsPlayer();
 	
 		void createCore();	
 	
 	protected:
 
-		PolycodePlayerView *view;	
+		PolycodeView *view;	
 };

+ 4 - 70
Player/Contents/Platform/Windows/Standalone/main.cpp

@@ -17,81 +17,15 @@ for(int i = 0; i < SourceSize; ++i)
 Dest[i] = (char)Source[i];
 }
 
-static void OpenConsole()
-{
-    int outHandle, errHandle, inHandle;
-    FILE *outFile, *errFile, *inFile;
-    AllocConsole();
-    CONSOLE_SCREEN_BUFFER_INFO coninfo;
-    GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
-    coninfo.dwSize.Y = 9999;
-    SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
-
-    outHandle = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
-    errHandle = _open_osfhandle((long)GetStdHandle(STD_ERROR_HANDLE),_O_TEXT);
-    inHandle = _open_osfhandle((long)GetStdHandle(STD_INPUT_HANDLE),_O_TEXT );
-
-    outFile = _fdopen(outHandle, "w" );
-    errFile = _fdopen(errHandle, "w");
-    inFile =  _fdopen(inHandle, "r");
-
-    *stdout = *outFile;
-    *stderr = *errFile;
-    *stdin = *inFile;
-
-    setvbuf( stdout, NULL, _IONBF, 0 );
-    setvbuf( stderr, NULL, _IONBF, 0 );
-    setvbuf( stdin, NULL, _IONBF, 0 );
-
-    std::ios::sync_with_stdio();
-
-}
-
 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
 {
 	
-	String args = String(GetCommandLineW());
-	String fileName;
-	for(int i=0; i < args.length(); i++) {
-		if(args[i] != '\"')
-			fileName += args.substr(i, 1);
-		if(args[i] == '\"' && i != args.length()-1)
-			fileName = "";
-	}
-
-	if(fileName == " ")
-		fileName = "";
-
-	if(fileName.length() > 1)  {
-		fileName = fileName.replace(":", "");
-		fileName = fileName.replace("\\", "/");
-		fileName = fileName.substr(1, fileName.length() - 1);
-
-	}
-
-	char path[2049];
-	TCHAR tpath[2049];
-	GetModuleFileName(NULL, (LPWSTR)tpath, 2048);
-	wtoc(path, tpath, 2048);
-	
-	String basePath = path;
-	vector<String> cpts = basePath.split("\\");
-	String installPath = "";
-	for(int i=0; i < cpts.size() - 1; i++) {
-		installPath = installPath + cpts[i];
-		installPath += String("\\");
-	}
-	
-	SetCurrentDirectory(installPath.getWDataWithEncoding(String::ENCODING_UTF8));
-
-
-	PolycodePlayerView *view = new PolycodePlayerView(true, hInstance, nCmdShow, L"");
-	PolycodeWindowsPlayer *player = new PolycodeWindowsPlayer(view, "main.polyapp", false);
 
-	player->addEventListener(view, PolycodeDebugEvent::EVENT_ERROR);
-	player->addEventListener(view, PolycodeDebugEvent::EVENT_PRINT);
+	PolycodeView *view = new PolycodeView(hInstance, nCmdShow, L"", false, false);
+	PolycodeWindowsPlayer *player = new PolycodeWindowsPlayer(view, "main.polyapp", false, false);
 
-	//OpenConsole();
+	//player->addEventListener(view, PolycodeDebugEvent::EVENT_ERROR);
+	//player->addEventListener(view, PolycodeDebugEvent::EVENT_PRINT);
 
 	player->runPlayer();
 

+ 10 - 37
Player/Contents/Platform/Windows/main.cpp

@@ -1,7 +1,7 @@
 
 #include "PolycodeWindowsPlayer.h"
 #include <Polycode.h>
-#include "PolycodePlayerView.h"
+#include "PolycodeView.h"
 #include "windows.h"
 #include "resource.h"
 
@@ -20,47 +20,20 @@ Dest[i] = (char)Source[i];
 
 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
 {
-	
-	String args = String(GetCommandLineW());
-	String fileName;
-	for(int i=0; i < args.length(); i++) {
-		if(args[i] != '\"')
-			fileName += args.substr(i, 1);
-		if(args[i] == '\"' && i != args.length()-1)
-			fileName = "";
-	}
-
-	if(fileName == " ")
-		fileName = "";
-
-	if(fileName.length() > 1)  {
-		fileName = fileName.replace(":", "");
-		fileName = fileName.replace("\\", "/");
-		fileName = fileName.substr(1, fileName.length() - 1);
 
-	}
-
-	char path[2049];
-	TCHAR tpath[2049];
-	GetModuleFileName(NULL, (LPWSTR)tpath, 2048);
-	wtoc(path, tpath, 2048);
+	int nArgs;
+	LPWSTR *szArglist =  CommandLineToArgvW(GetCommandLineW(), &nArgs);
 	
-	String basePath = path;
-	vector<String> cpts = basePath.split("\\");
-	String installPath = "";
-	for(int i=0; i < cpts.size() - 1; i++) {
-		installPath = installPath + cpts[i];
-		installPath += String("\\");
+	String fileName = "";
+	if(nArgs > 1) {
+		fileName = String(szArglist[1]);
 	}
-	
-	SetCurrentDirectory(installPath.getWDataWithEncoding(String::ENCODING_UTF8));
-
 
-	PolycodePlayerView *view = new PolycodePlayerView(false, hInstance, nCmdShow, L"Polycode Player");
-	PolycodeWindowsPlayer *player = new PolycodeWindowsPlayer(view, fileName.c_str(), false);
+	PolycodeView *view = new PolycodeView(hInstance, nCmdShow, L"Polycode Player", false, false);
+	PolycodeWindowsPlayer *player = new PolycodeWindowsPlayer(view, fileName.c_str(), false, true);
 
-	player->addEventListener(view, PolycodeDebugEvent::EVENT_ERROR);
-	player->addEventListener(view, PolycodeDebugEvent::EVENT_PRINT);
+//	player->addEventListener(view, PolycodeDebugEvent::EVENT_ERROR);
+//	player->addEventListener(view, PolycodeDebugEvent::EVENT_PRINT);
 
 
 	player->runPlayer();

+ 1 - 1
Player/Contents/Source/PolycodeWindowsPlayer.cpp

@@ -22,7 +22,7 @@ THE SOFTWARE.
 #include "PolycodeWindowsPlayer.h"
 
 
-PolycodeWindowsPlayer::PolycodeWindowsPlayer(PolycodePlayerView *view, String fileName, bool knownArchive) : PolycodePlayer(fileName, knownArchive) {
+PolycodeWindowsPlayer::PolycodeWindowsPlayer(PolycodeView *view, String fileName, bool knownArchive, bool useDebugger) : PolycodePlayer(fileName, knownArchive, useDebugger) {
 	this->view = view;
 }
 

+ 4 - 8
Tools/Contents/polybuild/Source/polybuild.cpp

@@ -20,7 +20,7 @@
 using std::vector;
 
 vector<BuildArg> args;
-#define MAXFILENAME (256)
+#define MAXFILENAME (2048)
 
 String getArg(String argName) {
 	/*
@@ -195,6 +195,7 @@ int main(int argc, char **argv) {
 			BuildArg arg;
 			arg.name = bits[0];
 			arg.value = bits[1];
+		//	printf("arg: %s=%s\n", arg.name.c_str(), arg.value.c_str());
 			args.push_back(arg);
 		}
 		
@@ -221,12 +222,13 @@ int main(int argc, char **argv) {
 #else
 	getcwd(dirPath, sizeof(dirPath));
 #endif
+
 	String currentPath = String(dirPath);
 
 	String configPath = getArg("--config");
 
 	String finalPath = configPath;
-	if(configPath[0] != '/') {
+	if(configPath[0] != '/' && configPath[1] !=':') {
 
 #ifdef _WINDOWS
 		finalPath = currentPath+"\\"+configPath;
@@ -235,12 +237,6 @@ int main(int argc, char **argv) {
 #endif
 	}
 
-#ifdef _WINDOWS
-	finalPath = finalPath.replace(":", "");
-	finalPath = finalPath.replace("\\", "/");
-	finalPath = finalPath.substr(1, finalPath.length() - 1);
-#endif
-
 	printf("Reading config file from %s\n", finalPath.c_str());
 
 	Object configFile;