|
|
@ -27,7 +27,9 @@ |
|
|
|
to put all your own elements under, but make a div |
|
|
|
to put all your own elements under, but make a div |
|
|
|
underneath so it can be entirely hidden. |
|
|
|
underneath so it can be entirely hidden. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function HuesUI(parent, name) { |
|
|
|
class HuesUI { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(parent, name) { |
|
|
|
if(!parent) { |
|
|
|
if(!parent) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -74,11 +76,11 @@ function HuesUI(parent, name) { |
|
|
|
this.initUI(); |
|
|
|
this.initUI(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HuesUI.prototype.addCoreCallback = function(name, func) { |
|
|
|
addCoreCallback(name, func) { |
|
|
|
this.callbacks.push({name : name, func : func}); |
|
|
|
this.callbacks.push({name : name, func : func}); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HuesUI.prototype.initUI = function() { |
|
|
|
initUI() { |
|
|
|
// Major info, image, song names
|
|
|
|
// Major info, image, song names
|
|
|
|
let imageName = document.createElement("div"); |
|
|
|
let imageName = document.createElement("div"); |
|
|
|
this.imageName = imageName; |
|
|
|
this.imageName = imageName; |
|
|
@ -161,9 +163,9 @@ HuesUI.prototype.initUI = function() { |
|
|
|
this.addCoreCallback("time", this.updateTime.bind(this)); |
|
|
|
this.addCoreCallback("time", this.updateTime.bind(this)); |
|
|
|
this.addCoreCallback("invert", this.invert.bind(this)); |
|
|
|
this.addCoreCallback("invert", this.invert.bind(this)); |
|
|
|
this.resizeHandler = this.resize.bind(this); |
|
|
|
this.resizeHandler = this.resize.bind(this); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HuesUI.prototype.connectCore = function(core) { |
|
|
|
connectCore(core) { |
|
|
|
this.core = core; |
|
|
|
this.core = core; |
|
|
|
this.root.style.display = "block"; |
|
|
|
this.root.style.display = "block"; |
|
|
|
if(core.resourceManager.hasUI) { |
|
|
|
if(core.resourceManager.hasUI) { |
|
|
@ -176,9 +178,9 @@ HuesUI.prototype.connectCore = function(core) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
window.addEventListener('resize', this.resizeHandler); |
|
|
|
window.addEventListener('resize', this.resizeHandler); |
|
|
|
this.resizeHandler(); |
|
|
|
this.resizeHandler(); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HuesUI.prototype.disconnect = function() { |
|
|
|
disconnect() { |
|
|
|
this.callbacks.forEach(callback => { |
|
|
|
this.callbacks.forEach(callback => { |
|
|
|
this.core.removeEventListener(callback.name, callback.func); |
|
|
|
this.core.removeEventListener(callback.name, callback.func); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -191,40 +193,40 @@ HuesUI.prototype.disconnect = function() { |
|
|
|
this.visualiserContainer.removeChild(this.visualiserContainer.firstElementChild); |
|
|
|
this.visualiserContainer.removeChild(this.visualiserContainer.firstElementChild); |
|
|
|
} |
|
|
|
} |
|
|
|
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() { |
|
|
|
show() { |
|
|
|
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() { |
|
|
|
hide() { |
|
|
|
this.root.style.display = "none"; |
|
|
|
this.root.style.display = "none"; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HuesUI.prototype.toggleHide = function() { |
|
|
|
toggleHide() { |
|
|
|
this.hidden = !this.hidden; |
|
|
|
this.hidden = !this.hidden; |
|
|
|
if(this.hidden) { |
|
|
|
if(this.hidden) { |
|
|
|
this.root.classList.add("hues-ui--hidden"); |
|
|
|
this.root.classList.add("hues-ui--hidden"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.root.classList.remove("hues-ui--hidden"); |
|
|
|
this.root.classList.remove("hues-ui--hidden"); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HuesUI.prototype.resize = function() {}; |
|
|
|
resize() {} |
|
|
|
HuesUI.prototype.updateVolume = function(vol) {}; |
|
|
|
updateVolume(vol) {} |
|
|
|
|
|
|
|
|
|
|
|
HuesUI.prototype.newSong = function(song) { |
|
|
|
newSong(song) { |
|
|
|
if(!song) { |
|
|
|
if(!song) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.songLink.textContent = song.title.toUpperCase(); |
|
|
|
this.songLink.textContent = song.title.toUpperCase(); |
|
|
|
this.songLink.href = song.source; |
|
|
|
this.songLink.href = song.source; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HuesUI.prototype.newImage = function(image) { |
|
|
|
newImage(image) { |
|
|
|
if(!image) { |
|
|
|
if(!image) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -233,62 +235,52 @@ HuesUI.prototype.newImage = function(image) { |
|
|
|
|
|
|
|
|
|
|
|
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.newColour = function(colour) { |
|
|
|
newColour(colour) { |
|
|
|
this.hueName.textContent = colour.n.toUpperCase(); |
|
|
|
this.hueName.textContent = colour.n.toUpperCase(); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HuesUI.prototype.blurUpdated = function(x, y) { |
|
|
|
blurUpdated(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.intToHex(x, 2); |
|
|
|
this.xBlur.textContent = "X=" + this.intToHex(x, 2); |
|
|
|
this.yBlur.textContent = "Y=" + this.intToHex(y, 2); |
|
|
|
this.yBlur.textContent = "Y=" + this.intToHex(y, 2); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HuesUI.prototype.updateTime = function(time) { |
|
|
|
updateTime(time) { |
|
|
|
time = Math.floor(time * 1000); |
|
|
|
time = Math.floor(time * 1000); |
|
|
|
this.timer.textContent = "T=" + this.intToHex(time, 5); |
|
|
|
this.timer.textContent = "T=" + this.intToHex(time, 5); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HuesUI.prototype.intToHex = function(num, pad) { |
|
|
|
intToHex(num, pad) { |
|
|
|
let str = Math.abs(num).toString(16); |
|
|
|
let str = Math.abs(num).toString(16); |
|
|
|
while (str.length < pad) |
|
|
|
while (str.length < pad) |
|
|
|
str = "0" + str; |
|
|
|
str = "0" + str; |
|
|
|
let prefix = num < 0 ? "-" : "$"; |
|
|
|
let prefix = num < 0 ? "-" : "$"; |
|
|
|
return prefix + "0x" + str; |
|
|
|
return prefix + "0x" + str; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HuesUI.prototype.invert = function(invert) { |
|
|
|
invert(invert) { |
|
|
|
if (invert) { |
|
|
|
if (invert) { |
|
|
|
this.root.classList.add("inverted"); |
|
|
|
this.root.classList.add("inverted"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.root.classList.remove("inverted"); |
|
|
|
this.root.classList.remove("inverted"); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
|
Individual UIs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
|
|
Individual UIs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
function RetroUI(parent, name) { |
|
|
|
class RetroUI extends HuesUI { |
|
|
|
this.container = null; |
|
|
|
constructor(parent, name) { |
|
|
|
this.mode = null; |
|
|
|
super(parent, name ? name : "RetroUI"); |
|
|
|
this.beatBar = null; |
|
|
|
|
|
|
|
this.colourIndex = null; |
|
|
|
|
|
|
|
this.version = null; |
|
|
|
|
|
|
|
this.imageModeAuto = null; |
|
|
|
|
|
|
|
this.imageModeAuto = null; |
|
|
|
|
|
|
|
this.subControls = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HuesUI.call(this, parent, name ? name : "RetroUI"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RetroUI.prototype = Object.create(HuesUI.prototype); |
|
|
|
initUI() { |
|
|
|
RetroUI.prototype.constructor = RetroUI; |
|
|
|
super.initUI(); |
|
|
|
|
|
|
|
|
|
|
|
RetroUI.prototype.initUI = function() { |
|
|
|
|
|
|
|
HuesUI.prototype.initUI.call(this); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let container = document.createElement("div"); |
|
|
|
let container = document.createElement("div"); |
|
|
|
container.className = "hues-r-container"; |
|
|
|
container.className = "hues-r-container"; |
|
|
@ -376,9 +368,9 @@ RetroUI.prototype.initUI = function() { |
|
|
|
|
|
|
|
|
|
|
|
this.addCoreCallback("beat", this.beat.bind(this)); |
|
|
|
this.addCoreCallback("beat", this.beat.bind(this)); |
|
|
|
this.addCoreCallback("newmode", this.newMode.bind(this)); |
|
|
|
this.addCoreCallback("newmode", this.newMode.bind(this)); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RetroUI.prototype.toggleHide = function() { |
|
|
|
toggleHide() { |
|
|
|
this.hidden = !this.hidden; |
|
|
|
this.hidden = !this.hidden; |
|
|
|
if(this.hidden) { |
|
|
|
if(this.hidden) { |
|
|
|
this.subControls.classList.add("hues-ui--hidden"); |
|
|
|
this.subControls.classList.add("hues-ui--hidden"); |
|
|
@ -391,73 +383,71 @@ RetroUI.prototype.toggleHide = function() { |
|
|
|
this.container.classList.remove("hues-ui--hidden"); |
|
|
|
this.container.classList.remove("hues-ui--hidden"); |
|
|
|
this.hideRestore.classList.remove("hues-ui--hidden"); |
|
|
|
this.hideRestore.classList.remove("hues-ui--hidden"); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RetroUI.prototype.connectCore = function(core) { |
|
|
|
connectCore(core) { |
|
|
|
HuesUI.prototype.connectCore.call(this, core); |
|
|
|
super.connectCore(core); |
|
|
|
|
|
|
|
|
|
|
|
this.version.textContent = "V=$" + core.versionHex; |
|
|
|
this.version.textContent = "V=$" + core.versionHex; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RetroUI.prototype.newMode = function(isAuto) { |
|
|
|
newMode(isAuto) { |
|
|
|
this.mode.textContent = "M=" + (isAuto ? "FULL AUTO" : "NORMAL"); |
|
|
|
this.mode.textContent = "M=" + (isAuto ? "FULL AUTO" : "NORMAL"); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RetroUI.prototype.newImage = function(image) { |
|
|
|
newImage(image) { |
|
|
|
if(!image) { |
|
|
|
if(!image) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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.newColour = function(colour) { |
|
|
|
newColour(colour) { |
|
|
|
HuesUI.prototype.newColour.call(this, colour); |
|
|
|
super.newColour(colour); |
|
|
|
|
|
|
|
|
|
|
|
this.colourIndex.textContent = "C=" + this.intToHex(this.core.colourIndex, 2); |
|
|
|
this.colourIndex.textContent = "C=" + this.intToHex(this.core.colourIndex, 2); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RetroUI.prototype.beat = function(beats, index) { |
|
|
|
beat(beats, index) { |
|
|
|
let rest = beats.slice(1); |
|
|
|
let rest = beats.slice(1); |
|
|
|
this.beatBar.textContent = ">>" + rest; |
|
|
|
this.beatBar.textContent = ">>" + rest; |
|
|
|
this.beatCount.textContent = "B=" + this.intToHex(index, 4); |
|
|
|
this.beatCount.textContent = "B=" + this.intToHex(index, 4); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RetroUI.prototype.resize = function() { |
|
|
|
resize() { |
|
|
|
this.core.visualiser.width = this.visualiserContainer.offsetWidth; |
|
|
|
this.core.visualiser.width = this.visualiserContainer.offsetWidth; |
|
|
|
this.core.resizeVisualiser(); |
|
|
|
this.core.resizeVisualiser(); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function MinimalUI(parent, name) { |
|
|
|
|
|
|
|
RetroUI.call(this, parent, name ? name : "MinimalUI"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
MinimalUI.prototype = Object.create(RetroUI.prototype); |
|
|
|
class MinimalUI extends RetroUI { |
|
|
|
MinimalUI.prototype.constructor = MinimalUI; |
|
|
|
constructor(parent, name) { |
|
|
|
|
|
|
|
super(parent, name ? name : "MinimalUI"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
MinimalUI.prototype.initUI = function() { |
|
|
|
initUI() { |
|
|
|
RetroUI.prototype.initUI.call(this); |
|
|
|
super.initUI(); |
|
|
|
|
|
|
|
|
|
|
|
this.root.removeChild(this.controls); |
|
|
|
this.root.removeChild(this.controls); |
|
|
|
this.root.removeChild(this.subControls); |
|
|
|
this.root.removeChild(this.subControls); |
|
|
|
this.container.removeChild(this.beatBar); |
|
|
|
this.container.removeChild(this.beatBar); |
|
|
|
this.container.innerHTML = ""; |
|
|
|
this.container.innerHTML = ""; |
|
|
|
this.container.appendChild(this.beatBar); |
|
|
|
this.container.appendChild(this.beatBar); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function WeedUI(parent, name) { |
|
|
|
class WeedUI extends RetroUI { |
|
|
|
RetroUI.call(this, parent, name ? name : "WeedUI"); |
|
|
|
constructor(parent, name) { |
|
|
|
|
|
|
|
super(parent, name ? name : "WeedUI"); |
|
|
|
|
|
|
|
|
|
|
|
this.xVariance = 10; |
|
|
|
this.xVariance = 10; |
|
|
|
this.yVariance = 20; |
|
|
|
this.yVariance = 20; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WeedUI.prototype = Object.create(RetroUI.prototype); |
|
|
|
initUI() { |
|
|
|
WeedUI.prototype.constructor = WeedUI; |
|
|
|
super.initUI(); |
|
|
|
|
|
|
|
|
|
|
|
WeedUI.prototype.initUI = function() { |
|
|
|
|
|
|
|
RetroUI.prototype.initUI.call(this); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.container.removeChild(this.beatBar); |
|
|
|
this.container.removeChild(this.beatBar); |
|
|
|
|
|
|
|
|
|
|
@ -483,18 +473,18 @@ WeedUI.prototype.initUI = function() { |
|
|
|
this.imageModeAuto.textContent = "MANY"; |
|
|
|
this.imageModeAuto.textContent = "MANY"; |
|
|
|
|
|
|
|
|
|
|
|
this.visualiserContainer.className += " hues-w-visualisercontainer"; |
|
|
|
this.visualiserContainer.className += " hues-w-visualisercontainer"; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WeedUI.prototype.toggleHide = function() { |
|
|
|
toggleHide() { |
|
|
|
RetroUI.prototype.toggleHide.call(this); |
|
|
|
super.toggleHide(this); |
|
|
|
if(this.hidden) { |
|
|
|
if(this.hidden) { |
|
|
|
this.beatBar.classList.add("hues-ui--hidden"); |
|
|
|
this.beatBar.classList.add("hues-ui--hidden"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.beatBar.classList.remove("hues-ui--hidden"); |
|
|
|
this.beatBar.classList.remove("hues-ui--hidden"); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WeedUI.prototype.beat = function(beats, index) { |
|
|
|
beat(beats, index) { |
|
|
|
let rest = beats.slice(1); |
|
|
|
let rest = beats.slice(1); |
|
|
|
|
|
|
|
|
|
|
|
this.beatLeft.textContent = rest; |
|
|
|
this.beatLeft.textContent = rest; |
|
|
@ -516,29 +506,20 @@ WeedUI.prototype.beat = function(beats, index) { |
|
|
|
this.root.appendChild(beatCenter); |
|
|
|
this.root.appendChild(beatCenter); |
|
|
|
window.setTimeout(this.removeBeat.bind(this, beatCenter), 1500); |
|
|
|
window.setTimeout(this.removeBeat.bind(this, beatCenter), 1500); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WeedUI.prototype.round10 = function(num) { |
|
|
|
round10(num) { |
|
|
|
return Math.round(num * 10) / 10; |
|
|
|
return Math.round(num * 10) / 10; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WeedUI.prototype.removeBeat = function(element) { |
|
|
|
removeBeat(element) { |
|
|
|
this.root.removeChild(element); |
|
|
|
this.root.removeChild(element); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function ModernUI(parent, name) { |
|
|
|
class ModernUI extends HuesUI { |
|
|
|
this.beatBar = null; |
|
|
|
constructor(parent, name) { |
|
|
|
this.beatLeft = null; |
|
|
|
super(parent, name ? name : "ModernUI"); |
|
|
|
this.beatRight = null; |
|
|
|
|
|
|
|
this.beatCenter = null; |
|
|
|
|
|
|
|
this.rightBox = null; |
|
|
|
|
|
|
|
this.leftBox = null; |
|
|
|
|
|
|
|
this.rightInfo = null; |
|
|
|
|
|
|
|
this.leftInfo = null; |
|
|
|
|
|
|
|
this.controls = null; |
|
|
|
|
|
|
|
this.volInput = null; |
|
|
|
|
|
|
|
this.volLabel = null; |
|
|
|
|
|
|
|
this.hideRestore = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.textSize_normal = 0; |
|
|
|
this.textSize_normal = 0; |
|
|
|
this.textSize_small = 0; |
|
|
|
this.textSize_small = 0; |
|
|
@ -547,16 +528,11 @@ function ModernUI(parent, name) { |
|
|
|
|
|
|
|
|
|
|
|
this.currentBeat = "."; |
|
|
|
this.currentBeat = "."; |
|
|
|
|
|
|
|
|
|
|
|
HuesUI.call(this, parent, name ? name : "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); |
|
|
|
initUI() { |
|
|
|
ModernUI.prototype.constructor = ModernUI; |
|
|
|
super.initUI(); |
|
|
|
|
|
|
|
|
|
|
|
ModernUI.prototype.initUI = function() { |
|
|
|
|
|
|
|
HuesUI.prototype.initUI.call(this); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.imageName.className = "hues-m-imagename"; |
|
|
|
this.imageName.className = "hues-m-imagename"; |
|
|
|
this.songName.className = "hues-m-songtitle"; |
|
|
|
this.songName.className = "hues-m-songtitle"; |
|
|
@ -715,9 +691,9 @@ ModernUI.prototype.initUI = function() { |
|
|
|
|
|
|
|
|
|
|
|
this.addCoreCallback("beat", this.beat.bind(this)); |
|
|
|
this.addCoreCallback("beat", this.beat.bind(this)); |
|
|
|
this.addCoreCallback("newmode", this.newMode.bind(this)); |
|
|
|
this.addCoreCallback("newmode", this.newMode.bind(this)); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ModernUI.prototype.toggleHide = function() { |
|
|
|
toggleHide() { |
|
|
|
// classList is new-ish, but if you have web audio you'll have this
|
|
|
|
// classList is new-ish, but if you have web audio you'll have this
|
|
|
|
this.beatBar.classList.remove("hues-ui--hidden"); |
|
|
|
this.beatBar.classList.remove("hues-ui--hidden"); |
|
|
|
this.beatCenter.classList.remove("hues-ui--hidden"); |
|
|
|
this.beatCenter.classList.remove("hues-ui--hidden"); |
|
|
@ -733,26 +709,26 @@ ModernUI.prototype.toggleHide = function() { |
|
|
|
this.hideRestore.classList.add("hues-ui--hidden"); |
|
|
|
this.hideRestore.classList.add("hues-ui--hidden"); |
|
|
|
} |
|
|
|
} |
|
|
|
this.hidden = (this.hidden+1) % 3; |
|
|
|
this.hidden = (this.hidden+1) % 3; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ModernUI.prototype.updateVolume = function(vol) { |
|
|
|
updateVolume(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.newMode = function(isAuto) { |
|
|
|
newMode (isAuto) { |
|
|
|
if(isAuto) { |
|
|
|
if(isAuto) { |
|
|
|
this.imageMode.innerHTML = ''; // PAUSE;
|
|
|
|
this.imageMode.innerHTML = ''; // PAUSE;
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.imageMode.innerHTML = ""; // PLAY
|
|
|
|
this.imageMode.innerHTML = ""; // PLAY
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ModernUI.prototype.beat = function(beats, index) { |
|
|
|
beat(beats, index) { |
|
|
|
this.currentBeat = beats[0]; |
|
|
|
this.currentBeat = beats[0]; |
|
|
|
let rest = beats.slice(1); |
|
|
|
let rest = beats.slice(1); |
|
|
|
|
|
|
|
|
|
|
@ -769,10 +745,10 @@ ModernUI.prototype.beat = function(beats, index) { |
|
|
|
this.beatCenter.appendChild(span); |
|
|
|
this.beatCenter.appendChild(span); |
|
|
|
} |
|
|
|
} |
|
|
|
this.beatCount.textContent = "B=" + this.intToHex(index, 4); |
|
|
|
this.beatCount.textContent = "B=" + this.intToHex(index, 4); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// get the width of a single character in the link box for a given classname
|
|
|
|
// get the width of a single character in the link box for a given classname
|
|
|
|
ModernUI.prototype.textWidth = function(className) { |
|
|
|
textWidth(className) { |
|
|
|
// Could be song or image link, don't care
|
|
|
|
// Could be song or image link, don't care
|
|
|
|
let el = this.songLink; |
|
|
|
let el = this.songLink; |
|
|
|
let oldContent = el.innerHTML; |
|
|
|
let oldContent = el.innerHTML; |
|
|
@ -792,7 +768,7 @@ ModernUI.prototype.textWidth = function(className) { |
|
|
|
return size; |
|
|
|
return size; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ModernUI.prototype.resize = function() { |
|
|
|
resize() { |
|
|
|
this.textSize_normal = this.textWidth(""); |
|
|
|
this.textSize_normal = this.textWidth(""); |
|
|
|
this.textSize_small = this.textWidth("small"); |
|
|
|
this.textSize_small = this.textWidth("small"); |
|
|
|
this.songLink_size = this.songName.clientWidth; |
|
|
|
this.songLink_size = this.songName.clientWidth; |
|
|
@ -802,9 +778,9 @@ ModernUI.prototype.resize = function() { |
|
|
|
this.resizeImage(); |
|
|
|
this.resizeImage(); |
|
|
|
this.core.visualiser.width = this.controls.offsetWidth; |
|
|
|
this.core.visualiser.width = this.controls.offsetWidth; |
|
|
|
this.core.resizeVisualiser(); |
|
|
|
this.core.resizeVisualiser(); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ModernUI.prototype.resizeElement = function(el, parentSize) { |
|
|
|
resizeElement(el, parentSize) { |
|
|
|
let chars = el.textContent.length; |
|
|
|
let chars = el.textContent.length; |
|
|
|
if (chars * this.textSize_normal < parentSize) { |
|
|
|
if (chars * this.textSize_normal < parentSize) { |
|
|
|
el.className = ""; |
|
|
|
el.className = ""; |
|
|
@ -813,38 +789,40 @@ ModernUI.prototype.resizeElement = function(el, parentSize) { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
el.className = "x-small"; |
|
|
|
el.className = "x-small"; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ModernUI.prototype.resizeSong = function() { |
|
|
|
resizeSong() { |
|
|
|
this.resizeElement(this.songLink, this.songLink_size); |
|
|
|
this.resizeElement(this.songLink, this.songLink_size); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ModernUI.prototype.resizeImage = function() { |
|
|
|
resizeImage() { |
|
|
|
this.resizeElement(this.imageLink, this.imageLink_size); |
|
|
|
this.resizeElement(this.imageLink, this.imageLink_size); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ModernUI.prototype.newSong = function(song) { |
|
|
|
newSong(song) { |
|
|
|
HuesUI.prototype.newSong.call(this, song); |
|
|
|
super.newSong(song); |
|
|
|
|
|
|
|
|
|
|
|
if(!song) { |
|
|
|
if(!song) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.resizeSong(); |
|
|
|
this.resizeSong(); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ModernUI.prototype.newImage = function(image) { |
|
|
|
newImage(image) { |
|
|
|
HuesUI.prototype.newImage.call(this, image); |
|
|
|
super.newImage(image); |
|
|
|
|
|
|
|
|
|
|
|
if(!image) { |
|
|
|
if(!image) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.resizeImage(); |
|
|
|
this.resizeImage(); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function XmasUI(parent, name) { |
|
|
|
class XmasUI extends ModernUI { |
|
|
|
ModernUI.call(this, parent, name ? name : "XmasUI"); |
|
|
|
constructor(parent, name) { |
|
|
|
|
|
|
|
super(parent, name ? name : "XmasUI"); |
|
|
|
this.initSnow(); |
|
|
|
this.initSnow(); |
|
|
|
|
|
|
|
|
|
|
|
// This will cache our inverted lights images
|
|
|
|
// This will cache our inverted lights images
|
|
|
@ -913,59 +891,56 @@ function XmasUI(parent, name) { |
|
|
|
this.beatBar.appendChild(this.visualiserContainer); |
|
|
|
this.beatBar.appendChild(this.visualiserContainer); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
XmasUI.prototype = Object.create(ModernUI.prototype); |
|
|
|
invert(invert) { |
|
|
|
XmasUI.prototype.constructor = XmasUI; |
|
|
|
super.invert(invert); |
|
|
|
|
|
|
|
|
|
|
|
XmasUI.prototype.invert = function(invert) { |
|
|
|
|
|
|
|
HuesUI.prototype.invert.call(this, invert); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(invert) { |
|
|
|
if(invert) { |
|
|
|
this.snowContext.fillStyle = "rgba(0, 0, 0, 0.8)"; |
|
|
|
this.snowContext.fillStyle = "rgba(0, 0, 0, 0.8)"; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.snowContext.fillStyle = "rgba(255, 255, 255, 0.8)"; |
|
|
|
this.snowContext.fillStyle = "rgba(255, 255, 255, 0.8)"; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
XmasUI.prototype.connectCore = function(core) { |
|
|
|
connectCore(core) { |
|
|
|
HuesUI.prototype.connectCore.call(this, core); |
|
|
|
super.connectCore(core); |
|
|
|
this.startSnow(); |
|
|
|
this.startSnow(); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
XmasUI.prototype.disconnect = function() { |
|
|
|
disconnect() { |
|
|
|
this.stopSnow(); |
|
|
|
this.stopSnow(); |
|
|
|
HuesUI.prototype.disconnect.call(this); |
|
|
|
super.disconnect(); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
XmasUI.prototype.lightOn = function(light) { |
|
|
|
lightOn(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) { |
|
|
|
lightOff(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) { |
|
|
|
lightFadeOut(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) { |
|
|
|
lightRecolour(light) { |
|
|
|
let hue = Math.floor(Math.random() * 7) * -56; |
|
|
|
let hue = Math.floor(Math.random() * 7) * -56; |
|
|
|
light.on.style.backgroundPosition = hue + "px 0"; |
|
|
|
light.on.style.backgroundPosition = hue + "px 0"; |
|
|
|
light.off.style.backgroundPosition = hue + "px 0"; |
|
|
|
light.off.style.backgroundPosition = hue + "px 0"; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
XmasUI.prototype.randomLight = function(light) { |
|
|
|
randomLight(light) { |
|
|
|
if(Math.random() >= 0.5) { |
|
|
|
if(Math.random() >= 0.5) { |
|
|
|
this.lightOn(light); |
|
|
|
this.lightOn(light); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.lightOff(light); |
|
|
|
this.lightOff(light); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
XmasUI.prototype.newLight = function(l, parent) { |
|
|
|
newLight(l, parent) { |
|
|
|
let light = document.createElement("div"); |
|
|
|
let light = document.createElement("div"); |
|
|
|
light.className = "hues-x-light"; |
|
|
|
light.className = "hues-x-light"; |
|
|
|
let bulb = document.createElement("div"); |
|
|
|
let bulb = document.createElement("div"); |
|
|
@ -981,10 +956,10 @@ 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(beats, index) { |
|
|
|
beat(beats, index) { |
|
|
|
ModernUI.prototype.beat.call(this, beats, index); |
|
|
|
super.beat(beats, index); |
|
|
|
if(this.currentBeat != ".") { |
|
|
|
if(this.currentBeat != ".") { |
|
|
|
this.lights.forEach(function(light, i, a) { |
|
|
|
this.lights.forEach(function(light, i, a) { |
|
|
|
switch(this.currentBeat) { |
|
|
|
switch(this.currentBeat) { |
|
|
@ -1000,9 +975,9 @@ XmasUI.prototype.beat = function(beats, index) { |
|
|
|
} |
|
|
|
} |
|
|
|
}, this); |
|
|
|
}, this); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
XmasUI.prototype.initSnow = function() { |
|
|
|
initSnow() { |
|
|
|
this.snowCanvas = document.createElement("canvas"); |
|
|
|
this.snowCanvas = document.createElement("canvas"); |
|
|
|
this.snowContext = this.snowCanvas.getContext("2d"); |
|
|
|
this.snowContext = this.snowCanvas.getContext("2d"); |
|
|
|
this.snowCanvas.width = 1280; |
|
|
|
this.snowCanvas.width = 1280; |
|
|
@ -1019,11 +994,11 @@ XmasUI.prototype.initSnow = function() { |
|
|
|
this.snowflakes = []; |
|
|
|
this.snowflakes = []; |
|
|
|
|
|
|
|
|
|
|
|
this.addCoreCallback("frame", this.drawSnow.bind(this)); |
|
|
|
this.addCoreCallback("frame", this.drawSnow.bind(this)); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// From http://thecodeplayer.com/walkthrough/html5-canvas-snow-effect
|
|
|
|
// From http://thecodeplayer.com/walkthrough/html5-canvas-snow-effect
|
|
|
|
|
|
|
|
|
|
|
|
XmasUI.prototype.startSnow = function() { |
|
|
|
startSnow() { |
|
|
|
this.snowing = true; |
|
|
|
this.snowing = true; |
|
|
|
this.snowCanvas.style.display = "block"; |
|
|
|
this.snowCanvas.style.display = "block"; |
|
|
|
let height = this.snowCanvas.height; |
|
|
|
let height = this.snowCanvas.height; |
|
|
@ -1039,14 +1014,14 @@ XmasUI.prototype.startSnow = function() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
this.lastSnow = Date.now() / 1000; |
|
|
|
this.lastSnow = Date.now() / 1000; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
XmasUI.prototype.stopSnow = function() { |
|
|
|
stopSnow() { |
|
|
|
this.snowing = false; |
|
|
|
this.snowing = false; |
|
|
|
this.snowCanvas.style.display = "none"; |
|
|
|
this.snowCanvas.style.display = "none"; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
XmasUI.prototype.drawSnow = function() { |
|
|
|
drawSnow() { |
|
|
|
let width = this.snowCanvas.width; |
|
|
|
let width = this.snowCanvas.width; |
|
|
|
let height = this.snowCanvas.height; |
|
|
|
let height = this.snowCanvas.height; |
|
|
|
let now = Date.now() / 1000; |
|
|
|
let now = Date.now() / 1000; |
|
|
@ -1091,33 +1066,32 @@ XmasUI.prototype.drawSnow = function() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
XmasUI.prototype.resize = function() { |
|
|
|
resize() { |
|
|
|
ModernUI.prototype.resize.call(this); |
|
|
|
super.resize(); |
|
|
|
|
|
|
|
|
|
|
|
let ratio = window.innerWidth / window.innerHeight; |
|
|
|
let ratio = window.innerWidth / window.innerHeight; |
|
|
|
// cleared on resize
|
|
|
|
// cleared on resize
|
|
|
|
let savedFill = this.snowContext.fillStyle; |
|
|
|
let savedFill = this.snowContext.fillStyle; |
|
|
|
this.snowCanvas.width = Math.ceil(720 * ratio); |
|
|
|
this.snowCanvas.width = Math.ceil(720 * ratio); |
|
|
|
this.snowContext.fillStyle = savedFill; |
|
|
|
this.snowContext.fillStyle = savedFill; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
XmasUI.prototype.newColour = function(colour) {}; |
|
|
|
newColour(colour) {} |
|
|
|
XmasUI.prototype.blurUpdated = function(x, y) {}; |
|
|
|
blurUpdated(x, y) {} |
|
|
|
XmasUI.prototype.updateTime = function(time) {}; |
|
|
|
updateTime(time) {} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function HalloweenUI(parent, name) { |
|
|
|
class HalloweenUI extends ModernUI { |
|
|
|
ModernUI.call(this, parent, name ? name : "HalloweenUI"); |
|
|
|
constructor(parent, name) { |
|
|
|
|
|
|
|
super(parent, name ? name : "HalloweenUI"); |
|
|
|
// This will cache our inverted tombstone image
|
|
|
|
// This will cache our inverted tombstone image
|
|
|
|
this.invert(true); |
|
|
|
this.invert(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HalloweenUI.prototype = Object.create(ModernUI.prototype); |
|
|
|
initUI() { |
|
|
|
HalloweenUI.prototype.constructor = HalloweenUI; |
|
|
|
super.initUI(); |
|
|
|
|
|
|
|
|
|
|
|
HalloweenUI.prototype.initUI = function() { |
|
|
|
|
|
|
|
ModernUI.prototype.initUI.call(this); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.controls.className += " hues-h-controls"; |
|
|
|
this.controls.className += " hues-h-controls"; |
|
|
|
this.beatBar.className += " hues-h-beatbar"; |
|
|
|
this.beatBar.className += " hues-h-beatbar"; |
|
|
@ -1183,29 +1157,30 @@ HalloweenUI.prototype.initUI = function() { |
|
|
|
this.vignette = document.createElement("div"); |
|
|
|
this.vignette = document.createElement("div"); |
|
|
|
this.vignette.className = "hues-h-vignette"; |
|
|
|
this.vignette.className = "hues-h-vignette"; |
|
|
|
this.root.appendChild(this.vignette); |
|
|
|
this.root.appendChild(this.vignette); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HalloweenUI.prototype.beat = function(beats, index) { |
|
|
|
beat(beats, index) { |
|
|
|
ModernUI.prototype.beat.call(this, beats, index); |
|
|
|
super.beat(beats, index); |
|
|
|
|
|
|
|
|
|
|
|
if (this.currentBeat != ".") { |
|
|
|
if (this.currentBeat != ".") { |
|
|
|
let eyes = this.beatCenter.ownerDocument.createElement("div"); |
|
|
|
let eyes = this.beatCenter.ownerDocument.createElement("div"); |
|
|
|
eyes.className = "hues-m-beatcenter hues-h-eyes"; |
|
|
|
eyes.className = "hues-m-beatcenter hues-h-eyes"; |
|
|
|
this.beatCenter.appendChild(eyes); |
|
|
|
this.beatCenter.appendChild(eyes); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HalloweenUI.prototype.connectCore = function(core) { |
|
|
|
connectCore(core) { |
|
|
|
ModernUI.prototype.connectCore.call(this, core); |
|
|
|
super.connectCore(core); |
|
|
|
|
|
|
|
|
|
|
|
this.core.preloader.classList.add("hues-h-text"); |
|
|
|
this.core.preloader.classList.add("hues-h-text"); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HalloweenUI.prototype.disconnect = function() { |
|
|
|
disconnect() { |
|
|
|
this.core.preloader.classList.remove("hues-h-text"); |
|
|
|
this.core.preloader.classList.remove("hues-h-text"); |
|
|
|
|
|
|
|
|
|
|
|
ModernUI.prototype.disconnect.call(this); |
|
|
|
super.disconnect(); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Positions and angles for the Xmas lights
|
|
|
|
// Positions and angles for the Xmas lights
|
|
|
|
let xleft = [ |
|
|
|
let xleft = [ |
|
|
|