summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorAlex Xu <alex_y_xu@yahoo.ca>2013-08-15 13:00:51 -0400
committerAlex Xu <alex_y_xu@yahoo.ca>2013-08-15 13:00:51 -0400
commit4acddaff97ce6afb28086f4ce93afffceebd4f53 (patch)
tree543ab1c132e7606d50f422dc516d93cc19409f16 /www
parent50ce0d77bc041a0d0a60f0dd50de79815088069a (diff)
downloadhtml5ks-4acddaff97ce6afb28086f4ce93afffceebd4f53.tar.xz
html5ks-4acddaff97ce6afb28086f4ce93afffceebd4f53.zip
imachine.json
Diffstat (limited to 'www')
-rw-r--r--www/css/index.css10
-rw-r--r--www/index.html2
-rw-r--r--www/js/api.js9
-rw-r--r--www/js/imachine.js80
4 files changed, 66 insertions, 35 deletions
diff --git a/www/css/index.css b/www/css/index.css
index 8b59a6b..775bfc6 100644
--- a/www/css/index.css
+++ b/www/css/index.css
@@ -159,11 +159,15 @@ html.no-js #gotit {
}
#centered {
text-align: center;
- width: 100%;
+ top: 0;
+ bottom: 0;
+ left: 0;
+ height: 0;
}
.centered {
position: absolute;
margin: auto;
+ width: 100%;
left: 50%;
top: 50%;
}
@@ -173,7 +177,11 @@ html.no-js #gotit {
right: 10px;
display: none;
}
+#choices {
+ left: 0;
+}
.choice {
+ text-align: center;
background: url("../dump/ui/bg-choice.png") no-repeat top center;
height: 35px;
line-height: 30px;
diff --git a/www/index.html b/www/index.html
index 595bcbb..4c4f7fb 100644
--- a/www/index.html
+++ b/www/index.html
@@ -53,7 +53,7 @@
<img id="nvlctc" src="dump/ui/ctc_rotated.png">
</div>
<div id="choices" class="centered"></div>
- <div id="centered" class="say"></div>
+ <div id="centered" class="centered say"></div>
<img class="status" id="auto" src="dump/ui/sd-auto.png">
<img class="status" id="skip" src="dump/ui/sd-skip.png">
<div id="main-menu" style="display: none;">
diff --git a/www/js/api.js b/www/js/api.js
index d05611e..25e2f4f 100644
--- a/www/js/api.js
+++ b/www/js/api.js
@@ -220,6 +220,10 @@ window.html5ks.api = {
}
el.style.display = "block";
}
+ deferred.resolve();
+ };
+ el.onerror = function () {
+ deferred.resolve();
};
var nom = name;
if (type && type !== "None") {
@@ -266,7 +270,6 @@ window.html5ks.api = {
el.style.display = "none";
html5ks.elements.show.appendChild(el);
}
- deferred.resolve();
return deferred.promise;
},
hide: function (name) {
@@ -365,7 +368,9 @@ window.html5ks.api = {
});
};
if (w[1]) {
- setTimeout(html5ks.next, parseFloat(w[1], 10) * 1000);
+ setTimeout(function () {
+ html5ks.next();
+ }, parseFloat(w[1], 10) * 1000);
return deferred.promise;
}
} else {
diff --git a/www/js/imachine.js b/www/js/imachine.js
index 16d406f..5e21ac6 100644
--- a/www/js/imachine.js
+++ b/www/js/imachine.js
@@ -12,25 +12,28 @@ html5ks.imachine = (function () {
},
run: function (label) {
var deferred = when.defer(),
- ilabel = typeof label === "string" ? html5ks.data.imachine[label] || label : label,
+ ilabel = typeof label === "string" ? html5ks.data.imachine[label] : label,
i = 0,
runInst = function () {
var inst = ilabel[i++];
- console.log(inst);
switch (typeof inst) {
case "undefined":
deferred.resolve();
break;
- case "string": // jump_out
- if (!html5ks.data.imachine[inst]) {
- throw new Error("label does not exist");
- }
- this.run(inst);
- break;
case "object":
var cmd = inst[0];
var args = inst.slice(1);
switch (inst[0]) {
+ case "jump_out":
+ var newlabel = args[0];
+ if (newlabel === "restart") {
+ html5ks.menu.mainMenu();
+ } else if (!html5ks.data.imachine[newlabel]) {
+ throw new Error("label does not exist");
+ } else {
+ this.run(newlabel);
+ }
+ break;
case "iscene":
this.scene_register(inst[1]);
case "act_op":
@@ -44,34 +47,49 @@ html5ks.imachine = (function () {
break;
case "imenu":
html5ks.api.iscene(args[0]).then(function (choice) {
- var next = args[1][choice] || args[1].else;
- return html5ks.imachine.run(typeof next[0] === "string" ? [next] : next).then(runInst);
- });
- break;
- case "seen_scene":
- var next;
- if (this.seen_scene(inst[1])) {
- next = inst[2];
- } else {
- next = inst[3];
- }
- // TODO: there's probably an easier way to do this
- this.run(typeof next[0] === "string" ? [next] : next).then(runInst);
+ this._return = choice;
+ runInst();
+ }.bind(this));
break;
- case "attraction":
- if (typeof inst[2] === "number") {
- if (html5ks.store.attraction[inst[1]] > inst[2]) {
- runInst(inst[3]);
- } else {
- runInst(inst[4]);
+ case "if":
+ var cpy = inst.slice(0),
+ type = '';
+ el: while (type = cpy.shift()) {
+ switch (type) {
+ case "if":
+ case "elif":
+ var cond = cpy.shift(),
+ next = cpy.shift();
+ switch (cond[0]) {
+ case "_return":
+ if (this._return == cond[1]) {
+ break el;
+ }
+ break;
+ case "seen_scene":
+ if (this.seen_scene(cond[1])) {
+ break el;
+ }
+ break;
+ case "attraction_sc":
+ case "attraction_hanako":
+ case "attraction_kenji":
+ if (html5ks.store.attraction[cond[0]] > cond[1]) {
+ break el;
+ }
+ default:
+ throw new Error("unhandled if statement");
+ }
+ break;
+ case "else":
+ next = cpy.shift();
+ break el;
}
- } else {
- html5ks.store.attraction[inst[1]]++;
- runInst();
}
+ return html5ks.imachine.run(next).then(runInst);
break;
case "path_end":
- // TODO: disp vid
+ // TODO: disp vid + add to persistent
deferred.resolve();
break;
default: