comparison mde/gui/WidgetManager.d @ 128:41582439a42b

Added support for dynamic EnumContent loading and saving, with translation loading. WMScreen.init removed; code moved to this() since class is now created by main() instead of a static this(). Fix for SwitchWidget not passing events. Still some resizing bugs evident in SwitchWidget :-(
author Diggory Hardy <diggory.hardy@gmail.com>
date Wed, 14 Jan 2009 20:24:14 +0000
parents c9843fbaac88
children ad91de8867a0
comparison
equal deleted inserted replaced
127:3328c6fb77ca 128:41582439a42b
22 module mde.gui.WidgetManager; 22 module mde.gui.WidgetManager;
23 23
24 import mde.gui.WidgetDataSet; 24 import mde.gui.WidgetDataSet;
25 import mde.gui.widget.Ifaces; 25 import mde.gui.widget.Ifaces;
26 import mde.gui.exception; 26 import mde.gui.exception;
27
28 import imde = mde.imde;
29 import mde.lookup.Options; // miscOpts.L10n callback
27 import mde.content.Content; 30 import mde.content.Content;
28 31 import Items = mde.content.Items; // loadTranslation
29 import imde = mde.imde; 32
30 import mde.file.mergetag.Reader; 33 import mde.file.mergetag.Reader;
31 import mde.file.mergetag.Writer; 34 import mde.file.mergetag.Writer;
32 import mde.setup.paths; 35 import mde.setup.paths;
33 36
34 // Widgets to create: 37 // Widgets to create:
62 * fileName = Name of file specifying the gui, excluding path and extension. 65 * fileName = Name of file specifying the gui, excluding path and extension.
63 */ 66 */
64 protected this (char[] file) { 67 protected this (char[] file) {
65 mutex = new Mutex; // Used on functions intended to be called from outside the gui package. 68 mutex = new Mutex; // Used on functions intended to be called from outside the gui package.
66 fileName = file; 69 fileName = file;
70 miscOpts.L10n.addCallback (&reloadStrings);
71
72 clickCallbacks = new typeof(clickCallbacks);
73 motionCallbacks = new typeof(motionCallbacks);
67 } 74 }
68 75
69 /* Load the widgets' data from the file specified to the CTOR. 76 /* Load the widgets' data from the file specified to the CTOR.
70 * 77 *
71 * params: 78 * params:
121 } catch (Exception e) { 128 } catch (Exception e) {
122 logger.error ("Unable to load GUI: errors parsing config file ("~confDir.getFileName(fileName,PRIORITY.HIGH_LOW)~"):"); 129 logger.error ("Unable to load GUI: errors parsing config file ("~confDir.getFileName(fileName,PRIORITY.HIGH_LOW)~"):");
123 logger.error (e.msg); 130 logger.error (e.msg);
124 throw new GuiException ("Failure parsing config file"); 131 throw new GuiException ("Failure parsing config file");
125 } 132 }
133
134 Items.loadTranslation ();
126 } 135 }
127 136
128 /** Load the gui from some design. 137 /** Load the gui from some design.
129 * 138 *
130 * If a design was previously loaded, its changes are saved first. 139 * If a design was previously loaded, its changes are saved first.
178 preSave; 187 preSave;
179 188
180 mutex.lock; 189 mutex.lock;
181 scope(exit) mutex.unlock; 190 scope(exit) mutex.unlock;
182 191
183 // Make all widgets save any changed data; return if no changes: 192 // Make all widgets save any changed data:
184 if (!child.saveChanges) 193 child.saveChanges;
194
195 if (changes.noChanges)
185 return; 196 return;
186 197
187 if (loadUserFile) { // merge entries from user file into current changes 198 if (loadUserFile) { // merge entries from user file into current changes
188 try { 199 try {
189 scope IReader reader = confDir.makeMTReader ( 200 scope IReader reader = confDir.makeMTReader (