Mercurial > projects > mde
annotate mde/setup/Init.d @ 77:3dfd934100f7
Continuing widget data changes started in last commit: all previous widgets work again now (but lacking saving).
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Tue, 29 Jul 2008 17:11:22 +0100 |
parents | 108d123238c0 |
children | 56c0ddd90193 |
rev | line source |
---|---|
20 | 1 /* LICENSE BLOCK |
2 Part of mde: a Modular D game-oriented Engine | |
3 Copyright © 2007-2008 Diggory Hardy | |
4 | |
26
611f7b9063c6
Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
25
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify it under the terms |
611f7b9063c6
Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
25
diff
changeset
|
6 of the GNU General Public License as published by the Free Software Foundation, either |
611f7b9063c6
Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
25
diff
changeset
|
7 version 2 of the License, or (at your option) any later version. |
20 | 8 |
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | |
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
11 See the GNU General Public License for more details. | |
12 | |
26
611f7b9063c6
Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
25
diff
changeset
|
13 You should have received a copy of the GNU General Public License |
611f7b9063c6
Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
25
diff
changeset
|
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
20 | 15 |
16 /************************************************************************************************** | |
17 * Initialisation setup and exit cleanup module. | |
18 * | |
19 * This module provides an infrastructure for handling much of the initialisation and | |
20 * deinitialisation of the program. It does not, however, provide much of the (de)initialisation | |
21 * code; with the exception of that for the logger. | |
22 *************************************************************************************************/ | |
63
66d555da083e
Moved many modules/packages to better reflect usage.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
56
diff
changeset
|
23 module mde.setup.Init; |
20 | 24 |
63
66d555da083e
Moved many modules/packages to better reflect usage.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
56
diff
changeset
|
25 import mde.setup.init2; // This module is responsible for setting up some init functions. |
66d555da083e
Moved many modules/packages to better reflect usage.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
56
diff
changeset
|
26 import mde.setup.initFunctions; |
66d555da083e
Moved many modules/packages to better reflect usage.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
56
diff
changeset
|
27 import mde.setup.exception; |
20 | 28 |
63
66d555da083e
Moved many modules/packages to better reflect usage.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
56
diff
changeset
|
29 import mde.lookup.Options; |
66d555da083e
Moved many modules/packages to better reflect usage.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
56
diff
changeset
|
30 import paths = mde.setup.paths; |
20 | 31 import mde.exception; |
32 | |
33 // tango imports | |
34 import tango.core.Thread; | |
35 import tango.core.Exception; | |
36 import tango.stdc.stringz : fromStringz; | |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
37 import tango.io.Console; // for printing command-line usage |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
38 import TimeStamp = tango.text.convert.TimeStamp, tango.time.WallClock; // output date in log file |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
39 import tango.util.Arguments; |
67
108d123238c0
Changes to work with tango r3700 (post 0.99.6).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
40 import tango.util.log.Log : Log, Logger, Level; |
108d123238c0
Changes to work with tango r3700 (post 0.99.6).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
41 import tango.util.log.AppendConsole; |
108d123238c0
Changes to work with tango r3700 (post 0.99.6).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
42 import tango.util.log.AppendFiles; |
20 | 43 |
29
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
44 // Derelict imports |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
45 import derelict.opengl.gl; |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
46 import derelict.sdl.sdl; |
56
f9f5e04f20b2
Bit of polish for a public release, including some more documentation.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
55
diff
changeset
|
47 //import derelict.sdl.image; Was to be used... for now isn't |
30
467c74d4804d
Major changes to the scheduler, previously only used by the main loop.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
29
diff
changeset
|
48 import derelict.freetype.ft; |
29
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
49 import derelict.util.exception; |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
50 |
20 | 51 /** |
52 * Static CTOR | |
53 * | |
54 * This should handle a minimal amount of functionality where useful. For instance, configuring the | |
55 * logger here and not in Init allows unittests to use the logger. | |
56 */ | |
57 static this() | |
58 { | |
67
108d123238c0
Changes to work with tango r3700 (post 0.99.6).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
59 Logger root = Log.root; |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
60 // Set the level here, but set it again once options have been loaded: |
67
108d123238c0
Changes to work with tango r3700 (post 0.99.6).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
61 debug root.level(Logger.Trace); |
108d123238c0
Changes to work with tango r3700 (post 0.99.6).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
62 else root.level(Logger.Info); |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
63 // Temporarily log to the console (until we've found paths and loaded options): |
67
108d123238c0
Changes to work with tango r3700 (post 0.99.6).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
64 root.add(new AppendConsole); |
20 | 65 } |
66 static ~this() | |
67 { | |
68 } | |
69 | |
70 /** | |
71 * Init class | |
72 * | |
73 * A scope class created at beginning of the program and destroyed at the end; thus the CTOR | |
74 * handles program initialisation and the DTOR handles program cleanup. | |
75 */ | |
76 scope class Init | |
77 { | |
25
2c28ee04a4ed
Some minor and some futile efforts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
24
diff
changeset
|
78 //private bool failure = false; // set true on failure during init, so that clean |
20 | 79 private static Logger logger; |
80 static this() { | |
63
66d555da083e
Moved many modules/packages to better reflect usage.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
56
diff
changeset
|
81 logger = Log.getLogger ("mde.setup.Init"); |
20 | 82 } |
83 | |
29
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
84 /** this() − initialisation |
20 | 85 * |
86 * Runs general initialisation code, in a threaded manner where this isn't difficult. | |
29
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
87 * If any init fails, cleanup is still handled by ~this(). |
20 | 88 * |
29
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
89 * Init order: 1. Pre-init (loads components needed by most init functions). 2. Dynamic library |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
90 * loading (load any dynamic libraries first, so that if loading fails nothing else need be |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
91 * done). 3. Init functions (threaded functions handling the rest of initialisation). |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
92 */ |
20 | 93 /* In a single-threaded function this could be done with: |
94 * scope(failure) cleanup; | |
95 * This won't work with a threaded init function since any threads completing succesfully will | |
96 * not clean-up, and a fixed list of clean-up functions cannot be used since clean-up functions | |
97 * must not run where the initialisation functions have failed. | |
98 * Hence a list of clean-up functions is built similarly to scope(failure) --- see addCleanupFct. | |
99 */ | |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
100 this(char[][] cmdArgs) |
20 | 101 { |
24
32eff0e01c05
Only locally-changed options are stored in user-config now. Log levels revised.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
21
diff
changeset
|
102 debug logger.trace ("Init: starting"); |
20 | 103 |
104 //BEGIN Pre-init (stage init0) | |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
105 //FIXME: warn on invalid arguments, including base-path on non-Windows |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
106 // But Arguments doesn't support this (in tango 0.99.6 and in r3563). |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
107 Arguments args; |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
108 try { |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
109 args = new Arguments(); |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
110 args.define("base-path").parameters(1); |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
111 args.define("data-path").parameters(1,-1); |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
112 args.define("conf-path").parameters(1,-1); |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
113 args.define("paths"); |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
114 args.define("q").aliases(["quick-exit"]); |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
115 args.define("help").aliases(["h"]); |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
116 args.parse(cmdArgs); |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
117 if (args.contains("help")) // lazy way to print help |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
118 throw new InitException ("Help requested"); // and stop |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
119 } catch (Exception e) { |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
120 printUsage(cmdArgs[0]); |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
121 throw new InitException ("Parsing arguments failed: "~e.msg); |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
122 } |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
123 |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
124 // Find/create paths: |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
125 try { |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
126 if (args.contains("data-path")) |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
127 paths.extraDataPath = args["data-path"]; |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
128 if (args.contains("conf-path")) |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
129 paths.extraConfPath = args["conf-path"]; |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
130 if (args.contains("base-path")) |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
131 paths.resolvePaths (args["base-path"]); |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
132 else |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
133 paths.resolvePaths(); |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
134 } catch (Exception e) { |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
135 throw new InitException ("Resolving paths failed: " ~ e.msg); |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
136 } |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
137 if (args.contains("paths")) { |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
138 paths.mdeDirectory.printPaths; |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
139 throw new InitException ("Paths requested"); // lazy way to stop |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
140 } |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
141 debug logger.trace ("Init: resolved paths successfully"); |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
142 |
20 | 143 /* Load options now. Don't load in a thread since: |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
144 * Loading should be fast & most work is probably disk access |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
145 * It enables logging to be controlled by options |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
146 * It's a really good idea to let the options apply to all other loading */ |
20 | 147 try { |
148 Options.load(); | |
149 } catch (optionsLoadException e) { | |
25
2c28ee04a4ed
Some minor and some futile efforts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
24
diff
changeset
|
150 throw new InitException ("Loading options failed: " ~ e.msg); |
20 | 151 } |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
152 debug logger.trace ("Init: loaded options successfully"); |
20 | 153 |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
154 // Set up the logger: |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
155 Logger root; |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
156 try { |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
157 enum LOG { |
55
f3d8c0441408
Implemented gl.texture (without testing) & fixed log options adjusted previously.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
53
diff
changeset
|
158 LEVEL = 0xF, // mask for log level |
f3d8c0441408
Implemented gl.texture (without testing) & fixed log options adjusted previously.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
53
diff
changeset
|
159 CONSOLE = 0x1000, // log to console? |
f3d8c0441408
Implemented gl.texture (without testing) & fixed log options adjusted previously.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
53
diff
changeset
|
160 ROLLFILE= 0x2000 // use Rolling/Switching File Appender? |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
161 } |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
162 |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
163 // Where logging is done to is determined at compile-time, currently just via static ifs. |
67
108d123238c0
Changes to work with tango r3700 (post 0.99.6).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
164 root = Log.root; |
108d123238c0
Changes to work with tango r3700 (post 0.99.6).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
165 root.clear; // we may no longer want to log to the console |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
166 |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
167 // Now re-set the logging level, using the value from the config file: |
67
108d123238c0
Changes to work with tango r3700 (post 0.99.6).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
168 root.level (cast(Level) (miscOpts.logOptions & LOG.LEVEL), true); |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
169 |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
170 // Log to a file (first appender so root seperator messages don't show on console): |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
171 if (miscOpts.logOptions & LOG.ROLLFILE) { |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
172 // Use 2 log files with a maximum size of 1 MB: |
67
108d123238c0
Changes to work with tango r3700 (post 0.99.6).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
173 root.add (new AppendFiles (paths.logDir~"/log-.txt", 2, 1024*1024)); |
108d123238c0
Changes to work with tango r3700 (post 0.99.6).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
174 root.info (""); // some kind of separation between runs |
108d123238c0
Changes to work with tango r3700 (post 0.99.6).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
175 root.info (""); |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
176 } else if (!(miscOpts.logOptions & LOG.CONSOLE)) { |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
177 // make sure at least one logger is enabled |
64
cc3763817b8a
Overhauled Options so that it now uses templates and mixins for type-specific internals, and supported types can be adjusted via just one list.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
63
diff
changeset
|
178 miscOpts.set!(int) ("logOptions", miscOpts.logOptions | LOG.CONSOLE); |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
179 } |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
180 if (miscOpts.logOptions & LOG.CONSOLE) { // Log to the console |
67
108d123238c0
Changes to work with tango r3700 (post 0.99.6).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
181 root.add(new AppendConsole); |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
182 } |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
183 logger.info ("Starting mde [no version] on " ~ TimeStamp.toString(WallClock.now)); |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
184 } catch (Exception e) { |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
185 // Presumably it was only adding a file appender which failed; set up a new console |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
186 // logger and if that fails let the exception kill the program. |
67
108d123238c0
Changes to work with tango r3700 (post 0.99.6).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
187 root.clear; |
108d123238c0
Changes to work with tango r3700 (post 0.99.6).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
188 root.add (new AppendConsole); |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
189 logger.warn ("Exception while setting up the logger; logging to the console instead."); |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
190 } |
20 | 191 |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
192 // a debugging option: |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
193 imde.run = !args.contains("q") && !miscOpts.exitImmediately; |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
194 debug logger.trace ("Init: applied pre-init options"); |
29
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
195 |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
196 //BEGIN Load dynamic libraries |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
197 /* Can be done by init functions but much neater to do here. |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
198 * Also means that init functions aren't run if a library fails to load. */ |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
199 try { |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
200 DerelictSDL.load(); |
56
f9f5e04f20b2
Bit of polish for a public release, including some more documentation.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
55
diff
changeset
|
201 // SDLImage was going to be used... for now it isn't because of gl texturing problems |
f9f5e04f20b2
Bit of polish for a public release, including some more documentation.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
55
diff
changeset
|
202 //DerelictSDLImage.load(); |
29
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
203 DerelictGL.load(); |
30
467c74d4804d
Major changes to the scheduler, previously only used by the main loop.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
29
diff
changeset
|
204 DerelictFT.load(); |
29
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
205 } catch (DerelictException de) { |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
206 logger.fatal ("Loading dynamic library failed:"); |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
207 logger.fatal (de.msg); |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
208 |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
209 throw new InitException ("Loading dynamic libraries failed (see above)."); |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
210 } |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
211 debug logger.trace ("Init: dynamic libraries loaded"); |
29
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
212 //END Load dynamic libraries |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
213 //END Pre-init |
29
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
214 |
20 | 215 |
216 //BEGIN Init (stages init2, init4) | |
217 /* Call init functions. | |
218 * | |
219 * Current method is to try using threads, and on failure assume no threads were actually | |
220 * created and run functions in a non-threaded manner. */ | |
221 | |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
222 try { |
25
2c28ee04a4ed
Some minor and some futile efforts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
24
diff
changeset
|
223 if (runStageThreaded (init)) runStageForward (init); |
20 | 224 } |
225 catch (InitStageException) { // This init stage failed. | |
25
2c28ee04a4ed
Some minor and some futile efforts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
24
diff
changeset
|
226 // FIXME: check DTOR still runs |
2c28ee04a4ed
Some minor and some futile efforts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
24
diff
changeset
|
227 throw new InitException ("An init function failed (see above message(s))"); |
20 | 228 } |
229 //END Init | |
230 | |
24
32eff0e01c05
Only locally-changed options are stored in user-config now. Log levels revised.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
21
diff
changeset
|
231 debug logger.trace ("Init: done"); |
20 | 232 } |
233 | |
234 /** DTOR - runs cleanup functions. */ | |
235 ~this() | |
236 { | |
24
32eff0e01c05
Only locally-changed options are stored in user-config now. Log levels revised.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
21
diff
changeset
|
237 debug logger.trace ("Cleanup: starting"); |
20 | 238 |
239 Options.save(); // save options... do so here for now | |
240 | |
25
2c28ee04a4ed
Some minor and some futile efforts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
24
diff
changeset
|
241 // General cleanup: |
2c28ee04a4ed
Some minor and some futile efforts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
24
diff
changeset
|
242 try { |
2c28ee04a4ed
Some minor and some futile efforts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
24
diff
changeset
|
243 if (runStageThreaded (cleanup)) runStageReverse (cleanup); |
2c28ee04a4ed
Some minor and some futile efforts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
24
diff
changeset
|
244 } |
2c28ee04a4ed
Some minor and some futile efforts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
24
diff
changeset
|
245 catch (InitStageException) { |
2c28ee04a4ed
Some minor and some futile efforts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
24
diff
changeset
|
246 // Nothing else to do but report: |
2c28ee04a4ed
Some minor and some futile efforts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
24
diff
changeset
|
247 logger.error ("One or more cleanup functions failed!"); |
2c28ee04a4ed
Some minor and some futile efforts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
24
diff
changeset
|
248 } |
20 | 249 |
24
32eff0e01c05
Only locally-changed options are stored in user-config now. Log levels revised.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
21
diff
changeset
|
250 debug logger.trace ("Cleanup: done"); |
20 | 251 } |
252 | |
253 | |
254 //BEGIN runStage... | |
255 private static { | |
256 /* The following three functions, runStage*, each run all functions in a stage in some order, | |
257 * catching any exceptions thrown by the functions (although this isn't guaranteed for threads), | |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
258 * and throw an InitStageException on initFailure. */ |
20 | 259 |
29
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
260 const LOG_IF_MSG = "Init function "; |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
261 const LOG_CF_MSG = "Cleanup function "; |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
262 const LOG_F_START = " - running"; |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
263 const LOG_F_END = " - completed"; |
45
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
264 const LOG_F_BAD = " - failed"; |
77
3dfd934100f7
Continuing widget data changes started in last commit: all previous widgets work again now (but lacking saving).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
67
diff
changeset
|
265 const LOG_F_FAIL = " - exception: "; |
20 | 266 /* Runs all functions consecutively, first-to-last. |
267 * If any function fails, halts immediately. */ | |
268 void runStageForward (InitStage s) { | |
269 foreach (func; s.funcs) { | |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
270 if (initFailure) break; |
20 | 271 try { |
29
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
272 debug logger.trace (LOG_IF_MSG ~ func.name ~ LOG_F_START); |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
273 func.func(); |
45
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
274 debug logger.trace (LOG_IF_MSG ~ func.name ~ (initFailure ? LOG_F_BAD : LOG_F_END)); |
20 | 275 } catch (Exception e) { |
29
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
276 logger.fatal (LOG_IF_MSG ~ func.name ~ LOG_F_FAIL ~ |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
277 ((e.msg is null || e.msg == "") ? "(no failure message)" : e.msg) ); |
20 | 278 |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
279 setInitFailure(); |
20 | 280 } |
281 } | |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
282 |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
283 if (initFailure) throw new InitStageException; // Problem running; abort and cleanup from here. |
20 | 284 } |
285 /* Runs all functions consecutively, last-to-first. | |
286 * If any function fails, continue until all have been run. */ | |
287 void runStageReverse (InitStage s) { | |
288 foreach_reverse (func; s.funcs) { | |
289 try { | |
29
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
290 debug logger.trace (LOG_CF_MSG ~ func.name ~ LOG_F_START); |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
291 func.func(); |
45
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
292 debug logger.trace (LOG_CF_MSG ~ func.name ~ (initFailure ? LOG_F_BAD : LOG_F_END)); |
20 | 293 } catch (Exception e) { |
29
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
294 logger.fatal (LOG_CF_MSG ~ func.name ~ LOG_F_FAIL ~ |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
295 ((e.msg is null || e.msg == "") ? "(no failure message)" : e.msg) ); |
20 | 296 |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
297 setInitFailure(); |
20 | 298 } |
299 } | |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
300 if (initFailure) throw new InitStageException; // Problem running; abort and cleanup from here. |
20 | 301 } |
302 /* Tries running functions in a threaded way. Returns false if successful, true if not but | |
303 * functions should be run without threads. */ | |
304 bool runStageThreaded (InitStage s) { | |
24
32eff0e01c05
Only locally-changed options are stored in user-config now. Log levels revised.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
21
diff
changeset
|
305 if (!miscOpts.useThreads) return true; // Use unthreaded route instead |
20 | 306 |
307 ThreadGroup tg; | |
308 try { // creating/starting threads could fail | |
309 tg = new ThreadGroup; | |
29
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
310 foreach (func; s.funcs) { // Start all threads |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
311 debug logger.trace (LOG_IF_MSG ~ func.name ~ LOG_F_START); |
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
312 tg.create(func.func); |
45
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
313 debug logger.trace (LOG_IF_MSG ~ func.name ~ (initFailure ? LOG_F_BAD : LOG_F_END)); |
29
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
314 } |
20 | 315 } catch (ThreadException e) { // Problem with threading; try without threads |
24
32eff0e01c05
Only locally-changed options are stored in user-config now. Log levels revised.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
21
diff
changeset
|
316 logger.error ("Caught ThreadException while trying to create threads:"); |
32eff0e01c05
Only locally-changed options are stored in user-config now. Log levels revised.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
21
diff
changeset
|
317 logger.error (e.msg); |
29
f985c28c0ec9
A new GUI widget plus changes to the init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
28
diff
changeset
|
318 logger.info ("Will disable threads and continue, assuming no threads were created."); |
20 | 319 |
64
cc3763817b8a
Overhauled Options so that it now uses templates and mixins for type-specific internals, and supported types can be adjusted via just one list.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
63
diff
changeset
|
320 miscOpts.set!(bool)("useThreads", false); // Disable threads entirely |
20 | 321 return true; // Try again without threads |
322 } | |
323 | |
324 /* Wait for all threads to complete. | |
325 * | |
326 * If something went wrong, we still need to do this before cleaning up. | |
327 */ | |
328 foreach (t; tg) { | |
329 try { | |
330 t.join (true); | |
331 } catch (Exception e) { | |
332 // Relying on catching exceptions thrown by other threads is a bad idea. | |
333 // Hence all threads should catch their own exceptions and return safely. | |
334 | |
335 logger.fatal ("Unhandled exception from Init function:"); | |
336 logger.fatal (e.msg); | |
337 | |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
338 setInitFailure (); // abort (but join other threads first) |
20 | 339 } |
340 } | |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
341 |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
342 if (initFailure) throw new InitStageException; // Problem running; abort and cleanup from here. |
20 | 343 return false; // Done successfully |
344 } | |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
345 //END runStage... |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
346 |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
347 void printUsage (char[] progName) { |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
348 Cout ("mde [no version]").newline; |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
349 Cout ("Usage:").newline; |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
350 Cout (progName ~ ` [options]`).newline; |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
351 version(Windows) |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
352 Cout ( |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
353 ` --base-path path Use path as the base (install) path (Windows only). It |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
354 should contain the "data" directory.`).newline; |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
355 Cout ( |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
356 ` --data-path path(s) Add path(s) as a potential location for data files. |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
357 First path argument becomes the preffered location to |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
358 load data files from. |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
359 --conf-path path(s) Add path(s) as a potential location for config files. |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
360 Configuration in the first path given take highest |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
361 priority. |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
362 --paths Print all paths found and exit. |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
363 --quick-exit, -q Exit immediately, without entering main loop. |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
364 --help, -h Print this message.`).newline; |
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
365 } |
20 | 366 } |
367 | |
368 debug (mdeUnitTest) unittest { | |
369 /* Fake init and cleanup. Use unittest-specific init and cleanup InitStages to avoid | |
370 * messing other init/cleanup up. */ | |
371 static InitStage initUT, cleanupUT; | |
372 | |
373 static bool initialised = false; | |
374 static void cleanupFunc1 () { | |
375 initialised = false; | |
376 } | |
377 static void cleanupFunc2 () { | |
378 assert (initialised == true); | |
379 } | |
380 | |
381 static void initFunc () { | |
382 initialised = true; | |
30
467c74d4804d
Major changes to the scheduler, previously only used by the main loop.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
29
diff
changeset
|
383 cleanupUT.addFunc (&cleanupFunc1, "UT cleanup 1"); |
467c74d4804d
Major changes to the scheduler, previously only used by the main loop.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
29
diff
changeset
|
384 cleanupUT.addFunc (&cleanupFunc2, "UT cleanup 2"); |
20 | 385 } |
386 | |
30
467c74d4804d
Major changes to the scheduler, previously only used by the main loop.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
29
diff
changeset
|
387 initUT.addFunc (&initFunc, "UT init"); |
20 | 388 |
389 runStageForward (initUT); | |
390 assert (initialised); | |
391 | |
392 runStageReverse (cleanupUT); | |
393 assert (!initialised); | |
394 | |
395 logger.info ("Unittest complete."); | |
396 } | |
397 } |