diff options
author | Alex Xu <alex_y_xu@yahoo.ca> | 2013-06-29 13:20:49 -0400 |
---|---|---|
committer | Alex Xu <alex_y_xu@yahoo.ca> | 2013-06-29 13:20:49 -0400 |
commit | 182fb2db03e5c4bfd1ca42e9d32aa162abad6e68 (patch) | |
tree | 10bc2f9e15ead2768cbb8bd8e1805b61b0fb2ecb /www/js | |
parent | fcf62890c9abb994fd2534a44de66def114575da (diff) | |
download | html5ks-182fb2db03e5c4bfd1ca42e9d32aa162abad6e68.tar.xz html5ks-182fb2db03e5c4bfd1ca42e9d32aa162abad6e68.zip |
do stuff
Diffstat (limited to 'www/js')
-rw-r--r-- | www/js/api.js | 53 | ||||
-rw-r--r-- | www/js/imachine.js | 66 | ||||
-rw-r--r-- | www/js/menu.js | 2 |
3 files changed, 95 insertions, 26 deletions
diff --git a/www/js/api.js b/www/js/api.js index 41139f9..128cd9c 100644 --- a/www/js/api.js +++ b/www/js/api.js @@ -54,6 +54,7 @@ window.html5ks.api = { deferred.resolve(); return deferred.promise; }, + movie_cutscene: function (vid_src) { var deferred = when.defer(), video = html5ks.elements.video, @@ -106,6 +107,30 @@ window.html5ks.api = { return deferred.promise; }, + with: function (transition, action) { + return this.runInst(action); + }, + + runInst: function (inst) { + var cmd = inst[0], + args = inst.slice(1); + if (html5ks.data.characters[cmd]) { + return this.character(cmd, args); + } else { + if (this[cmd]) { + return this[cmd].apply(this, args); + } else if (/^[A-Z]/.test(cmd)) { + console.log("cmd starts with caps, probably character"); + return this.character(cmd, args); + } else { + console.error("no such cmd " + cmd); + var deferred = when.defer(); + deferred.resolve(); + return deferred.promise; + } + } + }, + window: function (action, transition) { var windw = html5ks.elements.window, deferred = when.defer(); @@ -169,30 +194,6 @@ window.html5ks.api = { return deferred.promise; }, - with: function (transition, action) { - return this.runInst(action); - }, - - runInst: function (inst) { - var cmd = inst[0], - args = inst.slice(1); - if (html5ks.data.characters[cmd]) { - return this.character(cmd, args); - } else { - if (this[cmd]) { - return this[cmd].apply(this, args); - } else if (/^[A-Z]/.test(cmd)) { - console.log("cmd starts with caps, probably character"); - return this.character(cmd, args); - } else { - console.error("no such cmd " + cmd); - var deferred = when.defer(); - deferred.resolve(); - return deferred.promise; - } - } - }, - character: function (name, str) { var deferred = when.defer(), text = str, @@ -218,7 +219,9 @@ window.html5ks.api = { deferred.resolve(text); html5ks.next = function () {}; }; - if (html5ks.state.auto) { + if (html5ks.state.skip) { + html5ks.next(); + } else if (html5ks.state.auto) { setTimeout(html5ks.next, 1000 + html5ks.persistent.settings.autospeed * text.length); } return deferred.promise; diff --git a/www/js/imachine.js b/www/js/imachine.js new file mode 100644 index 0000000..fd657ef --- /dev/null +++ b/www/js/imachine.js @@ -0,0 +1,66 @@ +html5ks.imachine = (function () { + "use strict"; + return { + start: function () { + return this.run("imachine"); + }, + run: function (label) { + var deferred = when.defer(), + ilabel = html5ks.data.imachine[label], + i = 0, + runInst = function () { + var inst = ilabel[i++]; + console.log(inst); + switch (typeof inst) { + case "undefined": + break; + case "string": // jump_out + this.run(inst); + break; + case "object": + switch (inst[0]) { + case "iscene": + case "act_op": + switch (inst[1]) { + case "op_vid1": + html5ks.api.movie_cutscene("op_1").then(runInst); + break; + default: + html5ks.api[inst[0]](inst[1]).then(runInst); + } + break; + case "seen_scene": + if (this.seen_scene(inst[1])) { + runInst(inst[2]); + } else { + runInst(inst[3]); + } + break; + case "attraction_sc": + case "attraction_hanako": + case "attraction_kenji": + if (typeof inst[1] === "number") { + if (html5ks.persistent.store[inst[0]] > inst[1]) { + runInst(inst[3]); + } else { + runInst(inst[4]); + } + } else { + html5ks.persistent.store[inst[0]]++; + } + break; + case "path_end": + // TODO: disp vid + deferred.resolve(); + break; + default: + console.error("unknown imachine inst"); + console.error(inst); + } + } + }.bind(this); + runInst(); + return deferred.promise; + } + }; +}()); diff --git a/www/js/menu.js b/www/js/menu.js index 573dd8d..589ae41 100644 --- a/www/js/menu.js +++ b/www/js/menu.js @@ -38,7 +38,7 @@ this.elements.main.start.addEventListener("click", function () { if (this._imachine_loaded) { this.elements.mainMenu.style.display = "none"; - html5ks.api.iscene("en_NOP1").then(this.mainMenu.bind(this)); + html5ks.imachine.start().then(this.mainMenu.bind(this)); } }.bind(this), false); this.elements.main.optionsButton.addEventListener("click", function () { |