diff mde/content/Content.d @ 110:6acd96f8685f

Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui. Gave AContent support for multiple callbacks. New locale: "en".
author Diggory Hardy <diggory.hardy@gmail.com>
date Fri, 05 Dec 2008 11:29:39 +0000
parents 08651e8a8c51
children fe061009029d
line wrap: on
line diff
--- a/mde/content/Content.d	Thu Dec 04 10:32:20 2008 +0000
+++ b/mde/content/Content.d	Fri Dec 05 11:29:39 2008 +0000
@@ -17,6 +17,8 @@
  */
 module mde.content.Content;
 
+import util = mde.util;
+
 debug {
     import tango.util.log.Log : Log, Logger;
     private Logger logger;
@@ -68,9 +70,14 @@
 	desc_ = d;
     }
     
-    /// Current implementation has 1 callback; can be changed to allow many.
+    /** Add a callback. Callbacks are called in the order added. */
     EventContent addCallback (void delegate (AContent) cb) {
-	this.cb = cb;
+	this.cb ~= cb;
+	return this;
+    }
+    /// ditto
+    EventContent addCallback (void function (AContent) cb) {
+	this.cb ~= util.toDg (cb);
 	return this;
     }
     
@@ -83,17 +90,16 @@
     
     /// End of an event, e.g. a button release or end of an edit (calls callbacks).
     void endEvent () {
-	if (cb)
-	    cb (this);
+	foreach (dg; cb)
+	    dg (this);
     }
     
     final char[] symbol;	// Symbol name for this content
 protected:
     char[] name_, desc_;	// name and description
-    void delegate (AContent) cb;
+    void delegate (AContent) cb[];
 }
 
-// FIXME: needs changes to allow updating translated strings. Move to Content and extend AContent?
 /** A generic way to handle a list of type IContent. */
 class ContentList : AContent
 {