From d47fade7099b96fdabb3a5fd3d6196b9a66ce49e Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Sat, 3 Aug 2013 16:21:37 -0400 Subject: fix stuff --- www/js/api.js | 93 ++++++++++++++++++++++------------------------------ www/js/characters.js | 22 ++++++------- www/js/html5ks.js | 2 ++ www/js/images.js | 2 +- www/js/menu.js | 22 ++++++------- 5 files changed, 65 insertions(+), 76 deletions(-) (limited to 'www') diff --git a/www/js/api.js b/www/js/api.js index 44923ac..da45467 100644 --- a/www/js/api.js +++ b/www/js/api.js @@ -79,6 +79,10 @@ window.html5ks.api = { video = html5ks.elements.video, src = "dump/video/" + vid_src + "."; + this.stop("all"); + this.speed("auto", false); + this.speed("skip", false); + if (Modernizr.video.webm) { video.src = src + "webm"; } else if (Modernizr.video.ogg) { @@ -87,8 +91,6 @@ window.html5ks.api = { video.src = src + "mp4"; } - this.stop("all"); - video.load(); video.style.display = "block"; video.volume = html5ks.persistent.musicVolume; @@ -149,10 +151,8 @@ window.html5ks.api = { if (this[cmd]) { return this[cmd].apply(this, args); } else if (inst.length === 1) { - console.log("hopefully this is dialogue"); return this.character("name_only", cmd); } else if (/^[A-Z]/.test(cmd)) { - console.log("cmd starts with caps, probably character"); return this.character(cmd, args[0]); } else { console.error("no such cmd " + cmd); @@ -305,33 +305,17 @@ window.html5ks.api = { return str; }, - nvlsay: function (text) { - var deferred = when.defer(); - html5ks.elements.nvlsay.innerHTML += "" + text + ""; - html5ks.elements.nvlctc.style.display = "block"; - html5ks.next = function () { - html5ks.elements.nvlctc.style.display = "none"; - deferred.resolve(); - html5ks.next = function () {}; - }; - return deferred.promise; - }, - - character: function (name, str, extend, noc) { + character: function (charName, str, extend) { var deferred = when.defer(), text = this.tag(str), - char = html5ks.data.characters[name], - w = /{w(=\d*\.\d*)?}/.exec(str); + char = typeof charName === "string" ? html5ks.data.characters[charName] : charName, + w = /{w=?(\d*\.\d*)?}(.*)/.exec(str); if (!char) { - if (name) { - char = { - name: name, - }; - } else { - char = this._lastchar; - } + char = { + name: name + }; } if (typeof char.what_prefix === "undefined") { char.what_prefix = "“"; @@ -348,9 +332,14 @@ window.html5ks.api = { } if (char.kind === "nvl") { - this.nvlsay(text).then(function () { + var deferred = when.defer(); + html5ks.elements.nvlsay.innerHTML += "" + text + ""; + html5ks.elements.nvlctc.style.display = "block"; + html5ks.next = function () { + html5ks.elements.nvlctc.style.display = "none"; deferred.resolve(); - }); + html5ks.next = function () {}; + }; return deferred.promise; } var who = html5ks.elements.who; @@ -369,37 +358,35 @@ window.html5ks.api = { html5ks.elements.say.innerHTML = text; } - if (!noc) { - if (w) { - html5ks.next = function () { - html5ks.next = function () {}; - html5ks.api.extend(str.substring(w.index + w[0].length)).then(function () { - deferred.resolve(); - }); - }; - if (w[1]) { - setTimeout(html5ks.next, parseFloat(w[1].substring(1), 10) * 1000); - return deferred.promise; - } - } else { - html5ks.next = function () { - html5ks.elements.ctc.style.display = "none"; - deferred.resolve(text); - html5ks.next = function () {}; - }; - } - 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.autoModeDelay * text.length); + if (w) { + html5ks.next = function () { + html5ks.next = function () {}; + html5ks.api.extend(w[2]).then(function () { + deferred.resolve(); + }); + }; + if (w[1]) { + setTimeout(html5ks.next, parseFloat(w[1], 10) * 1000); + return deferred.promise; } + } else { + html5ks.next = function () { + html5ks.elements.ctc.style.display = "none"; + deferred.resolve(text); + html5ks.next = function () {}; + }; + } + html5ks.elements.ctc.style.display = "block"; + if (html5ks.state.skip || str.indexOf("{nw}") > -1) { + html5ks.next(); + } else if (html5ks.state.auto) { + setTimeout(html5ks.next, 3.5 * html5ks.persistent.autoModeDelay * (3000 + text.length)); } return deferred.promise; }, extend: function (str) { - return this.character(null, str, true); + return this.character(this._lastchar, str, true); }, Pause: function (duration) { diff --git a/www/js/characters.js b/www/js/characters.js index c5d41d6..df6209c 100644 --- a/www/js/characters.js +++ b/www/js/characters.js @@ -1,18 +1,18 @@ window.html5ks.data.characters = { name_only: {name: "", what_prefix: "", what_suffix: ""}, - + hi: {name: "Hisao", color: "#629276"}, - + ha: {name: "Hanako", color: "#897CBF"}, emi: {name: "Emi", color: "#FF8D7C"}, rin: {name: "Rin", color: "#b14343"}, li: {name: "Lilly", color: "#F9EAA0"}, shi: {name: "Shizune", color: "#72ADEE"}, mi: {name: "Misha", color: "#FF809F"}, - + mi_shi: {name: "Shizune", color: "#FF809F"}, mi_not_shi: {name: "{s}Shizune{/s} Misha", color: "#FF809F"}, - + ke: {name: "Kenji", color: "#CC7C2A"}, mu: {name: "Mutou", color: "#FFFFFF"}, nk: {name: "Nurse", color: "#FFFFFF"}, @@ -25,12 +25,12 @@ window.html5ks.data.characters = { emm: {name: "Meiko", color: "#995050"}, sk: {name: "Shopkeep", color: "#7187A8"}, mk: {name: "Miki", color: "#AD735E"}, - + mystery: {name: "???"}, - + ssh: {name: "Shizune", color: "#72ADEE", what_prefix: "[ ", what_suffix: " ]"}, his: {name: "Hisao", color: "#629276", what_prefix: "[ ", what_suffix: " ]"}, - + ha_: {name: "Purple-haired girl", color: "#897CBF"}, emi_: {name: "Twintails girl", color: "#FF8D7C"}, rin_: {name: "Strange girl", color: "#b14343"}, @@ -46,17 +46,17 @@ window.html5ks.data.characters = { hx_: {name: "Huge man", color: "#99AACC"}, hh_: {name: "Slim girl", color: "#6299FF"}, emm_: {name: "Woman with braid", color: "#995050"}, - + n: {name: null, kind: "nvl", what_prefix: "", what_suffix: ""}, - - nb: {name: null, + + nb: {name: null, ctc: null, what_color: "#666666", what_line_spacing: 8, what_prefix: "", what_suffix: "", window_style: "b_nvl_window"}, - + rinbabble: {name: null, kind: "nvl", what_prefix: "{color: #FF8D7C}{b}Rin{/b}{/color}\n“", diff --git a/www/js/html5ks.js b/www/js/html5ks.js index 4f54844..ab50cea 100644 --- a/www/js/html5ks.js +++ b/www/js/html5ks.js @@ -134,6 +134,8 @@ window.html5ks = { window.onresize = html5ks.scale; this.elements.container.addEventListener("mouseup", function (e) { if (html5ks.state.status === "scene") { + html5ks.api.speed("skip", false); + html5ks.api.speed("auto", false); switch (e.button) { case 0: html5ks.next(); diff --git a/www/js/images.js b/www/js/images.js index c5e95ad..31e1434 100644 --- a/www/js/images.js +++ b/www/js/images.js @@ -1171,7 +1171,7 @@ window.html5ks.data.images = { }, "mural_pan": "vfx/mural.jpg", - rin_exhibition_paintings: "vfx/rin_exhibition_paintings.jpg", + rin_exhibition_paintings: "vfx/rin_exhibition_paintings.jpg", rin_exhibition_sold: "vfx/rin_exhibition_sold.jpg", rin_exhibition_c: "vfx/rin_exhibition_c.jpg", diff --git a/www/js/menu.js b/www/js/menu.js index c03212e..b940b30 100644 --- a/www/js/menu.js +++ b/www/js/menu.js @@ -43,7 +43,7 @@ var options = document.getElementsByClassName("option"); var change = function (e) { var target = e.target; - values[target.id] = target.type === "checkbox" ? target.checked : target.value; + html5ks.persistent[target.id] = target.type === "checkbox" ? target.checked : target.value; switch (target.id) { case "fullscreen": if (target.checked) { @@ -87,8 +87,6 @@ switch (html5ks.state.status) { case "scene": case "context": - html5ks.api.speed("skip", false); - html5ks.api.speed("auto", false); this.context(); } e.preventDefault(); @@ -106,16 +104,17 @@ e.stopPropagation(); }, false); + var close = function () { + window.close(); + top.open('','_self',''); + top.close(); + }; ["AppleWebKit", "MSIE", "Trident"].forEach(function (ua) { if (navigator.userAgent.indexOf(ua) > -1) { var quit = document.getElementsByClassName("quit"); - for (var i = quit.length - 1; i >= 0; i++) { - quit[i].className = quit.className.replace("disabled", ""); - quit[i].addEventListener("click", function () { - window.close(); - top.open('','_self',''); - top.close(); - }, false); + for (var i = quit.length - 1; i >= 0; i--) { + quit[i].className = quit[i].className.replace("disabled", ""); + quit[i].addEventListener("click", close, false); } return false; } @@ -197,6 +196,7 @@ context: function (show, transitional) { switch (show) { case true: + this._hadWindow = html5ks.elements.window.style.display !== "none"; html5ks.state.status = "context"; html5ks.elements.gray.style.display = "block"; html5ks.elements.window.style.display = "none"; @@ -205,7 +205,7 @@ case false: html5ks.state.status = "scene"; html5ks.elements.gray.style.display = "none"; - if (html5ks.state.status === "scene") { + if (html5ks.state.status === "scene" && this._hadWindow) { html5ks.elements.window.style.display = "block"; } this.elements.context.style.display = "none"; -- cgit v1.2.3-70-g09d2