comparison mde/lookup/Options.d @ 84:e0f1ec7fe73a

Merge plus a few tweaks.
author Diggory Hardy <diggory.hardy@gmail.com>
date Sun, 31 Aug 2008 15:59:17 +0100
parents ac1e3fd07275
children 56c0ddd90193
comparison
equal deleted inserted replaced
82:ac1e3fd07275 84:e0f1ec7fe73a
12 12
13 You should have received a copy of the GNU General Public License 13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
15 15
16 /** This module handles stored options, currently all except input maps. 16 /** This module handles stored options, currently all except input maps.
17 * 17 *
18 * The purpose of having all options centrally controlled is to allow generic handling by the GUI 18 * The purpose of having all options centrally controlled is to allow generic handling by the GUI
19 * and ease saving and loading of values. The Options class is only really designed around handling 19 * and ease saving and loading of values. The Options class is only really designed around handling
20 * small numbers of variables for now. 20 * small numbers of variables for now.
21 */ 21 *
22 * Note: This module uses some non-spec functionality, which "works for me", but may need to be
23 * changed if it throws up problems. Specifically: templated virtual functions (Options.set, get
24 * and list), and accessing private templates from an unrelated class (Options.TName, TYPES).
25 * OptionChanges used to have a templated set member function (used by Options.set), which caused
26 * linker problems when the module wasn't compiled from scratch.
27 */
22 module mde.lookup.Options; 28 module mde.lookup.Options;
23 29
24 import mde.setup.paths; 30 import mde.setup.paths;
25 import mde.exception; 31 import mde.exception;
26 32
48 * char[] id. This list is used for saving, loading and to provide generic GUI options screens. The 54 * char[] id. This list is used for saving, loading and to provide generic GUI options screens. The
49 * built-in support in Options is only for bool, int and char[] types (a float type may get added). 55 * built-in support in Options is only for bool, int and char[] types (a float type may get added).
50 * Further to this, a generic class is used to store all options which have been changed, and if any 56 * Further to this, a generic class is used to store all options which have been changed, and if any
51 * have been changed, is merged with options from the user conf dir and saved on exit. 57 * have been changed, is merged with options from the user conf dir and saved on exit.
52 */ 58 */
59 /* An idea for potentially extending Options, but which doesn't seem necessary now:
60 Move static code from Options to an OptionSet class, which may be sub-classed. These sub-classes
61 may be hooked in to the master OptionSet class to shadow all Options classes and be notified of
62 changes, and may or may not have values loaded from files during init. Change-sets could be
63 rewritten to use this.
64 However, only the changesets should need to be notified of each change (gui interfaces could simply
65 be notified that a change occured and redraw everything; users of options can just re-take their
66 values every time they use them). */
53 class Options : IDataSection 67 class Options : IDataSection
54 { 68 {
69 protected this() {} /// Do not instantiate directly.
70
55 // All supported types, for generic handling via templates. It should be possible to change 71 // All supported types, for generic handling via templates. It should be possible to change
56 // the supported types simply by changing this list now (untested). 72 // the supported types simply by changing this list now (untested).
57 template store(A...) { alias A store; } 73 template store(A...) { alias A store; }
58 alias store!(bool, int, double, char[]) TYPES; 74 alias store!(bool, int, double, char[]) TYPES;
59 //BEGIN Templates: internal 75 //BEGIN Templates: internal