|
|
@ -80,8 +80,7 @@ function HuesCore(defaults) { |
|
|
|
* |
|
|
|
* |
|
|
|
* Called on every new beat. |
|
|
|
* Called on every new beat. |
|
|
|
* beatString is a 256 char long array of current and upcoming beat chars |
|
|
|
* beatString is a 256 char long array of current and upcoming beat chars |
|
|
|
* beatIndex is a "safe to display" beat index. 0 during buildups, |
|
|
|
* beatIndex is the beat index. Negative during buildups |
|
|
|
* index % beatmap length otherwise. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
beat : [], |
|
|
|
beat : [], |
|
|
|
/* callback invert(isInverted) |
|
|
|
/* callback invert(isInverted) |
|
|
@ -172,13 +171,16 @@ function HuesCore(defaults) { |
|
|
|
|
|
|
|
|
|
|
|
document.onkeydown = function(e){ |
|
|
|
document.onkeydown = function(e){ |
|
|
|
e = e || window.event; |
|
|
|
e = e || window.event; |
|
|
|
|
|
|
|
if(e.defaultPrevented) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
// Ignore modifiers so we don't steal other events
|
|
|
|
// Ignore modifiers so we don't steal other events
|
|
|
|
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { |
|
|
|
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
// If we've focused a text input, let the input go through!
|
|
|
|
// If we've focused a text input, let the input go through!
|
|
|
|
if(document.activeElement.tagName.toLowerCase() == "input" && |
|
|
|
if((e.target.tagName.toLowerCase() == "input" && e.target.type == "text") |
|
|
|
document.activeElement.type == "text") { |
|
|
|
|| e.target.contentEditable === "true") { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
var key = e.keyCode || e.which; |
|
|
|
var key = e.keyCode || e.which; |
|
|
@ -281,14 +283,22 @@ HuesCore.prototype.animationLoop = function() { |
|
|
|
this.callEventListeners("frame"); |
|
|
|
this.callEventListeners("frame"); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
HuesCore.prototype.getSafeBeatIndex = function() { |
|
|
|
HuesCore.prototype.getBeatIndex = function() { |
|
|
|
if(!this.soundManager.playing) { |
|
|
|
if(!this.soundManager.playing) { |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
|
|
|
|
} else if(this.beatIndex < 0) { |
|
|
|
|
|
|
|
return this.beatIndex; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return this.beatIndex % this.currentSong.rhythm.length; |
|
|
|
} |
|
|
|
} |
|
|
|
if(this.beatIndex < 0) { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HuesCore.prototype.getSafeBeatIndex = function() { |
|
|
|
|
|
|
|
var index = this.getBeatIndex(); |
|
|
|
|
|
|
|
if(index < 0) { |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return this.beatIndex % this.currentSong.rhythm.length; |
|
|
|
return index; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -549,7 +559,7 @@ HuesCore.prototype.getBeat = function(index) { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
HuesCore.prototype.beater = function(beat) { |
|
|
|
HuesCore.prototype.beater = function(beat) { |
|
|
|
this.callEventListeners("beat", this.getBeatString(), this.getSafeBeatIndex()); |
|
|
|
this.callEventListeners("beat", this.getBeatString(), this.getBeatIndex()); |
|
|
|
switch(beat) { |
|
|
|
switch(beat) { |
|
|
|
case 'X': |
|
|
|
case 'X': |
|
|
|
case 'x': |
|
|
|
case 'x': |
|
|
|