alternate-visualiser
William Toohey 10 years ago
parent 566fbfde63
commit ed78cf6e95
  1. 56
      js/HuesCanvas.js
  2. 91
      js/HuesCore.js
  3. 35
      js/HuesSettings.js
  4. 156
      js/HuesUI.js
  5. 121
      js/ResourceManager.js
  6. 68
      js/ResourcePack.js
  7. 32
      js/SoundManager.js

@ -79,7 +79,7 @@ function HuesCanvas(element, aContext, core) {
HuesCanvas.prototype.resizeHandler = function(that) { HuesCanvas.prototype.resizeHandler = function(that) {
return function() {that.resize();}; return function() {that.resize();};
} };
HuesCanvas.prototype.resize = function() { HuesCanvas.prototype.resize = function() {
// height is constant 720px, we expand width to suit // height is constant 720px, we expand width to suit
@ -88,7 +88,7 @@ HuesCanvas.prototype.resize = function() {
var snow = document.getElementById("snow").getContext("2d"); var snow = document.getElementById("snow").getContext("2d");
snow.canvas.width = Math.ceil(720 * ratio); snow.canvas.width = Math.ceil(720 * ratio);
this.needsRedraw = true; this.needsRedraw = true;
} };
HuesCanvas.prototype.redraw = function() { HuesCanvas.prototype.redraw = function() {
var offset; // for centering/right/left align var offset; // for centering/right/left align
@ -159,19 +159,19 @@ HuesCanvas.prototype.redraw = function() {
} else { } else {
this.needsRedraw = false; this.needsRedraw = false;
} }
} };
/* Second fastest method from /* Second fastest method from
http://stackoverflow.com/questions/10073699/pad-a-number-with-leading-zeros-in-javascript http://stackoverflow.com/questions/10073699/pad-a-number-with-leading-zeros-in-javascript
It stil does millions of ops per second, and isn't ugly like the integer if/else */ It stil does millions of ops per second, and isn't ugly like the integer if/else */
HuesCanvas.prototype.intToHex = function(num) { HuesCanvas.prototype.intToHex = function(num) {
return '#' + ("00000"+num.toString(16)).slice(-6); return '#' + ("00000"+num.toString(16)).slice(-6);
} };
HuesCanvas.prototype.getAnimLoop = function() { HuesCanvas.prototype.getAnimLoop = function() {
var that = this; var that = this;
return function() {that.animationLoop()}; return function() {that.animationLoop();};
} };
HuesCanvas.prototype.animationLoop = function() { HuesCanvas.prototype.animationLoop = function() {
if (this.colourFade) { if (this.colourFade) {
@ -234,7 +234,7 @@ HuesCanvas.prototype.animationLoop = function() {
if(this.animating) { if(this.animating) {
requestAnimationFrame(this.getAnimLoop()); requestAnimationFrame(this.getAnimLoop());
} }
} };
HuesCanvas.prototype.setImage = function(image) { HuesCanvas.prototype.setImage = function(image) {
this.needsRedraw = true; this.needsRedraw = true;
@ -251,11 +251,11 @@ HuesCanvas.prototype.setImage = function(image) {
this.syncAnim(); this.syncAnim();
} }
} }
} };
HuesCanvas.prototype.beat = function() { HuesCanvas.prototype.beat = function() {
this.lastBeat = this.aContext.currentTime; this.lastBeat = this.aContext.currentTime;
} };
HuesCanvas.prototype.syncAnim = function() { HuesCanvas.prototype.syncAnim = function() {
var song = this.core.currentSong; var song = this.core.currentSong;
@ -275,7 +275,7 @@ HuesCanvas.prototype.syncAnim = function() {
this.animFrame = Math.floor(aLen * (beatLoc / this.image.beatsPerAnim)); this.animFrame = Math.floor(aLen * (beatLoc / this.image.beatsPerAnim));
// Because negative mods are different in JS // Because negative mods are different in JS
this.animFrame = ((this.animFrame % aLen) + aLen) % aLen; this.animFrame = ((this.animFrame % aLen) + aLen) % aLen;
} };
HuesCanvas.prototype.setColour = function(colour, isFade) { HuesCanvas.prototype.setColour = function(colour, isFade) {
if(isFade) { if(isFade) {
@ -285,7 +285,7 @@ HuesCanvas.prototype.setColour = function(colour, isFade) {
this.colour = colour; this.colour = colour;
} }
this.needsRedraw = true; this.needsRedraw = true;
} };
HuesCanvas.prototype.doBlackout = function(whiteout) { HuesCanvas.prototype.doBlackout = function(whiteout) {
if (typeof(whiteout)==='undefined') whiteout = false; if (typeof(whiteout)==='undefined') whiteout = false;
@ -301,7 +301,7 @@ HuesCanvas.prototype.doBlackout = function(whiteout) {
if(localStorage["blackoutUI"] == "on") { if(localStorage["blackoutUI"] == "on") {
this.core.userInterface.hide(); this.core.userInterface.hide();
} }
} };
// for song changes // for song changes
HuesCanvas.prototype.clearBlackout = function() { HuesCanvas.prototype.clearBlackout = function() {
@ -311,27 +311,27 @@ HuesCanvas.prototype.clearBlackout = function() {
if(localStorage["blackoutUI"] == "on") { if(localStorage["blackoutUI"] == "on") {
this.core.userInterface.show(); this.core.userInterface.show();
} }
} };
HuesCanvas.prototype.doShortBlackout = function(beatTime) { HuesCanvas.prototype.doShortBlackout = function(beatTime) {
this.doBlackout(); this.doBlackout();
this.blackoutTimeout = this.aContext.currentTime + beatTime / 1.7; this.blackoutTimeout = this.aContext.currentTime + beatTime / 1.7;
// looks better if we go right to black // looks better if we go right to black
this.blackoutStart = 0; this.blackoutStart = 0;
} };
HuesCanvas.prototype.doColourFade = function(length) { HuesCanvas.prototype.doColourFade = function(length) {
this.colourFade = true; this.colourFade = true;
this.colourFadeLength = length; this.colourFadeLength = length;
this.colourFadeStart = this.aContext.currentTime; this.colourFadeStart = this.aContext.currentTime;
this.oldColour = this.colour; this.oldColour = this.colour;
} };
HuesCanvas.prototype.stopFade = function() { HuesCanvas.prototype.stopFade = function() {
this.colourFade = false; this.colourFade = false;
this.colourFadeStart = 0; this.colourFadeStart = 0;
this.colourFadeLength = 0; this.colourFadeLength = 0;
} };
HuesCanvas.prototype.mixColours = function(percent) { HuesCanvas.prototype.mixColours = function(percent) {
percent = Math.min(1, percent); percent = Math.min(1, percent);
@ -345,7 +345,7 @@ HuesCanvas.prototype.mixColours = function(percent) {
var mixG = oldG * (1 - percent) + newG * percent; var mixG = oldG * (1 - percent) + newG * percent;
var mixB = oldB * (1 - percent) + newB * percent; var mixB = oldB * (1 - percent) + newB * percent;
this.colour = mixR << 16 | mixG << 8 | mixB; this.colour = mixR << 16 | mixG << 8 | mixB;
} };
HuesCanvas.prototype.doXBlur = function() { HuesCanvas.prototype.doXBlur = function() {
this.blurStart = this.aContext.currentTime; this.blurStart = this.aContext.currentTime;
@ -353,7 +353,7 @@ HuesCanvas.prototype.doXBlur = function() {
this.xBlur = true; this.xBlur = true;
this.yBlur = false; this.yBlur = false;
this.needsRedraw = true; this.needsRedraw = true;
} };
HuesCanvas.prototype.doYBlur = function() { HuesCanvas.prototype.doYBlur = function() {
this.blurStart = this.aContext.currentTime; this.blurStart = this.aContext.currentTime;
@ -361,32 +361,32 @@ HuesCanvas.prototype.doYBlur = function() {
this.xBlur = false; this.xBlur = false;
this.yBlur = true; this.yBlur = true;
this.needsRedraw = true; this.needsRedraw = true;
} };
HuesCanvas.prototype.setBlurDecay = function(decay) { HuesCanvas.prototype.setBlurDecay = function(decay) {
this.blurDecay = {"slow" : 7.8, "medium" : 14.1, "fast" : 20.8, "faster!" : 28.7}[decay]; this.blurDecay = {"slow" : 7.8, "medium" : 14.1, "fast" : 20.8, "faster!" : 28.7}[decay];
} };
HuesCanvas.prototype.setBlurQuality = function(quality) { HuesCanvas.prototype.setBlurQuality = function(quality) {
this.blurIterations = {"low" : 3, "medium" : 11, "high" : 19, "extreme" : 35}[quality]; this.blurIterations = {"low" : 3, "medium" : 11, "high" : 19, "extreme" : 35}[quality];
this.blurDelta = 1 / (this.blurIterations/2); this.blurDelta = 1 / (this.blurIterations/2);
this.blurAlpha = 1 / (this.blurIterations/2); this.blurAlpha = 1 / (this.blurIterations/2);
} };
HuesCanvas.prototype.setBlurAmount = function(amount) { HuesCanvas.prototype.setBlurAmount = function(amount) {
this.blurAmount = {"low" : 48, "medium" : 96, "high" : 384}[amount]; this.blurAmount = {"low" : 48, "medium" : 96, "high" : 384}[amount];
} };
HuesCanvas.prototype.setSmartAlign = function(align) { HuesCanvas.prototype.setSmartAlign = function(align) {
this.smartAlign = align == "on"; this.smartAlign = align == "on";
} };
HuesCanvas.prototype.setAnimating = function(anim) { HuesCanvas.prototype.setAnimating = function(anim) {
if(!this.animating && anim) { if(!this.animating && anim) {
requestAnimationFrame(this.animationLoop); requestAnimationFrame(this.animationLoop);
} }
this.animating = anim; this.animating = anim;
} };
// From http://thecodeplayer.com/walkthrough/html5-canvas-snow-effect // From http://thecodeplayer.com/walkthrough/html5-canvas-snow-effect
@ -403,15 +403,15 @@ HuesCanvas.prototype.startSnow = function() {
y: Math.random()*height, //y-coordinate y: Math.random()*height, //y-coordinate
r: Math.random()*4+1, //radius r: Math.random()*4+1, //radius
d: Math.random()*25 //density d: Math.random()*25 //density
}) });
} }
this.lastSnow = this.aContext.currentTime; this.lastSnow = this.aContext.currentTime;
} };
HuesCanvas.prototype.stopSnow = function() { HuesCanvas.prototype.stopSnow = function() {
this.snowing = false; this.snowing = false;
document.getElementById("snow").style.display = "none"; document.getElementById("snow").style.display = "none";
} };
HuesCanvas.prototype.drawSnow = function() { HuesCanvas.prototype.drawSnow = function() {
var ctx = document.getElementById("snow").getContext("2d"); var ctx = document.getElementById("snow").getContext("2d");
@ -459,4 +459,4 @@ HuesCanvas.prototype.drawSnow = function() {
} }
} }
this.lastSnow = this.aContext.currentTime; this.lastSnow = this.aContext.currentTime;
} };

