From 828588ccb0e7f203c53b1abad1d70f77d3185a81 Mon Sep 17 00:00:00 2001
From: Alex Xu <alex_y_xu@yahoo.ca>
Date: Mon, 1 Jul 2013 10:26:53 -0400
Subject: add nvl

---
 TODO              |   5 +--
 www/css/index.css |  16 ++++++++-
 www/index.html    |   4 +++
 www/js/api.js     | 106 +++++++++++++++++++++++++++++++++++++-----------------
 www/js/html5ks.js |   5 ++-
 5 files changed, 100 insertions(+), 36 deletions(-)

diff --git a/TODO b/TODO
index c7c2657..124d37a 100644
--- a/TODO
+++ b/TODO
@@ -1,11 +1,12 @@
 todo ordered by most to least important... ish
-all of this should be completed for a 1.0 release
+all of this should (read: must) be completed for a 1.0 release
 
-- nvl
 - menu
 - show command
 - redo images.js using json including ALL transitions
 - transitions. ALL THE TRANSITIONS
+- text reveal
+- wallodrugs
 - fix cursor to apply to all document
 - cache script.json files
 - organize the CSS into a reasonable order
diff --git a/www/css/index.css b/www/css/index.css
index e5a5c19..85125be 100644
--- a/www/css/index.css
+++ b/www/css/index.css
@@ -35,6 +35,8 @@ body {
 #container {
   width: 800px;
   height: 600px;
+  left: 50%;
+  top: 50%;
   margin-top: -300px;
   margin-left: -400px;
 }
@@ -141,7 +143,7 @@ input[type="checkbox"] + span:before {
 input[type="checkbox"]:checked + span:before {
   background: url("../dump/ui/bt-cf-checked.png") no-repeat left bottom;
 }
-#ctc {
+#ctc, #nvlctc {
   position: absolute;
   bottom: 20px;
   right: 10px;
@@ -149,3 +151,15 @@ input[type="checkbox"]:checked + span:before {
   -moz-animation: blink 2s infinite;
   animation: blink 2s infinite;
 }
+#nvl {
+  position: absolute;
+  top: 0;
+  left: 0;
+  width: 100%;
+  height: 100%;
+  background: url("../dump/ui/bg-nvl.png") no-repeat top left;
+}
+#nvlsay {
+  padding: 25px 35px;
+  color: white;
+}
diff --git a/www/index.html b/www/index.html
index b01fea4..ff38ee2 100644
--- a/www/index.html
+++ b/www/index.html
@@ -51,6 +51,10 @@
         <div id="say"></div>
         <img id="ctc" src="dump/ui/ctc.png" style="display: none">
       </div>
+      <div id="nvl" style="display: none;">
+        <div id="nvlsay"></div>
+        <img id="nvlctc" src="dump/ui/ctc_rotated.png">
+      </div>
       <div id="main-menu" style="display: none;">
         <div id="main-menu-buttons" style="top: 377px; position: absolute; left: 81px;">
           <div id="start" class="button button-enabled">Start</div>
