Răsfoiți Sursa

More Linux fixes

Ivan Safrin 13 ani în urmă
părinte
comite
c29cf18bf5

+ 2 - 0
.gitignore

@@ -77,6 +77,8 @@ Player/Build/Mac OS X/Polycode Player.xcodeproj/project.xcworkspace/xcuserdata/i
 
 
 /IDE/Contents/Resources/Standalone
 /IDE/Contents/Resources/Standalone
 
 
+/IDE/Build/Linux/Build
+
 /Core/Build/Mac\ OS\ X/build
 /Core/Build/Mac\ OS\ X/build
 /IDE/Build/Mac\ OS\ X/build
 /IDE/Build/Mac\ OS\ X/build
 /Modules/Build/Mac\ OS\ X/build
 /Modules/Build/Mac\ OS\ X/build

+ 4 - 0
BUILD.md

@@ -195,6 +195,10 @@ of variables to the cmake commands above. To build the bindings, you
 need a python installation with the PLY python module. You can get
 need a python installation with the PLY python module. You can get
 the PLY module at http://www.dabeaz.com/ply/
 the PLY module at http://www.dabeaz.com/ply/
 
 
+Note: You will need python 2 for this step. If you have python 3 installed,
+pass -DPYTHON_EXECUTABLE=/usr/bin/python2 or whatever the full path to
+the python2 executable is on your system.
+
 To enable the bindings and the player, add the following options to the
 To enable the bindings and the player, add the following options to the
 cmake command. Otherwise, the steps are exactly the same as the regular 
 cmake command. Otherwise, the steps are exactly the same as the regular 
 Polycode build for your system.
 Polycode build for your system.

+ 8 - 3
BUILD.txt

@@ -79,9 +79,10 @@ directory from a command prompt (for VS2010):
     cd Build
     cd Build
     cmake -G "Visual Studio 10" ..
     cmake -G "Visual Studio 10" ..
     
     
-This generates a PolycodeDependencies.sln in the Build directory.
-Building the ALL_BUILD project in the solution in Visual Studio will download,
-build and install the dependencies. Note that you need to build both Debug and Release.
+This generates a PolycodeDependencies.sln in the Build directory. 
+Building the ALL_BUILD project in the solution in Visual Studio will download, build and 
+install the dependencies. Note that you need to build both Debug and
+Release.
 
 
 You will also need to manually build the "glext" and "wglext" projects.
 You will also need to manually build the "glext" and "wglext" projects.
 
 
@@ -194,6 +195,10 @@ of variables to the cmake commands above. To build the bindings, you
 need a python installation with the PLY python module. You can get
 need a python installation with the PLY python module. You can get
 the PLY module at http://www.dabeaz.com/ply/
 the PLY module at http://www.dabeaz.com/ply/
 
 
+Note: You will need python 2 for this step. If you have python 3 installed,
+pass -DPYTHON_EXECUTABLE=/usr/bin/python2 or whatever the full path to
+the python2 executable is on your system.
+
 To enable the bindings and the player, add the following options to the
 To enable the bindings and the player, add the following options to the
 cmake command. Otherwise, the steps are exactly the same as the regular 
 cmake command. Otherwise, the steps are exactly the same as the regular 
 Polycode build for your system.
 Polycode build for your system.

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

@@ -41,7 +41,7 @@ namespace Polycode {
 		
 		
 	public:
 	public:
 		
 		
-		SDLCore(PolycodeView *view, int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate, int monitorIndex=-1);
+		SDLCore(PolycodeView *view, int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate, int monitorIndex=-1, bool resizableWindow = false);
 		~SDLCore();
 		~SDLCore();
 
 
 		void enableMouse(bool newval);
 		void enableMouse(bool newval);
@@ -70,8 +70,8 @@ namespace Polycode {
 		void openURL(String url);
 		void openURL(String url);
 
 
 	private:
 	private:
-		
-		
+		uint32_t flags;
+		bool resizableWindow;
 		
 		
 	};
 	};
 }
 }

+ 59 - 10
Core/Contents/Source/PolySDLCore.cpp

@@ -34,6 +34,10 @@
 #include <SDL/SDL.h>
 #include <SDL/SDL.h>
 #include <iostream>
 #include <iostream>
 
 
+#include <unistd.h>
+#include <sys/types.h>
+#include <pwd.h>
+
 using namespace Polycode;
 using namespace Polycode;
 using std::vector;
 using std::vector;
 
 
@@ -49,11 +53,25 @@ void Core::getScreenInfo(int *width, int *height, int *hz) {
 	if (hz) *hz = 0;
 	if (hz) *hz = 0;
 }
 }
 
 
