Strip trailing whitespace

alternate-visualiser
William Toohey 10 years ago
parent ed78cf6e95
commit 33f492cc7e
  1. 13
      js/HuesCanvas.js
  2. 21
      js/HuesCore.js
  3. 14
      js/HuesSettings.js
  4. 104
      js/ResourceManager.js
  5. 53
      js/ResourcePack.js
  6. 16
      js/SoundManager.js

@ -66,7 +66,7 @@ function HuesCanvas(element, aContext, core) {
this.canvas = document.getElementById(element).getContext("2d"); this.canvas = document.getElementById(element).getContext("2d");
window.addEventListener('resize', this.resizeHandler(this)); window.addEventListener('resize', this.resizeHandler(this));
this.resize(); this.resize();
this.snowing = false; this.snowing = false;
this.maxSnow = 30; this.maxSnow = 30;
this.snowAngle = 0; 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 // 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 beatLoc = (index / song.charsPerBeat) % this.image.beatsPerAnim;
var aLen = this.image.bitmaps.length; var aLen = this.image.bitmaps.length;
this.animFrame = Math.floor(aLen * (beatLoc / this.image.beatsPerAnim)); 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 // Because negative mods are different in JS
this.animFrame = ((this.animFrame % aLen) + aLen) % aLen; this.animFrame = ((this.animFrame % aLen) + aLen) % aLen;
}; };
@ -368,7 +371,7 @@ HuesCanvas.prototype.setBlurDecay = function(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" : -1, "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);
}; };
@ -428,7 +431,7 @@ HuesCanvas.prototype.drawSnow = function() {
ctx.arc(p.x, p.y, p.r, 0, Math.PI*2, true); ctx.arc(p.x, p.y, p.r, 0, Math.PI*2, true);
} }
ctx.fill(); ctx.fill();
this.snowAngle += delta / 6; this.snowAngle += delta / 6;
for(var i = 0; i < this.maxSnow; i++) { for(var i = 0; i < this.maxSnow; i++) {
var p = this.snowflakes[i]; var p = this.snowflakes[i];
@ -438,7 +441,7 @@ HuesCanvas.prototype.drawSnow = function() {
//Lets make it more random by adding in the radius //Lets make it more random by adding in the radius
p.y += Math.cos(this.snowAngle+p.d) + 1 + p.r/2; p.y += Math.cos(this.snowAngle+p.d) + 1 + p.r/2;
p.x += Math.sin(this.snowAngle) * 2; p.x += Math.sin(this.snowAngle) * 2;
//Sending flakes back from the top when it exits //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. //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) { if(p.x > W+5 || p.x < -5 || p.y > H) {

@ -22,7 +22,7 @@
/* We don't want localstorage variables optimised to different identifiers*/ /* We don't want localstorage variables optimised to different identifiers*/
/*jshint -W069 */ /*jshint -W069 */
HuesCore = function(defaults) { function HuesCore(defaults) {
// Bunch-o-initialisers // Bunch-o-initialisers
this.version = "0x01"; this.version = "0x01";
this.beatIndex = 0; this.beatIndex = 0;
@ -39,14 +39,14 @@ HuesCore = function(defaults) {
this.loadedFiles=0; this.loadedFiles=0;
this.doBuildup=true; this.doBuildup=true;
this.userInterface = null; this.userInterface = null;
var that = this; var that = this;
window.onerror = function(msg, url, line, col, error) { window.onerror = function(msg, url, line, col, error) {
that.error(msg); that.error(msg);
// Get more info in console // Get more info in console
return false; return false;
}; };
console.log("0x40 Hues - start your engines!"); console.log("0x40 Hues - start your engines!");
this.colours = this.oldColours; this.colours = this.oldColours;
this.uiArray = []; this.uiArray = [];
@ -61,13 +61,13 @@ HuesCore = function(defaults) {
return; return;
} }
this.renderer = new HuesCanvas("waifu", this.soundManager.context, this); this.renderer = new HuesCanvas("waifu", this.soundManager.context, this);
this.uiArray.push(new RetroUI(), new WeedUI(), new ModernUI(), new XmasUI()); this.uiArray.push(new RetroUI(), new WeedUI(), new ModernUI(), new XmasUI());
this.settings.connectCore(this); this.settings.connectCore(this);
// Update with merged // Update with merged
defaults = this.settings.defaults; defaults = this.settings.defaults;
this.setColour(this.colourIndex); this.setColour(this.colourIndex);
if(defaults.load) { if(defaults.load) {
this.resourceManager.addAll(defaults.respacks, function() { this.resourceManager.addAll(defaults.respacks, function() {
document.getElementById("preloadHelper").className = "loaded"; document.getElementById("preloadHelper").className = "loaded";
@ -99,9 +99,9 @@ HuesCore = function(defaults) {
var key = e.keyCode || e.which; var key = e.keyCode || e.which;
return that.keyHandler(key); return that.keyHandler(key);
}; };
this.animationLoop(); this.animationLoop();
}; }
HuesCore.prototype.animationLoop = function() { HuesCore.prototype.animationLoop = function() {
var that = this; var that = this;
@ -381,6 +381,7 @@ HuesCore.prototype.beater = function(beat) {
if(this.isFullAuto) { if(this.isFullAuto) {
this.randomImage(); this.randomImage();
} }
/* falls through */
case '~': case '~':
// case: fade in build, not in rhythm. Must max out fade timer. // case: fade in build, not in rhythm. Must max out fade timer.
var maxSearch = this.currentSong.rhythm.length; var maxSearch = this.currentSong.rhythm.length;
@ -652,7 +653,7 @@ HuesCore.prototype.error = function(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'},
{'c': 0x550000, 'n': 'brick'}, {'c': 0x550000, 'n': 'brick'},
{'c': 0xAA0000, 'n': 'crimson'}, {'c': 0xAA0000, 'n': 'crimson'},
@ -717,7 +718,7 @@ HuesCore.prototype.oldColours =
{'c': 0x55FFFF, 'n': 'turquoise'}, {'c': 0x55FFFF, 'n': 'turquoise'},
{'c': 0xAAFFFF, 'n': 'powder'}, {'c': 0xAAFFFF, 'n': 'powder'},
{'c': 0xFFFFFF, 'n': 'white'}]; {'c': 0xFFFFFF, 'n': 'white'}];
HuesCore.prototype.pastelColours = HuesCore.prototype.pastelColours =
[{'c': 0xCD4A4A, 'n': 'Mahogany'}, [{'c': 0xCD4A4A, 'n': 'Mahogany'},
{'c': 0xFAE7B5, 'n': 'Banana Mania'}, {'c': 0xFAE7B5, 'n': 'Banana Mania'},
{'c': 0x9F8170, 'n': 'Beaver'}, {'c': 0x9F8170, 'n': 'Beaver'},
@ -782,7 +783,7 @@ HuesCore.prototype.pastelColours =
{'c': 0xFCE883, 'n': 'Yellow'}, {'c': 0xFCE883, 'n': 'Yellow'},
{'c': 0xC5E384, 'n': 'Yellow Green'}, {'c': 0xC5E384, 'n': 'Yellow Green'},
{'c': 0xFFB653, 'n': 'Yellow Orange'}]; {'c': 0xFFB653, 'n': 'Yellow Orange'}];
HuesCore.prototype.weedColours = HuesCore.prototype.weedColours =
[{'c': 0x00FF00, 'n': 'Green'}, [{'c': 0x00FF00, 'n': 'Green'},
{'c': 0x5A6351, 'n': 'Lizard'}, {'c': 0x5A6351, 'n': 'Lizard'},
{'c': 0x636F57, 'n': 'Cactus'}, {'c': 0x636F57, 'n': 'Cactus'},

@ -35,7 +35,7 @@ HuesSettings.prototype.defaultSettings = {
preloadPrefix: "0x", preloadPrefix: "0x",
preloadBase: 16, preloadBase: 16,
preloadMax: 0x40, preloadMax: 0x40,
// UI accessible config // UI accessible config
// Autosong stuff is a todo, becuase why even implement that // Autosong stuff is a todo, becuase why even implement that
smartAlign: "on", smartAlign: "on",
@ -113,7 +113,7 @@ HuesSettings.prototype.settingsOptions = {
name : "Play buildups", name : "Play buildups",
options : ["off", "once", "on"] options : ["off", "once", "on"]
} }
}; };
function HuesSettings(defaults) { function HuesSettings(defaults) {
@ -121,7 +121,7 @@ function HuesSettings(defaults) {
this.root = document.getElementById("huesSettings"); this.root = document.getElementById("huesSettings");
this.window = document.getElementById("settingsHelper"); this.window = document.getElementById("settingsHelper");
this.hide(); this.hide();
for(var attr in this.defaultSettings) { for(var attr in this.defaultSettings) {
if(this.defaultSettings.hasOwnProperty(attr)) { if(this.defaultSettings.hasOwnProperty(attr)) {
if(defaults[attr] === undefined) { if(defaults[attr] === undefined) {
@ -140,9 +140,9 @@ function HuesSettings(defaults) {
} }
} }
} }
this.defaults = defaults; this.defaults = defaults;
this.initUI(); this.initUI();
} }
@ -188,10 +188,10 @@ HuesSettings.prototype.showInfo = function() {
HuesSettings.prototype.initUI = function() { HuesSettings.prototype.initUI = function() {
var doc = this.root.ownerDocument; var doc = this.root.ownerDocument;
var that = this; var that = this;
document.getElementById("closeButton").onclick = function() {that.hide();}; document.getElementById("closeButton").onclick = function() {that.hide();};
// To order things nicely // To order things nicely
for(var cat in this.settingsCategories) { for(var cat in this.settingsCategories) {
if(this.settingsCategories.hasOwnProperty(cat)) { if(this.settingsCategories.hasOwnProperty(cat)) {

@ -24,20 +24,20 @@ var packsURL = "http://cdn.0x40hu.es/getRespacks.php";
function Resources(core) { function Resources(core) {
this.core = core; this.core = core;
this.resourcePacks = []; this.resourcePacks = [];
this.allSongs = []; this.allSongs = [];
this.allImages = []; this.allImages = [];
this.enabledSongs = []; this.enabledSongs = [];
this.enabledImages = []; this.enabledImages = [];
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;
this.root = null; this.root = null;
// For songs/images // For songs/images
this.listView = null; this.listView = null;
@ -132,12 +132,12 @@ Resources.prototype.addPack = function(pack) {
this.addResourcesToArrays(pack); this.addResourcesToArrays(pack);
this.rebuildEnabled(); this.rebuildEnabled();
this.updateTotals(); this.updateTotals();
this.appendListItem("respacks", pack.name, "res" + id, this.packsView.respackList, this.appendListItem("respacks", pack.name, "res" + id, this.packsView.respackList,
function() { function() {
pack.enabled = this.checked; pack.enabled = this.checked;
that.rebuildEnabled(); that.rebuildEnabled();
}, },
this.selectPackCallback(id) this.selectPackCallback(id)
); );
}; };
@ -151,7 +151,7 @@ Resources.prototype.rebuildArrays = function() {
this.allSongs = []; this.allSongs = [];
this.allImages = []; this.allImages = [];
this.allAnimations = []; this.allAnimations = [];
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]);
} }
@ -179,11 +179,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);
@ -253,7 +253,7 @@ Resources.prototype.parseLocalQueue = function(recursing) {
this.currentlyParsing = true; this.currentlyParsing = true;
if(this.fileParseQueue.length) { if(this.fileParseQueue.length) {
var r = new Respack(); var r = new Respack();
r.loadBlob(this.fileParseQueue.shift(), r.loadBlob(this.fileParseQueue.shift(),
function() { function() {
that.addPack(r); that.addPack(r);
that.localComplete(); that.localComplete();
@ -269,7 +269,7 @@ Resources.prototype.parseLocalQueue = function(recursing) {
Resources.prototype.localProgress = function(progress, respack) { Resources.prototype.localProgress = function(progress, respack) {
this.packsView.progressStatus.textContent = "Processing..."; this.packsView.progressStatus.textContent = "Processing...";
this.packsView.progressBar.style.width = (progress * 100) + "%"; this.packsView.progressBar.style.width = (progress * 100) + "%";
this.packsView.progressCurrent.textContent = respack.filesLoaded; this.packsView.progressCurrent.textContent = respack.filesLoaded;
this.packsView.progressTop.textContent = respack.filesToLoad; this.packsView.progressTop.textContent = respack.filesToLoad;
@ -280,7 +280,7 @@ Resources.prototype.localComplete = function(progress) {
var progStat = this.packsView.progressStatus; var progStat = this.packsView.progressStatus;
progStat.textContent = "Complete"; progStat.textContent = "Complete";
window.setTimeout(function() {progStat.textContent = "Idle";}, 2000); window.setTimeout(function() {progStat.textContent = "Idle";}, 2000);
this.packsView.progressBar.style.width = "100%"; this.packsView.progressBar.style.width = "100%";
this.packsView.progressCurrent.textContent = "0b"; this.packsView.progressCurrent.textContent = "0b";
this.packsView.progressTop.textContent = "0b"; this.packsView.progressTop.textContent = "0b";
@ -290,10 +290,10 @@ Resources.prototype.localComplete = function(progress) {
Resources.prototype.initUI = function() { Resources.prototype.initUI = function() {
this.root = document.getElementById("huesResources"); this.root = document.getElementById("huesResources");
var that = this; var that = this;
var packsContainer = document.createElement("div"); var packsContainer = document.createElement("div");
packsContainer.className = "res-packscontainer"; packsContainer.className = "res-packscontainer";
var packHeader = document.createElement("div"); var packHeader = document.createElement("div");
packHeader.textContent = "Current respacks"; packHeader.textContent = "Current respacks";
packHeader.className = "res-header"; packHeader.className = "res-header";
@ -318,7 +318,7 @@ Resources.prototype.initUI = function() {
} else { } else {
packList.className += " noremotes"; packList.className += " noremotes";
} }
var buttons = document.createElement("div"); var buttons = document.createElement("div");
buttons.className = "res-buttons"; buttons.className = "res-buttons";
var loadRemote = document.createElement("div"); var loadRemote = document.createElement("div");
@ -332,7 +332,7 @@ Resources.prototype.initUI = function() {
buttons.appendChild(loadLocal); buttons.appendChild(loadLocal);
buttons.appendChild(loadRemote); buttons.appendChild(loadRemote);
this.packsView.loadRemote = loadRemote; this.packsView.loadRemote = loadRemote;
this.fileInput = document.createElement("input"); this.fileInput = document.createElement("input");
this.fileInput.type ="file"; this.fileInput.type ="file";
this.fileInput.accept="application/zip"; this.fileInput.accept="application/zip";
@ -348,7 +348,7 @@ Resources.prototype.initUI = function() {
progressBar.appendChild(progressFilled); progressBar.appendChild(progressFilled);
var progressStatus = document.createElement("div"); var progressStatus = document.createElement("div");
progressStatus.textContent = "Idle"; progressStatus.textContent = "Idle";
var progressTexts = document.createElement("div"); var progressTexts = document.createElement("div");
progressTexts.id = "res-progress-texts"; progressTexts.id = "res-progress-texts";
var progressCurrent = document.createElement("div"); var progressCurrent = document.createElement("div");
@ -363,7 +363,7 @@ Resources.prototype.initUI = function() {
progressTexts.appendChild(progressCurrent); progressTexts.appendChild(progressCurrent);
progressTexts.appendChild(progressTop); progressTexts.appendChild(progressTop);
progressTexts.appendChild(progressPercent); progressTexts.appendChild(progressPercent);
this.packsView.progressBar = progressFilled; this.packsView.progressBar = progressFilled;
this.packsView.progressStatus = progressStatus; this.packsView.progressStatus = progressStatus;
this.packsView.progressCurrent = progressCurrent; this.packsView.progressCurrent = progressCurrent;
@ -372,7 +372,7 @@ Resources.prototype.initUI = function() {
progressContainer.appendChild(progressStatus); progressContainer.appendChild(progressStatus);
progressContainer.appendChild(progressBar); progressContainer.appendChild(progressBar);
progressContainer.appendChild(progressTexts); progressContainer.appendChild(progressTexts);
packsContainer.appendChild(packHeader); packsContainer.appendChild(packHeader);
packsContainer.appendChild(packList); packsContainer.appendChild(packList);
if(!this.core.settings.defaults.disableRemoteResources) { if(!this.core.settings.defaults.disableRemoteResources) {
@ -381,10 +381,10 @@ Resources.prototype.initUI = function() {
} }
packsContainer.appendChild(buttons); packsContainer.appendChild(buttons);
packsContainer.appendChild(progressContainer); packsContainer.appendChild(progressContainer);
var indivView = document.createElement("div"); var indivView = document.createElement("div");
indivView.className = "res-packcontainer"; indivView.className = "res-packcontainer";
var packName = document.createElement("div"); var packName = document.createElement("div");
packName.textContent = "<select a respack>"; packName.textContent = "<select a respack>";
var packInfo = document.createElement("div"); var packInfo = document.createElement("div");
@ -401,10 +401,10 @@ Resources.prototype.initUI = function() {
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";
var songCheck = document.createElement("input"); var songCheck = document.createElement("input");
songCheck.type = "radio"; songCheck.type = "radio";
songCheck.name = "packtab"; songCheck.name = "packtab";
@ -416,7 +416,7 @@ Resources.prototype.initUI = function() {
songCount.htmlFor = "res-songtab"; songCount.htmlFor = "res-songtab";
packTabs.appendChild(songCheck); packTabs.appendChild(songCheck);
packTabs.appendChild(songCount); packTabs.appendChild(songCount);
var imageCheck = document.createElement("input"); var imageCheck = document.createElement("input");
imageCheck.type = "radio"; imageCheck.type = "radio";
imageCheck.name = "packtab"; imageCheck.name = "packtab";
@ -427,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";
@ -436,7 +436,7 @@ Resources.prototype.initUI = function() {
imageList.className = "res-list"; imageList.className = "res-list";
packTabs.appendChild(songList); packTabs.appendChild(songList);
packTabs.appendChild(imageList); packTabs.appendChild(imageList);
var packButtons = document.createElement("div"); var packButtons = document.createElement("div");
packButtons.className = "res-buttons hidden"; packButtons.className = "res-buttons hidden";
packButtons.id = "res-packbuttons"; packButtons.id = "res-packbuttons";
@ -455,10 +455,10 @@ Resources.prototype.initUI = function() {
packButtons.appendChild(enableAll); packButtons.appendChild(enableAll);
packButtons.appendChild(invert); packButtons.appendChild(invert);
packButtons.appendChild(disableAll); packButtons.appendChild(disableAll);
var totalCounts = document.createElement("div"); var totalCounts = document.createElement("div");
totalCounts.id = "res-countscontainer"; totalCounts.id = "res-countscontainer";
var totalSongsCont = document.createElement("div"); var totalSongsCont = document.createElement("div");
var totalSongsLabel = document.createElement("span"); var totalSongsLabel = document.createElement("span");
totalSongsLabel.textContent = "Total Songs:"; totalSongsLabel.textContent = "Total Songs:";
@ -474,10 +474,10 @@ Resources.prototype.initUI = function() {
totalImages.className = "res-counts"; totalImages.className = "res-counts";
totalImagesCont.appendChild(totalImagesLabel); totalImagesCont.appendChild(totalImagesLabel);
totalImagesCont.appendChild(totalImages); totalImagesCont.appendChild(totalImages);
totalCounts.appendChild(totalSongsCont); totalCounts.appendChild(totalSongsCont);
totalCounts.appendChild(totalImagesCont); totalCounts.appendChild(totalImagesCont);
this.packView.name = packName; this.packView.name = packName;
this.packView.creator = packCreatorText; this.packView.creator = packCreatorText;
this.packView.size = packSize; this.packView.size = packSize;
@ -489,17 +489,17 @@ Resources.prototype.initUI = function() {
this.packView.packButtons = packButtons; this.packView.packButtons = packButtons;
this.packView.totalSongs = totalSongs; this.packView.totalSongs = totalSongs;
this.packView.totalImages = totalImages; this.packView.totalImages = totalImages;
indivView.appendChild(packName); indivView.appendChild(packName);
indivView.appendChild(packInfo); indivView.appendChild(packInfo);
indivView.appendChild(packDesc); indivView.appendChild(packDesc);
indivView.appendChild(packTabs); indivView.appendChild(packTabs);
indivView.appendChild(packButtons); indivView.appendChild(packButtons);
indivView.appendChild(totalCounts); indivView.appendChild(totalCounts);
this.root.appendChild(packsContainer); this.root.appendChild(packsContainer);
this.root.appendChild(indivView); this.root.appendChild(indivView);
this.listView = document.createElement("div"); this.listView = document.createElement("div");
this.enabledSongList = document.createElement("div"); this.enabledSongList = document.createElement("div");
this.enabledSongList.id = "res-enabledsonglist"; this.enabledSongList.id = "res-enabledsonglist";
@ -507,7 +507,7 @@ Resources.prototype.initUI = function() {
this.enabledImageList = document.createElement("div"); this.enabledImageList = document.createElement("div");
this.enabledImageList.id = "res-enabledimagelist"; this.enabledImageList.id = "res-enabledimagelist";
this.enabledImageList.className = "hidden"; this.enabledImageList.className = "hidden";
this.listView.appendChild(this.enabledSongList); this.listView.appendChild(this.enabledSongList);
this.listView.appendChild(this.enabledImageList); this.listView.appendChild(this.enabledImageList);
}; };
@ -549,10 +549,10 @@ Resources.prototype.truncateNum = function(num) {
Resources.prototype.selectPack = function(id) { Resources.prototype.selectPack = function(id) {
var pack = this.resourcePacks[id]; var pack = this.resourcePacks[id];
this.packView.pack = pack; this.packView.pack = pack;
this.packView.packButtons.className = "res-buttons"; this.packView.packButtons.className = "res-buttons";
this.packsView.loadRemote.className = "res-button hidden"; this.packsView.loadRemote.className = "res-button hidden";
this.packView.name.textContent = pack.name; this.packView.name.textContent = pack.name;
this.packView.creator.textContent = pack.author; this.packView.creator.textContent = pack.author;
this.packView.creator.href = pack.link ? pack.link : ""; this.packView.creator.href = pack.link ? pack.link : "";
@ -565,16 +565,16 @@ Resources.prototype.selectPack = function(id) {
this.packView.desc.textContent = pack.description; this.packView.desc.textContent = pack.description;
this.packView.songCount.textContent = "Songs: " + pack.songs.length; this.packView.songCount.textContent = "Songs: " + pack.songs.length;
this.packView.imageCount.textContent = "Images: " + pack.images.length; this.packView.imageCount.textContent = "Images: " + pack.images.length;
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++) {
var song = pack.songs[i]; var song = pack.songs[i];
this.appendListItem("songs", song.title, "song" + i, songList, this.appendListItem("songs", song.title, "song" + i, songList,
@ -582,7 +582,7 @@ Resources.prototype.selectPack = function(id) {
this.clickResourceCallback(song, true), this.clickResourceCallback(song, true),
song.enabled); song.enabled);
} }
for(var i = 0; i < pack.images.length; i++) { for(var i = 0; i < pack.images.length; i++) {
var image = pack.images[i]; var image = pack.images[i];
this.appendListItem("images", image.name, "image" + i, imageList, this.appendListItem("images", image.name, "image" + i, imageList,
@ -644,7 +644,7 @@ Resources.prototype.enableAll = function() {
for(var i = 0; i < tab.arr.length; i++) { for(var i = 0; i < tab.arr.length; i++) {
tab.arr[i].enabled = true; tab.arr[i].enabled = true;
document.getElementById(tab.elName + i).checked = true; document.getElementById(tab.elName + i).checked = true;
} }
this.rebuildEnabled(); this.rebuildEnabled();
}; };
@ -655,7 +655,7 @@ Resources.prototype.disableAll = function() {
for(var i = 0; i < tab.arr.length; i++) { for(var i = 0; i < tab.arr.length; i++) {
tab.arr[i].enabled = false; tab.arr[i].enabled = false;
document.getElementById(tab.elName + i).checked = false; document.getElementById(tab.elName + i).checked = false;
} }
this.rebuildEnabled(); this.rebuildEnabled();
}; };
@ -666,7 +666,7 @@ Resources.prototype.invert = function() {
for(var i = 0; i < tab.arr.length; i++) { for(var i = 0; i < tab.arr.length; i++) {
tab.arr[i].enabled = !tab.arr[i].enabled; tab.arr[i].enabled = !tab.arr[i].enabled;
document.getElementById(tab.elName + i).checked = tab.arr[i].enabled; document.getElementById(tab.elName + i).checked = tab.arr[i].enabled;
} }
this.rebuildEnabled(); this.rebuildEnabled();
}; };
@ -701,7 +701,7 @@ Resources.prototype.loadRemotes = function() {
remoteList.removeChild(remoteList.firstElementChild); remoteList.removeChild(remoteList.firstElementChild);
} }
var item = this.appendSimpleListItem("Loading...", remoteList); var item = this.appendSimpleListItem("Loading...", remoteList);
var req = new XMLHttpRequest(); var req = new XMLHttpRequest();
req.open('GET', packsURL, true); req.open('GET', packsURL, true);
req.responseType = 'json'; req.responseType = 'json';
@ -739,7 +739,7 @@ Resources.prototype.getRemoteCallback = function(index) {
Resources.prototype.selectRemotePack = function(id) { Resources.prototype.selectRemotePack = function(id) {
var pack = this.remotes[id]; var pack = this.remotes[id];
this.packView.pack = pack; this.packView.pack = pack;
this.packView.packButtons.className = "res-buttons hidden"; this.packView.packButtons.className = "res-buttons hidden";
this.packsView.loadRemote.className = "res-button"; this.packsView.loadRemote.className = "res-button";
if(pack.loaded) { if(pack.loaded) {
@ -748,7 +748,7 @@ Resources.prototype.selectRemotePack = function(id) {
} else { } else {
this.packsView.loadRemote.textContent = "LOAD REMOTE"; this.packsView.loadRemote.textContent = "LOAD REMOTE";
} }
this.packView.name.textContent = pack.name; this.packView.name.textContent = pack.name;
this.packView.creator.textContent = pack.author; this.packView.creator.textContent = pack.author;
this.packView.creator.href = pack.link ? pack.link : ""; this.packView.creator.href = pack.link ? pack.link : "";
@ -761,21 +761,21 @@ Resources.prototype.selectRemotePack = function(id) {
this.packView.desc.textContent = pack.description; this.packView.desc.textContent = pack.description;
this.packView.songCount.textContent = "Songs: " + pack.songcount; this.packView.songCount.textContent = "Songs: " + pack.songcount;
this.packView.imageCount.textContent = "Images: " + pack.imagecount; this.packView.imageCount.textContent = "Images: " + pack.imagecount;
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++) {
var song = pack.songs[i]; var song = pack.songs[i];
this.appendSimpleListItem(song, songList); this.appendSimpleListItem(song, songList);
} }
for(var i = 0; i < pack.images.length; i++) { for(var i = 0; i < pack.images.length; i++) {
var image = pack.images[i]; var image = pack.images[i];
this.appendSimpleListItem(image, imageList); this.appendSimpleListItem(image, imageList);
@ -785,12 +785,12 @@ Resources.prototype.selectRemotePack = function(id) {
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;
} }
// TODO Error checking on failure // TODO Error checking on failure
pack.loaded = true; pack.loaded = true;
that.packsView.loadRemote.className = "res-button loaded"; that.packsView.loadRemote.className = "res-button loaded";
@ -822,7 +822,7 @@ Resources.prototype.remoteComplete = function(progress) {
progStat.textContent = "Complete"; progStat.textContent = "Complete";
window.setTimeout(function() {progStat.textContent = "Idle";}, 2000); window.setTimeout(function() {progStat.textContent = "Idle";}, 2000);
this.packsView.loadRemote.textContent = "LOADED"; this.packsView.loadRemote.textContent = "LOADED";
this.packsView.progressBar.style.width = "100%"; this.packsView.progressBar.style.width = "100%";
this.packsView.progressCurrent.textContent = "0b"; this.packsView.progressCurrent.textContent = "0b";
this.packsView.progressTop.textContent = "0b"; this.packsView.progressTop.textContent = "0b";

@ -31,7 +31,7 @@ function Respack(url) {
this.songQueue = []; this.songQueue = [];
this.images = []; this.images = [];
this.imageQueue = []; this.imageQueue = [];
this.name = "<no name>"; this.name = "<no name>";
this.author = "<unknown>"; this.author = "<unknown>";
this.description = "<no description>"; this.description = "<no description>";
@ -55,7 +55,7 @@ function Respack(url) {
this.filesToLoad = 0; this.filesToLoad = 0;
this.filesLoaded = 0; this.filesLoaded = 0;
this.loadedFromURL = false; this.loadedFromURL = false;
if(url) if(url)
this.loadFromURL(url); this.loadFromURL(url);
} }
@ -76,9 +76,9 @@ Respack.prototype.updateProgress = function() {
Respack.prototype.loadFromURL = function(url, callback, progress) { Respack.prototype.loadFromURL = function(url, callback, progress) {
var that = this; var that = this;
this.loadedFromURL = true; this.loadedFromURL = true;
var req = new XMLHttpRequest(); var req = new XMLHttpRequest();
req.open('GET', url, true); req.open('GET', url, true);
req.responseType = 'blob'; req.responseType = 'blob';
@ -119,28 +119,28 @@ Respack.prototype.loadBlob = function(blob, callback, progress, errorCallback) {
if(errorCallback) { if(errorCallback) {
errorCallback(error.toString()); errorCallback(error.toString());
} }
} }
); );
}; };
Respack.prototype.parseWholeZip = function() { Respack.prototype.parseWholeZip = function() {
// TODO might break on bad file // TODO might break on bad file
console.log("Loading new respack: " + this.file.root.children[0].name); console.log("Loading new respack: " + this.file.root.children[0].name);
var entries = this.file.entries; var entries = this.file.entries;
this.totalFiles = 0; this.totalFiles = 0;
// Progress events // Progress events
this.filesToLoad = 0; this.filesToLoad = 0;
this.filesLoaded = 0; this.filesLoaded = 0;
for(var i = 0; i < entries.length; i++) { for(var i = 0; i < entries.length; i++) {
if(!entries[i].directory && entries[i].name) { if(!entries[i].directory && entries[i].name) {
this.totalFiles++; this.totalFiles++;
this.parseFile(entries[i]); this.parseFile(entries[i]);
} }
} }
debug("ZIP loader: trying to finish"); debug("ZIP loader: trying to finish");
this.tryFinish(); this.tryFinish();
}; };
@ -180,7 +180,7 @@ Respack.prototype.parseImage = function(file) {
Respack.prototype.parseXML = function() { Respack.prototype.parseXML = function() {
var that = this; var that = this;
if (this._infoFile) { if (this._infoFile) {
this._infoFile.getText(function(text) { this._infoFile.getText(function(text) {
text = text.replace(/&amp;/g, '&'); text = text.replace(/&amp;/g, '&');
@ -219,10 +219,10 @@ Respack.prototype.parseXML = function() {
}); });
return; return;
} }
// Finally done! // Finally done!
this.file = null; this.file = null;
console.log("Loaded", this.name, "successfully with", this.songs.length, console.log("Loaded", this.name, "successfully with", this.songs.length,
"songs and", this.images.length, "images."); "songs and", this.images.length, "images.");
if(this._completionCallback) { if(this._completionCallback) {
this._completionCallback(); this._completionCallback();
@ -237,14 +237,14 @@ Element.prototype.getTag = function(tag, def) {
Respack.prototype.parseSongFile = function(text) { Respack.prototype.parseSongFile = function(text) {
debug(" - Parsing songFile"); debug(" - Parsing songFile");
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;
} }
var newSongs = []; var newSongs = [];
// Not supported in mobile safari // Not supported in mobile safari
// var songsXML = oDOM.documentElement.children; // var songsXML = oDOM.documentElement.children;
@ -257,13 +257,13 @@ Respack.prototype.parseSongFile = function(text) {
song.title = "<no name>"; song.title = "<no name>";
debug(" WARNING!", song.name, "has no title!"); debug(" WARNING!", song.name, "has no title!");
} }
song.rhythm = el.getTag("rhythm"); song.rhythm = el.getTag("rhythm");
if(!song.rhythm) { if(!song.rhythm) {
song.rhythm = "..no..rhythm.."; song.rhythm = "..no..rhythm..";
debug(" WARNING!!", song.name, "has no rhythm!!"); debug(" WARNING!!", song.name, "has no rhythm!!");
} }
song.startSilence = el.getTag("startSilence"); song.startSilence = el.getTag("startSilence");
song.endSilence = el.getTag("endSilence"); song.endSilence = el.getTag("endSilence");
song.buildupLength = el.getTag("buildupLength"); song.buildupLength = el.getTag("buildupLength");
@ -283,11 +283,11 @@ Respack.prototype.parseSongFile = function(text) {
debug(" WARNING!", "Didn't find a buildup '" + song.buildup + "'!"); debug(" WARNING!", "Didn't find a buildup '" + song.buildup + "'!");
} }
} }
song.buildupRhythm = el.getTag("buildupRhythm"); song.buildupRhythm = el.getTag("buildupRhythm");
song.source = el.getTag("source"); song.source = el.getTag("source");
song.charsPerBeat = parseFloat(el.getTag("charsPerBeat")); song.charsPerBeat = parseFloat(el.getTag("charsPerBeat"));
// Because PackShit breaks everything // Because PackShit breaks everything
if(this.name == "PackShit") { if(this.name == "PackShit") {
song.forceTrim = true; song.forceTrim = true;
@ -295,7 +295,7 @@ Respack.prototype.parseSongFile = function(text) {
newSongs.push(song); newSongs.push(song);
debug(" [I] " + song.name, ": '" + song.title + "' added to songs"); debug(" [I] " + song.name, ": '" + song.title + "' added to songs");
} else { } else {
debug(" WARNING!", "songs.xml: <song> element", i + 1, debug(" WARNING!", "songs.xml: <song> element", i + 1,
"- no song '" + el.attributes[0].value + "' found"); "- no song '" + el.attributes[0].value + "' found");
} }
} }
@ -309,7 +309,7 @@ Respack.prototype.parseSongFile = function(text) {
Respack.prototype.parseInfoFile = function(text) { Respack.prototype.parseInfoFile = function(text) {
debug(" - Parsing infoFile"); debug(" - Parsing infoFile");
var oParser = new DOMParser(); var oParser = new DOMParser();
var oDOM = oParser.parseFromString(text, "text/xml"); var oDOM = oParser.parseFromString(text, "text/xml");
var info = oDOM.documentElement; var info = oDOM.documentElement;
@ -317,7 +317,7 @@ Respack.prototype.parseInfoFile = function(text) {
console.log("info.xml error, corrupt file?"); console.log("info.xml error, corrupt file?");
return; return;
} }
// self reference strings to avoid changing strings twice in future // self reference strings to avoid changing strings twice in future
this.name = info.getTag("name", this.name); this.name = info.getTag("name", this.name);
this.author = info.getTag("author", this.author); this.author = info.getTag("author", this.author);
@ -327,14 +327,14 @@ Respack.prototype.parseInfoFile = function(text) {
Respack.prototype.parseImageFile = function(text) { Respack.prototype.parseImageFile = function(text) {
debug(" - Parsing imagefile"); debug(" - Parsing imagefile");
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;
} }
var newImages = []; var newImages = [];
// not in mobile safari // not in mobile safari
// var imagesXML = oDOM.documentElement.children; // var imagesXML = oDOM.documentElement.children;
@ -350,6 +350,7 @@ Respack.prototype.parseImageFile = function(text) {
// self reference defaults to avoid changing strings twice in future // self reference defaults to avoid changing strings twice in future
image.align = el.getTag("align", image.align); image.align = el.getTag("align", image.align);
image.beatsPerAnim = parseFloat(el.getTag("beatsPerAnim")); image.beatsPerAnim = parseFloat(el.getTag("beatsPerAnim"));
image.syncOffset = parseFloat(el.getTag("syncOffset"));
var frameDur = el.getTag("frameDuration"); var frameDur = el.getTag("frameDuration");
if(frameDur) { if(frameDur) {
image.frameDurations = []; image.frameDurations = [];
@ -370,7 +371,7 @@ Respack.prototype.parseImageFile = function(text) {
debug(" WARNING!!", "Image", image.name, "has no bitmap nor animation frames!"); debug(" WARNING!!", "Image", image.name, "has no bitmap nor animation frames!");
} }
} else { } else {
debug(" WARNING!", "images.xml: <image> element", debug(" WARNING!", "images.xml: <image> element",
i + 1, "- no image '" + el.attributes[0].value + "' found"); i + 1, "- no image '" + el.attributes[0].value + "' found");
} }
} }
@ -417,7 +418,7 @@ Respack.prototype.parseSongQueue = function() {
var that = this; var that = this;
var songFile = this.songQueue.shift(); var songFile = this.songQueue.shift();
var name = songFile.name.replace(this.audioExtensions, ""); var name = songFile.name.replace(this.audioExtensions, "");
debug("parsing song: " + name); debug("parsing song: " + name);
if (this.containsSong(name)) { if (this.containsSong(name)) {
var oldSong = this.getSong(name); var oldSong = this.getSong(name);
@ -463,7 +464,7 @@ Respack.prototype.parseSongQueue = function() {
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

@ -27,7 +27,7 @@ function SoundManager(core) {
this.core = core; this.core = core;
this.playing = false; this.playing = false;
this.song = null; this.song = null;
/* Lower level audio and timing info */ /* Lower level audio and timing info */
this.bufSource = null; this.bufSource = null;
this.buffer = null; this.buffer = null;
@ -35,21 +35,21 @@ function SoundManager(core) {
this.startTime = 0; // File start time - 0 is loop start, not build start this.startTime = 0; // File start time - 0 is loop start, not build start
this.loopStart = 0; // When the build ends, if any this.loopStart = 0; // When the build ends, if any
this.loopLength = 0; // For calculating beat lengths this.loopLength = 0; // For calculating beat lengths
// Volume // Volume
this.gainNode = null; this.gainNode = null;
this.mute = false; this.mute = false;
this.lastVol = 1; this.lastVol = 1;
// For concatenating our files // For concatenating our files
this.leftToLoad = 0; this.leftToLoad = 0;
this.tmpBuffer = null; this.tmpBuffer = null;
this.tmpBuild = null; this.tmpBuild = null;
this.onLoadCallback = null; this.onLoadCallback = null;
// In case of API non-support // In case of API non-support
this.canUse = true; this.canUse = true;
// Check Web Audio API Support // Check Web Audio API Support
try { try {
// More info at http://caniuse.com/#feat=audio-api // More info at http://caniuse.com/#feat=audio-api
@ -70,7 +70,7 @@ function SoundManager(core) {
this.errorMsg = "MP3 not supported in this browser."; this.errorMsg = "MP3 not supported in this browser.";
return; return;
} }
var that = this; var that = this;
window.addEventListener('touchend', function() { window.addEventListener('touchend', function() {
// create empty buffer // create empty buffer
@ -97,7 +97,7 @@ SoundManager.prototype.playSong = function(song, playBuild, callback) {
if(!song || (!song.sound)) { // null song if(!song || (!song.sound)) { // null song
return; return;
} }
this.loadBuffer(song, function() { this.loadBuffer(song, function() {
// To prevent race condition if you press "next" twice fast // To prevent race condition if you press "next" twice fast
if(song == that.song) { if(song == that.song) {
@ -111,7 +111,7 @@ SoundManager.prototype.playSong = function(song, playBuild, callback) {
that.bufSource.loopStart = that.loopStart; that.bufSource.loopStart = that.loopStart;
that.bufSource.loopEnd = that.buffer.duration; that.bufSource.loopEnd = that.buffer.duration;
that.bufSource.connect(that.gainNode); that.bufSource.connect(that.gainNode);
// This fixes sync issues on Firefox and slow machines. // This fixes sync issues on Firefox and slow machines.
if(that.context.suspend && that.context.resume) { if(that.context.suspend && that.context.resume) {
that.context.suspend().then(function() { that.context.suspend().then(function() {

Loading…
Cancel
Save