From 7d93ca6b9b7c899ff4f6d3173d8fc4ca551ebf30 Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Sat, 13 Jul 2013 13:28:16 -0400 Subject: Fix imachine imenu, seen_scenes: runInst after fork --- www/js/api.js | 14 ++++++++------ www/js/imachine.js | 10 +++++++--- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'www') diff --git a/www/js/api.js b/www/js/api.js index 4aebde1..5b494ab 100644 --- a/www/js/api.js +++ b/www/js/api.js @@ -30,7 +30,6 @@ window.html5ks.api = { return deferred.promise; }, play: function (channel, name, fade) { - // TODO: fade var deferred = when.defer(), audio = html5ks.elements.audio[channel]; audio.src = "dump/" + (channel === "music" ? "bgm/" + html5ks.data.music[name] + ".ogg" : html5ks.data.sfx[name]); @@ -202,11 +201,14 @@ window.html5ks.api = { bgright: { xpos: 0.6, xanchor: 0.5, ypos: 1.0, yanchor: 1.0 } }; var pos = positions[location]; - el.style.left = pos.xpos * 800 + "px"; - el.style.top = pos.ypos * 600 + "px"; - el.style.marginLeft = "-" + pos.xanchor * el.width + "px"; - el.style.marginTop = "-" + pos.yanchor * el.height + "px"; - el.style.display = "block"; + // TODO: implement transitions + if (pos) { + el.style.left = pos.xpos * 800 + "px"; + el.style.top = pos.ypos * 600 + "px"; + el.style.marginLeft = "-" + pos.xanchor * el.width + "px"; + el.style.marginTop = "-" + pos.yanchor * el.height + "px"; + el.style.display = "block"; + } } deferred.resolve(); }; diff --git a/www/js/imachine.js b/www/js/imachine.js index a256019..b6117f7 100644 --- a/www/js/imachine.js +++ b/www/js/imachine.js @@ -19,6 +19,7 @@ html5ks.imachine = (function () { console.log(inst); switch (typeof inst) { case "undefined": + deferred.resolve(); break; case "string": // jump_out if (!html5ks.data.imachine[inst]) { @@ -44,15 +45,18 @@ html5ks.imachine = (function () { case "imenu": html5ks.api.menu(args[0]).then(function (choice) { var next = args[1][choice] || args[1].else; - html5ks.imachine.run(typeof next[0] === "string" ? [next] : next); + return html5ks.imachine.run(typeof next[0] === "string" ? [next] : next).then(runInst); }); break; case "seen_scene": + var next; if (this.seen_scene(inst[1])) { - this.run(inst[2]); + next = inst[2]; } else { - this.run(inst[3]); + next = inst[3]; } + // TODO: there's probably an easier way to do this + this.run(typeof next[0] === "string" ? [next] : next).then(runInst); break; case "attraction": if (typeof inst[2] === "number") { -- cgit v1.2.3-70-g09d2