@ -19,6 +19,9 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
/* We don't want localstorage variables optimised to different identifiers*/
/*jshint -W069 */
HuesCore = function(defaults) { HuesCore = function(defaults) {
// Bunch-o-initialisers // Bunch-o-initialisers
this.version = "0x01"; this.version = "0x01";
@ -98,12 +101,12 @@ HuesCore = function(defaults) {
}; };
this.animationLoop(); this.animationLoop();
} };
HuesCore.prototype.animationLoop = function() { HuesCore.prototype.animationLoop = function() {
var that = this; var that = this;
if(!this.soundManager.playing) { if(!this.soundManager.playing) {
requestAnimationFrame(function() {that.animationLoop()}); requestAnimationFrame(function() {that.animationLoop();});
return; return;
} }
var now = this.soundManager.currentTime(); var now = this.soundManager.currentTime();
@ -120,12 +123,12 @@ HuesCore.prototype.animationLoop = function() {
var beat = this.getBeat(this.beatIndex); var beat = this.getBeat(this.beatIndex);
this.beater(beat); this.beater(beat);
} }
requestAnimationFrame(function() {that.animationLoop()}); requestAnimationFrame(function() {that.animationLoop();});
} };
HuesCore.prototype.getCurrentMode = function() { HuesCore.prototype.getCurrentMode = function() {
return this.isFullAuto ? "FULL AUTO" : "NORMAL"; return this.isFullAuto ? "FULL AUTO" : "NORMAL";
} };
HuesCore.prototype.getSafeBeatIndex = function() { HuesCore.prototype.getSafeBeatIndex = function() {
if(!this.soundManager.playing) { if(!this.soundManager.playing) {
@ -136,23 +139,23 @@ HuesCore.prototype.getSafeBeatIndex = function() {
} else { } else {
return this.beatIndex % this.currentSong.rhythm.length; return this.beatIndex % this.currentSong.rhythm.length;
} }
} };
HuesCore.prototype.blurUpdated = function(x, y) { HuesCore.prototype.blurUpdated = function(x, y) {
this.userInterface.blurUpdated(x, y); this.userInterface.blurUpdated(x, y);
} };
HuesCore.prototype.nextSong = function() { HuesCore.prototype.nextSong = function() {
this.lastSongArray = []; this.lastSongArray = [];
var index = (this.songIndex + 1) % this.resourceManager.enabledSongs.length; var index = (this.songIndex + 1) % this.resourceManager.enabledSongs.length;
this.setSong(index); this.setSong(index);
} };
HuesCore.prototype.previousSong = function() { HuesCore.prototype.previousSong = function() {
this.lastSongArray = []; this.lastSongArray = [];
var index = ((this.songIndex - 1) + this.resourceManager.enabledSongs.length) % this.resourceManager.enabledSongs.length; var index = ((this.songIndex - 1) + this.resourceManager.enabledSongs.length) % this.resourceManager.enabledSongs.length;
this.setSong(index); this.setSong(index);
} };
HuesCore.prototype.setSongByName = function(name) { HuesCore.prototype.setSongByName = function(name) {
var songs = this.resourceManager.enabledSongs; var songs = this.resourceManager.enabledSongs;
@ -163,7 +166,7 @@ HuesCore.prototype.setSongByName = function(name) {
} }
} }
this.setSong(0); // fallback this.setSong(0); // fallback
} };
HuesCore.prototype.setSong = function(index) { HuesCore.prototype.setSong = function(index) {
if(this.currentSong == this.resourceManager.enabledSongs[index]) { if(this.currentSong == this.resourceManager.enabledSongs[index]) {
@ -171,7 +174,7 @@ HuesCore.prototype.setSong = function(index) {
} }
this.songIndex = index; this.songIndex = index;
this.currentSong = this.resourceManager.enabledSongs[this.songIndex]; this.currentSong = this.resourceManager.enabledSongs[this.songIndex];
if (this.currentSong == undefined) { if (this.currentSong === undefined) {
this.currentSong = {"name":"None", "title":"None", "rhythm":".", "source":null, "crc":"none", "sound":null, "enabled":true, "filename":"none"}; this.currentSong = {"name":"None", "title":"None", "rhythm":".", "source":null, "crc":"none", "sound":null, "enabled":true, "filename":"none"};
} }
console.log("Next song:", this.songIndex, this.currentSong); console.log("Next song:", this.songIndex, this.currentSong);
@ -197,12 +200,12 @@ HuesCore.prototype.setSong = function(index) {
that.resetAudio(); that.resetAudio();
that.fillBuildup(); that.fillBuildup();
}); });
} };
HuesCore.prototype.fillBuildup = function() { HuesCore.prototype.fillBuildup = function() {
this.beatLength = this.soundManager.loopLength / this.currentSong.rhythm.length; this.beatLength = this.soundManager.loopLength / this.currentSong.rhythm.length;
var buildBeats = Math.floor(this.soundManager.loopStart / this.beatLength) + 1; var buildBeats = Math.floor(this.soundManager.loopStart / this.beatLength) + 1;
if (this.currentSong.buildupRhythm == null) { if (this.currentSong.buildupRhythm === null) {
this.currentSong.buildupRhythm = ""; this.currentSong.buildupRhythm = "";
} }
if (this.currentSong.buildupRhythm.length < buildBeats) { if (this.currentSong.buildupRhythm.length < buildBeats) {
@ -213,22 +216,22 @@ HuesCore.prototype.fillBuildup = function() {
} }
console.log("Buildup length:", buildBeats); console.log("Buildup length:", buildBeats);
this.beatIndex = this.doBuildup ? -this.currentSong.buildupRhythm.length : 0; this.beatIndex = this.doBuildup ? -this.currentSong.buildupRhythm.length : 0;
} };
HuesCore.prototype.randomSong = function() { HuesCore.prototype.randomSong = function() {
var index=Math.floor((Math.random() * this.resourceManager.enabledSongs.length)); var index=Math.floor((Math.random() * this.resourceManager.enabledSongs.length));
if (index == this.songIndex && this.resourceManager.enabledSongs.length > 1 || !(this.lastSongArray.indexOf(index) == -1)) { if (index == this.songIndex && this.resourceManager.enabledSongs.length > 1 || this.lastSongArray.indexOf(index) != -1) {
this.randomSong(); this.randomSong();
} else { } else {
console.log("Randoming a song!"); console.log("Randoming a song!");
this.setSong(index); this.setSong(index);
this.lastSongArray.push(index); this.lastSongArray.push(index);
noRepeat = Math.min(5, Math.floor((this.resourceManager.enabledSongs.length / 2))); var noRepeat = Math.min(5, Math.floor((this.resourceManager.enabledSongs.length / 2)));
while (this.lastSongArray.length > noRepeat && noRepeat >= 0) { while (this.lastSongArray.length > noRepeat && noRepeat >= 0) {
this.lastSongArray.shift(); this.lastSongArray.shift();
} }
} }
} };
/* /*
HuesCore.prototype.onLoop = function() { HuesCore.prototype.onLoop = function() {
this.loopCount = this.loopCount + 1; this.loopCount = this.loopCount + 1;
@ -261,12 +264,12 @@ HuesCore.prototype.songDataUpdated = function() {
} else { } else {
this.beatLength = -1; this.beatLength = -1;
} }
} };
HuesCore.prototype.resetAudio = function() { HuesCore.prototype.resetAudio = function() {
this.beatIndex = 0; this.beatIndex = 0;
this.songDataUpdated(); this.songDataUpdated();
} };
HuesCore.prototype.randomImage = function() { HuesCore.prototype.randomImage = function() {
var len = this.resourceManager.enabledImages.length; var len = this.resourceManager.enabledImages.length;
@ -281,13 +284,13 @@ HuesCore.prototype.randomImage = function() {
this.lastImageArray.shift(); this.lastImageArray.shift();
} }
} }
} };
HuesCore.prototype.setImage = function(index) { HuesCore.prototype.setImage = function(index) {
// If there are no images, this corrects NaN to 0 // If there are no images, this corrects NaN to 0
this.imageIndex = index ? index : 0; this.imageIndex = index ? index : 0;
var img=this.resourceManager.enabledImages[this.imageIndex]; var img=this.resourceManager.enabledImages[this.imageIndex];
if (img == this.currentImage && !(img == null)) { if (img == this.currentImage && img !== null) {
return; return;
} }
if (img) { if (img) {
@ -299,21 +302,21 @@ HuesCore.prototype.setImage = function(index) {
} }
this.renderer.setImage(this.currentImage); this.renderer.setImage(this.currentImage);
this.userInterface.setImageText(); this.userInterface.setImageText();
} };
HuesCore.prototype.nextImage = function() { HuesCore.prototype.nextImage = function() {
this.setIsFullAuto(false); this.setIsFullAuto(false);
var img=(this.imageIndex + 1) % this.resourceManager.enabledImages.length; var img=(this.imageIndex + 1) % this.resourceManager.enabledImages.length;
this.setImage(img); this.setImage(img);
this.lastImageArray = []; this.lastImageArray = [];
} };
HuesCore.prototype.previousImage = function() { HuesCore.prototype.previousImage = function() {
this.setIsFullAuto(false); this.setIsFullAuto(false);
var img=((this.imageIndex - 1) + this.resourceManager.enabledImages.length) % this.resourceManager.enabledImages.length; var img=((this.imageIndex - 1) + this.resourceManager.enabledImages.length) % this.resourceManager.enabledImages.length;
this.setImage(img); this.setImage(img);
this.lastImageArray = []; this.lastImageArray = [];
} };
HuesCore.prototype.randomColourIndex = function() { HuesCore.prototype.randomColourIndex = function() {
var index=Math.floor((Math.random() * 64)); var index=Math.floor((Math.random() * 64));
@ -321,18 +324,18 @@ HuesCore.prototype.randomColourIndex = function() {
return this.randomColourIndex(); return this.randomColourIndex();
} }
return index; return index;
} };
HuesCore.prototype.randomColour = function(isFade) { HuesCore.prototype.randomColour = function(isFade) {
var index=this.randomColourIndex(); var index=this.randomColourIndex();
this.setColour(index, isFade); this.setColour(index, isFade);
} };
HuesCore.prototype.setColour = function(index, isFade) { HuesCore.prototype.setColour = function(index, isFade) {
this.colourIndex = index; this.colourIndex = index;
this.renderer.setColour(this.colours[this.colourIndex].c, isFade); this.renderer.setColour(this.colours[this.colourIndex].c, isFade);
this.userInterface.setColourText(); this.userInterface.setColourText();
} };
HuesCore.prototype.getBeat = function(index) { HuesCore.prototype.getBeat = function(index) {
if(index < 0) { if(index < 0) {
@ -340,7 +343,7 @@ HuesCore.prototype.getBeat = function(index) {
} else { } else {
return this.currentSong.rhythm[index % this.currentSong.rhythm.length]; return this.currentSong.rhythm[index % this.currentSong.rhythm.length];
} }
} };
HuesCore.prototype.beater = function(beat) { HuesCore.prototype.beater = function(beat) {
this.userInterface.beat(); this.userInterface.beat();
@ -404,7 +407,7 @@ HuesCore.prototype.beater = function(beat) {
this.randomImage(); this.randomImage();
} }
} }
} };
HuesCore.prototype.getBeatString = function(length) { HuesCore.prototype.getBeatString = function(length) {
length = length ? length : 256; length = length ? length : 256;
@ -424,18 +427,18 @@ HuesCore.prototype.getBeatString = function(length) {
} }
return beatString; return beatString;
} };
HuesCore.prototype.setIsFullAuto = function(auto) { HuesCore.prototype.setIsFullAuto = function(auto) {
this.isFullAuto = auto; this.isFullAuto = auto;
if (this.userInterface) { if (this.userInterface) {
this.userInterface.modeUpdated(); this.userInterface.modeUpdated();
} }
} };
HuesCore.prototype.toggleFullAuto = function() { HuesCore.prototype.toggleFullAuto = function() {
this.setIsFullAuto(!this.isFullAuto); this.setIsFullAuto(!this.isFullAuto);
} };
/*HuesCore.prototype.enterFrame = function() { /*HuesCore.prototype.enterFrame = function() {
this.setTexts(); this.setTexts();
@ -460,7 +463,7 @@ HuesCore.prototype.toggleFullAuto = function() {
HuesCore.prototype.respackLoaded = function() { HuesCore.prototype.respackLoaded = function() {
this.init(); this.init();
} };
/*HuesCore.prototype.rightClickListener = function(event) { /*HuesCore.prototype.rightClickListener = function(event) {
switch (event) { switch (event) {
@ -478,7 +481,7 @@ HuesCore.prototype.respackLoaded = function() {
}*/ }*/
HuesCore.prototype.changeUI = function(index) { HuesCore.prototype.changeUI = function(index) {
if (index >= 0 && this.uiArray.length > index && !(this.userInterface == this.uiArray[index])) { if (index >= 0 && this.uiArray.length > index && this.userInterface != this.uiArray[index]) {
this.hideLists(); this.hideLists();
if(this.userInterface) if(this.userInterface)
this.userInterface.disconnect(); this.userInterface.disconnect();
@ -490,7 +493,7 @@ HuesCore.prototype.changeUI = function(index) {
this.userInterface.beat(); this.userInterface.beat();
this.userInterface.modeUpdated(); this.userInterface.modeUpdated();
} }
} };
HuesCore.prototype.settingsUpdated = function() { HuesCore.prototype.settingsUpdated = function() {
this.renderer.setSmartAlign(localStorage["smartAlign"]); this.renderer.setSmartAlign(localStorage["smartAlign"]);
@ -537,37 +540,37 @@ HuesCore.prototype.settingsUpdated = function() {
this.loopCount = 0; this.loopCount = 0;
this.autoSong = this.settings.autosong; this.autoSong = this.settings.autosong;
}*/ }*/
} };
HuesCore.prototype.enabledChanged = function() { HuesCore.prototype.enabledChanged = function() {
this.resourceManager.rebuildEnabled(); this.resourceManager.rebuildEnabled();
} };
HuesCore.prototype.hideLists = function() { HuesCore.prototype.hideLists = function() {
this.resourceManager.hideLists(); this.resourceManager.hideLists();
} };
HuesCore.prototype.toggleSongList = function() { HuesCore.prototype.toggleSongList = function() {
this.settings.hide(); this.settings.hide();
this.resourceManager.toggleSongList(); this.resourceManager.toggleSongList();
} };
HuesCore.prototype.toggleImageList = function() { HuesCore.prototype.toggleImageList = function() {
this.settings.hide(); this.settings.hide();
this.resourceManager.toggleImageList(); this.resourceManager.toggleImageList();
} };
HuesCore.prototype.openSongSource = function() { HuesCore.prototype.openSongSource = function() {
if (this.currentSong && this.currentSong.source) { if (this.currentSong && this.currentSong.source) {
window.open(this.currentSong.source,'_blank'); window.open(this.currentSong.source,'_blank');
} }
} };
HuesCore.prototype.openImageSource = function() { HuesCore.prototype.openImageSource = function() {
if (this.currentImage && this.currentImage.source) { if (this.currentImage && this.currentImage.source) {
window.open(this.currentImage.source,'_blank'); window.open(this.currentImage.source,'_blank');
} }
} };
HuesCore.prototype.keyHandler = function(key) { HuesCore.prototype.keyHandler = function(key) {
switch (key) { switch (key) {
@ -642,12 +645,12 @@ HuesCore.prototype.keyHandler = function(key) {
return true; return true;
} }
return false; return false;
} };
HuesCore.prototype.error = function(message) { HuesCore.prototype.error = function(message) {
document.getElementById("preSub").textContent = "Error: " + message; document.getElementById("preSub").textContent = "Error: " + message;
document.getElementById("preMain").style.color = "#F00"; document.getElementById("preMain").style.color = "#F00";
} };
HuesCore.prototype.oldColours = HuesCore.prototype.oldColours =
[{'c': 0x000000, 'n': 'black'}, [{'c': 0x000000, 'n': 'black'},

@ -47,7 +47,7 @@ HuesSettings.prototype.defaultSettings = {
blackoutUI: "off", blackoutUI: "off",
playBuildups: "on", playBuildups: "on",
volume : 0.7 volume : 0.7
} };
// Don't get saved to localStorage // Don't get saved to localStorage
HuesSettings.prototype.ephemeralSettings = [ HuesSettings.prototype.ephemeralSettings = [
@ -78,7 +78,7 @@ HuesSettings.prototype.settingsCategories = {
"Audio Settings" : [ "Audio Settings" : [
"playBuildups" "playBuildups"
] ]
} };
HuesSettings.prototype.settingsOptions = { HuesSettings.prototype.settingsOptions = {
smartAlign : { smartAlign : {
@ -114,7 +114,7 @@ HuesSettings.prototype.settingsOptions = {
options : ["off", "once", "on"] options : ["off", "once", "on"]
} }
} };
function HuesSettings(defaults) { function HuesSettings(defaults) {
this.core = null; this.core = null;
@ -123,7 +123,8 @@ function HuesSettings(defaults) {
this.hide(); this.hide();
for(var attr in this.defaultSettings) { for(var attr in this.defaultSettings) {
if(defaults[attr] == undefined) { if(this.defaultSettings.hasOwnProperty(attr)) {
if(defaults[attr] === undefined) {
defaults[attr] = this.defaultSettings[attr]; defaults[attr] = this.defaultSettings[attr];
} }
// don't write to local if it's a temp settings // don't write to local if it's a temp settings
@ -134,10 +135,11 @@ function HuesSettings(defaults) {
localStorage[attr] = defaults[attr]; localStorage[attr] = defaults[attr];
} }
// populate defaults, ignoring current // populate defaults, ignoring current
if(localStorage[attr] == undefined) { if(localStorage[attr] === undefined) {
localStorage[attr] = defaults[attr]; localStorage[attr] = defaults[attr];
} }
} }
}
this.defaults = defaults; this.defaults = defaults;
@ -153,11 +155,11 @@ HuesSettings.prototype.show = function() {
if(this.core) if(this.core)
this.core.hideLists(); this.core.hideLists();
this.window.style.display = "block"; this.window.style.display = "block";
} };
HuesSettings.prototype.hide = function() { HuesSettings.prototype.hide = function() {
this.window.style.display = "none"; this.window.style.display = "none";
} };
HuesSettings.prototype.toggle = function() { HuesSettings.prototype.toggle = function() {
if(this.window.style.display == "none") { if(this.window.style.display == "none") {
@ -167,22 +169,22 @@ HuesSettings.prototype.toggle = function() {
} else { } else {
this.window.style.display = "none"; this.window.style.display = "none";
} }
} };
HuesSettings.prototype.showRespacks = function() { HuesSettings.prototype.showRespacks = function() {
this.show(); this.show();
document.getElementById("tab1").checked = true; document.getElementById("tab1").checked = true;
} };
HuesSettings.prototype.showOptions = function() { HuesSettings.prototype.showOptions = function() {
this.show(); this.show();
document.getElementById("tab2").checked = true; document.getElementById("tab2").checked = true;
} };
HuesSettings.prototype.showInfo = function() { HuesSettings.prototype.showInfo = function() {
this.show(); this.show();
document.getElementById("tab3").checked = true; document.getElementById("tab3").checked = true;
} };
HuesSettings.prototype.initUI = function() { HuesSettings.prototype.initUI = function() {
var doc = this.root.ownerDocument; var doc = this.root.ownerDocument;
@ -191,7 +193,8 @@ HuesSettings.prototype.initUI = function() {
document.getElementById("closeButton").onclick = function() {that.hide();}; document.getElementById("closeButton").onclick = function() {that.hide();};
// To order things nicely // To order things nicely
for(cat in this.settingsCategories) { for(var cat in this.settingsCategories) {
if(this.settingsCategories.hasOwnProperty(cat)) {
var catContainer = doc.createElement("div"); var catContainer = doc.createElement("div");
catContainer.textContent = cat; catContainer.textContent = cat;
catContainer.className = "settings-category"; catContainer.className = "settings-category";
@ -215,10 +218,9 @@ HuesSettings.prototype.initUI = function() {
if(localStorage[setName] == option) { if(localStorage[setName] == option) {
checkbox.checked = true; checkbox.checked = true;
} }
var that = this;
checkbox.onclick = function() { checkbox.onclick = function() {
that.set(this.name, this.value); that.set(this.name, this.value);
} };
buttonContainer.appendChild(checkbox); buttonContainer.appendChild(checkbox);
// So we can style this nicely // So we can style this nicely
var label = doc.createElement("label"); var label = doc.createElement("label");
@ -233,6 +235,7 @@ HuesSettings.prototype.initUI = function() {
this.root.appendChild(catContainer); this.root.appendChild(catContainer);
} }
} }
};
// Set a named index to its named value, returns false if name doesn't exist // Set a named index to its named value, returns false if name doesn't exist
HuesSettings.prototype.set = function(setting, value) { HuesSettings.prototype.set = function(setting, value) {
@ -249,15 +252,17 @@ HuesSettings.prototype.set = function(setting, value) {
localStorage[setting] = value; localStorage[setting] = value;
core.settingsUpdated(); core.settingsUpdated();
return true; return true;
} };
// Note: This is not defaults as per defaultSettings, but those merged with // Note: This is not defaults as per defaultSettings, but those merged with
// the defaults given in the initialiser // the defaults given in the initialiser
HuesSettings.prototype.setDefaults = function() { HuesSettings.prototype.setDefaults = function() {
for(var attr in this.defaults) { for(var attr in this.defaults) {
if(this.defaults.hasOwnProperty(attr)) {
if(this.ephemeralSettings.indexOf(attr) != -1) { if(this.ephemeralSettings.indexOf(attr) != -1) {
continue; continue;
} }
localStorage[attr] = this.defaults[attr]; localStorage[attr] = this.defaults[attr];
} }
} }
};

@ -105,11 +105,11 @@ HuesUI.prototype.initUI = function() {
var songList = document.createElement("div"); var songList = document.createElement("div");
songList.textContent = "SONGS"; songList.textContent = "SONGS";
songList.onclick = function() {that.core.toggleSongList()}; songList.onclick = function() {that.core.toggleSongList();};
this.songList = songList; this.songList = songList;
var imageList = document.createElement("div"); var imageList = document.createElement("div");
imageList.textContent = "IMAGES"; imageList.textContent = "IMAGES";
imageList.onclick = function() {that.core.toggleImageList()}; imageList.onclick = function() {that.core.toggleImageList();};
this.imageList = imageList; this.imageList = imageList;
// Beat timer, x and y blur, millis timer // Beat timer, x and y blur, millis timer
@ -130,21 +130,20 @@ HuesUI.prototype.initUI = function() {
this.settingsToggle.innerHTML = '<i class="fa fa-cog"></i>'; this.settingsToggle.innerHTML = '<i class="fa fa-cog"></i>';
this.settingsToggle.onclick = function() { this.settingsToggle.onclick = function() {
that.core.settings.toggle(); that.core.settings.toggle();
} };
this.hideToggle = document.createElement("div"); this.hideToggle = document.createElement("div");
this.hideToggle.innerHTML = "&#x25BC;"; this.hideToggle.innerHTML = "&#x25BC;";
this.hideToggle.onclick = function() { this.hideToggle.onclick = function() {
that.toggleHide(); that.toggleHide();
} };
this.listContainer = document.createElement("div"); this.listContainer = document.createElement("div");
var that = this;
this.resizeHandler = function() { this.resizeHandler = function() {
that.resize(); that.resize();
} };
} };
HuesUI.prototype.connectCore = function(core) { HuesUI.prototype.connectCore = function(core) {
this.core = core; this.core = core;
@ -153,7 +152,7 @@ HuesUI.prototype.connectCore = function(core) {
window.addEventListener('resize', this.resizeHandler); window.addEventListener('resize', this.resizeHandler);
this.resizeHandler(); this.resizeHandler();
} };
HuesUI.prototype.disconnect = function() { HuesUI.prototype.disconnect = function() {
this.core = null; this.core = null;
@ -163,17 +162,17 @@ HuesUI.prototype.disconnect = function() {
} }
window.removeEventListener('resize', this.resizeHandler); window.removeEventListener('resize', this.resizeHandler);
} };
// ONLY FOR CHANGING UI, NOT FOR "HIDE" FEATURE // ONLY FOR CHANGING UI, NOT FOR "HIDE" FEATURE
HuesUI.prototype.show = function() { HuesUI.prototype.show = function() {
this.root.style.display = "block"; this.root.style.display = "block";
} };
// ONLY FOR CHANGING UI, NOT FOR "HIDE" FEATURE // ONLY FOR CHANGING UI, NOT FOR "HIDE" FEATURE
HuesUI.prototype.hide = function() { HuesUI.prototype.hide = function() {
this.root.style.display = "none"; this.root.style.display = "none";
} };
HuesUI.prototype.toggleHide = function() { HuesUI.prototype.toggleHide = function() {
this.hidden = !this.hidden; this.hidden = !this.hidden;
@ -182,13 +181,13 @@ HuesUI.prototype.toggleHide = function() {
} else { } else {
this.root.className = this.constructor.name; this.root.className = this.constructor.name;
} }
} };
// May do nothing, may scale elements if needed etc etc // May do nothing, may scale elements if needed etc etc
HuesUI.prototype.resize = function() {} HuesUI.prototype.resize = function() {};
HuesUI.prototype.modeUpdated = function() {} HuesUI.prototype.modeUpdated = function() {};
HuesUI.prototype.beat = function() {} HuesUI.prototype.beat = function() {};
HuesUI.prototype.updateVolume = function(vol) {} HuesUI.prototype.updateVolume = function(vol) {};
HuesUI.prototype.setSongText = function() { HuesUI.prototype.setSongText = function() {
var song = this.core.currentSong; var song = this.core.currentSong;
@ -198,7 +197,7 @@ HuesUI.prototype.setSongText = function() {
this.songLink.textContent = song.title.toUpperCase(); this.songLink.textContent = song.title.toUpperCase();
this.songLink.href = song.source; this.songLink.href = song.source;
} };
HuesUI.prototype.setImageText = function() { HuesUI.prototype.setImageText = function() {
var image = this.core.currentImage; var image = this.core.currentImage;
@ -210,37 +209,37 @@ HuesUI.prototype.setImageText = function() {
this.imageLink.textContent = name.toUpperCase(); this.imageLink.textContent = name.toUpperCase();
this.imageLink.href = image.source ? image.source : ""; this.imageLink.href = image.source ? image.source : "";
} };
HuesUI.prototype.setColourText = function(colour) { HuesUI.prototype.setColourText = function() {
var colour = this.core.colours[this.core.colourIndex]; var colour = this.core.colours[this.core.colourIndex];
this.hueName.textContent = colour.n.toUpperCase(); this.hueName.textContent = colour.n.toUpperCase();
} };
HuesUI.prototype.blurUpdated = function(x, y) { HuesUI.prototype.blurUpdated = function(x, y) {
x = Math.floor(x * 0xFF); x = Math.floor(x * 0xFF);
y = Math.floor(y * 0xFF);; y = Math.floor(y * 0xFF);
this.xBlur.textContent = "X=" + this.intToHex2(x); this.xBlur.textContent = "X=" + this.intToHex2(x);
this.yBlur.textContent = "Y=" + this.intToHex2(y); this.yBlur.textContent = "Y=" + this.intToHex2(y);
} };
HuesUI.prototype.updateTime = function(time) { HuesUI.prototype.updateTime = function(time) {
time = Math.floor(time * 1000); time = Math.floor(time * 1000);
this.timer.textContent = "T=" + this.intToHex4(time); this.timer.textContent = "T=" + this.intToHex4(time);
} };
HuesUI.prototype.intToHex2 = function(num) { HuesUI.prototype.intToHex2 = function(num) {
return '$0x' + ("00"+num.toString(16)).slice(-2); return '$0x' + ("00"+num.toString(16)).slice(-2);
} };
HuesUI.prototype.intToHex3 = function(num) { HuesUI.prototype.intToHex3 = function(num) {
return '$0x' + ("000"+num.toString(16)).slice(-3); return '$0x' + ("000"+num.toString(16)).slice(-3);
} };
HuesUI.prototype.intToHex4 = function(num) { HuesUI.prototype.intToHex4 = function(num) {
return '$0x' + ("0000"+num.toString(16)).slice(-4); return '$0x' + ("0000"+num.toString(16)).slice(-4);
} };
/* /*
Individual UIs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Individual UIs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -258,6 +257,7 @@ function RetroUI() {
HuesUI.call(this); HuesUI.call(this);
} }
RetroUI.prototype = Object.create(HuesUI.prototype); RetroUI.prototype = Object.create(HuesUI.prototype);
RetroUI.prototype.constructor = RetroUI; RetroUI.prototype.constructor = RetroUI;
@ -337,12 +337,12 @@ RetroUI.prototype.initUI = function() {
this.hideRestore.innerHTML = "&#x25B2;"; this.hideRestore.innerHTML = "&#x25B2;";
this.hideRestore.onclick = function() { this.hideRestore.onclick = function() {
that.toggleHide(); that.toggleHide();
} };
this.root.appendChild(this.hideRestore); this.root.appendChild(this.hideRestore);
this.listContainer.className = "hues-r-listcontainer"; this.listContainer.className = "hues-r-listcontainer";
this.root.appendChild(this.listContainer); this.root.appendChild(this.listContainer);
} };
RetroUI.prototype.toggleHide = function(stylename) { RetroUI.prototype.toggleHide = function(stylename) {
stylename = stylename ? stylename : 'r'; stylename = stylename ? stylename : 'r';
@ -358,18 +358,18 @@ RetroUI.prototype.toggleHide = function(stylename) {
this.hideRestore.className = "hues-r-hiderestore hidden"; this.hideRestore.className = "hues-r-hiderestore hidden";
} }
this.hidden = !this.hidden; this.hidden = !this.hidden;
} };
RetroUI.prototype.connectCore = function(core) { RetroUI.prototype.connectCore = function(core) {
HuesUI.prototype.connectCore.call(this, core); HuesUI.prototype.connectCore.call(this, core);
this.version.textContent = "V=$" + core.version; this.version.textContent = "V=$" + core.version;
this.modeUpdated(); this.modeUpdated();
} };
RetroUI.prototype.modeUpdated = function() { RetroUI.prototype.modeUpdated = function() {
this.mode.textContent = "M=" + this.core.getCurrentMode(); this.mode.textContent = "M=" + this.core.getCurrentMode();
} };
RetroUI.prototype.setImageText = function() { RetroUI.prototype.setImageText = function() {
var image = this.core.currentImage; var image = this.core.currentImage;
@ -379,13 +379,13 @@ RetroUI.prototype.setImageText = function() {
this.imageLink.textContent = "I=" + image.name.toUpperCase(); this.imageLink.textContent = "I=" + image.name.toUpperCase();
this.imageLink.href = image.source; this.imageLink.href = image.source;
} };
RetroUI.prototype.setColourText = function(colour) { RetroUI.prototype.setColourText = function(colour) {
HuesUI.prototype.setColourText.call(this, colour); HuesUI.prototype.setColourText.call(this, colour);
this.colourIndex.textContent = "C=" + this.intToHex2(this.core.colourIndex); this.colourIndex.textContent = "C=" + this.intToHex2(this.core.colourIndex);
} };
RetroUI.prototype.beat = function() { RetroUI.prototype.beat = function() {
var beats = this.core.getBeatString(); var beats = this.core.getBeatString();
@ -394,7 +394,7 @@ RetroUI.prototype.beat = function() {
this.beatBar.textContent = ">>" + rest; this.beatBar.textContent = ">>" + rest;
this.beatCount.textContent = "B=" + this.intToHex3(this.core.getSafeBeatIndex()); this.beatCount.textContent = "B=" + this.intToHex3(this.core.getSafeBeatIndex());
} };
function WeedUI() { function WeedUI() {
RetroUI.call(this); RetroUI.call(this);
@ -402,13 +402,14 @@ function WeedUI() {
this.xVariance = 10; this.xVariance = 10;
this.yVariance = 20; this.yVariance = 20;
} }
WeedUI.prototype = Object.create(RetroUI.prototype); WeedUI.prototype = Object.create(RetroUI.prototype);
WeedUI.prototype.constructor = WeedUI; WeedUI.prototype.constructor = WeedUI;
WeedUI.prototype.initUI = function() { WeedUI.prototype.initUI = function() {
RetroUI.prototype.initUI.call(this); RetroUI.prototype.initUI.call(this);
this.container.removeChild(this.beatBar) this.container.removeChild(this.beatBar);
this.controls.className = "hues-w-controls"; this.controls.className = "hues-w-controls";
this.subControls.className = "hues-w-subcontrols"; this.subControls.className = "hues-w-subcontrols";
@ -430,7 +431,7 @@ WeedUI.prototype.initUI = function() {
this.imageModeManual.textContent = "ONE"; this.imageModeManual.textContent = "ONE";
this.imageModeAuto.textContent = "MANY"; this.imageModeAuto.textContent = "MANY";
} };
WeedUI.prototype.toggleHide = function() { WeedUI.prototype.toggleHide = function() {
if(this.hidden) { if(this.hidden) {
@ -439,7 +440,7 @@ WeedUI.prototype.toggleHide = function() {
this.beatBar.className = "hues-w-beatbar hidden"; this.beatBar.className = "hues-w-beatbar hidden";
} }
RetroUI.prototype.toggleHide.call(this, 'w'); RetroUI.prototype.toggleHide.call(this, 'w');
} };
WeedUI.prototype.beat = function() { WeedUI.prototype.beat = function() {
var beats = this.core.getBeatString(); var beats = this.core.getBeatString();
@ -464,18 +465,18 @@ WeedUI.prototype.beat = function() {
this.root.appendChild(beatCenter); this.root.appendChild(beatCenter);
window.setTimeout(this.getRemoveBeat(beatCenter), 1500); window.setTimeout(this.getRemoveBeat(beatCenter), 1500);
} }
} };
WeedUI.prototype.round10 = function(num) { WeedUI.prototype.round10 = function(num) {
return Math.round(num * 10) / 10; return Math.round(num * 10) / 10;
} };
WeedUI.prototype.getRemoveBeat = function(element) { WeedUI.prototype.getRemoveBeat = function(element) {
var that = this; var that = this;
return function() { return function() {
that.root.removeChild(element); that.root.removeChild(element);
}; };
} };
function ModernUI() { function ModernUI() {
this.beatBar = null; this.beatBar = null;
@ -497,6 +498,7 @@ function ModernUI() {
this.hidden = 0; // we have a 3 stage hide this.hidden = 0; // we have a 3 stage hide
} }
ModernUI.prototype = Object.create(HuesUI.prototype); ModernUI.prototype = Object.create(HuesUI.prototype);
ModernUI.prototype.constructor = ModernUI; ModernUI.prototype.constructor = ModernUI;
@ -542,7 +544,7 @@ ModernUI.prototype.initUI = function() {
label.textContent = "VOL"; label.textContent = "VOL";
label.className = "hues-m-vol-label"; label.className = "hues-m-vol-label";
label.onclick = function() { label.onclick = function() {
that.core.soundManager.toggleMute() that.core.soundManager.toggleMute();
}; };
volBar.appendChild(label); volBar.appendChild(label);
this.volLabel = label; this.volLabel = label;
@ -552,7 +554,7 @@ ModernUI.prototype.initUI = function() {
infoToggle.className = "hues-m-question"; infoToggle.className = "hues-m-question";
infoToggle.onclick = function() { infoToggle.onclick = function() {
that.core.settings.showInfo(); that.core.settings.showInfo();
} };
volCluster.appendChild(infoToggle); volCluster.appendChild(infoToggle);
var input = document.createElement("input"); var input = document.createElement("input");
@ -564,7 +566,7 @@ ModernUI.prototype.initUI = function() {
this.volInput = input; this.volInput = input;
input.oninput = function() { input.oninput = function() {
that.core.soundManager.setVolume(parseFloat(input.value)); that.core.soundManager.setVolume(parseFloat(input.value));
} };
var rightBox = document.createElement("div"); var rightBox = document.createElement("div");
rightBox.className = "hues-m-rightbox"; rightBox.className = "hues-m-rightbox";
@ -578,8 +580,8 @@ ModernUI.prototype.initUI = function() {
var songControls = document.createElement("div"); var songControls = document.createElement("div");
songControls.className = "hues-m-controlbuttons"; songControls.className = "hues-m-controlbuttons";
this.songPrev.className = "hues-m-prevbutton" this.songPrev.className = "hues-m-prevbutton";
this.songNext.className = "hues-m-nextbutton" this.songNext.className = "hues-m-nextbutton";
var songShuffle = document.createElement("div"); var songShuffle = document.createElement("div");
songShuffle.innerHTML = '<i class="fa fa-random"></i>'; songShuffle.innerHTML = '<i class="fa fa-random"></i>';
songShuffle.className = "hues-m-actbutton"; songShuffle.className = "hues-m-actbutton";
@ -619,7 +621,7 @@ ModernUI.prototype.initUI = function() {
leftInfo.appendChild(this.yBlur); leftInfo.appendChild(this.yBlur);
rightInfo.appendChild(this.timer); rightInfo.appendChild(this.timer);
rightInfo.appendChild(this.beatCount); rightInfo.appendChild(this.beatCount);
this.rightInfo = rightInfo this.rightInfo = rightInfo;
this.leftInfo = leftInfo; this.leftInfo = leftInfo;
controls.appendChild(leftInfo); controls.appendChild(leftInfo);
controls.appendChild(rightInfo); controls.appendChild(rightInfo);
@ -648,12 +650,12 @@ ModernUI.prototype.initUI = function() {
this.hideRestore.className = "hues-m-hiderestore"; this.hideRestore.className = "hues-m-hiderestore";
this.hideRestore.onclick = function() { this.hideRestore.onclick = function() {
that.toggleHide(); that.toggleHide();
} };
this.root.appendChild(this.hideRestore); this.root.appendChild(this.hideRestore);
this.listContainer.className = "hues-m-listcontainer"; this.listContainer.className = "hues-m-listcontainer";
this.root.appendChild(this.listContainer); this.root.appendChild(this.listContainer);
} };
ModernUI.prototype.toggleHide = function() { ModernUI.prototype.toggleHide = function() {
this.beatBar.className = "hues-m-beatbar"; this.beatBar.className = "hues-m-beatbar";
@ -669,16 +671,16 @@ ModernUI.prototype.toggleHide = function() {
this.hideRestore.className = "hues-m-hiderestore hidden"; this.hideRestore.className = "hues-m-hiderestore hidden";
} }
this.hidden = (this.hidden+1) % 3; this.hidden = (this.hidden+1) % 3;
} };
ModernUI.prototype.updateVolume = function(vol) { ModernUI.prototype.updateVolume = function(vol) {
this.volInput.value = vol; this.volInput.value = vol;
if(vol == 0) { if(vol === 0) {
this.volLabel.textContent = "(VOL)"; this.volLabel.textContent = "(VOL)";
} else { } else {
this.volLabel.textContent = "VOL"; this.volLabel.textContent = "VOL";
};
} }
};
ModernUI.prototype.modeUpdated = function() { ModernUI.prototype.modeUpdated = function() {
if(this.core.isFullAuto) { if(this.core.isFullAuto) {
@ -686,7 +688,7 @@ ModernUI.prototype.modeUpdated = function() {
} else { } else {
this.imageMode.innerHTML = "&#9654;"; // PLAY this.imageMode.innerHTML = "&#9654;"; // PLAY
} }
} };
ModernUI.prototype.beat = function() { ModernUI.prototype.beat = function() {
var beats = this.core.getBeatString(); var beats = this.core.getBeatString();
@ -707,30 +709,30 @@ ModernUI.prototype.beat = function() {
this.beatCenter.appendChild(span); this.beatCenter.appendChild(span);
} }
this.beatCount.textContent = "B=" + this.intToHex4(this.core.getSafeBeatIndex()); this.beatCount.textContent = "B=" + this.intToHex4(this.core.getSafeBeatIndex());
} };
ModernUI.prototype.resize = function() { ModernUI.prototype.resize = function() {
this.resizeSong(); this.resizeSong();
this.resizeImage(); this.resizeImage();
} };
ModernUI.prototype.resizeElement = function(el, parent) { ModernUI.prototype.resizeElement = function(el, parent) {
el.className = "" el.className = "";
if (el.offsetWidth > parent.clientWidth) { if (el.offsetWidth > parent.clientWidth) {
el.className = "small" el.className = "small";
} }
if (el.offsetWidth > parent.clientWidth) { if (el.offsetWidth > parent.clientWidth) {
el.className = "x-small" el.className = "x-small";
}
} }
};
ModernUI.prototype.resizeSong = function() { ModernUI.prototype.resizeSong = function() {
this.resizeElement(this.songLink, this.songName); this.resizeElement(this.songLink, this.songName);
} };
ModernUI.prototype.resizeImage = function() { ModernUI.prototype.resizeImage = function() {
this.resizeElement(this.imageLink, this.imageName); this.resizeElement(this.imageLink, this.imageName);
} };
ModernUI.prototype.setSongText = function() { ModernUI.prototype.setSongText = function() {
HuesUI.prototype.setSongText.call(this); HuesUI.prototype.setSongText.call(this);
@ -739,7 +741,7 @@ ModernUI.prototype.setSongText = function() {
return; return;
this.resizeSong(); this.resizeSong();
} };
ModernUI.prototype.setImageText = function() { ModernUI.prototype.setImageText = function() {
HuesUI.prototype.setImageText.call(this); HuesUI.prototype.setImageText.call(this);
@ -748,7 +750,7 @@ ModernUI.prototype.setImageText = function() {
return; return;
this.resizeImage(); this.resizeImage();
} };
function XmasUI() { function XmasUI() {
ModernUI.call(this); ModernUI.call(this);
@ -758,8 +760,7 @@ function XmasUI() {
this.controls.removeChild(this.rightInfo); this.controls.removeChild(this.rightInfo);
this.controls.removeChild(this.leftInfo); this.controls.removeChild(this.leftInfo);
this.leftBox = this.rightBox = this.hueName = this.xBlur = this.yBlur this.leftBox = this.rightBox = this.hueName = this.xBlur = this.yBlur = this.timer = null;
= this.timer = null;
this.controls.className = "hues-x-controls"; this.controls.className = "hues-x-controls";
this.beatBar.className = "hues-x-beatbar"; this.beatBar.className = "hues-x-beatbar";
@ -810,39 +811,40 @@ function XmasUI() {
wires.appendChild(bottomHelper); wires.appendChild(bottomHelper);
this.root.appendChild(wires); this.root.appendChild(wires);
} }
XmasUI.prototype = Object.create(ModernUI.prototype); XmasUI.prototype = Object.create(ModernUI.prototype);
XmasUI.prototype.constructor = XmasUI; XmasUI.prototype.constructor = XmasUI;
XmasUI.prototype.connectCore = function(core) { XmasUI.prototype.connectCore = function(core) {
HuesUI.prototype.connectCore.call(this, core); HuesUI.prototype.connectCore.call(this, core);
this.core.renderer.startSnow(); this.core.renderer.startSnow();
} };
XmasUI.prototype.disconnect = function() { XmasUI.prototype.disconnect = function() {
this.core.renderer.stopSnow(); this.core.renderer.stopSnow();
HuesUI.prototype.disconnect.call(this); HuesUI.prototype.disconnect.call(this);
} };
XmasUI.prototype.lightOn = function(light) { XmasUI.prototype.lightOn = function(light) {
light.on.className = "hues-x-lighton"; light.on.className = "hues-x-lighton";
light.off.className = "hues-x-lightoff"; light.off.className = "hues-x-lightoff";
} };
XmasUI.prototype.lightOff = function(light) { XmasUI.prototype.lightOff = function(light) {
light.on.className = "hues-x-lighton off"; light.on.className = "hues-x-lighton off";
light.off.className = "hues-x-lightoff off"; light.off.className = "hues-x-lightoff off";
} };
XmasUI.prototype.lightFadeOut = function(light) { XmasUI.prototype.lightFadeOut = function(light) {
light.on.className = "hues-x-lighton hues-x-fade off"; light.on.className = "hues-x-lighton hues-x-fade off";
light.off.className = "hues-x-lightoff hues-x-fade off"; light.off.className = "hues-x-lightoff hues-x-fade off";
} };
XmasUI.prototype.lightRecolour = function(light) { XmasUI.prototype.lightRecolour = function(light) {
var hue = Math.random() * 360; var hue = Math.random() * 360;
light.bulb.style.filter = "hue-rotate(" + hue + "deg)"; light.bulb.style.filter = "hue-rotate(" + hue + "deg)";
light.bulb.style.webkitFilter = "hue-rotate(" + hue + "deg)"; light.bulb.style.webkitFilter = "hue-rotate(" + hue + "deg)";
} };
XmasUI.prototype.randomLight = function(light) { XmasUI.prototype.randomLight = function(light) {
if(Math.random() >= 0.5) { if(Math.random() >= 0.5) {
@ -850,7 +852,7 @@ XmasUI.prototype.randomLight = function(light) {
} else { } else {
this.lightOff(light); this.lightOff(light);
} }
} };
XmasUI.prototype.newLight = function(l, parent) { XmasUI.prototype.newLight = function(l, parent) {
var light = document.createElement("div"); var light = document.createElement("div");
@ -870,7 +872,7 @@ XmasUI.prototype.newLight = function(l, parent) {
this.randomLight(light); this.randomLight(light);
this.lightRecolour(light); this.lightRecolour(light);
return light; return light;
} };
XmasUI.prototype.beat = function() { XmasUI.prototype.beat = function() {
ModernUI.prototype.beat.call(this); ModernUI.prototype.beat.call(this);
@ -890,7 +892,7 @@ XmasUI.prototype.beat = function() {
} }
} }
} }
} };
XmasUI.prototype.toggleHide = function() { XmasUI.prototype.toggleHide = function() {
this.beatBar.className = "hues-x-beatbar"; this.beatBar.className = "hues-x-beatbar";
@ -904,7 +906,7 @@ XmasUI.prototype.toggleHide = function() {
this.controls.className = "hues-x-controls hidden"; this.controls.className = "hues-x-controls hidden";
} }
this.hidden = (this.hidden+1) % 3; this.hidden = (this.hidden+1) % 3;
} };
XmasUI.prototype.setColourText = function(colour) {}; XmasUI.prototype.setColourText = function(colour) {};
XmasUI.prototype.blurUpdated = function(x, y) {}; XmasUI.prototype.blurUpdated = function(x, y) {};
@ -928,7 +930,7 @@ var xleft = [
{"angle":107.530202659,"x":50.45,"y":1068.75}, {"angle":107.530202659,"x":50.45,"y":1068.75},
{"angle":74.9981580491,"x":45.75,"y":1158.5}, {"angle":74.9981580491,"x":45.75,"y":1158.5},
{"angle":88.3307935055,"x":35.85,"y":1238.55} {"angle":88.3307935055,"x":35.85,"y":1238.55}
] ];
var xright = [ var xright = [
{"angle":120.001009518,"x":33.3,"y":-29.75}, {"angle":120.001009518,"x":33.3,"y":-29.75},
{"angle":90.0026227926,"x":35.35,"y":53.65}, {"angle":90.0026227926,"x":35.35,"y":53.65},
@ -948,7 +950,7 @@ var xright = [
{"angle":76.1887724128,"x":11.95,"y":1062.25}, {"angle":76.1887724128,"x":11.95,"y":1062.25},
{"angle":87.4690563489,"x":40.45,"y":1119.9}, {"angle":87.4690563489,"x":40.45,"y":1119.9},
{"angle":102.46813454,"x":20.9,"y":1193.85} {"angle":102.46813454,"x":20.9,"y":1193.85}
] ];
var xbottom = [ var xbottom = [
{"angle":32.5804579323,"x":110.35,"y":-12.1}, {"angle":32.5804579323,"x":110.35,"y":-12.1},
{"angle":3.28979777069,"x":168.05,"y":-5.55}, {"angle":3.28979777069,"x":168.05,"y":-5.55},
@ -984,4 +986,4 @@ var xbottom = [
{"angle":17.6989154099,"x":2540.2,"y":28.5}, {"angle":17.6989154099,"x":2540.2,"y":28.5},
{"angle":-18.378894807,"x":2627.55,"y":24.9}, {"angle":-18.378894807,"x":2627.55,"y":24.9},
{"angle":-4.561224264,"x":2710.4,"y":14.4} {"angle":-4.561224264,"x":2710.4,"y":14.4}
] ];

@ -34,7 +34,7 @@ function Resources(core) {
this.toLoad = 0; this.toLoad = 0;
this.progressState = []; this.progressState = [];
this.rToLoad = [] this.rToLoad = [];
this.loadFinishCallback = null; this.loadFinishCallback = null;
this.progressCallback = null; this.progressCallback = null;
@ -105,15 +105,15 @@ Resources.prototype.addAll = function(urls, callback, progressCallback) {
} }
}, this.createProgCallback(i)); }, this.createProgCallback(i));
} }
} };
Resources.prototype.createProgCallback = function(i) { Resources.prototype.createProgCallback = function(i) {
var that = this; var that = this;
return function(progress, pack) { return function(progress, pack) {
that.progressState[i] = progress; that.progressState[i] = progress;
that.updateProgress(pack); that.updateProgress(pack);
} };
} };
Resources.prototype.updateProgress = function(pack) { Resources.prototype.updateProgress = function(pack) {
var total = 0; var total = 0;
@ -122,7 +122,7 @@ Resources.prototype.updateProgress = function(pack) {
} }
total /= this.progressState.length; total /= this.progressState.length;
this.progressCallback(total, pack); this.progressCallback(total, pack);
} };
Resources.prototype.addPack = function(pack) { Resources.prototype.addPack = function(pack) {
console.log("Added", pack.name, "to respacks"); console.log("Added", pack.name, "to respacks");
@ -140,12 +140,12 @@ Resources.prototype.addPack = function(pack) {
}, },
this.selectPackCallback(id) this.selectPackCallback(id)
); );
} };
Resources.prototype.addResourcesToArrays = function(pack) { Resources.prototype.addResourcesToArrays = function(pack) {
this.allImages = this.allImages.concat(pack.images); this.allImages = this.allImages.concat(pack.images);
this.allSongs = this.allSongs.concat(pack.songs); this.allSongs = this.allSongs.concat(pack.songs);
} };
Resources.prototype.rebuildArrays = function() { Resources.prototype.rebuildArrays = function() {
this.allSongs = []; this.allSongs = [];
@ -155,7 +155,7 @@ Resources.prototype.rebuildArrays = function() {
for(var i = 0; i < this.resourcePacks.length; i++) { for(var i = 0; i < this.resourcePacks.length; i++) {
this.addResourcesToArrays(this.resourcePacks[i]); this.addResourcesToArrays(this.resourcePacks[i]);
} }
} };
Resources.prototype.rebuildEnabled = function() { Resources.prototype.rebuildEnabled = function() {
this.enabledSongs = []; this.enabledSongs = [];
@ -163,7 +163,7 @@ Resources.prototype.rebuildEnabled = function() {
for(var i = 0; i < this.resourcePacks.length; i++) { for(var i = 0; i < this.resourcePacks.length; i++) {
var pack = this.resourcePacks[i]; var pack = this.resourcePacks[i];
if (pack["enabled"] != true) { if (pack.enabled !== true) {
continue; continue;
} }
for(var j = 0; j < pack.songs.length; j++) { for(var j = 0; j < pack.songs.length; j++) {
@ -182,11 +182,11 @@ Resources.prototype.rebuildEnabled = function() {
var songList = this.enabledSongList; var songList = this.enabledSongList;
while(songList.firstElementChild) { while(songList.firstElementChild) {
songList.removeChild(songList.firstElementChild) songList.removeChild(songList.firstElementChild);
} }
var imageList = this.enabledImageList; var imageList = this.enabledImageList;
while(imageList.firstElementChild) { while(imageList.firstElementChild) {
imageList.removeChild(imageList.firstElementChild) imageList.removeChild(imageList.firstElementChild);
} }
for(var i = 0; i < this.enabledSongs.length; i++) { for(var i = 0; i < this.enabledSongs.length; i++) {
var song = this.enabledSongs[i]; var song = this.enabledSongs[i];
@ -197,14 +197,14 @@ Resources.prototype.rebuildEnabled = function() {
this.appendSimpleListItem(image.name, imageList, this.selectImageCallback(i)); this.appendSimpleListItem(image.name, imageList, this.selectImageCallback(i));
} }
this.updateTotals(); this.updateTotals();
} };
Resources.prototype.playSongCallback = function(index) { Resources.prototype.playSongCallback = function(index) {
var that = this; var that = this;
return function() { return function() {
that.core.setSong(index); that.core.setSong(index);
}; };
} };
Resources.prototype.selectImageCallback = function(index) { Resources.prototype.selectImageCallback = function(index) {
var that = this; var that = this;
@ -212,7 +212,7 @@ Resources.prototype.selectImageCallback = function(index) {
that.core.setImage(index); that.core.setImage(index);
that.core.setIsFullAuto(false); that.core.setIsFullAuto(false);
}; };
} };
Resources.prototype.removePack = function(pack) { Resources.prototype.removePack = function(pack) {
var index = this.resourcePacks.indexOf(pack); var index = this.resourcePacks.indexOf(pack);
@ -220,20 +220,20 @@ Resources.prototype.removePack = function(pack) {
this.resourcePacks.splice(index, 1); this.resourcePacks.splice(index, 1);
this.rebuildArrays(); this.rebuildArrays();
} }
} };
Resources.prototype.removeAllPacks = function() { Resources.prototype.removeAllPacks = function() {
this.resourcePacks = []; this.resourcePacks = [];
this.rebuildArrays(); this.rebuildArrays();
} };
Resources.prototype.getSongNames = function() { Resources.prototype.getSongNames = function() {
var names = [] var names = [];
for(var i = 0; i < this.allSongs.length; i++) { for(var i = 0; i < this.allSongs.length; i++) {
names.push(this.allSongs[i]); names.push(this.allSongs[i]);
} }
return names; return names;
} };
Resources.prototype.loadLocal = function() { Resources.prototype.loadLocal = function() {
console.log("Loading local zip(s)"); console.log("Loading local zip(s)");
@ -242,7 +242,7 @@ Resources.prototype.loadLocal = function() {
this.fileParseQueue.push(files[i]); this.fileParseQueue.push(files[i]);
} }
this.parseLocalQueue(); this.parseLocalQueue();
} };
Resources.prototype.parseLocalQueue = function(recursing) { Resources.prototype.parseLocalQueue = function(recursing) {
var that = this; var that = this;
@ -265,7 +265,7 @@ Resources.prototype.parseLocalQueue = function(recursing) {
console.log("Local respack parsing complete"); console.log("Local respack parsing complete");
this.currentlyParsing = false; this.currentlyParsing = false;
} }
} };
Resources.prototype.localProgress = function(progress, respack) { Resources.prototype.localProgress = function(progress, respack) {
this.packsView.progressStatus.textContent = "Processing..."; this.packsView.progressStatus.textContent = "Processing...";
@ -274,7 +274,7 @@ Resources.prototype.localProgress = function(progress, respack) {
this.packsView.progressCurrent.textContent = respack.filesLoaded; this.packsView.progressCurrent.textContent = respack.filesLoaded;
this.packsView.progressTop.textContent = respack.filesToLoad; this.packsView.progressTop.textContent = respack.filesToLoad;
this.packsView.progressPercent.textContent = Math.round(progress * 100) + "%"; this.packsView.progressPercent.textContent = Math.round(progress * 100) + "%";
} };
Resources.prototype.localComplete = function(progress) { Resources.prototype.localComplete = function(progress) {
var progStat = this.packsView.progressStatus; var progStat = this.packsView.progressStatus;
@ -285,7 +285,7 @@ Resources.prototype.localComplete = function(progress) {
this.packsView.progressCurrent.textContent = "0b"; this.packsView.progressCurrent.textContent = "0b";
this.packsView.progressTop.textContent = "0b"; this.packsView.progressTop.textContent = "0b";
this.packsView.progressPercent.textContent = "0%"; this.packsView.progressPercent.textContent = "0%";
} };
Resources.prototype.initUI = function() { Resources.prototype.initUI = function() {
this.root = document.getElementById("huesResources"); this.root = document.getElementById("huesResources");
@ -302,11 +302,14 @@ Resources.prototype.initUI = function() {
packList.className = "res-list"; packList.className = "res-list";
packList.id = "res-packlist"; packList.id = "res-packlist";
this.packsView.respackList = packList; this.packsView.respackList = packList;
// so we don't use it out of scope in the next if
var remoteHeader = null;
var remoteList = null;
if(!this.core.settings.defaults.disableRemoteResources) { if(!this.core.settings.defaults.disableRemoteResources) {
var remoteHeader = document.createElement("div"); remoteHeader = document.createElement("div");
remoteHeader.textContent = "Remote respacks"; remoteHeader.textContent = "Remote respacks";
remoteHeader.className = "res-header"; remoteHeader.className = "res-header";
var remoteList = document.createElement("div"); remoteList = document.createElement("div");
remoteList.className = "res-list"; remoteList.className = "res-list";
remoteList.id = "res-remotelist"; remoteList.id = "res-remotelist";
this.appendSimpleListItem("Click to load the list", remoteList, this.appendSimpleListItem("Click to load the list", remoteList,
@ -397,7 +400,7 @@ Resources.prototype.initUI = function() {
packInfo.appendChild(packSize); packInfo.appendChild(packSize);
var packDesc = document.createElement("div"); var packDesc = document.createElement("div");
packDesc.id = "res-packdesc"; packDesc.id = "res-packdesc";
packDesc.textContent = "<no description>" packDesc.textContent = "<no description>";
var packTabs = document.createElement("div"); var packTabs = document.createElement("div");
packTabs.id = "res-packtabs"; packTabs.id = "res-packtabs";
@ -424,7 +427,7 @@ Resources.prototype.initUI = function() {
imageCount.htmlFor = "res-imagetab"; imageCount.htmlFor = "res-imagetab";
packTabs.appendChild(imageCheck); packTabs.appendChild(imageCheck);
packTabs.appendChild(imageCount); packTabs.appendChild(imageCount);
;
var songList = document.createElement("div"); var songList = document.createElement("div");
songList.id = "res-songlist"; songList.id = "res-songlist";
songList.className = "res-list"; songList.className = "res-list";
@ -507,12 +510,12 @@ Resources.prototype.initUI = function() {
this.listView.appendChild(this.enabledSongList); this.listView.appendChild(this.enabledSongList);
this.listView.appendChild(this.enabledImageList); this.listView.appendChild(this.enabledImageList);
} };
Resources.prototype.hideLists = function() { Resources.prototype.hideLists = function() {
this.enabledSongList.className = "hidden"; this.enabledSongList.className = "hidden";
this.enabledImageList.className = "hidden"; this.enabledImageList.className = "hidden";
} };
Resources.prototype.toggleSongList = function() { Resources.prototype.toggleSongList = function() {
if(this.enabledSongList.className == "hidden") { if(this.enabledSongList.className == "hidden") {
@ -521,7 +524,7 @@ Resources.prototype.toggleSongList = function() {
this.enabledSongList.className = "hidden"; this.enabledSongList.className = "hidden";
} }
this.enabledImageList.className = "hidden"; this.enabledImageList.className = "hidden";
} };
Resources.prototype.toggleImageList = function() { Resources.prototype.toggleImageList = function() {
if(this.enabledImageList.className == "hidden") { if(this.enabledImageList.className == "hidden") {
@ -530,18 +533,18 @@ Resources.prototype.toggleImageList = function() {
this.enabledImageList.className = "hidden"; this.enabledImageList.className = "hidden";
} }
this.enabledSongList.className = "hidden"; this.enabledSongList.className = "hidden";
} };
Resources.prototype.updateTotals = function() { Resources.prototype.updateTotals = function() {
this.packView.totalSongs.textContent = this.packView.totalSongs.textContent =
this.enabledSongs.length + "/" + this.allSongs.length; this.enabledSongs.length + "/" + this.allSongs.length;
this.packView.totalImages.textContent = this.packView.totalImages.textContent =
this.enabledImages.length + "/" + this.allImages.length; this.enabledImages.length + "/" + this.allImages.length;
} };
Resources.prototype.truncateNum = function(num) { Resources.prototype.truncateNum = function(num) {
return Math.round(num * 100) / 100; return Math.round(num * 100) / 100;
} };
Resources.prototype.selectPack = function(id) { Resources.prototype.selectPack = function(id) {
var pack = this.resourcePacks[id]; var pack = this.resourcePacks[id];
@ -566,10 +569,10 @@ Resources.prototype.selectPack = function(id) {
var songList = this.packView.songList; var songList = this.packView.songList;
var imageList = this.packView.imageList; var imageList = this.packView.imageList;
while (songList.firstElementChild) { while (songList.firstElementChild) {
songList.removeChild(songList.firstElementChild) songList.removeChild(songList.firstElementChild);
} }
while (imageList.firstElementChild) { while (imageList.firstElementChild) {
imageList.removeChild(imageList.firstElementChild) imageList.removeChild(imageList.firstElementChild);
} }
for(var i = 0; i < pack.songs.length; i++) { for(var i = 0; i < pack.songs.length; i++) {
@ -587,12 +590,12 @@ Resources.prototype.selectPack = function(id) {
this.clickResourceCallback(image, false), this.clickResourceCallback(image, false),
image.enabled); image.enabled);
} }
} };
Resources.prototype.selectPackCallback = function(id) { Resources.prototype.selectPackCallback = function(id) {
var that = this; var that = this;
return function() {that.selectPack(id)}; return function() {that.selectPack(id);};
} };
Resources.prototype.selectResourceCallback = function(res) { Resources.prototype.selectResourceCallback = function(res) {
var that = this; var that = this;
@ -600,7 +603,7 @@ Resources.prototype.selectResourceCallback = function(res) {
res.enabled = this.checked; res.enabled = this.checked;
that.rebuildEnabled(); that.rebuildEnabled();
}; };
} };
Resources.prototype.clickResourceCallback = function(res, isSong) { Resources.prototype.clickResourceCallback = function(res, isSong) {
var that = this; var that = this;
@ -618,7 +621,7 @@ Resources.prototype.clickResourceCallback = function(res, isSong) {
that.core.setIsFullAuto(false); that.core.setIsFullAuto(false);
} }
}; };
} };
Resources.prototype.getEnabledTabContents = function() { Resources.prototype.getEnabledTabContents = function() {
var pack = this.packView.pack; var pack = this.packView.pack;
@ -632,7 +635,7 @@ Resources.prototype.getEnabledTabContents = function() {
ret.elName = "song"; ret.elName = "song";
} }
return ret; return ret;
} };
Resources.prototype.enableAll = function() { Resources.prototype.enableAll = function() {
var tab = this.getEnabledTabContents(); var tab = this.getEnabledTabContents();
@ -643,7 +646,7 @@ Resources.prototype.enableAll = function() {
document.getElementById(tab.elName + i).checked = true; document.getElementById(tab.elName + i).checked = true;
} }
this.rebuildEnabled(); this.rebuildEnabled();
} };
Resources.prototype.disableAll = function() { Resources.prototype.disableAll = function() {
var tab = this.getEnabledTabContents(); var tab = this.getEnabledTabContents();
@ -654,7 +657,7 @@ Resources.prototype.disableAll = function() {
document.getElementById(tab.elName + i).checked = false; document.getElementById(tab.elName + i).checked = false;
} }
this.rebuildEnabled(); this.rebuildEnabled();
} };
Resources.prototype.invert = function() { Resources.prototype.invert = function() {
var tab = this.getEnabledTabContents(); var tab = this.getEnabledTabContents();
@ -665,10 +668,10 @@ Resources.prototype.invert = function() {
document.getElementById(tab.elName + i).checked = tab.arr[i].enabled; document.getElementById(tab.elName + i).checked = tab.arr[i].enabled;
} }
this.rebuildEnabled(); this.rebuildEnabled();
} };
Resources.prototype.appendListItem = function(name, value, id, root, oncheck, onclick, checked) { Resources.prototype.appendListItem = function(name, value, id, root, oncheck, onclick, checked) {
if(checked == undefined) { if(checked === undefined) {
checked = true; checked = true;
} }
var div = document.createElement("div"); var div = document.createElement("div");
@ -689,13 +692,13 @@ Resources.prototype.appendListItem = function(name, value, id, root, oncheck, on
div.appendChild(checkStyler); div.appendChild(checkStyler);
div.appendChild(label); div.appendChild(label);
root.appendChild(div); root.appendChild(div);
} };
Resources.prototype.loadRemotes = function() { Resources.prototype.loadRemotes = function() {
var that = this; var that = this;
var remoteList = this.packsView.remoteList; var remoteList = this.packsView.remoteList;
while(remoteList.firstElementChild) { while(remoteList.firstElementChild) {
remoteList.removeChild(remoteList.firstElementChild) remoteList.removeChild(remoteList.firstElementChild);
} }
var item = this.appendSimpleListItem("Loading...", remoteList); var item = this.appendSimpleListItem("Loading...", remoteList);
@ -712,26 +715,26 @@ Resources.prototype.loadRemotes = function() {
req.onerror = function() { req.onerror = function() {
item.textContent = "Could not load list! Click to try again"; item.textContent = "Could not load list! Click to try again";
item.onclick = function() {that.loadRemotes();}; item.onclick = function() {that.loadRemotes();};
} };
req.send(); req.send();
} };
Resources.prototype.populateRemotes = function() { Resources.prototype.populateRemotes = function() {
var remoteList = this.packsView.remoteList; var remoteList = this.packsView.remoteList;
while(remoteList.firstElementChild) { while(remoteList.firstElementChild) {
remoteList.removeChild(remoteList.firstElementChild) remoteList.removeChild(remoteList.firstElementChild);
} }
for(var i = 0; i < this.remotes.length; i++) { for(var i = 0; i < this.remotes.length; i++) {
this.remotes[i].loaded = false; this.remotes[i].loaded = false;
this.appendSimpleListItem(this.remotes[i].name, remoteList, this.appendSimpleListItem(this.remotes[i].name, remoteList,
this.getRemoteCallback(i)); this.getRemoteCallback(i));
} }
} };
Resources.prototype.getRemoteCallback = function(index) { Resources.prototype.getRemoteCallback = function(index) {
var that = this; var that = this;
return function() {that.selectRemotePack(index);}; return function() {that.selectRemotePack(index);};
} };
Resources.prototype.selectRemotePack = function(id) { Resources.prototype.selectRemotePack = function(id) {
var pack = this.remotes[id]; var pack = this.remotes[id];
@ -762,10 +765,10 @@ Resources.prototype.selectRemotePack = function(id) {
var songList = this.packView.songList; var songList = this.packView.songList;
var imageList = this.packView.imageList; var imageList = this.packView.imageList;
while (songList.firstElementChild) { while (songList.firstElementChild) {
songList.removeChild(songList.firstElementChild) songList.removeChild(songList.firstElementChild);
} }
while (imageList.firstElementChild) { while (imageList.firstElementChild) {
imageList.removeChild(imageList.firstElementChild) imageList.removeChild(imageList.firstElementChild);
} }
for(var i = 0; i < pack.songs.length; i++) { for(var i = 0; i < pack.songs.length; i++) {
@ -777,14 +780,14 @@ Resources.prototype.selectRemotePack = function(id) {
var image = pack.images[i]; var image = pack.images[i];
this.appendSimpleListItem(image, imageList); this.appendSimpleListItem(image, imageList);
} }
} };
Resources.prototype.loadCurrentRemote = function() { Resources.prototype.loadCurrentRemote = function() {
var pack = this.packView.pack; var pack = this.packView.pack;
var that = this; var that = this;
// Not actually a remote, ignore. How did you press this :< // Not actually a remote, ignore. How did you press this :<
if(pack.loaded == undefined || pack.loaded) { if(pack.loaded === undefined || pack.loaded) {
return; return;
} }
@ -796,7 +799,7 @@ Resources.prototype.loadCurrentRemote = function() {
that.remoteComplete(); that.remoteComplete();
}, function(progress, respack) {that.remoteProgress(progress, respack);} }, function(progress, respack) {that.remoteProgress(progress, respack);}
); );
} };
Resources.prototype.remoteProgress = function(progress, respack) { Resources.prototype.remoteProgress = function(progress, respack) {
if(progress < 0.5) { if(progress < 0.5) {
@ -812,7 +815,7 @@ Resources.prototype.remoteProgress = function(progress, respack) {
this.packsView.progressBar.style.width = ((progress - 0.5) * 2 * 100) + "%"; this.packsView.progressBar.style.width = ((progress - 0.5) * 2 * 100) + "%";
this.packsView.progressPercent.textContent = Math.round((progress - 0.5) * 2 * 100) + "%"; this.packsView.progressPercent.textContent = Math.round((progress - 0.5) * 2 * 100) + "%";
} }
} };
Resources.prototype.remoteComplete = function(progress) { Resources.prototype.remoteComplete = function(progress) {
var progStat = this.packsView.progressStatus; var progStat = this.packsView.progressStatus;
@ -824,7 +827,7 @@ Resources.prototype.remoteComplete = function(progress) {
this.packsView.progressCurrent.textContent = "0b"; this.packsView.progressCurrent.textContent = "0b";
this.packsView.progressTop.textContent = "0b"; this.packsView.progressTop.textContent = "0b";
this.packsView.progressPercent.textContent = "0%"; this.packsView.progressPercent.textContent = "0%";
} };
Resources.prototype.appendSimpleListItem = function(value, root, onclick) { Resources.prototype.appendSimpleListItem = function(value, root, onclick) {
var div = document.createElement("div"); var div = document.createElement("div");
@ -835,4 +838,4 @@ Resources.prototype.appendSimpleListItem = function(value, root, onclick) {
div.appendChild(label); div.appendChild(label);
root.appendChild(div); root.appendChild(div);
return label; return label;
} };

@ -72,7 +72,7 @@ Respack.prototype.updateProgress = function() {
} }
this.progressCallback(percent, this); this.progressCallback(percent, this);
} }
} };
Respack.prototype.loadFromURL = function(url, callback, progress) { Respack.prototype.loadFromURL = function(url, callback, progress) {
var that = this; var that = this;
@ -87,7 +87,7 @@ Respack.prototype.loadFromURL = function(url, callback, progress) {
}; };
req.onerror = function() { req.onerror = function() {
console.log("Could not load respack at URL", url); console.log("Could not load respack at URL", url);
} };
req.onprogress = function(event) { req.onprogress = function(event) {
if (event.lengthComputable) { if (event.lengthComputable) {
that.size = event.total; that.size = event.total;
@ -99,9 +99,9 @@ Respack.prototype.loadFromURL = function(url, callback, progress) {
} else { } else {
// Unable to compute progress information since the total size is unknown // Unable to compute progress information since the total size is unknown
} }
} };
req.send(); req.send();
} };
Respack.prototype.loadBlob = function(blob, callback, progress, errorCallback) { Respack.prototype.loadBlob = function(blob, callback, progress, errorCallback) {
this._completionCallback = callback; this._completionCallback = callback;
@ -121,7 +121,7 @@ Respack.prototype.loadBlob = function(blob, callback, progress, errorCallback) {
} }
} }
); );
} };
Respack.prototype.parseWholeZip = function() { Respack.prototype.parseWholeZip = function() {
// TODO might break on bad file // TODO might break on bad file
@ -143,10 +143,10 @@ Respack.prototype.parseWholeZip = function() {
debug("ZIP loader: trying to finish"); debug("ZIP loader: trying to finish");
this.tryFinish(); this.tryFinish();
} };
Respack.prototype.parseFile = function(file) { Respack.prototype.parseFile = function(file) {
var name = file.name var name = file.name;
if (name.match(this.audioExtensions)) { if (name.match(this.audioExtensions)) {
this.parseSong(file); this.parseSong(file);
this.filesToLoad++; this.filesToLoad++;
@ -168,15 +168,15 @@ Respack.prototype.parseFile = function(file) {
default: default:
} }
} }
} };
Respack.prototype.parseSong = function(file) { Respack.prototype.parseSong = function(file) {
this.songQueue.push(file); this.songQueue.push(file);
} };
Respack.prototype.parseImage = function(file) { Respack.prototype.parseImage = function(file) {
this.imageQueue.push(file); this.imageQueue.push(file);
} };
Respack.prototype.parseXML = function() { Respack.prototype.parseXML = function() {
var that = this; var that = this;
@ -227,13 +227,13 @@ Respack.prototype.parseXML = function() {
if(this._completionCallback) { if(this._completionCallback) {
this._completionCallback(); this._completionCallback();
} }
} };
// Save some chars // Save some chars
Element.prototype.getTag = function(tag, def) { Element.prototype.getTag = function(tag, def) {
var t = this.getElementsByTagName(tag)[0]; var t = this.getElementsByTagName(tag)[0];
return t ? t.textContent : (def ? def : null); return t ? t.textContent : (def ? def : null);
} };
Respack.prototype.parseSongFile = function(text) { Respack.prototype.parseSongFile = function(text) {
debug(" - Parsing songFile"); debug(" - Parsing songFile");
@ -241,7 +241,7 @@ Respack.prototype.parseSongFile = function(text) {
var oParser = new DOMParser(); var oParser = new DOMParser();
var oDOM = oParser.parseFromString(text, "text/xml"); var oDOM = oParser.parseFromString(text, "text/xml");
if(oDOM.documentElement.nodeName !== "songs"){ if(oDOM.documentElement.nodeName !== "songs"){
console.log("songs.xml error, corrupt file?") console.log("songs.xml error, corrupt file?");
return; return;
} }
@ -280,7 +280,7 @@ Respack.prototype.parseSongFile = function(text) {
// get rid of the junk // get rid of the junk
this.songs.splice(this.songs.indexOf(build), 1); this.songs.splice(this.songs.indexOf(build), 1);
} else { } else {
debug(" WARNING!", "Didn't find a buildup '" + buildup + "'!"); debug(" WARNING!", "Didn't find a buildup '" + song.buildup + "'!");
} }
} }
@ -301,11 +301,11 @@ Respack.prototype.parseSongFile = function(text) {
} }
for(var i = 0; i < this.songs.length; i++) { for(var i = 0; i < this.songs.length; i++) {
if(newSongs.indexOf(this.songs[i]) == -1) { if(newSongs.indexOf(this.songs[i]) == -1) {
debug(" WARNING!", "We have a file for", song.name, "but no information for it"); debug(" WARNING!", "We have a file for", this.songs[i].name, "but no information for it");
} }
} }
this.songs = newSongs; this.songs = newSongs;
} };
Respack.prototype.parseInfoFile = function(text) { Respack.prototype.parseInfoFile = function(text) {
debug(" - Parsing infoFile"); debug(" - Parsing infoFile");
@ -314,7 +314,7 @@ Respack.prototype.parseInfoFile = function(text) {
var oDOM = oParser.parseFromString(text, "text/xml"); var oDOM = oParser.parseFromString(text, "text/xml");
var info = oDOM.documentElement; var info = oDOM.documentElement;
if(info.nodeName !== "info"){ if(info.nodeName !== "info"){
console.log("info.xml error, corrupt file?") console.log("info.xml error, corrupt file?");
return; return;
} }
@ -323,7 +323,7 @@ Respack.prototype.parseInfoFile = function(text) {
this.author = info.getTag("author", this.author); this.author = info.getTag("author", this.author);
this.description = info.getTag("description", this.description); this.description = info.getTag("description", this.description);
this.link = info.getTag("link", this.link); this.link = info.getTag("link", this.link);
} };
Respack.prototype.parseImageFile = function(text) { Respack.prototype.parseImageFile = function(text) {
debug(" - Parsing imagefile"); debug(" - Parsing imagefile");
@ -331,7 +331,7 @@ Respack.prototype.parseImageFile = function(text) {
var oParser = new DOMParser(); var oParser = new DOMParser();
var oDOM = oParser.parseFromString(text, "text/xml"); var oDOM = oParser.parseFromString(text, "text/xml");
if(oDOM.documentElement.nodeName !== "images"){ if(oDOM.documentElement.nodeName !== "images"){
console.log("images.xml error, corrupt file?") console.log("images.xml error, corrupt file?");
return; return;
} }
@ -352,7 +352,7 @@ Respack.prototype.parseImageFile = function(text) {
image.beatsPerAnim = parseFloat(el.getTag("beatsPerAnim")); image.beatsPerAnim = parseFloat(el.getTag("beatsPerAnim"));
var frameDur = el.getTag("frameDuration"); var frameDur = el.getTag("frameDuration");
if(frameDur) { if(frameDur) {
image.frameDurations = [] image.frameDurations = [];
var strSplit = frameDur.split(","); var strSplit = frameDur.split(",");
for(var j = 0; j < strSplit.length; j++) { for(var j = 0; j < strSplit.length; j++) {
image.frameDurations.push(parseInt(strSplit[j])); image.frameDurations.push(parseInt(strSplit[j]));
@ -385,15 +385,15 @@ Respack.prototype.parseImageFile = function(text) {
return a.name.localeCompare(b.name); return a.name.localeCompare(b.name);
}); });
this.images = newImages; this.images = newImages;
} };
Respack.prototype.containsSong = function(name) { Respack.prototype.containsSong = function(name) {
return this.getSong(name) !== null; return this.getSong(name) !== null;
} };
Respack.prototype.containsImage = function(name) { Respack.prototype.containsImage = function(name) {
return this.getImage(name) !== null; return this.getImage(name) !== null;
} };
Respack.prototype.getSong = function(name) { Respack.prototype.getSong = function(name) {
for(var i = 0; i < this.songs.length; i++) { for(var i = 0; i < this.songs.length; i++) {
@ -402,7 +402,7 @@ Respack.prototype.getSong = function(name) {
} }
} }
return null; return null;
} };
Respack.prototype.getImage = function(name) { Respack.prototype.getImage = function(name) {
for(var i = 0; i < this.images.length; i++) { for(var i = 0; i < this.images.length; i++) {
@ -411,7 +411,7 @@ Respack.prototype.getImage = function(name) {
} }
} }
return null; return null;
} };
Respack.prototype.parseSongQueue = function() { Respack.prototype.parseSongQueue = function() {
var that = this; var that = this;
@ -458,14 +458,14 @@ Respack.prototype.parseSongQueue = function() {
}); });
this.songs.push(newSong); this.songs.push(newSong);
} }
} };
Respack.prototype.parseImageQueue = function() { Respack.prototype.parseImageQueue = function() {
var imgFile = this.imageQueue.shift(); var imgFile = this.imageQueue.shift();
var name = imgFile.name.replace(this.imageExtensions, ""); var name = imgFile.name.replace(this.imageExtensions, "");
if (match = name.match(new RegExp("^(.*)_(\\d+)$"))) { if((match = name.match(new RegExp("^(.*)_(\\d+)$")))) {
var anim = this.getImage(match[1]) var anim = this.getImage(match[1]);
if(!anim) { // make a fresh one if(!anim) { // make a fresh one
anim = {"name":match[1], anim = {"name":match[1],
"fullname":match[1], "fullname":match[1],
@ -493,10 +493,10 @@ Respack.prototype.parseImageQueue = function() {
this.images.push(img); this.images.push(img);
this.imageLoadStart(imgFile, img); this.imageLoadStart(imgFile, img);
} else { } else {
existing = this.getImage(name); var existing = this.getImage(name);
debug("WARNING: Image", name, "already exists! Conflict with", imgFile.name, "and", existing.name); debug("WARNING: Image", name, "already exists! Conflict with", imgFile.name, "and", existing.name);
} }
} };
Respack.prototype.imageLoadStart = function(imgFile, imageObj) { Respack.prototype.imageLoadStart = function(imgFile, imageObj) {
var that = this; var that = this;
@ -519,10 +519,10 @@ Respack.prototype.imageLoadStart = function(imgFile, imageObj) {
imgFile.getData64URI(mime, function(image) { imgFile.getData64URI(mime, function(image) {
that.imageLoadComplete(image, imageObj); that.imageLoadComplete(image, imageObj);
}); });
} };
Respack.prototype.imageLoadComplete = function(imageBmp, imageObj) { Respack.prototype.imageLoadComplete = function(imageBmp, imageObj) {
newImg = new Image(); var newImg = new Image();
newImg.src = imageBmp; newImg.src = imageBmp;
if (imageObj.animated) { if (imageObj.animated) {
imageObj.bitmaps.push(newImg); imageObj.bitmaps.push(newImg);
@ -533,7 +533,7 @@ Respack.prototype.imageLoadComplete = function(imageBmp, imageObj) {
this.filesLoaded++; this.filesLoaded++;
this.updateProgress(); this.updateProgress();
this.tryFinish(); this.tryFinish();
} };
Respack.prototype.tryFinish = function() { Respack.prototype.tryFinish = function() {
if (this.imageQueue.length > 0) { if (this.imageQueue.length > 0) {
@ -544,4 +544,4 @@ Respack.prototype.tryFinish = function() {
debug("Finished parsing images/songs, parsing xml files..."); debug("Finished parsing images/songs, parsing xml files...");
this.parseXML(); this.parseXML();
} }
} };

@ -144,7 +144,7 @@ SoundManager.prototype.playSong = function(song, playBuild, callback) {
} }
} }
}); });
} };
SoundManager.prototype.stop = function() { SoundManager.prototype.stop = function() {
if (this.playing) { if (this.playing) {
@ -157,7 +157,7 @@ SoundManager.prototype.stop = function() {
this.loopStart = 0; this.loopStart = 0;
this.loopLength = 0; this.loopLength = 0;
} }
} };
// In seconds, relative to the loop start // In seconds, relative to the loop start
SoundManager.prototype.currentTime = function() { SoundManager.prototype.currentTime = function() {
@ -165,7 +165,7 @@ SoundManager.prototype.currentTime = function() {
return 0; return 0;
} }
return this.context.currentTime - this.startTime; return this.context.currentTime - this.startTime;
} };
SoundManager.prototype.displayableTime = function() { SoundManager.prototype.displayableTime = function() {
if(!this.playing) { if(!this.playing) {
@ -177,7 +177,7 @@ SoundManager.prototype.displayableTime = function() {
} else { } else {
return time % this.loopLength; return time % this.loopLength;
} }
} };
SoundManager.prototype.loadBuffer = function(song, callback) { SoundManager.prototype.loadBuffer = function(song, callback) {
if(callback) { if(callback) {
@ -187,7 +187,7 @@ SoundManager.prototype.loadBuffer = function(song, callback) {
this.loadAudioFile(song, true); this.loadAudioFile(song, true);
} }
this.loadAudioFile(song, false); this.loadAudioFile(song, false);
} };
SoundManager.prototype.loadAudioFile = function(song, isBuild) { SoundManager.prototype.loadAudioFile = function(song, isBuild) {
this.context.decodeAudioData( this.context.decodeAudioData(
@ -197,7 +197,7 @@ SoundManager.prototype.loadAudioFile = function(song, isBuild) {
console.log('Error decoding audio "' + song.name + '".'); console.log('Error decoding audio "' + song.name + '".');
} }
); );
} };
/* decodeAudioData nukes our original MP3 array, but we want to keep it around /* decodeAudioData nukes our original MP3 array, but we want to keep it around
for memory saving purposes, so we must duplicate it locally here */ for memory saving purposes, so we must duplicate it locally here */
@ -223,7 +223,7 @@ SoundManager.prototype.getAudioCallback = function(song, isBuild) {
} }
that.onSongLoad(song); that.onSongLoad(song);
}; };
} };
SoundManager.prototype.onSongLoad = function(song) { SoundManager.prototype.onSongLoad = function(song) {
// if this fails, we need to wait for the other part to load // if this fails, we need to wait for the other part to load
@ -243,7 +243,7 @@ SoundManager.prototype.onSongLoad = function(song) {
this.onLoadCallback = null; this.onLoadCallback = null;
} }
} }
} };
// because MP3 is bad, we nuke silence // because MP3 is bad, we nuke silence
SoundManager.prototype.trimMP3 = function(buffer, forceTrim, noTrim) { SoundManager.prototype.trimMP3 = function(buffer, forceTrim, noTrim) {
@ -272,7 +272,7 @@ SoundManager.prototype.trimMP3 = function(buffer, forceTrim, noTrim) {
} }
} }
return ret; return ret;
} };
// This wouldn't be required if Web Audio could do gapless playback properly // This wouldn't be required if Web Audio could do gapless playback properly
SoundManager.prototype.concatenateAudioBuffers = function(buffer1, buffer2) { SoundManager.prototype.concatenateAudioBuffers = function(buffer1, buffer2) {
@ -312,27 +312,27 @@ SoundManager.prototype.setMute = function(mute) {
this.core.userInterface.updateVolume(this.gainNode.gain.value); this.core.userInterface.updateVolume(this.gainNode.gain.value);
this.mute = mute; this.mute = mute;
return mute; return mute;
} };
SoundManager.prototype.toggleMute = function() { SoundManager.prototype.toggleMute = function() {
return this.setMute(!this.mute); return this.setMute(!this.mute);
} };
SoundManager.prototype.decreaseVolume = function() { SoundManager.prototype.decreaseVolume = function() {
this.setMute(false); this.setMute(false);
val = Math.max(this.gainNode.gain.value - 0.1, 0); var val = Math.max(this.gainNode.gain.value - 0.1, 0);
this.gainNode.gain.value = val; this.gainNode.gain.value = val;
this.core.userInterface.updateVolume(val); this.core.userInterface.updateVolume(val);
} };
SoundManager.prototype.increaseVolume = function() { SoundManager.prototype.increaseVolume = function() {
this.setMute(false); this.setMute(false);
val = Math.min(this.gainNode.gain.value + 0.1, 1); var val = Math.min(this.gainNode.gain.value + 0.1, 1);
this.gainNode.gain.value = val; this.gainNode.gain.value = val;
this.core.userInterface.updateVolume(val); this.core.userInterface.updateVolume(val);
} };
SoundManager.prototype.setVolume = function(vol) { SoundManager.prototype.setVolume = function(vol) {
this.gainNode.gain.value = vol; this.gainNode.gain.value = vol;
this.core.userInterface.updateVolume(vol); this.core.userInterface.updateVolume(vol);
} };
Loading…
Cancel
Save