annotate mde/gui/gui.d @ 27:0aa621b3e070

Some GUI work, plus a small fix in the paths module. Implemented GUI code to load windows from file with a basic widget and draw. Fixed a bug in mde.resource.paths.mdeDirectory.makeMTReader when called with readOrder == PRIORITY.HIGH_ONLY. committer: Diggory Hardy <diggory.hardy@gmail.com>
author Diggory Hardy <diggory.hardy@gmail.com>
date Fri, 04 Apr 2008 17:07:38 +0100
parents
children b5fadd8d930b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
1 /* LICENSE BLOCK
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
2 Part of mde: a Modular D game-oriented Engine
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
3 Copyright © 2007-2008 Diggory Hardy
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
4
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
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
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
6 of the GNU General Public License as published by the Free Software Foundation, either
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
7 version 2 of the License, or (at your option) any later version.
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
8
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
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;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
11 See the GNU General Public License for more details.
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
12
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
13 You should have received a copy of the GNU General Public License
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
15
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
16 /// Base GUI module.
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
17 module mde.gui.gui;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
18
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
19 import mde.gui.Widget;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
20 import mde.gui.exception;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
21
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
22 import mt = mde.mergetag.DataSet;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
23 import mt = mde.mergetag.exception;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
24 import mde.mergetag.Reader;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
25
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
26 import mde.resource.paths;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
27 import mde.scheduler.InitFunctions;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
28
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
29 import tango.scrapple.text.convert.parseTo : parseTo;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
30 import tango.scrapple.text.convert.parseFrom : parseFrom;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
31
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
32 private Logger logger;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
33 static this () {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
34 logger = Log.getLogger ("mde.gui.gui");
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
35
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
36 init.addFunc (&GUI.load);
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
37 }
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
38
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
39 struct GUI {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
40 static:
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
41 private const fileName = "gui";
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
42 void load() {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
43 if (!confDir.exists (fileName)) {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
44 logger.error ("Unable to load GUI: no config file!");
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
45 return; // not a fatal error (so long as the game can run without a GUI!)
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
46 }
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
47
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
48 IReader reader;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
49 try {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
50 reader = confDir.makeMTReader (fileName, PRIORITY.HIGH_ONLY);
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
51 reader.dataSecCreator = delegate mt.IDataSection(mt.ID) {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
52 return new Window;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
53 };
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
54 reader.read;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
55 } catch (mt.MTException e) {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
56 logger.error ("Loading GUI aborted:");
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
57 logger.error (e.msg);
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
58
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
59 return;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
60 }
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
61
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
62 // get list
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
63 windows.length = reader.dataset.sec.length; // pre-allocate
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
64 windows.length = 0;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
65 foreach (sec; reader.dataset.sec) {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
66 Window w = cast(Window) sec;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
67 if (w !is null) { // extra safety
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
68 windows ~= w;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
69 try {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
70 w.finalise();
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
71 } catch (WindowLoadException e) {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
72 logger.error ("Window failed to load: " ~ e.msg);
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
73 }
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
74
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
75 gl.addDrawCallback (&w.draw);
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
76 }
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
77 }
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
78 }
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
79
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
80 private:
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
81 Window[] windows;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
82 }
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
83
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
84 package: // Nothing else here is for external use.
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
85
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
86 /** GUI Window class
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
87 *
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
88 * A window class instance does two things: (1) specify a region of the screen upon which the window
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
89 * and its associated widgets are drawn, and (2) load, save, and generally manage all its widgets.
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
90 *
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
91 * Let the window load a table of widget data, of type int[][widgetID]. Each widget will, when
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
92 * created, be given its int[] of data, which this() must confirm is valid (or throw).
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
93 */
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
94 class Window : mt.IDataSection
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
95 {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
96 alias int widgetID; // Widget ID type. Each ID is unique under this window. Type is int since this is the widget data type.
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
97 private int[][widgetID] widgetData; // Data for all widgets under this window.
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
98 private Widget[widgetID] widgets; // List of all widgets under this window (created on demand).
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
99
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
100 Widget widget; // The primary widget in this window.
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
101 int x,y; // Window position
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
102 int w,h; // Window size (calculated from Widgets)
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
103
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
104 const BORDER_WIDTH = 5; // Temporary way to handle window decorations
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
105
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
106
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
107 // Call after loading is finished to setup the window and confirm that it's valid.
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
108 void finalise () {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
109 // Create the widget, throwing on error:
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
110 widget = getWidget (0); // primary widget always has ID 0.
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
111 widget.getSize (w,h); // Find the initial size
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
112 w += BORDER_WIDTH * 2; // Adjust for border
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
113 h += BORDER_WIDTH * 2;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
114 }
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
115
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
116 Widget getWidget (widgetID i) {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
117 // See if it's already been created:
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
118 Widget* p = i in widgets;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
119 if (p !is null) return *p; // yes
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
120 else { // no
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
121 int[]* d = i in widgetData;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
122 if (d is null) throw new WindowLoadException ("Widget not found");
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
123
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
124 // Throws WidgetDataException (a WindowLoadException) if bad data:
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
125 Widget w = createWidget (*d);
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
126 widgets[i] = w;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
127 return w;
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
128 }
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
129 }
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
130
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
131 void draw () {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
132 //BEGIN Window border/back
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
133 gl.setColor (0.0f, 0.0f, 0.5f);
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
134 gl.drawBox (x,x+w, y,y+h);
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
135 //END Window border/back
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
136
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
137 // Tell the widget to draw itself:
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
138 widget.draw(x + BORDER_WIDTH, y + BORDER_WIDTH);
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
139 }
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
140
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
141 //BEGIN Mergetag code
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
142 void addTag (char[] tp, mt.ID id, char[] dt) {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
143 if (tp == "int[][int]") {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
144 if (id == "widgetData") {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
145 widgetData = cast(int[][widgetID]) parseTo!(int[][int]) (dt);
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
146 }
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
147 } else if (tp == "int") {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
148 if (id == "x") {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
149 x = parseTo!(int) (dt);
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
150 } else if (id == "y") {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
151 y = parseTo!(int) (dt);
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
152 }
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
153 }
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
154 }
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
155 void writeAll (ItemDelg dlg) {
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
156 }
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
157 //END Mergetag code
0aa621b3e070 Some GUI work, plus a small fix in the paths module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
158 }