-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) {
+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) {
+
+	this->resizableWindow = resizableWindow;
+
+	char *buffer = getcwd(NULL, 0);
+	defaultWorkingDirectory = String(buffer);
+	free(buffer);
+
+	struct passwd *pw = getpwuid(getuid());
+	const char *homedir = pw->pw_dir;
+	userHomeDirectory = String(homedir);
 
 
 	String *windowTitle = (String*)view->windowData;
 	String *windowTitle = (String*)view->windowData;
 
 
-	putenv("SDL_VIDEO_CENTERED=1");
+	if(resizableWindow) {
+		unsetenv("SDL_VIDEO_CENTERED");
+	} else {
+		setenv("SDL_VIDEO_CENTERED", "1", 1);
+	}
 
 
 	if(SDL_Init(SDL_INIT_VIDEO) < 0) {
 	if(SDL_Init(SDL_INIT_VIDEO) < 0) {
 	}
 	}
@@ -95,16 +113,20 @@ void SDLCore::setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int
 	
 	
 	SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0);
 	SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0);
 	
 	
+	flags = SDL_OPENGL;
+
 	if(fullScreen) {
 	if(fullScreen) {
-		if( SDL_SetVideoMode(xRes, yRes, 0, SDL_OPENGL|SDL_FULLSCREEN) == NULL ) {
-		}	
-	} else {
-		if( SDL_SetVideoMode(xRes, yRes, 0, SDL_OPENGL) == NULL ) {
-		}
+		flags |= SDL_FULLSCREEN;
 	}
 	}
+
+	if(resizableWindow) {
+		flags |= SDL_RESIZABLE;
+	}
+	SDL_SetVideoMode(xRes, yRes, 0, flags);
 	
 	
 	renderer->Resize(xRes, yRes);
 	renderer->Resize(xRes, yRes);
-	CoreServices::getInstance()->getMaterialManager()->reloadProgramsAndTextures();
+	//CoreServices::getInstance()->getMaterialManager()->reloadProgramsAndTextures();
+	dispatchEvent(new Event(), EVENT_CORE_RESIZE);	
 }
 }
 
 
 vector<Polycode::Rectangle> SDLCore::getVideoModes() {
 vector<Polycode::Rectangle> SDLCore::getVideoModes() {
@@ -130,7 +152,22 @@ void SDLCore::openURL(String url) {
 }
 }
 
 
 String SDLCore::executeExternalCommand(String command) {
 String SDLCore::executeExternalCommand(String command) {
-	
+	FILE *fp = popen(command.c_str(), "r");
+	if(!fp) {
+		return "Unable to execute command";
+	}	
+
+	int fd = fileno(fp);
+
+	char path[2048];
+	String retString;
+
+	while (fgets(path, sizeof(path), fp) != NULL) {
+		retString = retString + String(path);
+	}
+
+	pclose(fp);
+	return retString;
 }
 }
 
 
 int SDLThreadFunc(void *data) {
 int SDLThreadFunc(void *data) {
@@ -157,7 +194,7 @@ void SDLCore::enableMouse(bool newval) {
 	}
 	}
 	Core::enableMouse(newval);
 	Core::enableMouse(newval);
 }
 }
