diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | README | 10 | ||||
-rw-r--r-- | lighttpd.conf | 4 | ||||
-rw-r--r-- | unrpyc/Makefile | 6 | ||||
-rw-r--r-- | unrpyc/README | 2 | ||||
-rw-r--r-- | unrpyc/decompiler.py | 8 | ||||
-rw-r--r-- | www/css/index.css | 1 | ||||
-rw-r--r-- | www/js/api.js | 66 | ||||
-rw-r--r-- | www/js/characters.js | 4 | ||||
-rw-r--r-- | www/js/html5ks.js | 2 | ||||
-rw-r--r-- | www/js/imachine.js | 2 |
11 files changed, 60 insertions, 47 deletions
@@ -1,4 +1,6 @@ /unrpyc/renpy +/unrpyc/*.json +/unrpyc/*.rpyc # ignore 'copyrighted' contents similar to emulators /www/scripts /www/dump @@ -4,9 +4,15 @@ jQuery is not used, but when.js [1] is used as a sensible Promises/A+ implementa It's still very much a WIP, but at least the first scene displays half-credibly. -Run nginx.sh to start nginx with appropriate options for development, then connect to localhost:8080. +How to use: +0. Get Katawa Shoujo. +1. Follow steps in unrpyc/README +2. Extract files from data.rpa with an appropriate tool. Put files in www/dump. +3. Modify www/dump/ui/bt-cf-{un,}checked.png to remove empty borders. -lighttpd -f lighttpd.conf should also work, but is not actively tested. +4. Run nginx.sh to start nginx with appropriate options for development, then connect to localhost:8080. +-- or -- +4. lighttpd -f lighttpd.conf should also work, but is not actively tested. Check Bugzilla for things that need to be done. [2] diff --git a/lighttpd.conf b/lighttpd.conf index c894d65..8c0699e 100644 --- a/lighttpd.conf +++ b/lighttpd.conf @@ -8,12 +8,12 @@ mimetype.assign = ( ".jpg" => "image/jpeg", ".js" => "application/javascript", ".json" => "application/json", -# ".mkv" => "video/x-matroska", + ".mkv" => "video/x-matroska", ".mp4" => "video/mp4", ".ogg" => "audio/ogg", ".png" => "image/png", ".svg" => "image/svg+xml", -# ".ttf" => "application/x-font-ttf", + ".ttf" => "application/x-font-ttf", ".txt" => "text/plain; charset=utf-8", ".webm" => "video/webm", ".webp" => "image/webp", diff --git a/unrpyc/Makefile b/unrpyc/Makefile index 86dcac3..6a94ca6 100644 --- a/unrpyc/Makefile +++ b/unrpyc/Makefile @@ -12,5 +12,7 @@ clean: test: all jshint --show-non-errors *.json -.PHONY: all clean test -.PRECIOUS: %.json.o +install: all + install -t ../www/scripts *.json + +.PHONY: all clean test install diff --git a/unrpyc/README b/unrpyc/README index c046fe8..8d68bac 100644 --- a/unrpyc/README +++ b/unrpyc/README @@ -8,7 +8,7 @@ How to use: 2. Execute "2to3 -w renpy/*.py". 3. Put the rpyc files from the official KS distribution in here. 4. Run "make" with appropriate -j options (yay auto-parallelization) -5. Copy the resulting .json files to /www/scripts. +5. Run "make install". If you want to hack on the code, have fun. This is all the documentation you get. diff --git a/unrpyc/decompiler.py b/unrpyc/decompiler.py index c6046f6..64d0e4c 100644 --- a/unrpyc/decompiler.py +++ b/unrpyc/decompiler.py @@ -21,6 +21,7 @@ import ast as python_ast import renpy.ast as ast import renpy.atl as atl +import code DECOMPILE_SCREENS = False firstLabel = True @@ -176,7 +177,7 @@ def print_imspec(f, imspec): # at if len(imspec[3]) > 0: - f.write(' at ') + f.write('", "') delim = '' for s in imspec[3]: f.write(delim + escape_string(s)) @@ -275,6 +276,8 @@ class PrintRenPython(python_ast.NodeVisitor): self.f.write(self.visit(node.func)) self.f.write(', ') self.f.write(', '.join(map(self.visit, node.args))) + self.f.write(', ') + self.f.write(', '.join(map(self.visit, node.keywords))) self.f.write('],\n') def quote(self, string): @@ -292,6 +295,9 @@ class PrintRenPython(python_ast.NodeVisitor): def visit_Str(self, node): return self.quote(escape_string(node.s)) + def visit_keyword(self, node): + return self.visit(node.value) + def print_Python(f, stmt, indent_level, early=False): code_src = stmt.code.source diff --git a/www/css/index.css b/www/css/index.css index f664438..7b671c2 100644 --- a/www/css/index.css +++ b/www/css/index.css @@ -194,4 +194,5 @@ html.no-js #gotit { .choice { background: url("../dump/ui/bg-choice.png") no-repeat top center; height: 35px; + line-height: 30px; } diff --git a/www/js/api.js b/www/js/api.js index 1cf9fbe..edc37b6 100644 --- a/www/js/api.js +++ b/www/js/api.js @@ -29,7 +29,7 @@ window.html5ks.api = { play: function (channel, name, ignore, fade) { this.stop(channel); var deferred = when.defer(), - audio = new Audio(); + audio = html5ks.elements.audio[channel]; if (channel === "music" || channel === "ambient") { audio.loop = true; } @@ -38,15 +38,15 @@ window.html5ks.api = { audio.load(); audio.volume = fade ? 0 : 1; audio.play(); - audio.addEventListener("playing", function playing() { + audio.onplaying = function () { deferred.resolve(); if (fade) { html5ks.api.set_volume(1, fade, channel); } - }, false); - audio.addEventListener("error", function error() { + }; + audio.onerror = function () { deferred.reject(this.error); - }, false); + }; return deferred.promise; }, @@ -88,30 +88,25 @@ window.html5ks.api = { video.play(); var done = function () { video.style.display = "none"; - // clear event listeners - var oldVideo = document.getElementById("vid"); - oldVideo.pause(); - var newVideo = video.cloneNode(true); - oldVideo.parentNode.replaceChild(newVideo, oldVideo); - html5ks.elements.video = newVideo; + video.pause(); deferred.resolve(); }; document.addEventListener("keyup", function keyupListener(e) { + document.removeEventListener("keyup", keyupListener, false); if (e.keyCode === 27) { done(); e.preventDefault(); - e.stopPropagation(); } }, false); - video.addEventListener("click", function clickListener(e) { + video.onclick = function (e) { if (e.button === 0 && skippable) { done(); } - }, false); - video.addEventListener("ended", done, false); - video.addEventListener("error", function () { + }; + video.onended = done; + video.onerror = function () { deferred.reject(this.error); - }, false); + }; return deferred.promise; }, @@ -207,7 +202,7 @@ window.html5ks.api = { bgleft: { xpos: 0.4, xanchor: 0.5, ypos: 1.0, yanchor: 1.0 }, bgright: { xpos: 0.6, xanchor: 0.5, ypos: 1.0, yanchor: 1.0 } }; - var pos = positions[location] || positions.center; + var pos = positions[location]; // TODO: implement transitions if (pos) { el.style.left = pos.xpos * 800 + "px"; @@ -229,13 +224,16 @@ window.html5ks.api = { var image = html5ks.data.images[nom]; switch (typeof image) { case "string": - el = document.createElement("div"); - el.style.backgroundColor = image; - el.style.width = "100%"; - el.style.height = "100%"; - el.src = ""; - deferred.resolve(); - return deferred.promise; + if (image.substring(0, 1) === "#") { + el = document.createElement("div"); + el.style.backgroundColor = image; + el.style.width = "100%"; + el.style.height = "100%"; + el.src = ""; + deferred.resolve(); + return deferred.promise; + } + break; case "undefined": switch (name) { case "bg": @@ -326,10 +324,12 @@ window.html5ks.api = { if (!char) { char = { name: name, - what_prefix: "“", - what_suffix: "”" }; } + if (typeof char.what_prefix === "undefined") { + char.what_prefix = "“"; + char.what_suffix = "”"; + } if (!extend && char.what_prefix) { text = char.what_prefix + text; } @@ -433,13 +433,8 @@ window.html5ks.api = { return deferred.promise; }, - menu: function (label) { - var deferred = when.defer(), - imenu = html5ks.data.script[label], - char = imenu[1], - str = imenu[2], - choices = imenu[3]; - this.character(char, str, null, true); + menu: function (choices) { + var deferred = when.defer(); var menu = html5ks.elements.choices, frag = document.createDocumentFragment(), choice = document.createElement("div"); @@ -448,13 +443,14 @@ window.html5ks.api = { for (var i in choices) { choice.innerHTML = i; + choice.id = choices[i]; frag.appendChild(choice); choice = choice.cloneNode(false); } menu.addEventListener("click", function (e) { html5ks.elements.choices.innerHTML = ""; - deferred.resolve(choices[e.target.innerHTML]); + deferred.resolve(e.target.id); }, false); html5ks.elements.choices.appendChild(frag); diff --git a/www/js/characters.js b/www/js/characters.js index 9138e5b..c5d41d6 100644 --- a/www/js/characters.js +++ b/www/js/characters.js @@ -1,5 +1,5 @@ window.html5ks.data.characters = { - name_only: {name: ""}, + name_only: {name: "", what_prefix: "", what_suffix: ""}, hi: {name: "Hisao", color: "#629276"}, @@ -47,7 +47,7 @@ window.html5ks.data.characters = { hh_: {name: "Slim girl", color: "#6299FF"}, emm_: {name: "Woman with braid", color: "#995050"}, - n: {name: null, kind: "nvl"}, + n: {name: null, kind: "nvl", what_prefix: "", what_suffix: ""}, nb: {name: null, ctc: null, diff --git a/www/js/html5ks.js b/www/js/html5ks.js index 182d08a..fc3f99a 100644 --- a/www/js/html5ks.js +++ b/www/js/html5ks.js @@ -107,7 +107,7 @@ window.html5ks = { } }, initEvents: function () { - window.addEventListener("resize", html5ks.scale, false); + window.onresize = html5ks.scale; this.elements.container.addEventListener("mouseup", function () { html5ks.next(); }, false); diff --git a/www/js/imachine.js b/www/js/imachine.js index b6117f7..16d406f 100644 --- a/www/js/imachine.js +++ b/www/js/imachine.js @@ -43,7 +43,7 @@ html5ks.imachine = (function () { } break; case "imenu": - html5ks.api.menu(args[0]).then(function (choice) { + 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); }); |