diff --git a/www/js/api.js b/www/js/api.js
index 1aec74d..34a34d9 100644
--- a/www/js/api.js
+++ b/www/js/api.js
@@ -225,7 +225,8 @@ window.html5ks.api = {
       /{\/color}/g, "</span>",
       /{w(=\d*\.\d*)?}.*/, "",
       /{nw}/, "",
-      /{fast}/, ""
+      /{fast}/, "",
+      /\n/g, "<br>"
     ];
     for (var i = 0; i < tags.length - 1; i += 2) {
       str = str.replace(tags[i], tags[i+1]);
@@ -233,6 +234,19 @@ window.html5ks.api = {
     return str;
   },
 
+  nvlsay: function (text) {
+    var deferred = when.defer();
+    html5ks.elements.nvlsay.innerHTML += text + "<br>";
+    html5ks.elements.nvlctc.style.display = "block";
+    html5ks.next = function () {
+      html5ks.elements.nvlctc.style.display = "none";
+      deferred.resolve();
+      html5ks.next = function () {};
+    };
+    return deferred.promise;
+  },
+
+
   character: function (name, str, extend) {
     var deferred = when.defer(),
         text = this.tag(str),
@@ -248,46 +262,52 @@ window.html5ks.api = {
     if ((!w || !w[1] || extend) && char.what_suffix) {
       text = text + char.what_suffix;
     }
-    var who = html5ks.elements.who;
-    if (!extend) {
-      who.innerHTML = char.name;
-      if (char.color) {
-        who.style.color = char.color;
-      } else {
-        who.style.color = "#ffffff";
-      }
-    }
 
-    if (extend) {
-      html5ks.elements.say.innerHTML += text;
+    if (char.kind === "nvl") {
+      this.nvlsay(text).then(function () {
+        deferred.resolve();
+      });
     } else {
-      html5ks.elements.say.innerHTML = text;
-    }
+      var who = html5ks.elements.who;
+      if (!extend) {
+        who.innerHTML = char.name;
+        if (char.color) {
+          who.style.color = char.color;
+        } else {
+          who.style.color = "#ffffff";
+        }
+      }
 
-    if (w) {
-      html5ks.next = function () {
-        html5ks.next = function () {};
-        html5ks.api.extend(str.substring(w.index + w[0].length)).then(function () {
-          deferred.resolve();
-        });
-      };
-      if (w[1]) {
-        setTimeout(html5ks.next, parseFloat(w[1].substring(1), 10) * 1000);
-        return deferred.promise;
+      if (extend) {
+        html5ks.elements.say.innerHTML += text;
+      } else {
+        html5ks.elements.say.innerHTML = text;
       }
-    } else {
-      html5ks.next = function () {
-        html5ks.elements.ctc.style.display = "none";
-        deferred.resolve(text);
-        html5ks.next = function () {};
-      };
+
+      if (w) {
+        html5ks.next = function () {
+          html5ks.next = function () {};
+          html5ks.api.extend(str.substring(w.index + w[0].length)).then(function () {
+            deferred.resolve();
+          });
+        };
+        if (w[1]) {
+          setTimeout(html5ks.next, parseFloat(w[1].substring(1), 10) * 1000);
+          return deferred.promise;
+        }
+      } else {
+        html5ks.next = function () {
+          html5ks.elements.ctc.style.display = "none";
+          deferred.resolve(text);
+          html5ks.next = function () {};
+        };
+      }
+      html5ks.elements.ctc.style.display = "block";
     }
     if (html5ks.state.skip || str.indexOf("{nw}") > -1) {
       html5ks.next();
     } else if (html5ks.state.auto) {
       setTimeout(html5ks.next, 1000 + html5ks.persistent.settings.autospeed * text.length);
-    } else {
-      html5ks.elements.ctc.style.display = "block";
     }
     return deferred.promise;
   },
@@ -302,5 +322,27 @@ window.html5ks.api = {
       deferred.resolve();
     }, duration * 1000);
     return deferred.promise;
+  },
+
+  nvl: function (action, transition) {
+    var deferred = when.defer(),
+        nvl = html5ks.elements.nvl;
+    switch (action) {
+      case "show":
+        nvl.style.display = "block";
+        deferred.resolve();
+        break;
+      case "hide":
+        nvl.style.display = "none";
+        deferred.resolve();
+        break;
+      case "clear":
+        html5ks.elements.nvlsay.innerHTML = "";
+        deferred.resolve();
+        break;
+      default:
+        console.error("no such nvl action " + action);
+    }
+    return deferred.promise;
   }
 };
diff --git a/www/js/html5ks.js b/www/js/html5ks.js
index 653b407..86278f0 100644
--- a/www/js/html5ks.js
+++ b/www/js/html5ks.js
@@ -40,7 +40,10 @@ window.html5ks = {
       say: document.getElementById("say"),
       bg: document.getElementById("bg"),
       window: document.getElementById("window"),
-      ctc: document.getElementById("ctc")
+      ctc: document.getElementById("ctc"),
+      nvl: document.getElementById("nvl"),
+      nvlsay: document.getElementById("nvlsay"),
+      nvlctc: document.getElementById("nvlctc")
     };
     this.elements.audio.music.loop = true;
     this.elements.audio.ambient.loop = true;
-- 
cgit v1.2.3-70-g09d2