changeset 84:0f6cf96a6aee

Implemented wimp-out instruction, which is invoked often in Galatea.
author Atul Varma <varmaa@toolness.com>
date Wed, 21 May 2008 15:20:01 -0700
parents e813e427fbe6
children 7ddacb62f0e5
files engine-runner.js web-zui.js
diffstat 2 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/engine-runner.js	Wed May 21 15:08:52 2008 -0700
+++ b/engine-runner.js	Wed May 21 15:20:01 2008 -0700
@@ -21,7 +21,7 @@
   },
   onQuit: function() {
   },
-  onRestart: function(callback) {
+  onRestart: function() {
   },
   onWimpOut: function(callback) {
   },
@@ -131,6 +131,15 @@
       }
     },
 
+    _unWimpOut: function() {
+      self._isWaitingForCallback = false;
+      if (!self._isInLoop) {
+        self._continueRunning();
+      } else {
+        /* We're still inside _loop(), so just return. */
+      }
+    },
+
     _loop: function() {
       if (self._isInLoop)
         throw new Error("Already in loop!");
@@ -191,6 +200,9 @@
         self._zui.onRestart();
         break;
       case GNUSTO_EFFECT_WIMP_OUT:
+        self._isWaitingForCallback = true;
+        self._zui.onWimpOut(self._unWimpOut);
+        break;
       case GNUSTO_EFFECT_BREAKPOINT:
       case GNUSTO_EFFECT_FLAGS_CHANGED:
       case GNUSTO_EFFECT_PIRACY:
--- a/web-zui.js	Wed May 21 15:08:52 2008 -0700
+++ b/web-zui.js	Wed May 21 15:20:01 2008 -0700
@@ -223,6 +223,10 @@
       window.setTimeout(_webZuiStartup, 0);
     },
 
+    onWimpOut: function(callback) {
+      window.setTimeout(callback, 100);
+    },
+
     onSetStyle: function(textStyle, foreground, background) {
       switch (textStyle) {
       case 0: