1 module dlangui.core.config;
2 
3 extern(C) @property dstring DLANGUI_VERSION();
4 
5 //version = USE_CONSOLE;
6 
7 version(USE_CONSOLE) {
8     version = NO_OPENGL;
9     version = NO_FREETYPE;
10     enum ENABLE_OPENGL = false;
11     enum ENABLE_FREETYPE = false;
12     enum BACKEND_CONSOLE = true;
13     /// Tweaking widgets to console style drawing
14     enum WIDGET_STYLE_CONSOLE = true;
15     enum BACKEND_GUI = false;
16     enum BACKEND_SDL = false;
17     enum BACKEND_X11 = false;
18     enum BACKEND_DSFML = false;
19     enum BACKEND_WIN32 = false;
20     enum BACKEND_ANDROID = false;
21 } else {
22     version(USE_EXTERNAL) {
23         // Use this file to define any enums that is need for the external backend
24         mixin(import("external_cfg.d"));
25     }
26     else
27     {
28         enum BACKEND_GUI = true;
29         enum WIDGET_STYLE_CONSOLE = false;
30     }
31 
32     version (NO_FREETYPE) {
33         enum ENABLE_FREETYPE = false;
34     } else version (USE_FREETYPE) {
35         enum ENABLE_FREETYPE = true;
36     } else {
37         version (Windows) {
38             enum ENABLE_FREETYPE = false;
39         } else {
40             enum ENABLE_FREETYPE = true;
41         }
42     }
43 
44     // provide default configuratino definitions
45     version (USE_SDL) {
46         // SDL backend already selected using version identifier
47         version (NO_OPENGL) {
48             enum ENABLE_OPENGL = false;
49         } else {
50             version (USE_OPENGL) {
51                 enum ENABLE_OPENGL = true;
52             } else {
53                 enum ENABLE_OPENGL = false;
54             }
55         }
56         enum BACKEND_SDL = true;
57         enum BACKEND_X11 = false;
58         enum BACKEND_DSFML = false;
59         enum BACKEND_WIN32 = false;
60         enum BACKEND_ANDROID = false;
61         enum BACKEND_CONSOLE = false;
62     } else version (USE_ANDROID) {
63         // Android backend already selected using version identifier
64         version (USE_OPENGL) {
65             enum ENABLE_OPENGL = true;
66         } else {
67             enum ENABLE_OPENGL = false;
68         }
69         enum BACKEND_SDL = false;
70         enum BACKEND_X11 = false;
71         enum BACKEND_DSFML = false;
72         enum BACKEND_WIN32 = false;
73         enum BACKEND_ANDROID = true;
74         enum BACKEND_CONSOLE = false;
75     } else version (USE_X11) {
76         // X11 backend already selected using version identifier
77         version (NO_OPENGL) {
78             enum ENABLE_OPENGL = false;
79         } else {
80             version (USE_OPENGL) {
81                 enum ENABLE_OPENGL = true;
82             } else {
83                 enum ENABLE_OPENGL = false;
84             }
85         }
86         enum BACKEND_SDL = false;
87         enum BACKEND_X11 = true;
88         enum BACKEND_DSFML = false;
89         enum BACKEND_WIN32 = false;
90         enum BACKEND_CONSOLE = false;
91     } else version (USE_WIN32) {
92         // Win32 backend already selected using version identifier
93         version (NO_OPENGL) {
94             enum ENABLE_OPENGL = false;
95         } else {
96             version (USE_OPENGL) {
97                 enum ENABLE_OPENGL = true;
98             } else {
99                 enum ENABLE_OPENGL = false;
100             }
101         }
102         enum BACKEND_SDL = false;
103         enum BACKEND_X11 = false;
104         enum BACKEND_DSFML = false;
105         enum BACKEND_WIN32 = true;
106         enum BACKEND_ANDROID = false;
107         enum BACKEND_CONSOLE = false;
108     } else version (USE_DSFML) {
109         // DSFML backend already selected using version identifier
110         //version (USE_OPENGL) {
111             enum ENABLE_OPENGL = true;
112         //} else {
113         //    enum ENABLE_OPENGL = false;
114         //}
115         enum BACKEND_SDL = false;
116         enum BACKEND_X11 = false;
117         enum BACKEND_DSFML = true;
118         enum BACKEND_WIN32 = false;
119         enum BACKEND_ANDROID = false;
120         enum BACKEND_CONSOLE = false;
121     } else version (USE_EXTERNAL) {
122         // External backend already selected using version identifier
123         // All config variables should be settled in external config file
124     } else {
125         // no backend selected: set default based on platform
126         version (Windows) {
127             // For Windows
128             version (NO_OPENGL) {
129                 enum ENABLE_OPENGL = false;
130             } else {
131                 enum ENABLE_OPENGL = true;
132             }
133             enum BACKEND_SDL = false;
134             enum BACKEND_X11 = false;
135             enum BACKEND_DSFML = false;
136             enum BACKEND_WIN32 = true;
137             enum BACKEND_ANDROID = false;
138             enum BACKEND_CONSOLE = false;
139         } else version(Android) {
140             // Default for Linux: use SDL and OpenGL
141             enum ENABLE_OPENGL = true;
142             enum BACKEND_SDL = true;
143             enum BACKEND_X11 = false;
144             enum BACKEND_DSFML = false;
145             enum BACKEND_WIN32 = false;
146             enum BACKEND_ANDROID = true;
147             enum BACKEND_CONSOLE = false;
148         } else version(linux) {
149             // Default for Linux: use SDL and OpenGL
150             version (NO_OPENGL) {
151                 enum ENABLE_OPENGL = false;
152             } else {
153                 enum ENABLE_OPENGL = true;
154             }
155             enum BACKEND_SDL = true;
156             enum BACKEND_X11 = false;
157             enum BACKEND_DSFML = false;
158             enum BACKEND_WIN32 = false;
159             enum BACKEND_ANDROID = false;
160             enum BACKEND_CONSOLE = false;
161         } else version(OSX) {
162             // Default: use SDL and OpenGL
163             version (NO_OPENGL) {
164                 enum ENABLE_OPENGL = false;
165             } else {
166                 enum ENABLE_OPENGL = true;
167             }
168             enum BACKEND_SDL = true;
169             enum BACKEND_X11 = false;
170             enum BACKEND_DSFML = false;
171             enum BACKEND_WIN32 = false;
172             enum BACKEND_ANDROID = false;
173             enum BACKEND_CONSOLE = false;
174         } else {
175             // Unknown platform: use SDL and OpenGL
176             version (NO_OPENGL) {
177                 enum ENABLE_OPENGL = false;
178             } else {
179                 enum ENABLE_OPENGL = true;
180             }
181             enum BACKEND_SDL = true;
182             enum BACKEND_X11 = false;
183             enum BACKEND_DSFML = false;
184             enum BACKEND_WIN32 = false;
185             enum BACKEND_ANDROID = false;
186             enum BACKEND_CONSOLE = false;
187         }
188     }
189 }