comparison mde/content/miscContent.d @ 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. Content restrutured a lot: New IContent module, Content module includes more functionality. New ContentLoader module to manage content loading/saving/translation. Translation module moved to content dir and cut down to reflect current usage. File format unchanged except renames: FontOptions -> Font, VideoOptions -> Screen. Font render mode and LCD filter options are now enums. GUI loading needs to create content (and set type for enums), but doesn't save/load value. Some setup of mainSchedule moved to mde.mainLoop. Content callbacks are called on content change now. ContentLists are set up implicitly from content symbols. Not as fast but much easier! Bug-fix in the new MTTagReader. Renamed MT *Reader maker functions to avoid confusion in paths.d. New mde.setup.logger module to allow logger setup before any other module's static this().
author Diggory Hardy <diggory.hardy@gmail.com>
date Sat, 07 Feb 2009 12:46:03 +0000
parents 9cff74f68b84
children 620d4ea30228
comparison
equal deleted inserted replaced
136:4084f07f2c7a 137:9f035cd139c6
18 *****************************************************************************/ 18 *****************************************************************************/
19 module mde.content.miscContent; 19 module mde.content.miscContent;
20 20
21 public import mde.content.Content; 21 public import mde.content.Content;
22 22
23 /+
23 import tango.util.log.Log : Log, Logger; 24 import tango.util.log.Log : Log, Logger;
24 private Logger logger; 25 private Logger logger;
25 static this () { 26 static this () {
26 logger = Log.getLogger ("mde.content.miscContent"); 27 logger = Log.getLogger ("mde.content.miscContent");
27 } 28 }
28 29 +/
29 /** A generic way to handle a list of type IContent. */
30 class ContentList : Content, IContentList
31 {
32 this (char[] symbol, Content[] list = null) {
33 list_ = list;
34 super (symbol);
35 }
36 this (char[] symbol, Content[char[]] l) {
37 list_.length = l.length;
38 size_t i;
39 foreach (c; l)
40 list_[i++] = c;
41 super (symbol);
42 }
43
44 override Content[] list () {
45 return list_;
46 }
47
48 ContentList append (Content x) {
49 size_t l = list_.length;
50 list_.length = l + 1;
51 list_[l] = x;
52 return this;
53 }
54 ContentList append (Content[] x) {
55 list_ ~= x;
56 return this;
57 }
58
59 protected:
60 final Content[] list_;
61 }
62
63 /** Created on errors to display and log a message. */
64 class ErrorContent : Content
65 {
66 this (char[] name, char[] msg) {
67 super (name);
68 this.msg = msg;
69 logger.error (name ~ ": " ~ msg);
70 }
71
72 override char[] toString (uint i) {
73 return i == 0 ? msg
74 : i == 1 ? name_
75 : null;
76 }
77
78 protected:
79 char[] msg;
80 }
81 30
82 /** A Content with no value but able to pass on an event. 31 /** A Content with no value but able to pass on an event.
83 * 32 *
84 * The point being that a button can be tied to one of these. */ 33 * The point being that a button can be tied to one of these. */
85 class EventContent : Content { 34 class EventContent : Content {