Ver código fonte

Fix packer and ConstructAuto in windows

Pabloader 4 anos atrás
pai
commit
13c2500b6c

+ 40
- 0
.vscode/launch.json Ver arquivo

4
     // Для получения дополнительной информации посетите: https://go.microsoft.com/fwlink/?linkid=830387
4
     // Для получения дополнительной информации посетите: https://go.microsoft.com/fwlink/?linkid=830387
5
     "version": "0.2.0",
5
     "version": "0.2.0",
6
     "configurations": [
6
     "configurations": [
7
+        {
8
+            "name": "(gdb-win) Launch Packer",
9
+            "type": "cppdbg",
10
+            "request": "launch",
11
+            "program": "${workspaceFolder}\\packer\\packer.exe",
12
+            "args": ["--convert", "C:\\Projects\\AwoorwaOLC\\res\\awoorwa.png", "res\\awoorwa.spr"],
13
+            "stopAtEntry": false,
14
+            "cwd": "${workspaceFolder}",
15
+            "environment": [],
16
+            "externalConsole": false,
17
+            "MIMode": "gdb",
18
+            "miDebuggerPath": "C:\\MinGW\\mingw32\\bin\\gdb.exe",
19
+            "setupCommands": [
20
+                {
21
+                    "description": "Enable pretty-printing for gdb",
22
+                    "text": "-enable-pretty-printing",
23
+                    "ignoreFailures": true
24
+                }
25
+            ]
26
+        },
27
+        {
28
+            "name": "(gdb-win) Launch Awoorwae",
29
+            "type": "cppdbg",
30
+            "request": "launch",
31
+            "program": "${workspaceFolder}\\awoorwae.exe",
32
+            "args": [],
33
+            "stopAtEntry": false,
34
+            "cwd": "${workspaceFolder}",
35
+            "environment": [],
36
+            "externalConsole": false,
37
+            "MIMode": "gdb",
38
+            "miDebuggerPath": "C:\\MinGW\\mingw32\\bin\\gdb.exe",
39
+            "setupCommands": [
40
+                {
41
+                    "description": "Enable pretty-printing for gdb",
42
+                    "text": "-enable-pretty-printing",
43
+                    "ignoreFailures": true
44
+                }
45
+            ]
46
+        },
7
         {
47
         {
8
             "name": "(gdb) Launch",
48
             "name": "(gdb) Launch",
9
             "type": "cppdbg",
49
             "type": "cppdbg",

+ 5
- 4
Makefile Ver arquivo

3
 CPPFLAGS=-Wall -Wno-misleading-indentation -Werror --std=c++1z
3
 CPPFLAGS=-Wall -Wno-misleading-indentation -Werror --std=c++1z
4
 LDFLAGS=
4
 LDFLAGS=
5
 INCLUDES=-Ipge/include
5
 INCLUDES=-Ipge/include
6
-EXECUTABLE=awoorwae
7
-PACKER=packer/packer
8
 ifeq ($(OS),Windows_NT)
6
 ifeq ($(OS),Windows_NT)
9
 	LIBRARIES=-luser32 -lgdi32 -lopengl32 -lgdiplus -lwinmm
7
 	LIBRARIES=-luser32 -lgdi32 -lopengl32 -lgdiplus -lwinmm
10
-	EXECUTABLE+=.exe
11
-	PACKER+=.exe
8
+	EXECUTABLE=awoorwae.exe
9
+	PACKER=packer/packer.exe
12
 	LDFLAGS+=--machine=windows
10
 	LDFLAGS+=--machine=windows
13
 	CPP=i686-w64-mingw32-g++
11
 	CPP=i686-w64-mingw32-g++
14
 	CC=i686-w64-mingw32-gcc
12
 	CC=i686-w64-mingw32-gcc
13
+	MAKE=mingw32-make
15
 else
14
 else
16
 	LIBRARIES=-lX11 -lGL -lpthread -lpng -lasound
15
 	LIBRARIES=-lX11 -lGL -lpthread -lpng -lasound
16
+	EXECUTABLE=awoorwae
17
+	PACKER=packer/packer
17
 	CC=gcc
18
 	CC=gcc
18
 	CPP=g++
19
 	CPP=g++
19
 endif
20
 endif

+ 9
- 4
packer/Makefile Ver arquivo

1
-CPPFLAGS=-Wall -Wno-misleading-indentation -Werror --std=c++1z -O3 -flto
1
+CPPFLAGS=-Wall -Wno-misleading-indentation -Werror --std=c++1z
2
 LDFLAGS=
2
 LDFLAGS=
3
 INCLUDES=-I../pge/include
3
 INCLUDES=-I../pge/include
4
-EXECUTABLE=packer
5
 ifeq ($(OS),Windows_NT)
4
 ifeq ($(OS),Windows_NT)
6
 	LIBRARIES=-luser32 -lgdi32 -lgdiplus
5
 	LIBRARIES=-luser32 -lgdi32 -lgdiplus
7
-	EXECUTABLE+=.exe
6
+	EXECUTABLE=packer.exe
8
 	CPP=i686-w64-mingw32-g++
7
 	CPP=i686-w64-mingw32-g++
9
 	CC=i686-w64-mingw32-gcc
8
 	CC=i686-w64-mingw32-gcc
10
 else
9
 else
10
+	EXECUTABLE=packer
11
 	LIBRARIES=-lpng
11
 	LIBRARIES=-lpng
12
 	CC=gcc
12
 	CC=gcc
13
 	CPP=g++
13
 	CPP=g++
14
 endif
14
 endif
15
-SOURCES=packer.cpp ../pge/src/olcPGE_ResourcePack.cpp ../pge/src/olcPGE_Sprite.cpp ../pge/src/olcPGE_Pixel.cpp
15
+ifeq ($(DEBUG),1)
16
+	CPPFLAGS+=-g -Og
17
+else
18
+	CPPFLAGS+=-flto -O3
19
+endif
20
+SOURCES=packer.cpp ../pge/src/olcPGE_ResourcePack.cpp ../pge/src/olcPGE_Sprite.cpp ../pge/src/olcPGE_Pixel.cpp ../pge/src/olcPGE_Common.cpp
16
 OBJECTS=$(SOURCES:.cpp=.o)
21
 OBJECTS=$(SOURCES:.cpp=.o)
17
 
22
 
18
 all: $(SOURCES) $(EXECUTABLE)
23
 all: $(SOURCES) $(EXECUTABLE)

+ 3
- 0
pge/include/olcPGE_Common.h Ver arquivo

5
 	// Link to libraries
5
 	// Link to libraries
6
 #ifndef __MINGW32__
6
 #ifndef __MINGW32__
7
 	#pragma comment(lib, "user32.lib")
7
 	#pragma comment(lib, "user32.lib")
8
+	#pragma comment(lib, "gdi32.lib")
9
+	#pragma comment(lib, "gdiplus.lib")
8
 #else
10
 #else
9
 	// In Code::Blocks, Select C++14 in your build options, and add the
11
 	// In Code::Blocks, Select C++14 in your build options, and add the
10
 	// following libs to your linker: user32 gdi32 opengl32 gdiplus
12
 	// following libs to your linker: user32 gdi32 opengl32 gdiplus
18
 #endif
20
 #endif
19
 	// Include WinAPI
21
 	// Include WinAPI
20
 	#include <windows.h>
22
 	#include <windows.h>
23
+    #include <gdiplus.h>
21
 #else
24
 #else
22
 #endif
25
 #endif
23
 
26
 

+ 16
- 0
pge/src/olcPGE_Common.cpp Ver arquivo

14
 		return L"SVN FTW!";
14
 		return L"SVN FTW!";
15
 #endif
15
 #endif
16
 	}
16
 	}
17
+	
18
+#ifdef _WIN32
19
+	// Thanks @MaGetzUb for this, which allows sprites to be defined
20
+	// at construction, by initialising the GDI subsystem
21
+	static class GDIPlusStartup
22
+	{
23
+	public:
24
+		GDIPlusStartup()
25
+		{
26
+			Gdiplus::GdiplusStartupInput startupInput;
27
+			ULONG_PTR	token;
28
+			Gdiplus::GdiplusStartup(&token, &startupInput, NULL);
29
+		};
30
+	} gdistartup;
31
+#endif
32
+
17
 }
33
 }

