Mercurial > projects > mde
annotate mde/options.d @ 18:56a42ec95024
Changes to Init and logging.
Moved an Init function; hence events now depends on Init rather than vice-versa.
Paths and logging set up by Init's static this(). Logging location set at compile time.
committer: Diggory Hardy <diggory.hardy@gmail.com>
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Tue, 18 Mar 2008 17:51:52 +0000 |
parents | 5f90774ea1ef |
children | a60cbb7359dd |
rev | line source |
---|---|
17
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
1 /* LICENSE BLOCK |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
2 Part of mde: a Modular D game-oriented Engine |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
3 Copyright © 2007-2008 Diggory Hardy |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
4 |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
5 This program is free software; you can redistribute it and/or modify it under the terms of |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
6 the GNU General Public License, version 2, as published by the Free Software Foundation. |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
7 |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
8 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
9 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
10 See the GNU General Public License for more details. |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
11 |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
12 You should have received a copy of the GNU General Public License along |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
13 with this program; if not, write to the Free Software Foundation, Inc., |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
14 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
15 |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
16 /** This module handles stored options, currently all except input maps. |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
17 * |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
18 * The purpose of having all options centrally controlled is to allow generic handling by the GUI |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
19 * and ease saving and loading of values. The Options class is only really designed around handling |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
20 * small numbers of variables for now. |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
21 */ |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
22 module mde.options; |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
23 |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
24 import mde.exception; |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
25 |
14
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
12
diff
changeset
|
26 import mde.mergetag.Reader; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
12
diff
changeset
|
27 import mde.mergetag.Writer; |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
12
diff
changeset
|
28 import mde.mergetag.DataSet; |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
29 import mde.mergetag.exception; |
15
4608be19ebe2
Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
14
diff
changeset
|
30 import mde.resource.paths; |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
31 |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
32 import tango.scrapple.text.convert.parseTo : parseTo; |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
33 import tango.scrapple.text.convert.parseFrom : parseFrom; |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
34 |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
35 import tango.util.log.Log : Log, Logger; |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
36 |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
37 /** Base class for handling options. This class itself will handle no options and should not be |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
38 * instantiated, but sub-classes handle options. |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
39 * |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
40 * Each sub-class provides named variables for maximal-speed reading & writing. Sub-class references |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
41 * are stored by name, and will be available after pre-init has run (DO NOT access before this). |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
42 * |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
43 * The static class keeps track of all Options class instances for global loading and saving. |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
44 * |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
45 * Details: Options sub-classes hold associative arrays of pointers to all option variables, with a |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
46 * char[] id. This list is used for saving, loading and to provide generic GUI options screens. The |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
47 * built-in support in Options is only for bool, int and char[] types (a float type may get added). |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
48 */ |
14
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
12
diff
changeset
|
49 class Options : IDataSection |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
50 { |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
51 // No actual options are stored by this class. However, much of the infrastructure is |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
52 // present since it need not be redefined in sub-classes. |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
53 |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
54 // The "pointer lists": |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
55 protected bool* [ID] optsBool; |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
56 protected char[]*[ID] optsCharA; |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
57 protected int* [ID] optsInt; |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
58 |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
59 //BEGIN Mergtag loading/saving code |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
60 void addTag (char[] tp, ID id, char[] dt) { |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
61 if (tp == "bool") { |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
62 bool** p = id in optsBool; |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
63 if (p !is null) **p = parseTo!(bool) (dt); |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
64 } else if (tp == "char[]") { |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
65 char[]** p = id in optsCharA; |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
66 if (p !is null) **p = parseTo!(char[]) (dt); |
15
4608be19ebe2
Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
14
diff
changeset
|
67 } else if (tp == "int") { |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
68 int** p = id in optsInt; |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
69 if (p !is null) **p = parseTo!(int) (dt); |
12
bff0d802cb7d
Implemented some internationalization support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
11
diff
changeset
|
70 } |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
71 } |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
72 void writeAll (ItemDelg dlg) { |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
73 foreach (ID id, bool* val; optsBool) dlg ("bool" , id, parseFrom!(bool ) (*val)); |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
74 foreach (ID id, char[]* val; optsCharA) dlg ("char[]", id, parseFrom!(char[]) (*val)); |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
75 foreach (ID id, int* val; optsInt) dlg ("int" , id, parseFrom!(int ) (*val)); |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
76 } |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
77 //END Mergtag loading/saving code |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
78 |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
79 //BEGIN Static |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
80 // Each individual section |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
81 static OptionsMisc misc; |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
82 |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
83 /* Load/save options from file. |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
84 * |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
85 * If the file doesn't exist, no reading is attempted (options are left at default values). |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
86 */ |
15
4608be19ebe2
Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
14
diff
changeset
|
87 private static const fileName = "options"; |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
88 static void load () { |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
89 // Create all uncreated sections now, so that if we return early they are still created. |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
90 if (misc is null) misc = new OptionsMisc; |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
91 |
14
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
12
diff
changeset
|
92 // Check it exists (if not it should still be created on exit). |
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
12
diff
changeset
|
93 // Don't bother checking it's not a folder, because it could still be a block or something. |
15
4608be19ebe2
Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
14
diff
changeset
|
94 if (!confDir.exists (fileName)) return; |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
95 |
14
0047b364b6d9
Changed much of the mergetag structure and some functionality. First tests on windows.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
12
diff
changeset
|
96 IReader reader; |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
97 try { |
15
4608be19ebe2
Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
14
diff
changeset
|
98 reader = confDir.makeMTReader (fileName, PRIORITY.LOW_HIGH); |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
99 reader.dataSecCreator = delegate IDataSection(ID id) { |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
100 /* Recognise each defined section, and return null for unrecognised sections. */ |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
101 |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
102 if (id == cast(ID) "misc") return misc; |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
103 else return null; |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
104 }; |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
105 reader.read; |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
106 } catch (MTException e) { |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
107 logger.error ("Mergetag exception occurred:"); |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
108 logger.error (e.msg); |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
109 throw new optionsLoadException ("Loading aborted: mergetag exception"); |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
110 } |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
111 |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
112 if (misc is null) throw new optionsLoadException ("Loading failed: section \"misc\" not found"); |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
113 } |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
114 static void save () { |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
115 DataSet ds = new DataSet(); |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
116 ds.sec[cast(ID) "misc"] = misc; |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
117 |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
118 IWriter writer; |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
119 try { |
15
4608be19ebe2
Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
14
diff
changeset
|
120 writer = confDir.makeMTWriter (fileName, ds); |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
121 writer.write(); |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
122 } catch (MTException e) { |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
123 logger.error ("Mergetag exception occurred; saving aborted:"); |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
124 logger.error (e.msg); |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
125 //FIXME: currently nothing done besides logging the error |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
126 } |
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
127 } |
12
bff0d802cb7d
Implemented some internationalization support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
11
diff
changeset
|
128 |
bff0d802cb7d
Implemented some internationalization support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
11
diff
changeset
|
129 private static Logger logger; |
bff0d802cb7d
Implemented some internationalization support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
11
diff
changeset
|
130 static this() { |
bff0d802cb7d
Implemented some internationalization support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
11
diff
changeset
|
131 logger = Log.getLogger ("mde.options"); |
bff0d802cb7d
Implemented some internationalization support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
11
diff
changeset
|
132 } |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
133 //END Static |
11
b940f267419e
Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
134 } |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
135 |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
136 /** A home for all miscellaneous options, at least for now. */ |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
137 class OptionsMisc : Options { |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
138 bool useThreads; // set 0 to disable threading |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
139 char[] L10n; // locale, e.g. en-GB |
18
56a42ec95024
Changes to Init and logging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
140 |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
141 int logLevel; // tango logger level |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
142 |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
143 this () { |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
144 optsBool = ["useThreads":&useThreads]; |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
145 optsCharA = ["L10n":&L10n]; |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
146 optsInt = ["logLevel":&logLevel]; |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
147 } |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
15
diff
changeset
|
148 } |