projects
/
pwl6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove unused cache.
[pwl6.git]
/
src
/
yuu
/
director.js
diff --git
a/src/yuu/director.js
b/src/yuu/director.js
index
e1c0b53
..
7660b26
100644
(file)
--- a/
src/yuu/director.js
+++ b/
src/yuu/director.js
@@
-1,7
+1,7
@@
/* Copyright 2014 Yukkuri Games
Licensed under the terms of the GNU GPL v2 or later
/* Copyright 2014 Yukkuri Games
Licensed under the terms of the GNU GPL v2 or later
- @license http://www.gnu.org/licenses/gpl-2.0.html
- @source: http://yukkurigames.com/yuu/
+ @license http
s
://www.gnu.org/licenses/gpl-2.0.html
+ @source: http
s
://yukkurigames.com/yuu/
*/
(function (yuu) {
*/
(function (yuu) {
@@
-17,6
+17,13
@@
if (!yuu.InputState) require("./input");
if (!yuu.Material) require("./gfx");
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
yuu.Director = yT({
constructor: function (commandStack, input, tickHz) {
/** Manage and update a set of Scenes
@@
-133,7
+140,7
@@
// Aside from the performance considerations, deferring
// resizing by multiple frames fixes mis-sizing during startup
// Aside from the performance considerations, deferring
// resizing by multiple frames fixes mis-sizing during startup
- // and fullscreen transition in
node-webkit
on Windows. (And
+ // and fullscreen transition in
NW.js
on Windows. (And
// probably similar bugs in other configurations.)
_doresize: yf.debounce(function () {
this._resized = true;
// probably similar bugs in other configurations.)
_doresize: yf.debounce(function () {
this._resized = true;
@@
-298,18
+305,14
@@
return;
this._tickCount = 0;
this._timerStart = 0;
return;
this._tickCount = 0;
this._timerStart = 0;
- // GNU/Linux with
node-webkit
sizes things incorrectly on
+ // GNU/Linux with
NW.js
sizes things incorrectly on
// startup, so force a recalculating as soon as the render
// loop runs.
this._resized = true;
var director = this;
this._rafId = window.requestAnimationFrame(function _ (t) {
// startup, so force a recalculating as soon as the render
// loop runs.
this._resized = true;
var director = this;
this._rafId = window.requestAnimationFrame(function _ (t) {
- if (!director._timerStart)
{
+ if (!director._timerStart)
director._timerStart = t;
director._timerStart = t;
- director._audioOffset = yuu.audio
- ? yuu.audio.currentTime * 1000 - t
- : 0;
- }
director._rafId = window.requestAnimationFrame(_);
director.render(t);
});
director._rafId = window.requestAnimationFrame(_);
director.render(t);
});
@@
-373,7
+376,7
@@
yuu.downloadURL(
yuu.canvas.toDataURL("image/png"),
document.title + " (" + date + ").png");
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)
} catch (exc) {
var dialog = yuu.showError(exc);
if (dialog)
@@
-385,6
+388,10
@@
/** Tick and render all scenes, bottom to top */
var i;
/** 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;
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 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()) {
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. */
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()) {
switch (this.tagName.toLowerCase()) {
case "input":
switch (this.type.toLowerCase()) {
@@
-674,11
+681,19
@@
yuu.defaultKeybinds.bind("f11", "++fullscreen");
yuu.defaultKeybinds.bind("f12", "screenshot");
yuu.defaultKeybinds.bind(
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 */
var director = yuu.director = new yuu.Director();
/** The standard director */
+ if (yuu.audio) {
+ yuu.Animation.registerOperation(function playSound (sound) {
+ if (Array.isArray(sound))
+ sound = yuu.random.choice(sound);
+ (new yuu.Instrument(sound)).play();
+ });
+ }
+
yuu.registerInitHook(function () {
return yuu.ready(director._scenes);
});
yuu.registerInitHook(function () {
return yuu.ready(director._scenes);
});