Mercurial > projects > mde
annotate mde/gui/WidgetLoader.d @ 159:b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
There is now a GUI options section.
Created a third WidgetManager class called WidgetLoader to handle file loading/saving.
Moved most of the code in WMScreen's draw/clickEvent/motionEvent functions to WidgetManager.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Thu, 21 May 2009 20:55:10 +0200 |
parents | |
children | 7f7b2011b759 |
rev | line source |
---|---|
159
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
1 /* LICENSE BLOCK |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
2 Part of mde: a Modular D game-oriented Engine |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
3 Copyright © 2007-2008 Diggory Hardy |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
4 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify it under the terms |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
6 of the GNU General Public License as published by the Free Software Foundation, either |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
7 version 2 of the License, or (at your option) any later version. |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
8 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
11 See the GNU General Public License for more details. |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
12 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
13 You should have received a copy of the GNU General Public License |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
15 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
16 /****************************************************************************** |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
17 * A gui manager extension to load widgets from files. |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
18 * |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
19 * Public methods in this class should be thread safe (by locking on a mutex). |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
20 *****************************************************************************/ |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
21 module mde.gui.WidgetLoader; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
22 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
23 import mde.gui.WidgetManager; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
24 import mde.gui.WidgetDataSet; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
25 import mde.gui.exception; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
26 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
27 import mt = mde.file.mergetag.DataSet; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
28 import mde.file.mergetag.Reader; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
29 import mde.file.mergetag.Writer; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
30 import mde.file.paths; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
31 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
32 import tango.util.log.Log : Log, Logger; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
33 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
34 private Logger logger; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
35 static this () { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
36 logger = Log.getLogger ("mde.gui.WidgetLoader"); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
37 } |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
38 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
39 /****************************************************************************** |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
40 * Contains the code for loading and saving an entire gui (more than one may |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
41 * exist), but not the code for drawing it or handling user input. |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
42 * |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
43 * This abstract class exists solely for separating out some of the functionality. |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
44 *****************************************************************************/ |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
45 abstract scope class AWidgetLoader : AWidgetManager |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
46 { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
47 /** Construct a new widget loader. |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
48 * |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
49 * params: |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
50 * fileName = Name of file specifying the gui, excluding path and extension. |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
51 */ |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
52 protected this (char[] file) { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
53 mutex = new Mutex; // Used on functions intended to be called from outside the gui package. |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
54 fileName = file; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
55 super (file); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
56 } |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
57 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
58 /* Load the widgets' data from the file specified to the CTOR. |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
59 * |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
60 * params: |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
61 * allDesigns = Load all sections |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
62 */ |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
63 private void loadData (bool allDesigns = false) { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
64 if (allLoaded || (defaultDesign !is null && allDesigns == false)) |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
65 return; // test if already loaded |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
66 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
67 // Set up a reader |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
68 scope IReader reader; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
69 try { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
70 reader = confDir.makeMTReader (fileName, PRIORITY.HIGH_LOW, null, true); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
71 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
72 // Read from the HEADER: |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
73 // Get the renderer |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
74 char[]* p = "Renderer" in reader.dataset.header._charA; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
75 if (p is null || *p is null) { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
76 logger.warn ("No renderer specified: using \"Simple\""); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
77 rendName = "Simple"; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
78 } |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
79 else |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
80 rendName = *p; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
81 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
82 // Get which section to use |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
83 p = "Design" in reader.dataset.header._charA; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
84 if (p is null || *p is null) { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
85 logger.warn ("No gui design specified: trying \"Default\""); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
86 defaultDesign = "Default"; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
87 } |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
88 else |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
89 defaultDesign = *p; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
90 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
91 // Read the body: |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
92 // Load the chosen design |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
93 reader.dataSecCreator = delegate mt.IDataSection(mt.ID id) { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
94 WidgetDataSet* p = id in data; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
95 if (p is null) { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
96 data[id] = new WidgetDataSet; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
97 return *(id in data); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
98 } |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
99 return *p; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
100 }; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
101 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
102 if (allDesigns) { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
103 reader.read; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
104 allLoaded = true; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
105 } else |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
106 reader.read([defaultDesign]); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
107 } catch (NoFileException) { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
108 logger.error ("Unable to load GUI: no config file: "~fileName); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
109 // just return: not a fatal error (so long as the game can run without a GUI!) |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
110 } catch (Exception e) { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
111 logger.error ("Unable to load GUI: errors parsing config file ("~confDir.getFileName(fileName,PRIORITY.HIGH_LOW)~"):"); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
112 logger.error (e.msg); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
113 throw new GuiException ("Failure parsing config file"); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
114 } |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
115 } |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
116 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
117 /** Load the gui from some design. |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
118 * |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
119 * If a design was previously loaded, its changes are saved first. |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
120 * |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
121 * Params: |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
122 * name = Design to load. If null, the default will be loaded. |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
123 */ |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
124 void loadDesign (char[] name = null) { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
125 if (changes !is null) // A design was previously loaded |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
126 save; // own lock |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
127 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
128 mutex.lock; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
129 scope(exit) mutex.unlock; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
130 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
131 // Load data (loadData tests if it's already loaded first): |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
132 if (name is null) { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
133 loadData (false); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
134 name = defaultDesign; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
135 } else |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
136 loadData (true); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
137 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
138 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
139 // Get data: |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
140 auto p = name in data; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
141 while (p is null) { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
142 if (name == defaultDesign) |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
143 throw new GuiException ("Unable to load [specified or] default design"); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
144 name = defaultDesign; // try again with the default |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
145 p = name in data; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
146 } |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
147 curData = *p; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
148 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
149 // Get/create a changes section: |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
150 if (changesDS is null) |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
151 changesDS = new mt.DataSet; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
152 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
153 mt.IDataSection* q = name in changesDS.sec; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
154 if (!q || ((changes = cast(WidgetDataChanges) *q) is null)) { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
155 changes = new WidgetDataChanges (curData); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
156 changesDS.sec[name] = changes; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
157 } |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
158 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
159 // Create the widgets: |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
160 createRootWidget; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
161 underMouse = child; // must be something |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
162 } |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
163 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
164 /** Save changes, if any exist. |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
165 * |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
166 * Is run when the manager is destroyed, but could be run at other times too. */ |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
167 void save () { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
168 preSave; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
169 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
170 mutex.lock; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
171 scope(exit) mutex.unlock; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
172 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
173 // Make all widgets save any changed data: |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
174 child.saveChanges; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
175 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
176 if (changes.noChanges) |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
177 return; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
178 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
179 if (loadUserFile) { // merge entries from user file into current changes |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
180 try { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
181 scope IReader reader = confDir.makeMTReader ( |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
182 fileName, PRIORITY.HIGH_ONLY, changesDS, true); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
183 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
184 // Create if necessary, only corresponding to existing designs read: |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
185 reader.dataSecCreator = delegate mt.IDataSection(mt.ID id) { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
186 WidgetDataSet* p = id in data; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
187 if (p is null) |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
188 throw new Exception ("File has changed since it was loaded!"); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
189 return new WidgetDataChanges (*p); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
190 }; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
191 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
192 reader.read; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
193 } catch (NoFileException) { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
194 // No user file exists; not an error. |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
195 } catch (Exception e) { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
196 logger.error ("Error reading "~confDir.getFileName(fileName,PRIORITY.HIGH_ONLY)~" prior to saving:"); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
197 logger.error (e.msg); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
198 logger.error ("Overwriting the file."); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
199 // Continue... |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
200 } |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
201 loadUserFile = false; // don't need to do it again |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
202 } |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
203 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
204 try { // Save |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
205 IWriter writer; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
206 writer = confDir.makeMTWriter (fileName, changesDS); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
207 writer.write; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
208 } catch (Exception e) { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
209 logger.error ("Saving to "~confDir.getFileName(fileName,PRIORITY.HIGH_ONLY)~" failed:"); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
210 logger.error (e.msg); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
211 // No point in throwing since it doesn't affect anything else. |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
212 } |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
213 } |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
214 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
215 /** Get the names of all designs available. */ |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
216 char[][] designs() { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
217 synchronized(mutex) { |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
218 loadData (true); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
219 return data.keys; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
220 } |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
221 } |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
222 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
223 protected: |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
224 // Called by derived classes, not thread safe for the same instance |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
225 //BEGIN WidgetManagement methods |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
226 /** Second stage of loading the widgets. |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
227 * |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
228 * loadDesign handles the data; this method needs to: |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
229 * --- |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
230 * // 1. Create the root widget: |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
231 * child = makeWidget ("root"); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
232 * child.setup (0, 3); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
233 * // 2. Set the size: |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
234 * child.setWidth (child.minWidth, 1); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
235 * child.setHeight (child.minHeight, 1); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
236 * // 3. Set the position (necessary part of initialization): |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
237 * child.setPosition (0,0); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
238 * --- |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
239 */ |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
240 void createRootWidget(); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
241 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
242 /** Called before saving (usually when the GUI is about to be destroyed, although not |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
243 * necessarily). */ |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
244 void preSave (); |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
245 //END WidgetManagement methods |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
246 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
247 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
248 // Dataset/design data: |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
249 final char[] fileName; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
250 char[] defaultDesign; // The design specified in the file header. |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
251 |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
252 // Loaded data, indexed by design name. May not be loaded for all gui designs: |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
253 scope WidgetDataSet[char[]] data; |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
254 private bool allLoaded = false; // applies to data |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
255 scope mt.DataSet changesDS; // changes and sections from user file (used for saving) |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
256 bool loadUserFile = true; // still need to load user file for saving? |
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
257 } |