+ 25
- 21
pge/src/olcPixelGameEngine.cpp Ver arquivo

686
 			nMousePosYcache = 0;
686
 			nMousePosYcache = 0;
687
 	}
687
 	}
688
 
688
 
689
+#ifdef _WIN32
690
+	static int minWidth;
691
+	static int minHeight;
692
+	static WINAPI BOOL MonitorInfoProc(HMONITOR mon, HDC dc, LPRECT rect, LPARAM param) {
693
+		MONITORINFO info;
694
+		info.cbSize = sizeof(MONITORINFO);
695
+		GetMonitorInfo(mon, &info);
696
+		int w = info.rcWork.right - info.rcWork.left;
697
+		int h = info.rcWork.bottom - info.rcWork.top;
698
+		if (w < minWidth) {
699
+			minWidth = w;
700
+		}
701
+		if (h < minHeight) {
702
+			minHeight = h;
703
+		}
704
+		return TRUE;
705
+	}
706
+#endif
707
+
689
 	uint32_t PixelGameEngine::olc_GetMaximumPixelSize(uint32_t width, uint32_t height) 
708
 	uint32_t PixelGameEngine::olc_GetMaximumPixelSize(uint32_t width, uint32_t height) 
690
 	{
709
 	{
691
 #ifdef _WIN32
710
 #ifdef _WIN32
692
-		return 1; // TODO
711
+		minWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
712
+		minHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
713
+		EnumDisplayMonitors(NULL, NULL, &MonitorInfoProc, 0);
693
 #else
714
 #else
694
 		Display* d = XOpenDisplay(NULL);
715
 		Display* d = XOpenDisplay(NULL);
695
 		int defaultScreen = DefaultScreen(d);
716
 		int defaultScreen = DefaultScreen(d);
705
 			if (HeightOfScreen(s) < minHeight) {
726
 			if (HeightOfScreen(s) < minHeight) {
706
 				minHeight = HeightOfScreen(s);
727
 				minHeight = HeightOfScreen(s);
707
 			}
728
 			}
708
-		}
709
-
729
+		}		
730
+#endif
710
 		uint32_t pixelWidth = minWidth / width;
