comparison mde/content/Items.d @ 115:1b1e2297e2fc

Enums handled more generically now via either a popup list or flat list of BoolContentWidgets. EnumContent is an IContentList with BoolContent sub-contents. Content modules moved around (again). ContentListWidget can now list horizontally. Log-level setting callback.
author Diggory Hardy <diggory.hardy@gmail.com>
date Sat, 20 Dec 2008 17:57:05 +0000
parents 9824bee909fd
children d3b2cefd46c9
comparison
equal deleted inserted replaced
114:b16a534f5302 115:1b1e2297e2fc
16 /************************************************************************************************** 16 /**************************************************************************************************
17 * A generic way to access content items. Also loads translations on-demand. 17 * A generic way to access content items. Also loads translations on-demand.
18 *************************************************************************************************/ 18 *************************************************************************************************/
19 module mde.content.Items; 19 module mde.content.Items;
20 20
21 import mde.content.Content; 21 import mde.content.miscContent;
22 import mde.gui.exception; 22 import mde.gui.exception;
23 23
24 import imde = mde.imde; 24 import imde = mde.imde;
25 import mde.lookup.Options; 25 import mde.lookup.Options;
26 import mde.lookup.Translation; 26 import mde.lookup.Translation;
37 * 37 *
38 * loadTranslation() $(B must) be called before this function. 38 * loadTranslation() $(B must) be called before this function.
39 * 39 *
40 * E.g. get ("Options.MiscOptions.L10n") returns miscOpts.L10n, 40 * E.g. get ("Options.MiscOptions.L10n") returns miscOpts.L10n,
41 * Items.get ("Options.MiscOptions") returns a ContentList of all misc options. */ 41 * Items.get ("Options.MiscOptions") returns a ContentList of all misc options. */
42 AContent get (char[] item) { 42 Content get (char[] item) {
43 assert (currentL10n is miscOpts.L10n(), "must call loadTranslation (code error)"); 43 assert (currentL10n is miscOpts.L10n(), "must call loadTranslation (code error)");
44 44
45 char[] h = head (item); 45 char[] h = head (item);
46 if (h == "Options") { 46 if (h == "Options") {
47 if (item is null) 47 if (item is null)
73 void loadTranslation () { 73 void loadTranslation () {
74 if (currentL10n is miscOpts.L10n()) return; 74 if (currentL10n is miscOpts.L10n()) return;
75 75
76 // Create Option classes' ContentLists if necessary: 76 // Create Option classes' ContentLists if necessary:
77 if (Options.allContentList is null) { 77 if (Options.allContentList is null) {
78 AContent[] list; 78 Content[] list;
79 list.length = Options.optionsClasses.length; 79 list.length = Options.optionsClasses.length;
80 size_t i; 80 size_t i;
81 foreach (n,opts; Options.optionsClasses) { 81 foreach (n,opts; Options.optionsClasses) {
82 opts.contentList = new ContentList (n, opts.content); 82 opts.contentList = new ContentList (n, opts.content);
83 list[i++] = opts.contentList; 83 list[i++] = opts.contentList;
97 trle = trl.getStruct (n); 97 trle = trl.getStruct (n);
98 opts.contentList.name (trle.name, trle.desc); 98 opts.contentList.name (trle.name, trle.desc);
99 foreach (s, v; opts.content) { 99 foreach (s, v; opts.content) {
100 trle = trl.getStruct (s); 100 trle = trl.getStruct (s);
101 v.name (trle.name, trle.desc); 101 v.name (trle.name, trle.desc);
102 EnumContent ec = cast(EnumContent) v; 102 ContentList cl = cast(ContentList) v;
103 if (ec) { 103 if (cl) {
104 char[] tp = s ~ "."; 104 foreach (i,c; cl.list) {
105 foreach (i,sym; ec.enumSymbols) { 105 trle = trl.getStruct (c.symbol);
106 trle = trl.getStruct (tp~sym); 106 c.name (trle.name, trle.desc);
107 ec.nameEnum (i, trle.name, trle.desc);
108 } 107 }
109 } 108 }
110 } 109 }
111 } 110 }
112 111