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

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

@@ -43,7 +43,7 @@ namespace Polycode {
 		
 	public:
 		
-		SDLCore(PolycodeView *view, int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate, int monitorIndex=-1, bool resizableWindow = false);
+		SDLCore(PolycodeView *view, int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate, int monitorIndex=-1);
 		~SDLCore();
 
 		void enableMouse(bool newval);
@@ -71,7 +71,10 @@ namespace Polycode {
 		String executeExternalCommand(String command, String args, String inDirectory="");
 		void openURL(String url);
 
+
 	private:
+		bool checkSpecialKeyEvents(PolyKEY key);
+
 		uint32_t flags;
 		bool resizableWindow;
 		

+ 2 - 1
Core/Contents/PolycodeView/Linux/PolycodeView.cpp

@@ -2,9 +2,10 @@
 
 namespace Polycode {
 
-    PolycodeView::PolycodeView(const char *title) : PolycodeViewBase() {
+    PolycodeView::PolycodeView(const char *title, bool resizable) : PolycodeViewBase() {
         windowTitle = title;
         windowData = &windowTitle;
+	this->resizable = resizable;
     }
 
     PolycodeView::~PolycodeView() {

+ 2 - 1
Core/Contents/PolycodeView/Linux/PolycodeView.h

@@ -6,10 +6,11 @@ namespace Polycode {
 
     class PolycodeView : public PolycodeViewBase {
         public:
-            PolycodeView(const char *title);
+            PolycodeView(const char *title, bool resizable = false);
             ~PolycodeView();
 
             String windowTitle;
+	    bool resizable;
     };
 
 }

+ 41 - 4
Core/Contents/Source/PolySDLCore.cpp

@@ -55,9 +55,9 @@ void Core::getScreenInfo(int *width, int *height, int *hz) {
 	if (hz) *hz = 0;
 }
 
-SDLCore::SDLCore(PolycodeView *view, int _xRes, int _yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate, int monitorIndex, bool resizableWindow) : Core(_xRes, _yRes, fullScreen, vSync, aaLevel, anisotropyLevel, frameRate, monitorIndex) {
+SDLCore::SDLCore(PolycodeView *view, int _xRes, int _yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate, int monitorIndex) : Core(_xRes, _yRes, fullScreen, vSync, aaLevel, anisotropyLevel, frameRate, monitorIndex) {
 
-	this->resizableWindow = resizableWindow;
+	this->resizableWindow = view->resizable;
 
 	char *buffer = getcwd(NULL, 0);
 	defaultWorkingDirectory = String(buffer);
@@ -210,6 +210,41 @@ void SDLCore::enableMouse(bool newval) {
 	Core::enableMouse(newval);
 }
 
+bool SDLCore::checkSpecialKeyEvents(PolyKEY key) {
+	
+	if(key == KEY_a && (input->getKeyState(KEY_LCTRL) || input->getKeyState(KEY_RCTRL))) {
+		dispatchEvent(new Event(), Core::EVENT_SELECT_ALL);
+		return true;
+	}
+	
+	if(key == KEY_c && (input->getKeyState(KEY_LCTRL) || input->getKeyState(KEY_RCTRL))) {
+		dispatchEvent(new Event(), Core::EVENT_COPY);
+		return true;
+	}
+	
+	if(key == KEY_x && (input->getKeyState(KEY_LCTRL) || input->getKeyState(KEY_RCTRL))) {
+		dispatchEvent(new Event(), Core::EVENT_CUT);
+		return true;
+	}
+	
+	
+	if(key == KEY_z  && (input->getKeyState(KEY_LCTRL) || input->getKeyState(KEY_RCTRL)) && (input->getKeyState(KEY_LSHIFT) || input->getKeyState(KEY_RSHIFT))) {
+		dispatchEvent(new Event(), Core::EVENT_REDO);
+		return true;
+	}
+		
+	if(key == KEY_z  && (input->getKeyState(KEY_LCTRL) || input->getKeyState(KEY_RCTRL))) {
+		dispatchEvent(new Event(), Core::EVENT_UNDO);
+		return true;
+	}
+	
+	if(key == KEY_v && (input->getKeyState(KEY_LCTRL) || input->getKeyState(KEY_RCTRL))) {
+		dispatchEvent(new Event(), Core::EVENT_PASTE);
+		return true;
+	}
+	return false;
+}
+
 bool SDLCore::Update() {
 	if(!running)
 		return false;
@@ -241,7 +276,9 @@ bool SDLCore::Update() {
 //					input->setKeyState((PolyKEY)(event.key.keysym.sym), true);
 				break;
 				case SDL_KEYDOWN:
-					input->setKeyState((PolyKEY)(event.key.keysym.sym), (char)event.key.keysym.unicode, true, getTicks());
+					if(!checkSpecialKeyEvents((PolyKEY)(event.key.keysym.sym))) {
+						input->setKeyState((PolyKEY)(event.key.keysym.sym), (char)event.key.keysym.unicode, true, getTicks());
+					}
 				break;
 				case SDL_KEYUP:
 					input->setKeyState((PolyKEY)(event.key.keysym.sym), (char)event.key.keysym.unicode, false, getTicks());
@@ -323,7 +360,7 @@ void SDLCore::copyStringToClipboard(const String& str) {
 }
 
 String SDLCore::getClipboardString() {
-
+	return "";
 }
 
 void SDLCore::createFolder(const String& folderPath) {

+ 3 - 0
Core/Contents/Source/PolyString.cpp

@@ -128,6 +128,9 @@ vector<String> String::split(const String &delim) const {
 	vector<String> tokens;
 	bool trimEmpty = false;
 	
+	if(contents == "")
+		return tokens;
+
 		std::string::size_type pos, lastPos = 0;
 		while(true)
 		{

+ 1 - 1
IDE/Build/Linux/Makefile

@@ -5,7 +5,7 @@ LDFLAGS_DEBUG=-lrt -ldl -lpthread ../../../Release/Linux/Framework/Core/lib/libP
 SRCS=../../Contents/Source/ExampleBrowserWindow.cpp ../../Contents/Source/PolycodeEditorManager.cpp  ../../Contents/Source/PolycodeProject.cpp        ../../Contents/Source/PolycodeScreenEditor.cpp ../../Contents/Source/ExportProjectWindow.cpp  ../../Contents/Source/PolycodeFontEditor.cpp     ../../Contents/Source/PolycodeProjectBrowser.cpp ../../Contents/Source/PolycodeSpriteEditor.cpp ../../Contents/Source/NewFileWindow.cpp        ../../Contents/Source/PolycodeFrame.cpp          ../../Contents/Source/PolycodeProjectEditor.cpp  ../../Contents/Source/PolycodeTextEditor.cpp ../../Contents/Source/NewProjectWindow.cpp     ../../Contents/Source/PolycodeIDEApp.cpp         ../../Contents/Source/PolycodeProjectManager.cpp ../../Contents/Source/PolycodeToolLauncher.cpp ../../Contents/Source/PolycodeConsole.cpp      ../../Contents/Source/PolycodeImageEditor.cpp    ../../Contents/Source/PolycodeProps.cpp          ../../Contents/Source/TextureBrowser.cpp ../../Contents/Source/PolycodeEditor.cpp       ../../Contents/Source/PolycodeMaterialEditor.cpp ../../Contents/Source/PolycodeRemoteDebugger.cpp ../../Contents/Source/ToolWindows.cpp
 
 default:
-	$(CC) $(CFLAGS) main.cpp $(SRCS) -o ./Build/Polycode $(LDFLAGS)
+	$(CC) $(CFLAGS) -O2 main.cpp $(SRCS) -o ./Build/Polycode $(LDFLAGS)
 	cp -R ../../Contents/Resources/* Build/
 	cp ../../../Release/Linux/Framework/Core/Assets/default.pak Build/
 	cp -R ../../../Release/Linux/Standalone Build

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

@@ -3,7 +3,7 @@
 #include "PolycodeIDEApp.h"
 
 int main(int argc, char *argv[]) {
-	PolycodeView *view = new PolycodeView("Hello Polycode!");
+	PolycodeView *view = new PolycodeView("Polycode", true);
 	PolycodeIDEApp *app = new PolycodeIDEApp(view);
 	while(app->Update()) {}
 	app->saveConfigFile();

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

@@ -143,6 +143,7 @@ PolycodeIDEApp::PolycodeIDEApp(PolycodeView *view) : EventDispatcher() {
 
 	UIMenuBarEntry *helpEntry = menuBar->addMenuBarEntry("Help");
 	helpEntry->addItem("API Reference", "show_api");
+	helpEntry->addItem("About Polycode", "show_about");
 
 
 	menuBar->addEventListener(this, UIEvent::OK_EVENT);
@@ -421,6 +422,8 @@ void PolycodeIDEApp::handleEvent(Event *event) {
 			exportProject();
 		} else if(action == "show_api") {
 			openDocs();
+		} else if(action == "show_about") {
+			showAbout();
 		}
 	}
 

+ 3 - 1
IDE/Contents/Source/PolycodeToolLauncher.cpp

@@ -42,7 +42,9 @@ void PolycodeRunner::runThread() {
 	String args = polyappPath;
 	String inFolder = polycodeBasePath+"/Standalone/Player";
 #else
-	String command = "cd "+polycodeBasePath+"/Standalone/Player && ./PolycodePlayer "+polyappPath;
+	String command = "./PolycodePlayer";	
+	String inFolder = polycodeBasePath+"/Standalone/Player";
+	String args = polyappPath;
 #endif
 
 	String ret = CoreServices::getInstance()->getCore()->executeExternalCommand(command, args, inFolder);

+ 1 - 0
Player/Contents/Platform/Linux/Standalone/main.cpp

@@ -7,5 +7,6 @@ int main(int argc, char *argv[]) {
 	PolycodeLinuxPlayer *player = new PolycodeLinuxPlayer(view, "main.polyapp", false);
 	player->runPlayer();
 	while(player->Update()) {}
+	delete player;
 	return 0;
 }

+ 1 - 0
Player/Contents/Platform/Linux/main.cpp

@@ -11,5 +11,6 @@ int main(int argc, char *argv[]) {
 	PolycodeLinuxPlayer *player = new PolycodeLinuxPlayer(view, argv[1], false, true);
 	player->runPlayer();
 	while(player->Update()) {}
+	delete player;
 	return 0;
 }