X-Git-Url: https://git.yukkurigames.com/?p=pwl6.git;a=blobdiff_plain;f=src%2Fyuu%2Fdirector.js;h=051eb539855d01da348b9b63f324cf8a2acb2427;hp=e1c0b538b24230cd19e8a00a301d1e64d4ad0dad;hb=4f825dcb19e107ac82a76f52759c23533ed9936b;hpb=8b63b6c5d0e8b87a19ff29a8fdc81b8db82907ee diff --git a/src/yuu/director.js b/src/yuu/director.js index e1c0b53..051eb53 100644 --- a/src/yuu/director.js +++ b/src/yuu/director.js @@ -17,6 +17,13 @@ if (!yuu.InputState) require("./input"); if (!yuu.Material) require("./gfx"); + function getCommand (element) { + var command = element.getAttribute('data-yuu-command'); + if (!command || command === 'data-yuu-command') + element.setAttribute('data-yuu-command', command = element.id); + return command; + } + yuu.Director = yT({ constructor: function (commandStack, input, tickHz) { /** Manage and update a set of Scenes @@ -304,12 +311,8 @@ this._resized = true; var director = this; this._rafId = window.requestAnimationFrame(function _ (t) { - if (!director._timerStart) { + if (!director._timerStart) director._timerStart = t; - director._audioOffset = yuu.audio - ? yuu.audio.currentTime * 1000 - t - : 0; - } director._rafId = window.requestAnimationFrame(_); director.render(t); }); @@ -373,7 +376,7 @@ yuu.downloadURL( yuu.canvas.toDataURL("image/png"), document.title + " (" + date + ").png"); - this.toast("\uf030", 0.5, "screenshot"); + this.toast("📷", 0.5, "screenshot"); } catch (exc) { var dialog = yuu.showError(exc); if (dialog) @@ -385,6 +388,10 @@ /** Tick and render all scenes, bottom to top */ var i; + this._audioOffset = yuu.audio + ? yuu.audio.currentTime * 1000 - t + : 0; + if (this._resized) { this._dispatchSceneInput("resize", [yuu.canvas]); this._resized = false; @@ -564,7 +571,7 @@ var elements = element.querySelectorAll("[data-yuu-command]"); yf.each(function (element) { - var command = element.getAttribute("data-yuu-command"); + var command = getCommand(element); switch (element.tagName.toLowerCase()) { case "input": switch (element.type.toLowerCase()) { @@ -625,7 +632,7 @@ function handleElement (event) { /*jshint validthis:true */ /* `this` comes from being a DOM element event handler. */ - var command = this.getAttribute("data-yuu-command"); + var command = getCommand(this); switch (this.tagName.toLowerCase()) { case "input": switch (this.type.toLowerCase()) { @@ -674,7 +681,7 @@ yuu.defaultKeybinds.bind("f11", "++fullscreen"); yuu.defaultKeybinds.bind("f12", "screenshot"); yuu.defaultKeybinds.bind( - "control+s", "++mute && toast \uf026 1 mute || toast \uf028 1 mute"); + "control+s", "++mute && toast 🔈 1 mute || toast 🔊 1 mute"); var director = yuu.director = new yuu.Director(); /** The standard director */