comparison mde/gui/WMScreen.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 9cff74f68b84
comparison
equal deleted inserted replaced
127:3328c6fb77ca 128:41582439a42b
24 import mde.gui.WidgetManager; 24 import mde.gui.WidgetManager;
25 import mde.gui.widget.Ifaces; 25 import mde.gui.widget.Ifaces;
26 import mde.gui.renderer.createRenderer; 26 import mde.gui.renderer.createRenderer;
27 27
28 import mde.setup.Screen; 28 import mde.setup.Screen;
29 import Items = mde.content.Items; // loadTranslation
30 import mde.lookup.Options; // miscOpts.L10n callback
31 29
32 import tango.util.log.Log : Log, Logger; 30 import tango.util.log.Log : Log, Logger;
33 31
34 private Logger logger; 32 private Logger logger;
35 static this () { 33 static this () {
48 * Aside from the IWidgetManager methods, this class should be thread-safe. 46 * Aside from the IWidgetManager methods, this class should be thread-safe.
49 *************************************************************************************************/ 47 *************************************************************************************************/
50 scope class WMScreen : AWidgetManager, Screen.IDrawable { 48 scope class WMScreen : AWidgetManager, Screen.IDrawable {
51 /** Construct a new widget manager. 49 /** Construct a new widget manager.
52 * 50 *
51 * Must be run after static this.
52 *
53 * params: 53 * params:
54 * fileName = Name of file specifying the gui, excluding path and extension. 54 * fileName = Name of file specifying the gui, excluding path and extension.
55 */ 55 */
56 this (char[] file) { 56 this (char[] file) {
57 // Doesn't need a lock - cannot conflict with other class functions.
57 super(file); 58 super(file);
58 59
59 Screen.addDrawable (this); 60 Screen.addDrawable (this);
60 clickCallbacks = new typeof(clickCallbacks);
61 motionCallbacks = new typeof(motionCallbacks);
62 }
63
64 // this() runs during static this(), when imde.input doesn't exist. init() runs later.
65 void init () {
66 // Doesn't need a lock - cannot conflict with other class functions.
67 // Events we want to know about: 61 // Events we want to know about:
68 imde.input.addMouseClickCallback(&clickEvent); 62 imde.input.addMouseClickCallback(&clickEvent);
69 imde.input.addMouseMotionCallback(&motionEvent); 63 imde.input.addMouseMotionCallback(&motionEvent);
70 64 }
71 Items.loadTranslation ();
72 miscOpts.L10n.addCallback (&reloadStrings);
73 }
74
75 65
76 /** Draw the gui. */ 66 /** Draw the gui. */
77 void draw() { 67 void draw() {
78 synchronized(mutex) { 68 synchronized(mutex) {
79 if (child) 69 if (child)