731
 		uint32_t pixelWidth = minWidth / width;
711
 		uint32_t pixelHeight = minHeight / height;
732
 		uint32_t pixelHeight = minHeight / height;
712
 
733
 
713
-		return std::min(pixelWidth, pixelHeight);		
714
-#endif
734
+		return std::min(pixelWidth, pixelHeight);
715
 	}
735
 	}
716
 
736
 
717
 	void PixelGameEngine::EngineThread()
737
 	void PixelGameEngine::EngineThread()
959
 
979
 
960
 	}
980
 	}
961
 
981
 
962
-#ifdef _WIN32
963
-	// Thanks @MaGetzUb for this, which allows sprites to be defined
964
-	// at construction, by initialising the GDI subsystem
965
-	static class GDIPlusStartup
966
-	{
967
-	public:
968
-		GDIPlusStartup()
969
-		{
970
-			Gdiplus::GdiplusStartupInput startupInput;
971
-			ULONG_PTR	token;
972
-			Gdiplus::GdiplusStartup(&token, &startupInput, NULL);
973
-		};
974
-	} gdistartup;
975
-#endif
976
-
977
-
978
 	void PixelGameEngine::olc_ConstructFontSheet()
982
 	void PixelGameEngine::olc_ConstructFontSheet()
979
 	{
983
 	{
980
 		std::string data;
984
 		std::string data;

Carregando…
Cancelar
Salvar