소스 검색

Merge branch 'master' of https://github.com/ivansafrin/Polycode

Ivan Safrin 11 년 전
부모
커밋
0f54bea037

+ 1 - 1
Assets/Templates/C++/Windows/PolycodeTemplate.cpp

@@ -12,7 +12,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
 
 	MSG Msg;
 	do {
-		if(PeekMessage(&Msg, NULL, 0,0,PM_REMOVE)) {
+		while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {
 			TranslateMessage(&Msg);
 			DispatchMessage(&Msg);
 		}

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

@@ -393,7 +393,7 @@ namespace Polycode {
              * Returns the entity's rotation as euler angles
              @return Entity's rotation as euler angles
              */
-            Vector3 getEulerRotation() const;
+            Vector3 getRotationEuler() const;
 		
 			/**
 			* Returns the entity's pitch combined with the combined pitch of its parent.

+ 20 - 0
Core/Contents/Include/PolyLogger.h

@@ -63,5 +63,25 @@ namespace Polycode {
 			* @param str The c-string to log
 			*/
 			static void logw(const char *str);
+
+			void setLogToFile(bool val);
+			bool getLogToFile();
+
+			/**
+			* @return The file that is logged to
+			*/
+			FILE *getLogFile();
+
+			/**
+			* @return The logger instance
+			*/
+			static Logger *getInstance();
+
+	protected:
+		FILE *logFile;
+		bool logToFile;
+
+	private:
+		static Logger *overrideInstance;
 	};
 }

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

@@ -49,9 +49,9 @@ namespace Polycode {
 		void enableMouse(bool newval);
 		void captureMouse(bool);
 		unsigned int getTicks();
-		bool Update();
+		bool systemUpdate();
 		void Render();
-		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 createThread(Threaded *target);
 		std::vector<Rectangle> getVideoModes();
 		
@@ -68,6 +68,7 @@ namespace Polycode {
 		void removeDiskItem(const String& itemPath);
 		String openFolderPicker();
 		std::vector<String> openFilePicker(std::vector<CoreFileExtension> extensions, bool allowMultiple);
+                String saveFilePicker(std::vector<CoreFileExtension> extensions);
 		void resizeTo(int xRes, int yRes);
 
 		String executeExternalCommand(String command, String args, String inDirectory="");

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

@@ -122,7 +122,7 @@ void CoreServices::setupBasicListeners() {
 }
 
 CoreServices::CoreServices() : EventDispatcher() {
-	logger = new Logger();
+	logger = Logger::getInstance();
 	resourceManager = new ResourceManager();	
 	config = new Config();
 	materialManager = new MaterialManager();	

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

@@ -709,7 +709,7 @@ Vector3 Entity::getScale() const {
 	return scale;
 }
 
-Vector3 Entity::getEulerRotation() const {
+Vector3 Entity::getRotationEuler() const {
     return rotation;
 }
 

+ 47 - 2
Core/Contents/Source/PolyLogger.cpp

@@ -24,13 +24,17 @@
 #ifdef _MSC_VER
 #include <windows.h>
 #endif
+#include "PolyLogger.h"
 #include <stdio.h>
 #include <stdarg.h>
 #include <string>
 #include <iostream>
+#include <time.h>
 
 using namespace Polycode;
 
+Logger* Logger::overrideInstance = NULL;
+
 LoggerEvent::LoggerEvent(String message) : Event() {
 	this->message = message;
 }
@@ -41,11 +45,12 @@ LoggerEvent::~LoggerEvent() {
 
 
 Logger::Logger() : EventDispatcher() {
-
+	logToFile = false;
+	logFile = fopen("poly.log", "w");
 }
 
 Logger::~Logger() {
-
+	fclose(logFile);
 }
 
 void Logger::logBroadcast(String message) {
@@ -62,6 +67,12 @@ void Logger::log(const char *format, ...) {
 	va_start(args, format);
 	vfprintf(stderr, format, args);
 	va_end(args);
+	
+	if (Logger::getInstance()->getLogToFile()){
+		va_start(args, format);
+		vfprintf(Logger::getInstance()->getLogFile(), format, args);
+		va_end(args);
+	}
 
 #ifdef _MSC_VER
 #ifdef _DEBUG
@@ -84,3 +95,37 @@ void Logger::log(const char *format, ...) {
 #endif
 
 }
+
+void Logger::setLogToFile(bool val){
+	if (!logToFile && val){
+		time_t t = time(NULL);
+		char mbstr[100];
+		if (strftime(mbstr, sizeof(mbstr), "%y_%m_%d.log", localtime(&t))) {
+			//if (logFile)
+			//	fclose(logFile);
+			logFile = fopen((const char*)mbstr, "w");
+		} else {
+			logFile = fopen("poly.log", "w");
+		}
+	}
+
+	logToFile = val;
+}
+
+bool Logger::getLogToFile(){
+	return logToFile;
+}
+
+FILE *Logger::getLogFile(){
+	return logFile;
+}
+
+Logger *Logger::getInstance(){
+	if (overrideInstance) {
+		return overrideInstance;
+	}
+
+	overrideInstance = new Logger;
+	//Logger::log("Creating new logger instance...\n");
+	return overrideInstance;
+}

+ 7 - 2
Core/Contents/Source/PolySDLCore.cpp

@@ -133,7 +133,7 @@ SDLCore::SDLCore(PolycodeView *view, int _xRes, int _yRes, bool fullScreen, bool
 	CoreServices::getInstance()->installModule(new GLSLShaderModule());	
 }
 
-void SDLCore::setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel) {
+void SDLCore::setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, bool retinaSupport) {
 	this->xRes = xRes;
 	this->yRes = yRes;
 	this->fullScreen = fullScreen;
@@ -313,7 +313,7 @@ void SDLCore::Render() {
 	SDL_GL_SwapBuffers();
 }
 
-bool SDLCore::Update() {
+bool SDLCore::systemUpdate() {
 	if(!running)
 		return false;
 	doSleep();	
@@ -499,6 +499,11 @@ vector<String> SDLCore::openFilePicker(vector<CoreFileExtension> extensions, boo
 	return r;
 }
 
+String SDLCore::saveFilePicker(std::vector<CoreFileExtension> extensions) {
+        String r = "";
+        return r;
+}
+
 void SDLCore::resizeTo(int xRes, int yRes) {
 	renderer->Resize(xRes, yRes);
 }

+ 22 - 1
Core/Contents/Source/PolyWinCore.cpp

@@ -162,7 +162,27 @@ void Win32Core::enableMouse(bool newval) {
 void Win32Core::captureMouse(bool newval) {
 	// Capture the mouse in the window holding
 	// our polycode screen.
-	SetCapture(hWnd);
+	if (newval){
+		RECT rect;
+		GetWindowRect(core->hWnd, &rect);
+
+		RECT crect;
+		RECT arect;
+
+		GetClientRect(core->hWnd, &crect);
+		arect = crect;
+		AdjustWindowRectEx(&arect, WS_CAPTION | WS_BORDER, FALSE, 0);
+
+		rect.left += (crect.left - arect.left);
+		rect.right += (crect.right - arect.right);
+		rect.top += (crect.top - arect.top);
+		rect.bottom += (crect.bottom - arect.bottom);
+
+		ClipCursor(&rect);
+	}
+	else {
+		ClipCursor(NULL);
+	}
 
 	Core::captureMouse(newval);
 }
@@ -193,6 +213,7 @@ void Win32Core::Render() {
 bool Win32Core::systemUpdate() {
 	if(!running)
 		return false;
+	captureMouse(Core::mouseCaptured);
 	doSleep();
 	checkEvents();
 	Gamepad_processEvents();

+ 1 - 1
Examples/C++/Build/Windows/PolycodeExamples/PolycodeExample.cpp

@@ -12,7 +12,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
 
 	MSG Msg;
 	do {
-		if(PeekMessage(&Msg, NULL, 0,0,PM_REMOVE)) {
+		while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {
 			TranslateMessage(&Msg);
 			DispatchMessage(&Msg);
 		}

+ 6 - 6
IDE/Build/Windows/Polycode.props

@@ -28,14 +28,14 @@
       <SubSystem>Windows</SubSystem>
     </Link>
     <PostBuildEvent>
- <Command>if not exist "$(ProjectDir)default.pak" copy "$(PolycodeDir)Core\Assets\default.pak" "$(ProjectDir)"
-if not exist "$(ProjectDir)hdr.pak" copy "$(PolycodeDir)Core\Assets\hdr.pak" "$(ProjectDir)"
+ <Command>if not exist "$(TargetDir)default.pak" copy "$(PolycodeDir)Core\Assets\default.pak" "$(TargetDir)"
+if not exist "$(TargetDir)hdr.pak" copy "$(PolycodeDir)Core\Assets\hdr.pak" "$(TargetDir)"
 
-xcopy /E /Y "..\..\Contents\Resources" "$(ProjectDir)"
-if not exist "$(ProjectDir)Standalone" (
-  mkdir "$(ProjectDir)Standalone"
+xcopy /E /Y "..\..\Contents\Resources" "$(TargetDir)"
+if not exist "$(TargetDir)Standalone" (
+  mkdir "$(TargetDir)Standalone"
 )
-xcopy /E /Y "$(PolycodeDir)..\Standalone" "$(ProjectDir)Standalone"
+xcopy /E /Y "$(PolycodeDir)..\Standalone" "$(TargetDir)Standalone"
 
 if "$(ConfigurationName)" == "Debug" (
   if not exist "$(TargetDir)OpenAL32d.dll" copy "$(PolycodeDir)Core\Dependencies\bin\OpenAL32d.dll" "$(TargetDir)"

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

@@ -132,7 +132,7 @@
       <PrecompiledHeader>
       </PrecompiledHeader>
       <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>USE_POLYCODEUI_MENUBAR;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
     </ClCompile>
     <Link>
@@ -150,7 +150,7 @@
       <Optimization>MaxSpeed</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>USE_POLYCODEUI_MENUBAR;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
       <GenerateDebugInformation>true</GenerateDebugInformation>

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

@@ -88,7 +88,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
 
 	MSG Msg;
 	do {
-		if(PeekMessage(&Msg, NULL, 0,0,PM_REMOVE)) {
+		while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {
 			TranslateMessage(&Msg);
 			DispatchMessage(&Msg);
 		}

+ 6 - 6
IDE/Build/Windows2013/Polycode.props

@@ -28,14 +28,14 @@
       <SubSystem>Windows</SubSystem>
     </Link>
     <PostBuildEvent>
- <Command>if not exist "$(ProjectDir)default.pak" copy "$(PolycodeDir)Core\Assets\default.pak" "$(ProjectDir)"
-if not exist "$(ProjectDir)hdr.pak" copy "$(PolycodeDir)Core\Assets\hdr.pak" "$(ProjectDir)"
+ <Command>if not exist "$(TargetDir)default.pak" copy "$(PolycodeDir)Core\Assets\default.pak" "$(TargetDir)"
+if not exist "$(TargetDir)hdr.pak" copy "$(PolycodeDir)Core\Assets\hdr.pak" "$(TargetDir)"
 
-xcopy /E /Y "..\..\Contents\Resources" "$(ProjectDir)"
-if not exist "$(ProjectDir)Standalone" (
-  mkdir "$(ProjectDir)Standalone"
+xcopy /E /Y "..\..\Contents\Resources" "$(TargetDir)"
+if not exist "$(TargetDir)Standalone" (
+  mkdir "$(TargetDir)Standalone"
 )
-xcopy /E /Y "$(PolycodeDir)..\Standalone" "$(ProjectDir)Standalone"
+xcopy /E /Y "$(PolycodeDir)..\Standalone" "$(TargetDir)Standalone"
 
 if "$(ConfigurationName)" == "Debug" (
   if not exist "$(TargetDir)OpenAL32d.dll" copy "$(PolycodeDir)Core\Dependencies\bin\OpenAL32d.dll" "$(TargetDir)"

+ 2 - 2
IDE/Build/Windows2013/Polycode.vcxproj

@@ -171,7 +171,7 @@
       <PrecompiledHeader>
       </PrecompiledHeader>
       <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>USE_POLYCODEUI_MENUBAR;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
     </ClCompile>
     <Link>
@@ -205,7 +205,7 @@
       <Optimization>MaxSpeed</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>USE_POLYCODEUI_MENUBAR;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
       <GenerateDebugInformation>true</GenerateDebugInformation>

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

@@ -92,7 +92,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
 
 	MSG Msg;
 	do {
-		if(PeekMessage(&Msg, NULL, 0,0,PM_REMOVE)) {
+		while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {
 
 			if (!TranslateAccelerator(view->hwnd, view->haccel, &Msg)) {
 				TranslateMessage(&Msg);

+ 3 - 3
IDE/Contents/Source/PolycodeProps.cpp

@@ -2526,9 +2526,9 @@ void TransformSheet::Update() {
         lastScale = entity->getScale();
     }
     
-    if(entity->getEulerRotation() != lastRotation) {
-        rotationProp->set(entity->getEulerRotation());
-        lastRotation = entity->getEulerRotation();
+    if(entity->getRotationEuler() != lastRotation) {
+        rotationProp->set(entity->getRotationEuler());
+        lastRotation = entity->getRotationEuler();
     }
 }
 

+ 24 - 0
Modules/Contents/UI/Include/PolyUIElement.h

@@ -125,6 +125,30 @@ namespace Polycode {
         void setText(const String& text);
         String getText();
         
+		/**
+		* Sets the color of the Labels as normalized floating point values.
+		* @param r Red value as a 0-1 floating point number.
+		* @param g Green value as a 0-1 floating point number.
+		* @param b Blue value as a 0-1 floating point number.
+		* @param a Alpha value as a 0-1 floating point number.
+		*/
+		void setColor(Number r, Number g, Number b, Number a);
+
+		/**
+		* Sets the color of the entity as 0-255 integers.
+		* @param r Red value as a 0-255 integer.
+		* @param g Green value as a 0-255 integer.
+		* @param b Blue value as a 0-255 integer.
+		* @param a Alpha value as a 0-255 integer.
+		*/
+		void setColorInt(int r, int g, int b, int a);
+
+		/**
+		* Sets the color of the entity.
+		* @param color Color to set the entity color to.
+		*/
+		void setColor(Color color);
+
         ~UIMultilineLabel();
     protected:
         

+ 19 - 1
Modules/Contents/UI/Source/PolyUIElement.cpp

@@ -51,10 +51,10 @@ void UIMultilineLabel::setText(const String& text) {
         } else {
             UILabel *label = new UILabel(lines[i], labelSize, labelFontName, labelAAMode);
             lineSize = label->getHeight();
-            addChild(label);
             label->setPositionY(yPos);
             yPos += label->getHeight() + spacing;
             addChild(label);
+			labels.push_back(label);
         }
     }
 }
@@ -70,6 +70,24 @@ String UIMultilineLabel::getText() {
     return text;
 }
 
+void UIMultilineLabel::setColor(Color color) {
+	for (int i = 0; i < labels.size(); i++) {
+		labels[i]->color.setColor(&color);
+	}
+}
+
+void UIMultilineLabel::setColorInt(int r, int g, int b, int a) {
+	for (int i = 0; i < labels.size(); i++) {
+		labels[i]->color.setColorRGBA(r, g, b, a);
+	}
+}
+
+void UIMultilineLabel::setColor(Number r, Number g, Number b, Number a) {
+	for (int i = 0; i < labels.size(); i++) {
+		labels[i]->color.setColor(r, g, b, a);
+	}
+}
+
 void UIMultilineLabel::clearLabels() {
     for(int i=0; i < labels.size(); i++) {
         removeChild(labels[i]);

+ 1 - 1
Player/Build/MSVC/PolycodePlayer/main.cpp

@@ -77,7 +77,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
 	MSG Msg;
 
 		do {
-			if(PeekMessage(&Msg, NULL, 0,0,PM_REMOVE)) {
+			while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {
 				TranslateMessage(&Msg);
 				DispatchMessage(&Msg);
 			}

+ 1 - 1
Player/Contents/Platform/Windows/Standalone/main.cpp

@@ -37,7 +37,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
 	MSG Msg;
 
 		do {
-			if(PeekMessage(&Msg, NULL, 0,0,PM_REMOVE)) {
+			while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {
 				TranslateMessage(&Msg);
 				DispatchMessage(&Msg);
 			}

+ 1 - 1
Player/Contents/Platform/Windows/main.cpp

@@ -48,7 +48,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
 	MSG Msg;
 
 		do {
-			if(PeekMessage(&Msg, NULL, 0,0,PM_REMOVE)) {
+			while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {
 				TranslateMessage(&Msg);
 				DispatchMessage(&Msg);
 			}

+ 1 - 0
Standalone/CMakeLists.txt

@@ -36,6 +36,7 @@ IF(MSVC OR MINGW)
 
 INSTALL(PROGRAMS ${POLYCODE_RELEASE_DIR}/Framework/Tools/polybuild.exe DESTINATION Bin)
 INSTALL(PROGRAMS ${POLYCODE_RELEASE_DIR}/Framework/Tools/polyimport.exe DESTINATION Bin)
+INSTALL(PROGRAMS ${POLYCODE_RELEASE_DIR}/Framework/Tools/Dependencies/bin/archive.dll DESTINATION Bin)
 INSTALL(DIRECTORY ${PolycodeStandalone_SOURCE_DIR}/../Assets/Templates/Lua DESTINATION Template)