-	
+
 bool SDLCore::Update() {
 bool SDLCore::Update() {
 	if(!running)
 	if(!running)
 		return false;
 		return false;
@@ -173,6 +210,18 @@ bool SDLCore::Update() {
 				case SDL_QUIT:
 				case SDL_QUIT:
 					running = false;
 					running = false;
 				break;
 				break;
+				case SDL_VIDEORESIZE:
+	if(resizableWindow) {
+		unsetenv("SDL_VIDEO_CENTERED");
+	} else {
+		setenv("SDL_VIDEO_CENTERED", "1", 1);
+	}
+					this->xRes = event.resize.w;
+					this->yRes = event.resize.h;
+					SDL_SetVideoMode(xRes, yRes, 0, flags);
+					renderer->Resize(xRes, yRes);	
+					dispatchEvent(new Event(), EVENT_CORE_RESIZE);	
+				break;
 				case SDL_JOYBUTTONDOWN:
 				case SDL_JOYBUTTONDOWN:
 //					input->setKeyState((PolyKEY)(event.key.keysym.sym), true);
 //					input->setKeyState((PolyKEY)(event.key.keysym.sym), true);
 				break;
 				break;

+ 13 - 0
IDE/Build/Linux/Makefile

@@ -0,0 +1,13 @@
+CC=g++
+CFLAGS=-I../../Contents/Include -I../../../Release/Linux/Framework/Core/Dependencies/include -I../../../Release/Linux/Framework/Core/Dependencies/include/AL -I../../../Release/Linux/Framework/Core/include -I../../../Release/Linux/Framework/Modules/include -I../../../Release/Linux/Framework/Modules/Dependencies/include -I../../../Release/Linux/Framework/Modules/Dependencies/include/bullet
+LDFLAGS=-lrt -ldl -lpthread ../../../Release/Linux/Framework/Core/lib/libPolycore.a ../../../Release/Linux/Framework/Core/Dependencies/lib/libfreetype.a ../../../Release/Linux/Framework/Core/Dependencies/lib/liblibvorbisfile.a ../../../Release/Linux/Framework/Core/Dependencies/lib/liblibvorbis.a ../../../Release/Linux/Framework/Core/Dependencies/lib/liblibogg.a ../../../Release/Linux/Framework/Core/Dependencies/lib/libopenal.so ../../../Release/Linux/Framework/Core/Dependencies/lib/libphysfs.a ../../../Release/Linux/Framework/Core/Dependencies/lib/libpng15.a ../../../Release/Linux/Framework/Core/Dependencies/lib/libz.a -lGL -lGLU -lSDL ../../../Release/Linux/Framework/Modules/lib/libPolycode2DPhysics.a ../../../Release/Linux/Framework/Modules/Dependencies/lib/libBox2D.a ../../../Release/Linux/Framework/Modules/lib/libPolycode3DPhysics.a ../../../Release/Linux/Framework/Modules/Dependencies/lib/libBulletDynamics.a ../../../Release/Linux/Framework/Modules/Dependencies/lib/libBulletCollision.a ../../../Release/Linux/Framework/Modules/Dependencies/lib/libLinearMath.a ../../../Release/Linux/Framework/Modules/lib/libPolycodeUI.a
+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) -g 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
+clean:
+	rm ./Build/Polycode
+	

+ 10 - 0
IDE/Build/Linux/main.cpp

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

+ 2 - 2
IDE/Contents/Include/PolycodeIDEApp.h

@@ -26,7 +26,7 @@
 #include "PolycodeProjectManager.h"
 #include "PolycodeProjectManager.h"
 #include "PolycodeEditorManager.h"
 #include "PolycodeEditorManager.h"
 #include "Polycode.h"
 #include "Polycode.h"
-#include "PolyCocoaCore.h"
+//#include "PolyCocoaCore.h"
 #include "PolycodeUI.h"
 #include "PolycodeUI.h"
 #include "PolycodeFrame.h"
 #include "PolycodeFrame.h"
 
 
@@ -89,7 +89,7 @@ public:
 	
 	
 	const static int EVENT_SHOW_MENU = 1;
 	const static int EVENT_SHOW_MENU = 1;
 	
 	
-	CocoaCore *core;	
+	Core *core;	
 protected:
 protected:
 
 
 	bool willRunProject;
 	bool willRunProject;

+ 2 - 2
IDE/Contents/Include/PolycodeProjectManager.h

@@ -48,7 +48,7 @@ class PolycodeProjectManager {
 	
 	
 	PolycodeProject *getProjectByProjectFile(String projectFile);
 	PolycodeProject *getProjectByProjectFile(String projectFile);
 	
 	
-	void exportProject(PolycodeProject *project, String exportPath, bool macOS, bool windows, bool linux);
+	void exportProject(PolycodeProject *project, String exportPath, bool macOS, bool windows, bool _linux);
 	
 	
 	int removeProject(PolycodeProject *project);
 	int removeProject(PolycodeProject *project);
 	
 	
@@ -64,4 +64,4 @@ protected:
 	PolycodeProjectBrowser *projectBrowser;
 	PolycodeProjectBrowser *projectBrowser;
 	vector<PolycodeProject*> projects;
 	vector<PolycodeProject*> projects;
 	
 	
-};	
+};	

+ 1 - 1
IDE/Contents/Source/PolycodeIDEApp.cpp

@@ -29,7 +29,7 @@ UIGlobalMenu *globalMenu;
 SyntaxHighlightTheme *globalSyntaxTheme;
 SyntaxHighlightTheme *globalSyntaxTheme;
 
 
 PolycodeIDEApp::PolycodeIDEApp(PolycodeView *view) : EventDispatcher() {
 PolycodeIDEApp::PolycodeIDEApp(PolycodeView *view) : EventDispatcher() {
-	core = new CocoaCore(view, 900,700,false,true, 0, 0,30);	
+	core = new SDLCore(view, 900,700,false,true, 0, 0,30, -1, true);	
 	core->addEventListener(this, Core::EVENT_CORE_RESIZE);
 	core->addEventListener(this, Core::EVENT_CORE_RESIZE);
 	
 	
 	
 	

+ 1 - 1
IDE/Contents/Source/PolycodeProjectManager.cpp

@@ -136,7 +136,7 @@ void PolycodeProjectManager::createNewProject(String templateFolder, String proj
 	openProject(projectLocation+"/"+projectName+"/"+projectName+".polyproject");	
 	openProject(projectLocation+"/"+projectName+"/"+projectName+".polyproject");	
 }
 }
 
 
-void PolycodeProjectManager::exportProject(PolycodeProject *project, String exportPath, bool macOS, bool windows, bool linux) {
+void PolycodeProjectManager::exportProject(PolycodeProject *project, String exportPath, bool macOS, bool windows, bool _linux) {
 
 
 	String polycodeBasePath = CoreServices::getInstance()->getCore()->getDefaultWorkingDirectory();
 	String polycodeBasePath = CoreServices::getInstance()->getCore()->getDefaultWorkingDirectory();
 
 

+ 1 - 1
IDE/Contents/Source/PolycodeScreenEditor.cpp

@@ -788,7 +788,7 @@ void PolycodeScreenEditorMain::syncTransformToSelected() {
 		screenTransformShape->setShapeSize(selectedEntity->getWidth(),selectedEntity->getHeight());	
 		screenTransformShape->setShapeSize(selectedEntity->getWidth(),selectedEntity->getHeight());	
 		Matrix4 final = selectedEntity->getConcatenatedMatrixRelativeTo(baseEntity);
 		Matrix4 final = selectedEntity->getConcatenatedMatrixRelativeTo(baseEntity);
 		screenTransform->setPosition(final.getPosition());
 		screenTransform->setPosition(final.getPosition());
-		screenTransformShape->matrixDirty = false;
+		screenTransformShape->dirtyMatrix(false);
 		screenTransformShape->setTransformByMatrixPure(final);
 		screenTransformShape->setTransformByMatrixPure(final);
 		
 		
 		screenTransform->rotation.roll = selectedEntity->getCombinedRoll();
 		screenTransform->rotation.roll = selectedEntity->getCombinedRoll();

+ 6 - 2
IDE/Contents/Source/PolycodeToolLauncher.cpp

@@ -33,11 +33,15 @@ PolycodeRunner::PolycodeRunner(String polyappPath) : Threaded() {
 void PolycodeRunner::runThread() {
 void PolycodeRunner::runThread() {
 	String polycodeBasePath = CoreServices::getInstance()->getCore()->getDefaultWorkingDirectory();
 	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;
 		;		
 		;		
+#else
+	String command = "cd "+polycodeBasePath+"/Standalone/Player && ./PolycodePlayer "+polyappPath;
 
 
+#endif
 	String ret = CoreServices::getInstance()->getCore()->executeExternalCommand(command);
 	String ret = CoreServices::getInstance()->getCore()->executeExternalCommand(command);
-		core->removeDiskItem(polyappPath);	
+	core->removeDiskItem(polyappPath);	
 }
 }
 
 
 PolycodeToolLauncher::PolycodeToolLauncher() {
 PolycodeToolLauncher::PolycodeToolLauncher() {
@@ -92,4 +96,4 @@ void PolycodeToolLauncher::runPolyapp(String polyappPath) {
 
 
 #endif
 #endif
 
 
-}
+}

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

@@ -142,7 +142,7 @@ void UIWindow::onMouseDown(Number x, Number y) {
 	if(hasFocus)
 	if(hasFocus)
 		return;
 		return;
 	hasFocus = true;
 	hasFocus = true;
-	dispatchEvent(new ScreenEvent(), ScreenEvent::ENTITY_MOVE_TOP);
+	//dispatchEvent(new ScreenEvent(), ScreenEvent::ENTITY_MOVE_TOP);
 	for(int i=0; i < children.size(); i++) {
 	for(int i=0; i < children.size(); i++) {
 		if(((ScreenEntity*)children[i])->isFocusable()) {
 		if(((ScreenEntity*)children[i])->isFocusable()) {
 			focusChild(((ScreenEntity*)children[i]));
 			focusChild(((ScreenEntity*)children[i]));
@@ -189,4 +189,4 @@ void UIWindow::handleEvent(Event *event) {
 		enabled = false;		
 		enabled = false;		
 		windowTween->removeEventListener(this, Event::COMPLETE_EVENT);
 		windowTween->removeEventListener(this, Event::COMPLETE_EVENT);
 	}
 	}
-}
+}