comparison mde/gui/WidgetManager.d @ 81:d8fccaa45d5f

Moved file IO code from mde/mergetag to mde/file[/mergetag] and changed how some errors are caught.
author Diggory Hardy <diggory.hardy@gmail.com>
date Fri, 29 Aug 2008 11:59:43 +0100
parents ea58f277f487
children e0f1ec7fe73a
comparison
equal deleted inserted replaced
80:ea58f277f487 81:d8fccaa45d5f
185 185
186 import mde.gui.exception; 186 import mde.gui.exception;
187 import mde.gui.widget.Ifaces; 187 import mde.gui.widget.Ifaces;
188 import mde.gui.widget.createWidget; 188 import mde.gui.widget.createWidget;
189 189
190 import mde.mergetag.Reader; 190 import mde.file.mergetag.Reader;
191 import mde.mergetag.Writer; 191 import mde.file.mergetag.Writer;
192 import mde.setup.paths; 192 import mde.setup.paths;
193 193
194 /************************************************************************************************* 194 /*************************************************************************************************
195 * Contains the code for loading and saving the gui, but not the code for drawing it or handling 195 * Contains the code for loading and saving the gui, but not the code for drawing it or handling
196 * user input. 196 * user input.
218 * allDesigns = Load all sections 218 * allDesigns = Load all sections
219 */ 219 */
220 private void loadData (bool allDesigns = false) { 220 private void loadData (bool allDesigns = false) {
221 if (allLoaded || (defaultDesign !is null && allDesigns == false)) 221 if (allLoaded || (defaultDesign !is null && allDesigns == false))
222 return; // test if already loaded 222 return; // test if already loaded
223
224 if (!confDir.exists (fileName)) {
225 logger.error ("Unable to load GUI: no config file!");
226 return; // not a fatal error (so long as the game can run without a GUI!)
227 }
228 223
229 // Set up a reader 224 // Set up a reader
230 scope IReader reader; 225 scope IReader reader;
231 try { 226 try {
232 reader = confDir.makeMTReader (fileName, PRIORITY.HIGH_LOW, null, true); 227 reader = confDir.makeMTReader (fileName, PRIORITY.HIGH_LOW, null, true);
264 if (allDesigns) { 259 if (allDesigns) {
265 reader.read; 260 reader.read;
266 allLoaded = true; 261 allLoaded = true;
267 } else 262 } else
268 reader.read([defaultDesign]); 263 reader.read([defaultDesign]);
264 } catch (NoFileException) {
265 logger.error ("Unable to load GUI: no config file!");
266 // just return: not a fatal error (so long as the game can run without a GUI!)
269 } catch (Exception e) { 267 } catch (Exception e) {
270 logger.error ("Unable to load GUI: errors parsing config file ("~confDir.getFileName(fileName,PRIORITY.HIGH_LOW)~"):"); 268 logger.error ("Unable to load GUI: errors parsing config file ("~confDir.getFileName(fileName,PRIORITY.HIGH_LOW)~"):");
271 logger.error (e.msg); 269 logger.error (e.msg);
272 throw new GuiException ("Failure parsing config file"); 270 throw new GuiException ("Failure parsing config file");
273 } 271 }