summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorAlex Xu <alex_y_xu@yahoo.ca>2013-07-03 20:11:40 -0400
committerAlex Xu <alex_y_xu@yahoo.ca>2013-07-03 20:11:40 -0400
commit0e14fea8ebc1730d6937bcc46354188a0a14f87c (patch)
treed0554411cd49438b0fab77cbf29a1b2a6de27186 /www
parent77524b907b0737d97094f8530ff29578ae396414 (diff)
downloadhtml5ks-0e14fea8ebc1730d6937bcc46354188a0a14f87c.tar.xz
html5ks-0e14fea8ebc1730d6937bcc46354188a0a14f87c.zip
implement menu... sorta (doesn't work properly)
Diffstat (limited to 'www')
-rw-r--r--www/css/index.css6
-rw-r--r--www/index.html4
-rw-r--r--www/js/api.js86
-rw-r--r--www/js/html5ks.js15
-rw-r--r--www/js/imachine.js18
5 files changed, 72 insertions, 57 deletions
diff --git a/www/css/index.css b/www/css/index.css
index 4a1dbf5..baa349e 100644
--- a/www/css/index.css
+++ b/www/css/index.css
@@ -171,7 +171,7 @@ input[type="checkbox"]:checked + span:before {
display: block;
margin: 10px 8px;
}
-#centered {
+.centered {
width: 100%;
text-align: center;
position: absolute;
@@ -180,3 +180,7 @@ input[type="checkbox"]:checked + span:before {
height: 0;
margin: auto;
}
+.choice {
+ background: url("../dump/ui/bg-choice.png") no-repeat top center;
+ height: 35px;
+}
diff --git a/www/index.html b/www/index.html
index abf4855..c019183 100644
--- a/www/index.html
+++ b/www/index.html
@@ -55,8 +55,8 @@
<div id="nvlsay" class="say"></div>
<img id="nvlctc" src="dump/ui/ctc_rotated.png">
</div>
- <div id="choices"></div>
- <div id="centered" class="say"></div>
+ <div id="choices" class="centered"></div>
+ <div id="centered" class="centered say"></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 957bcf0..db09207 100644
--- a/www/js/api.js
+++ b/www/js/api.js
@@ -110,12 +110,12 @@ window.html5ks.api = {
var deferred = when.defer(),
label = html5ks.data.script[target],
i = 0;
- (function run() {
+ (function run(ret) {
if (label[i]) {
html5ks.api.runInst(label[i]).then(run, console.error);
i++;
} else {
- deferred.resolve();
+ deferred.resolve(ret);
}
}());
return deferred.promise;
@@ -244,7 +244,7 @@ window.html5ks.api = {
},
- character: function (name, str, extend) {
+ character: function (name, str, extend, noc) {
var deferred = when.defer(),
text = this.tag(str),
char = html5ks.data.characters[name],
@@ -264,23 +264,25 @@ window.html5ks.api = {
this.nvlsay(text).then(function () {
deferred.resolve();
});
- } else {
- 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;
+ return deferred.promise;
+ }
+ var who = html5ks.elements.who;
+ if (!extend) {
+ who.innerHTML = char.name;
+ if (char.color) {
+ who.style.color = char.color;
} else {
- html5ks.elements.say.innerHTML = text;
+ who.style.color = "#ffffff";
}
+ }
+ if (extend) {
+ html5ks.elements.say.innerHTML += text;
+ } else {
+ html5ks.elements.say.innerHTML = text;
+ }
+
+ if (!noc) {
if (w) {
html5ks.next = function () {
html5ks.next = function () {};
@@ -300,11 +302,11 @@ window.html5ks.api = {
};
}
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);
+ 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);
+ }
}
return deferred.promise;
},
@@ -354,26 +356,30 @@ window.html5ks.api = {
return deferred.promise;
},
- menu: function (char, str, choices) {
- var deferred = when.defer();
- this.character(char, str).then(function () {
- var menu = html5ks.elements.choices,
- frag = document.createDocumentFragment(),
- choice = document.createElement("div");
+ menu: function (label) {
+ var deferred = when.defer(),
+ menu = html5ks.data.script[label],
+ char = menu[1],
+ str = menu[2],
+ choices = menu[3];
+ this.character(char, str, null, true);
+ var menu = html5ks.elements.choices,
+ frag = document.createDocumentFragment(),
+ choice = document.createElement("div");
- choice.className = "choice";
+ choice.className = "choice button button-enabled";
- for (var i in choices) {
- choice.innerHTML = i;
- choice.addEventListener("click", function () {
- deferred.resolve(choices[i]);
- }, false);
- frag.appendChild(choice);
- choice = choice.cloneNode(false);
- }
+ for (var i in choices) {
+ choice.innerHTML = i;
+ choice.addEventListener("click", function () {
+ html5ks.elements.choices.innerHTML = "";
+ deferred.resolve(choices[i]);
+ }, false);
+ frag.appendChild(choice);
+ choice = choice.cloneNode(false);
+ }
- html5ks.elements.choices.innerHTML = "";
- html5ks.elements.choices.appendChild(frag);
- });
+ html5ks.elements.choices.appendChild(frag);
+ return deferred.promise;
}
};
diff --git a/www/js/html5ks.js b/www/js/html5ks.js
index d76f2a0..8de3c8d 100644
--- a/www/js/html5ks.js
+++ b/www/js/html5ks.js
@@ -5,11 +5,6 @@ window.html5ks = {
},
persistent: {
seen_scenes: {},
- attraction: {
- kenji: 0,
- sc: 0,
- hanako: 0
- },
settings: {
fade: 100,
gotit: false,
@@ -26,7 +21,12 @@ window.html5ks = {
}
},
store: {
- seen_scenes: {}
+ seen_scenes: {},
+ attraction: {
+ kenji: 0,
+ sc: 0,
+ hanako: 0
+ },
},
state: {},
initElements: function () {
@@ -45,7 +45,8 @@ window.html5ks = {
ctc: document.getElementById("ctc"),
nvl: document.getElementById("nvl"),
nvlsay: document.getElementById("nvlsay"),
- nvlctc: document.getElementById("nvlctc")
+ nvlctc: document.getElementById("nvlctc"),
+ choices: document.getElementById("choices")
};
this.elements.audio.music.loop = true;
this.elements.audio.ambient.loop = true;
diff --git a/www/js/imachine.js b/www/js/imachine.js
index 8c2f86d..adad442 100644
--- a/www/js/imachine.js
+++ b/www/js/imachine.js
@@ -35,9 +35,14 @@ html5ks.imachine = (function () {
html5ks.api.movie_cutscene("op_1").then(runInst);
break;
default:
- html5ks.api[cmd].apply(html5ks.api, args).then(runInst);
+ html5ks.api[cmd].apply(html5ks.api, args).then(function () { runInst(); });
}
break;
+ case "imenu":
+ html5ks.api.menu(args[0]).then(function (choice) {
+ html5ks.imachine.run(args[1][choice] || args[1].else);
+ });
+ break;
case "seen_scene":
if (this.seen_scene(inst[1])) {
this.run(inst[2]);
@@ -45,17 +50,16 @@ html5ks.imachine = (function () {
this.run(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]) {
+ case "attraction":
+ if (typeof inst[2] === "number") {
+ if (html5ks.store.attraction[inst[1]] > inst[2]) {
runInst(inst[3]);
} else {
runInst(inst[4]);
}
} else {
- html5ks.persistent.store[inst[0]]++;
+ html5ks.store.attraction[inst[1]]++;
+ runInst();
}
break;
case "path_end":