summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Xu <alex_y_xu@yahoo.ca>2014-02-11 15:18:22 -0500
committerAlex Xu <alex_y_xu@yahoo.ca>2014-02-11 15:18:22 -0500
commit7afd49eed799fddccc6339130f1980832b833c62 (patch)
tree578e3e67f3efe7776c1b4e41739a788f40d5f78f
parentc055175bc6c14fe35e076920fd9351b8d1db8e17 (diff)
downloadhtml5ks-7afd49eed799fddccc6339130f1980832b833c62.tar.xz
html5ks-7afd49eed799fddccc6339130f1980832b833c62.zip
prep for save system
-rw-r--r--www/js/api.js56
-rw-r--r--www/js/html5ks.js11
-rw-r--r--www/js/menu.js20
3 files changed, 53 insertions, 34 deletions
diff --git a/www/js/api.js b/www/js/api.js
index 784134a..2f204b9 100644
--- a/www/js/api.js
+++ b/www/js/api.js
@@ -26,7 +26,8 @@ window.html5ks.api = new (function () {
audio.pause();
/* falls through */
case 1:
- clearInterval(this._fading);
+ clearInterval(this._fading[channel]);
+ delete this._fading[channel];
}
}.bind(this), 50);
}
@@ -73,7 +74,7 @@ window.html5ks.api = new (function () {
audio.loop = true;
}
html5ks.elements.audio[channel] = audio;
- html5ks.state[channel] = name;
+ html5ks.store[channel] = name;
var src = "dump/", volume;
@@ -136,7 +137,7 @@ window.html5ks.api = new (function () {
this.stop("all");
clearInterval(html5ks._nextTimeout);
- if (html5ks.state.skip) {
+ if (html5ks.api.skip()) {
return deferred.resolve();
}
@@ -176,7 +177,7 @@ window.html5ks.api = new (function () {
iscene: function (target, is_h, is_end) {
- html5ks.state.status = "scene";
+ html5ks.store.status = "scene";
var deferred = when.defer(),
label = html5ks.data.script[html5ks.persistent.language + "_" + target],
i = 0;
@@ -217,12 +218,12 @@ window.html5ks.api = new (function () {
switch (action) {
case true:
case "show":
- html5ks.state.window = true;
+ html5ks.store.window = true;
windw.style.display = "block";
break;
case false:
case "hide":
- html5ks.state.window = false;
+ html5ks.store.window = false;
windw.style.display = "none";
break;
}
@@ -478,10 +479,10 @@ window.html5ks.api = new (function () {
_setNextTimeout: function (str, done) {
if (done) {
- if (html5ks.state.auto) {
- setTimeout(html5ks.next, 3.5 * html5ks.persistent.autoModeDelay);
+ if (this.auto()) {
+ setTimeout(html5ks.next, str.length + 3.5 * html5ks.persistent.autoModeDelay);
}
- } else if (html5ks.state.skip || str.indexOf("{nw}") > -1) {
+ } else if (html5ks.api.skip() || str.indexOf("{nw}") > -1) {
html5ks._next();
html5ks._nextTimeout = setTimeout(html5ks._next, 50);
}
@@ -504,12 +505,12 @@ window.html5ks.api = new (function () {
switch (action) {
case true:
case "show":
- html5ks.state.nvl = true;
+ html5ks.store.nvl = true;
nvl.style.display = "block";
break;
case false:
case "hide":
- html5ks.state.nvl = false;
+ html5ks.store.nvl = false;
nvl.style.display = "none";
break;
case "clear":
@@ -558,15 +559,34 @@ window.html5ks.api = new (function () {
return deferred.promise;
},
- speed: function (type, status) {
- switch (type) {
- case "all":
- this.speed("skip", status);
- this.speed("auto", status);
+ auto: function (arg) {
+ if (arg) {
+ return this.speed("auto");
+ } else {
+ return html5ks.store.speed === "auto";
+ }
+ },
+
+ skip: function (arg) {
+ if (arg) {
+ return this.speed("skip");
+ } else {
+ return html5ks.store.speed === "skip";
+ }
+ },
+
+ speed: function (state) {
+ switch (state) {
+ case "skip":
+ case "auto":
+ this.speed();
+ html5ks.store.speed = state;
+ document.getElementById(state).style.display = "block";
break;
default:
- html5ks.state[type] = status;
- document.getElementById(type).style.display = status ? "block" : "none";
+ html5ks.store.speed = "";
+ document.getElementById("auto").style.display = "none";
+ document.getElementById("skip").style.display = "none";
}
}
};})();
diff --git a/www/js/html5ks.js b/www/js/html5ks.js
index 338ea9b..6a7482f 100644
--- a/www/js/html5ks.js
+++ b/www/js/html5ks.js
@@ -49,10 +49,9 @@ window.html5ks = {
kenji: 0,
sc: 0,
hanako: 0
- }
- },
- state: {
- play: {}
+ },
+ play: {},
+ speed: ""
},
next: function () {
var _next = html5ks._next;
@@ -112,10 +111,10 @@ window.html5ks = {
initEvents: function () {
window.onresize = html5ks.scale;
this.elements.container.addEventListener("mouseup", function (e) {
- if (html5ks.state.status === "scene") {
+ if (html5ks.store.status === "scene") {
switch (e.button) {
case 0:
- html5ks.api.speed("all", false);
+ html5ks.api.speed("");
html5ks.next();
break;
case 1:
diff --git a/www/js/menu.js b/www/js/menu.js
index ee05fdd..7bbdd13 100644
--- a/www/js/menu.js
+++ b/www/js/menu.js
@@ -9,7 +9,7 @@
html5ks.api.play("music", "music_menus");
html5ks.api.show("url", "ui/main/bg-main.png");
this.elements.mainMenu.style.display = "block";
- html5ks.state.status = "menu";
+ html5ks.store.status = "menu";
},
activeDialog: null,
@@ -70,7 +70,7 @@
html5ks.menu.activeDialog.style.display = "none";
html5ks.menu.activeDialog = null;
html5ks.menu.elements.dialogs.style.display = "none";
- if (html5ks.state.status === "context") {
+ if (html5ks.store.status === "context") {
html5ks.menu.context(true);
} else {
html5ks.elements.gray.style.display = "none";
@@ -97,7 +97,7 @@
// context menu
html5ks.elements.container.addEventListener("contextmenu", function (e) {
- switch (html5ks.state.status) {
+ switch (html5ks.store.status) {
case "scene":
case "context":
this.context();
@@ -125,12 +125,12 @@
}, true);
contextButtonFactory("skip-mode", function () {
- html5ks.api.speed("skip", true);
+ html5ks.api.speed("skip");
html5ks.next();
});
contextButtonFactory("auto-mode", function () {
- html5ks.api.speed("auto", true);
+ html5ks.api.speed("auto");
html5ks.next();
});
@@ -188,13 +188,13 @@
// return early if context already on
if (this.context("status")) return;
this._state = this._state || {
- window: html5ks.state.window,
- nvl: html5ks.state.nvl,
- status: html5ks.state.status
+ window: html5ks.store.window,
+ nvl: html5ks.store.nvl,
+ status: html5ks.store.status
};
html5ks.api.window("hide");
html5ks.api.nvl("hide");
- html5ks.state.status = "context";
+ html5ks.store.status = "context";
html5ks.elements.gray.style.display = "block";
this.elements.context.style.display = "block";
break;
@@ -206,7 +206,7 @@
if (!this._state) return;
html5ks.api.window(this._state.window);
html5ks.api.nvl(this._state.nvl);
- html5ks.state.status = this._state.status;
+ html5ks.store.status = this._state.status;
break;
case "status":
return this.elements.context.style.display === "block";