summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--www/index.html1
-rw-r--r--www/js/api.js53
-rw-r--r--www/js/imachine.js66
-rw-r--r--www/js/menu.js2
5 files changed, 98 insertions, 28 deletions
diff --git a/.gitignore b/.gitignore
index ce5fbff..708f42e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,3 @@
# ignore 'copyrighted' contents similar to emulators
-/www/dump
-/rpy
+/www/dump/*
+/rpy/*
diff --git a/www/index.html b/www/index.html
index 4c054b9..19b109c 100644
--- a/www/index.html
+++ b/www/index.html
@@ -23,6 +23,7 @@
<script src="js/play.js"></script>
<script src="js/images.js"></script>
<script src="js/characters.js"></script>
+ <script src="js/imachine.js"></script>
</head>
<body><div id="all" style="height: 100%; position: absolute; width: 100%;">
<div id="warn-container">
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 () {