1 module PixelPerfectEngine.system.systemUtility;
2 /*
3  * Copyright (C) 2015-2017, by Laszlo Szeremi under the Boost license.
4  *
5  * Pixel Perfect Engine, system.systemUtility module
6  */
7 
8 public immutable wstring engineVer = "0.9.2";	///Defines engine version
9 public immutable wstring sdlVer = "2.0.5";		///Defines SDL version
10 version(X86){
11 	public immutable wstring sysInfo = "x86";	///Defines what CPU architecture the software is being built for.
12 }else version(X86_64){
13 	public immutable wstring sysInfo = "AMD86";
14 }else version(ARM){
15 	public immutable wstring sysInfo = "ARMv8";
16 }else version(AArch64){
17 	public immutable wstring sysInfo = "AArch64";
18 }else{
19 	public immutable wstring sysInfo = "UNDEFINED";	//Contact me or make a pull request if something needs to be added.
20 }
21 version(Windows){
22 	public immutable wstring osInfo = "Windows";	///Defines target OS
23 }else version(linux){
24 	public immutable wstring osInfo = "Linux";
25 }else version(OSX){
26 	public immutable wstring osInfo = "OSX";
27 }else version(Posix){
28 	public immutable wstring osInfo = "Posix";
29 }else{
30 	public immutable wstring osInfo = "UNDEFINED";
31 }
32 version(X86){
33 	version(NO_SSE2){
34 		public immutable wstring renderInfo = "CPUBLiT/MMX";
35 	}else{
36 		public immutable wstring renderInfo = "CPUBLiT/SSE2";	///Renderer information.
37 	}
38 }else version(X86_64){
39 	version(USE_AVX){
40 		public immutable wstring renderInfo = "CPUBLiT/AVX";
41 	}else{
42 		public immutable wstring renderInfo = "CPUBLiT/SSE2";
43 	}
44 }else version(ARM){
45 	version(NEON){
46 		public immutable wstring renderInfo = "CPUBLiT/NEON";
47 	}else{
48 		public immutable wstring renderInfo = "Slow";
49 	}
50 }else version(AArch64){
51 	version(NEON){
52 		public immutable wstring renderInfo = "CPUBLiT/NEON";
53 	}else{
54 		public immutable wstring renderInfo = "Slow";
55 	}
56 }else{
57 	public immutable wstring renderInfo = "Slow";
58 }
59 /**
60  * Initializes SDL2.
61  * Use "import derelict.sdl2.sdl;" to import derelictSDL2, and "mixin(INIT_SDL);" to insert it into your code.
62  */
63 string INIT_SDL(){
64 	string result;
65 	version(Windows){
66 		result ~= `DerelictSDL2.load("system\\SDL2.dll\")`;
67 	}else{
68 		result ~= `DerelictSDL2.load("/system/SDL2.so")`;
69 	}
70 	debug{
71 		result ~= `SDL_SetHint(SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING, "1")`;
72 	}
73 	return result;
74 }
75 
76 	import PixelPerfectEngine.concrete.window;
77 	import PixelPerfectEngine.system.file;
78 	import PixelPerfectEngine.extbmp.extbmp;
79 /**
80  * Loads the defaults for Concrete.
81  */
82 public void INIT_CONCRETE(WindowHandler wh){
83 	import PixelPerfectEngine.concrete.window;
84 	import PixelPerfectEngine.system.file;
85 	import PixelPerfectEngine.extbmp.extbmp;
86 	import PixelPerfectEngine.graphics.fontsets;
87 	import PixelPerfectEngine.graphics.bitmap;
88 	Fontset!Bitmap16Bit defaultFont = loadFontsetFromXMP(new ExtendibleBitmap("system/sysfont.xmp"), "font");
89 	ExtendibleBitmap ssOrigin = new ExtendibleBitmap("system/sysdef.xmp");
90 	StyleSheet ss = new StyleSheet();
91 	ss.setImage(loadBitmapFromXMP!Bitmap16Bit(ssOrigin,"GUI0"),"closeButtonA");
92 	ss.setImage(loadBitmapFromXMP!Bitmap16Bit(ssOrigin,"GUI1"),"closeButtonB");
93 	ss.setImage(loadBitmapFromXMP!Bitmap16Bit(ssOrigin,"GUI0"),"checkBoxA");
94 	ss.setImage(loadBitmapFromXMP!Bitmap16Bit(ssOrigin,"GUI1"),"checkBoxB");
95 	ss.setImage(loadBitmapFromXMP!Bitmap16Bit(ssOrigin,"GUI2"),"radioButtonA");
96 	ss.setImage(loadBitmapFromXMP!Bitmap16Bit(ssOrigin,"GUI3"),"radioButtonB");
97 	ss.setImage(loadBitmapFromXMP!Bitmap16Bit(ssOrigin,"GUI4"),"upArrowA");
98 	ss.setImage(loadBitmapFromXMP!Bitmap16Bit(ssOrigin,"GUI5"),"upArrowB");
99 	ss.setImage(loadBitmapFromXMP!Bitmap16Bit(ssOrigin,"GUI6"),"downArrowA");
100 	ss.setImage(loadBitmapFromXMP!Bitmap16Bit(ssOrigin,"GUI7"),"downArrowB");
101 	ss.setImage(loadBitmapFromXMP!Bitmap16Bit(ssOrigin,"GUI8"),"plusA");
102 	ss.setImage(loadBitmapFromXMP!Bitmap16Bit(ssOrigin,"GUI9"),"plusB");
103 	ss.setImage(loadBitmapFromXMP!Bitmap16Bit(ssOrigin,"GUIA"),"minusA");
104 	ss.setImage(loadBitmapFromXMP!Bitmap16Bit(ssOrigin,"GUIB"),"minusB");
105 	ss.setImage(loadBitmapFromXMP!Bitmap16Bit(ssOrigin,"GUIC"),"leftArrowA");
106 	ss.setImage(loadBitmapFromXMP!Bitmap16Bit(ssOrigin,"GUID"),"leftArrowB");
107 	ss.setImage(loadBitmapFromXMP!Bitmap16Bit(ssOrigin,"GUIE"),"rightArrowA");
108 	ss.setImage(loadBitmapFromXMP!Bitmap16Bit(ssOrigin,"GUIF"),"rightArrowB");
109 	ss.addFontset(defaultFont, "default");
110 	wh.defaultStyle = ss;
111 	Window.defaultStyle = ss;
112 	WindowElement.styleSheet = ss;
113 	PopUpElement.styleSheet = ss;
114 }