Mercurial > projects > mde
comparison mde/gui/Gui.d @ 45:0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Moved the implementable widgets from mde.gui.widget.Widget to miscWidgets, leaving base widgets in Widget.
Rewrote some of GridLayoutWidget's implementation. Made many operations general to work for either columns or rows. Some optimisations were intended but ended up being removed due to problems.
Allowed layout's to resize from either direction (only with window resizes).
committer: Diggory Hardy <diggory.hardy@gmail.com>
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Thu, 22 May 2008 11:34:09 +0100 |
parents | 1530d9c04d4d |
children | e0839643ff52 |
comparison
equal
deleted
inserted
replaced
44:07bd1a09e161 | 45:0fd51d2c6c8a |
---|---|
61 logger.error ("Unable to load GUI: no config file!"); | 61 logger.error ("Unable to load GUI: no config file!"); |
62 return; // not a fatal error (so long as the game can run without a GUI!) | 62 return; // not a fatal error (so long as the game can run without a GUI!) |
63 } | 63 } |
64 | 64 |
65 IReader reader; | 65 IReader reader; |
66 try { | 66 reader = confDir.makeMTReader (fileName, PRIORITY.HIGH_LOW, null, true); |
67 reader = confDir.makeMTReader (fileName, PRIORITY.HIGH_LOW, null, true); | 67 reader.dataSecCreator = delegate mt.IDataSection(mt.ID id) { |
68 reader.dataSecCreator = delegate mt.IDataSection(mt.ID id) { | 68 return new Window (id); |
69 return new Window (id); | 69 }; |
70 }; | 70 reader.read; |
71 reader.read; | |
72 } catch (mt.MTException e) { | |
73 logger.error ("Loading GUI aborted:"); | |
74 logger.error (e.msg); | |
75 | |
76 return; | |
77 } | |
78 | 71 |
79 // Get the renderer | 72 // Get the renderer |
80 char[]* p = RENDERER in reader.dataset.header.Arg!(char[]).Arg; | 73 char[]* p = RENDERER in reader.dataset.header.Arg!(char[]).Arg; |
81 if (p is null || *p is null) { | 74 if (p is null || *p is null) { |
82 logger.error ("Loading GUI aborted: no renderer specified"); | 75 logger.warn ("no renderer specified: defaulting to Simple"); |
83 return; | 76 rendName = "Simple"; |
84 } | 77 } |
85 rendName = *p; | 78 else |
79 rendName = *p; | |
86 | 80 |
87 // get list | 81 // get list |
88 windows.length = reader.dataset.sec.length; // pre-allocate | 82 windows.length = reader.dataset.sec.length; // pre-allocate |
89 windows.length = 0; | 83 windows.length = 0; |
90 foreach (sec; reader.dataset.sec) { | 84 foreach (sec; reader.dataset.sec) { |
92 debug if (w is null) { | 86 debug if (w is null) { |
93 logger.error (__FILE__ ~ "(GUI.load): code error (w is null)"); | 87 logger.error (__FILE__ ~ "(GUI.load): code error (w is null)"); |
94 continue; | 88 continue; |
95 } | 89 } |
96 try { | 90 try { |
97 w.finalise (this); | 91 w.finalise (this); // if this fails, the window (but nothing else) won't work |
98 windows ~= w; // only add if load successful | 92 windows ~= w; // only add if load successful |
99 } catch (Exception e) { | 93 } catch (Exception e) { |
100 logger.error ("Window failed to load: " ~ e.msg); | 94 logger.error ("Window failed to load: " ~ e.msg); |
101 } | 95 } |
102 } | 96 } |
103 | 97 |