Mercurial > projects > mde
annotate mde/content/Content.d @ 163:24d77c52243f
Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Updated layout and Translation unittests to run.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sat, 23 May 2009 15:47:32 +0200 |
parents | 2476790223b8 |
children | bb2f1a76346d |
rev | line source |
---|---|
61
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
1 /* LICENSE BLOCK |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
2 Part of mde: a Modular D game-oriented Engine |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
3 Copyright © 2007-2008 Diggory Hardy |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
4 |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify it under the terms |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
6 of the GNU General Public License as published by the Free Software Foundation, either |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
7 version 2 of the License, or (at your option) any later version. |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
8 |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
11 See the GNU General Public License for more details. |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
12 |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
13 You should have received a copy of the GNU General Public License |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
15 |
137
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
16 /****************************************************************************** |
115
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
17 * The content system − interfaces and base Content class. |
137
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
18 *****************************************************************************/ |
105
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
19 module mde.content.Content; |
61
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
20 |
137
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
21 public import mde.content.IContent; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
22 import mde.content.Translation; // loading strings |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
23 import mde.content.ValueCache; // saving/loading content values |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
24 import util = mde.util; // fp -> dlg |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
25 import mde.exception; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
26 import mde.setup.logger; |
110
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
27 |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
28 import tango.util.log.Log : Log, Logger; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
29 private Logger logger; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
30 static this () { |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
31 logger = Log.getLogger ("mde.gui.content.Content"); |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
32 } |
94
9520cc0448e5
Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
91
diff
changeset
|
33 |
115
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
34 /** Content lists. Impemented by EnumContent as well as ContentList. */ |
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
35 interface IContentList : IContent |
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
36 { |
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
37 /** Return all sub-contents. */ |
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
38 Content[] list (); |
137
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
39 |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
40 /** Append x to the content list. |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
41 * |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
42 * Done automatically in creation, from symbol name, so don't call |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
43 * externally. */ |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
44 void append (Content x); |
115
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
45 } |
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
46 |
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
47 |
137
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
48 /****************************************************************************** |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
49 * The base for most or all content classes. |
105
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
50 * |
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
51 * Includes generic callback support, toString implementation and symbol access. |
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
52 * |
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
53 * Derived classes should impement: |
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
54 * --- |
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
55 * this (char[] symbol, T val = /+ default value +/); |
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
56 * void opAssign (T val); // assign val, calling callbacks |
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
57 * T opCall (); // return value |
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
58 * alias opCall opCast; |
137
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
59 * void endEvent (); // extend to set new value in changed (if Content has a value) |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
60 * --- |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
61 *****************************************************************************/ |
115
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
62 class Content : IContent |
103
42e241e7be3e
ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
101
diff
changeset
|
63 { |
137
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
64 protected this (char[] symbol) { |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
65 //debug logger.trace ("Creating a {}: {}", this, symbol); |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
66 if (symbol in allContent) |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
67 throw new ContentException ("Multiple content with symbol "~ symbol); |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
68 allContent[symbol] = this; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
69 this.symbol = symbol; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
70 |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
71 // Name: |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
72 auto l10nP = symbol in translations; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
73 if (l10nP) |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
74 name (*l10nP); |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
75 else |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
76 name_ = symbol; // provide a temporary name |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
77 |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
78 // Add to a parent list: |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
79 ptrdiff_t i = symbol.length-1; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
80 while (i >= 0 && symbol[i] != '.') |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
81 --i; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
82 IContentList parent; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
83 if (i <= 0) { |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
84 if (symbol.length == 0) |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
85 return; // special case: is tree (content tree root) |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
86 parent = tree; // otherwise, use tree as root |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
87 } else { |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
88 char[] parentSym = symbol[0..i]; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
89 Content* parObj = parentSym in allContent; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
90 if (parObj) { // existing object |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
91 parent = cast(IContentList) *parObj; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
92 if (parent is null) { // it's not an IContentList! |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
93 logger.warn ("{} is not an IContentList, but a child, {}, exists!", parentSym, symbol); |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
94 return; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
95 } |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
96 } else // no existing object |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
97 parent = new ContentList (parentSym); |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
98 } |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
99 parent.append (this); |
105
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
100 } |
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
101 |
137
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
102 void name (Translation.Entry e) { |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
103 name_ = e.name; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
104 desc_ = e.desc; |
103
42e241e7be3e
ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
101
diff
changeset
|
105 } |
137
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
106 |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
107 /** Add a callback. Callbacks are called on a change or event, in the order |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
108 * added. */ |
115
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
109 Content addCallback (void delegate (Content) cb) { |
110
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
110 this.cb ~= cb; |
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
111 return this; |
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
112 } |
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
113 /// ditto |
115
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
114 Content addCallback (void function (Content) cb) { |
110
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
115 this.cb ~= util.toDg (cb); |
105
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
116 return this; |
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
117 } |
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
118 |
137
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
119 /** End of an event, e.g. a button release or end of an edit (calls callbacks). |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
120 * |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
121 * Content holding a value should override this, setting its new value in |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
122 * changed as well as calling callbacks, e.g.: |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
123 * --- |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
124 * Content.changed.boolData[symbol] = val; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
125 * super(); |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
126 * --- */ |
105
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
127 void endEvent () { |
110
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
128 foreach (dg; cb) |
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
129 dg (this); |
105
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
130 } |
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
131 |
162
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
132 override char[] toString (uint i) { |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
133 return i == 0 ? "No value" |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
134 : i == 1 ? name_ |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
135 : i == 2 ? desc_ |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
136 : null; |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
137 } |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
138 |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
139 /** A naive implementation which assumes the passed content is |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
140 * incompatible. */ |
163
24d77c52243f
Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
162
diff
changeset
|
141 override bool set (IContent) { |
162
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
142 return false; |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
143 } |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
144 |
105
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
145 protected: |
137
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
146 char[] symbol; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
147 char[] name_, desc_; // translated name and description |
115
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
148 void delegate (Content) cb[]; |
137
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
149 |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
150 public static: |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
151 /** Get Content with _symbol name symbol from the list of all content, or |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
152 * null if no such Content exists. */ |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
153 Content get (char[] symbol) { |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
154 auto p = symbol in allContent; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
155 if (p) |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
156 return *p; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
157 logger.warn ("Content {} does not exist",symbol); |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
158 return null; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
159 } |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
160 |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
161 // Would use tango.container.HashMap, but mde.workaround2371 doesn't work here. |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
162 Content[char[]] allContent; // all content hashed by symbol name |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
163 ContentList tree; // tree of all content. |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
164 |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
165 static this () { |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
166 tree = new ContentList (""); |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
167 } |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
168 |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
169 package static: |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
170 // Kept to set the value of other content as it is created: |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
171 ValueCache loaded; // loaded values not matching any content created yet |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
172 // The values in changed are what is written to file when saving: |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
173 ValueCache changed; // changed values and values from local config file |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
174 |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
175 Translation.Entry[char[]] translations; |
105
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
104
diff
changeset
|
176 } |
137
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
177 |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
178 /** A generic way to handle a list of type IContent. */ |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
179 class ContentList : Content, IContentList |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
180 { |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
181 this (char[] symbol) { |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
182 super (symbol); |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
183 } |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
184 |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
185 override Content[] list () { |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
186 return list_; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
187 } |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
188 |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
189 override void append (Content x) { |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
190 list_ ~= x; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
191 } |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
192 |
163
24d77c52243f
Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
162
diff
changeset
|
193 override bool set (IContent c) { |
162
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
194 IContentList cl = cast (IContentList) c; |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
195 if (cl !is null) { |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
196 list_ = cl.list(); |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
197 return true; |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
198 } |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
199 return false; |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
200 } |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
201 |
137
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
202 protected: |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
203 final Content[] list_; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
204 } |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
205 |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
206 /** Created on errors to display and log a message. */ |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
207 class ErrorContent : Content |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
208 { |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
209 this (char[] symbol, char[] msg) { |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
210 super (symbol); |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
211 this.msg = msg; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
212 logger.error (symbol ~ ": " ~ msg); |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
213 } |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
214 |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
215 override char[] toString (uint i) { |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
216 return i == 0 ? msg |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
217 : i == 1 ? name_ |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
218 : null; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
219 } |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
220 |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
221 protected: |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
222 char[] msg; |
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
223 } |