diff mde/input/input.d @ 31:baa87e68d7dc

GUI now supports basic interactible widgets, widget colour and border are more unified, and some code cleanup. Removed some circular dependencies which slipped in. As a result, the OpenGL code got separated into different files. Enabled widgets to recieve events. New IParentWidget interface allowing widgets to interact with their parents. New Widget base class. New WidgetDecoration class. New ButtonWidget class responding to events (in a basic way). committer: Diggory Hardy <diggory.hardy@gmail.com>
author Diggory Hardy <diggory.hardy@gmail.com>
date Tue, 29 Apr 2008 18:10:58 +0100
parents 611f7b9063c6
children
line wrap: on
line diff
--- a/mde/input/input.d	Mon Apr 28 10:59:47 2008 +0100
+++ b/mde/input/input.d	Tue Apr 29 18:10:58 2008 +0100
@@ -148,17 +148,21 @@
         *
         * Mouse events don't need config for the GUI. Handle them first so that if no config exists
         * some functionality at least is retained.
+        *
+        * Note that the mouse coordinates as reported by SDL put the top-left most pixel at 1,1.
+        * Internal coordinates put that pixel at 0,0 (see gui/GUI notes.txt).
         */
         switch (event.type) {
             case SDL_MOUSEBUTTONDOWN:
             case SDL_MOUSEBUTTONUP:
                 foreach (dg; mouseClickCallbacks)
-                    dg (event.button.x, event.button.y, event.button.button, event.button.state == SDL_PRESSED);
+                    dg (event.button.x - 1, event.button.y - 1,
+                        event.button.button, event.button.state == SDL_PRESSED);
                 break;
             
             case SDL_MOUSEMOTION:
-                mouse_x = event.motion.x;
-                mouse_y = event.motion.y;
+                mouse_x = event.motion.x - 1;
+                mouse_y = event.motion.y - 1;
                 break;
             
             default:
@@ -292,17 +296,17 @@
     
     /** Loads all configs, activating the requested id.
     *
-    * Returns: true if the requested config id wasn't found.
+    * Throws: ConfigLoadException if unable to load any configs or the requested config id wasn't
+    *   found.
     */
-    bool loadConfig (char[] profile = "Default") {
+    void loadConfig (char[] profile = "Default") {
         Config.load("input");	// FIXME: filename
         Config* c_p = profile in Config.configs;
-        if (c_p) {
-            config = *c_p;
-            return false;
+        if (c_p) config = *c_p;
+        else {
+            throw new ConfigLoadException;
+            logger.error ("Config profile \""~profile~"\" not found: input won't work unless a valid profile is loaded!");
         }
-        logger.error ("Config profile \""~profile~"\" not found: input won't work unless a valid profile is loaded!");
-        return true;
     }
     
 private: