diff --git a/js/HuesCanvas.js b/js/HuesCanvas.js index 3cae374..819b0e4 100644 --- a/js/HuesCanvas.js +++ b/js/HuesCanvas.js @@ -66,7 +66,7 @@ function HuesCanvas(element, aContext, core) { this.canvas = document.getElementById(element).getContext("2d"); window.addEventListener('resize', this.resizeHandler(this)); this.resize(); - + this.snowing = false; this.maxSnow = 30; this.snowAngle = 0; @@ -270,9 +270,12 @@ HuesCanvas.prototype.syncAnim = function() { } // This loops A-OK because the core's beatIndex never rolls over for a new loop var beatLoc = (index / song.charsPerBeat) % this.image.beatsPerAnim; - + var aLen = this.image.bitmaps.length; this.animFrame = Math.floor(aLen * (beatLoc / this.image.beatsPerAnim)); + if(this.image.syncOffset) { + this.animFrame += this.image.syncOffset; + } // Because negative mods are different in JS this.animFrame = ((this.animFrame % aLen) + aLen) % aLen; }; @@ -368,7 +371,7 @@ HuesCanvas.prototype.setBlurDecay = function(decay) { }; HuesCanvas.prototype.setBlurQuality = function(quality) { - this.blurIterations = {"low" : 3, "medium" : 11, "high" : 19, "extreme" : 35}[quality]; + this.blurIterations = {"low" : -1, "medium" : 11, "high" : 19, "extreme" : 35}[quality]; this.blurDelta = 1 / (this.blurIterations/2); this.blurAlpha = 1 / (this.blurIterations/2); }; @@ -428,7 +431,7 @@ HuesCanvas.prototype.drawSnow = function() { ctx.arc(p.x, p.y, p.r, 0, Math.PI*2, true); } ctx.fill(); - + this.snowAngle += delta / 6; for(var i = 0; i < this.maxSnow; i++) { var p = this.snowflakes[i]; @@ -438,7 +441,7 @@ HuesCanvas.prototype.drawSnow = function() { //Lets make it more random by adding in the radius p.y += Math.cos(this.snowAngle+p.d) + 1 + p.r/2; p.x += Math.sin(this.snowAngle) * 2; - + //Sending flakes back from the top when it exits //Lets make it a bit more organic and let flakes enter from the left and right also. if(p.x > W+5 || p.x < -5 || p.y > H) { diff --git a/js/HuesCore.js b/js/HuesCore.js index 30719c2..3277e7e 100644 --- a/js/HuesCore.js +++ b/js/HuesCore.js @@ -22,7 +22,7 @@ /* We don't want localstorage variables optimised to different identifiers*/ /*jshint -W069 */ -HuesCore = function(defaults) { +function HuesCore(defaults) { // Bunch-o-initialisers this.version = "0x01"; this.beatIndex = 0; @@ -39,14 +39,14 @@ HuesCore = function(defaults) { this.loadedFiles=0; this.doBuildup=true; this.userInterface = null; - + var that = this; window.onerror = function(msg, url, line, col, error) { that.error(msg); // Get more info in console return false; }; - + console.log("0x40 Hues - start your engines!"); this.colours = this.oldColours; this.uiArray = []; @@ -61,13 +61,13 @@ HuesCore = function(defaults) { return; } this.renderer = new HuesCanvas("waifu", this.soundManager.context, this); - + this.uiArray.push(new RetroUI(), new WeedUI(), new ModernUI(), new XmasUI()); this.settings.connectCore(this); // Update with merged defaults = this.settings.defaults; this.setColour(this.colourIndex); - + if(defaults.load) { this.resourceManager.addAll(defaults.respacks, function() { document.getElementById("preloadHelper").className = "loaded"; @@ -99,9 +99,9 @@ HuesCore = function(defaults) { var key = e.keyCode || e.which; return that.keyHandler(key); }; - + this.animationLoop(); -}; +} HuesCore.prototype.animationLoop = function() { var that = this; @@ -381,6 +381,7 @@ HuesCore.prototype.beater = function(beat) { if(this.isFullAuto) { this.randomImage(); } + /* falls through */ case '~': // case: fade in build, not in rhythm. Must max out fade timer. var maxSearch = this.currentSong.rhythm.length; @@ -652,7 +653,7 @@ HuesCore.prototype.error = function(message) { document.getElementById("preMain").style.color = "#F00"; }; -HuesCore.prototype.oldColours = +HuesCore.prototype.oldColours = [{'c': 0x000000, 'n': 'black'}, {'c': 0x550000, 'n': 'brick'}, {'c': 0xAA0000, 'n': 'crimson'}, @@ -717,7 +718,7 @@ HuesCore.prototype.oldColours = {'c': 0x55FFFF, 'n': 'turquoise'}, {'c': 0xAAFFFF, 'n': 'powder'}, {'c': 0xFFFFFF, 'n': 'white'}]; -HuesCore.prototype.pastelColours = +HuesCore.prototype.pastelColours = [{'c': 0xCD4A4A, 'n': 'Mahogany'}, {'c': 0xFAE7B5, 'n': 'Banana Mania'}, {'c': 0x9F8170, 'n': 'Beaver'}, @@ -782,7 +783,7 @@ HuesCore.prototype.pastelColours = {'c': 0xFCE883, 'n': 'Yellow'}, {'c': 0xC5E384, 'n': 'Yellow Green'}, {'c': 0xFFB653, 'n': 'Yellow Orange'}]; -HuesCore.prototype.weedColours = +HuesCore.prototype.weedColours = [{'c': 0x00FF00, 'n': 'Green'}, {'c': 0x5A6351, 'n': 'Lizard'}, {'c': 0x636F57, 'n': 'Cactus'}, diff --git a/js/HuesSettings.js b/js/HuesSettings.js index 40818b3..29a0ae9 100644 --- a/js/HuesSettings.js +++ b/js/HuesSettings.js @@ -35,7 +35,7 @@ HuesSettings.prototype.defaultSettings = { preloadPrefix: "0x", preloadBase: 16, preloadMax: 0x40, - + // UI accessible config // Autosong stuff is a todo, becuase why even implement that smartAlign: "on", @@ -113,7 +113,7 @@ HuesSettings.prototype.settingsOptions = { name : "Play buildups", options : ["off", "once", "on"] } - + }; function HuesSettings(defaults) { @@ -121,7 +121,7 @@ function HuesSettings(defaults) { this.root = document.getElementById("huesSettings"); this.window = document.getElementById("settingsHelper"); this.hide(); - + for(var attr in this.defaultSettings) { if(this.defaultSettings.hasOwnProperty(attr)) { if(defaults[attr] === undefined) { @@ -140,9 +140,9 @@ function HuesSettings(defaults) { } } } - + this.defaults = defaults; - + this.initUI(); } @@ -188,10 +188,10 @@ HuesSettings.prototype.showInfo = function() { HuesSettings.prototype.initUI = function() { var doc = this.root.ownerDocument; - + var that = this; document.getElementById("closeButton").onclick = function() {that.hide();}; - + // To order things nicely for(var cat in this.settingsCategories) { if(this.settingsCategories.hasOwnProperty(cat)) { diff --git a/js/ResourceManager.js b/js/ResourceManager.js index 0f4e0b7..b4f60f9 100644 --- a/js/ResourceManager.js +++ b/js/ResourceManager.js @@ -24,20 +24,20 @@ var packsURL = "http://cdn.0x40hu.es/getRespacks.php"; function Resources(core) { this.core = core; - + this.resourcePacks = []; this.allSongs = []; this.allImages = []; this.enabledSongs = []; this.enabledImages = []; - + this.toLoad = 0; this.progressState = []; this.rToLoad = []; this.loadFinishCallback = null; this.progressCallback = null; - + this.root = null; // For songs/images this.listView = null; @@ -132,12 +132,12 @@ Resources.prototype.addPack = function(pack) { this.addResourcesToArrays(pack); this.rebuildEnabled(); this.updateTotals(); - + this.appendListItem("respacks", pack.name, "res" + id, this.packsView.respackList, function() { pack.enabled = this.checked; that.rebuildEnabled(); - }, + }, this.selectPackCallback(id) ); }; @@ -151,7 +151,7 @@ Resources.prototype.rebuildArrays = function() { this.allSongs = []; this.allImages = []; this.allAnimations = []; - + for(var i = 0; i < this.resourcePacks.length; i++) { this.addResourcesToArrays(this.resourcePacks[i]); } @@ -179,11 +179,11 @@ Resources.prototype.rebuildEnabled = function() { } } } - + var songList = this.enabledSongList; while(songList.firstElementChild) { songList.removeChild(songList.firstElementChild); - } + } var imageList = this.enabledImageList; while(imageList.firstElementChild) { imageList.removeChild(imageList.firstElementChild); @@ -253,7 +253,7 @@ Resources.prototype.parseLocalQueue = function(recursing) { this.currentlyParsing = true; if(this.fileParseQueue.length) { var r = new Respack(); - r.loadBlob(this.fileParseQueue.shift(), + r.loadBlob(this.fileParseQueue.shift(), function() { that.addPack(r); that.localComplete(); @@ -269,7 +269,7 @@ Resources.prototype.parseLocalQueue = function(recursing) { Resources.prototype.localProgress = function(progress, respack) { this.packsView.progressStatus.textContent = "Processing..."; - + this.packsView.progressBar.style.width = (progress * 100) + "%"; this.packsView.progressCurrent.textContent = respack.filesLoaded; this.packsView.progressTop.textContent = respack.filesToLoad; @@ -280,7 +280,7 @@ Resources.prototype.localComplete = function(progress) { var progStat = this.packsView.progressStatus; progStat.textContent = "Complete"; window.setTimeout(function() {progStat.textContent = "Idle";}, 2000); - + this.packsView.progressBar.style.width = "100%"; this.packsView.progressCurrent.textContent = "0b"; this.packsView.progressTop.textContent = "0b"; @@ -290,10 +290,10 @@ Resources.prototype.localComplete = function(progress) { Resources.prototype.initUI = function() { this.root = document.getElementById("huesResources"); var that = this; - + var packsContainer = document.createElement("div"); packsContainer.className = "res-packscontainer"; - + var packHeader = document.createElement("div"); packHeader.textContent = "Current respacks"; packHeader.className = "res-header"; @@ -318,7 +318,7 @@ Resources.prototype.initUI = function() { } else { packList.className += " noremotes"; } - + var buttons = document.createElement("div"); buttons.className = "res-buttons"; var loadRemote = document.createElement("div"); @@ -332,7 +332,7 @@ Resources.prototype.initUI = function() { buttons.appendChild(loadLocal); buttons.appendChild(loadRemote); this.packsView.loadRemote = loadRemote; - + this.fileInput = document.createElement("input"); this.fileInput.type ="file"; this.fileInput.accept="application/zip"; @@ -348,7 +348,7 @@ Resources.prototype.initUI = function() { progressBar.appendChild(progressFilled); var progressStatus = document.createElement("div"); progressStatus.textContent = "Idle"; - + var progressTexts = document.createElement("div"); progressTexts.id = "res-progress-texts"; var progressCurrent = document.createElement("div"); @@ -363,7 +363,7 @@ Resources.prototype.initUI = function() { progressTexts.appendChild(progressCurrent); progressTexts.appendChild(progressTop); progressTexts.appendChild(progressPercent); - + this.packsView.progressBar = progressFilled; this.packsView.progressStatus = progressStatus; this.packsView.progressCurrent = progressCurrent; @@ -372,7 +372,7 @@ Resources.prototype.initUI = function() { progressContainer.appendChild(progressStatus); progressContainer.appendChild(progressBar); progressContainer.appendChild(progressTexts); - + packsContainer.appendChild(packHeader); packsContainer.appendChild(packList); if(!this.core.settings.defaults.disableRemoteResources) { @@ -381,10 +381,10 @@ Resources.prototype.initUI = function() { } packsContainer.appendChild(buttons); packsContainer.appendChild(progressContainer); - + var indivView = document.createElement("div"); indivView.className = "res-packcontainer"; - + var packName = document.createElement("div"); packName.textContent = "