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");
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) {

@ -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'},

@ -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)) {

@ -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 = "<select a respack>";
var packInfo = document.createElement("div");
@ -401,10 +401,10 @@ Resources.prototype.initUI = function() {
var packDesc = document.createElement("div");
packDesc.id = "res-packdesc";
packDesc.textContent = "<no description>";
var packTabs = document.createElement("div");
packTabs.id = "res-packtabs";
var songCheck = document.createElement("input");
songCheck.type = "radio";
songCheck.name = "packtab";
@ -416,7 +416,7 @@ Resources.prototype.initUI = function() {
songCount.htmlFor = "res-songtab";
packTabs.appendChild(songCheck);
packTabs.appendChild(songCount);
var imageCheck = document.createElement("input");
imageCheck.type = "radio";
imageCheck.name = "packtab";
@ -427,7 +427,7 @@ Resources.prototype.initUI = function() {
imageCount.htmlFor = "res-imagetab";
packTabs.appendChild(imageCheck);
packTabs.appendChild(imageCount);
var songList = document.createElement("div");
songList.id = "res-songlist";
songList.className = "res-list";
@ -436,7 +436,7 @@ Resources.prototype.initUI = function() {
imageList.className = "res-list";
packTabs.appendChild(songList);
packTabs.appendChild(imageList);
var packButtons = document.createElement("div");
packButtons.className = "res-buttons hidden";
packButtons.id = "res-packbuttons";
@ -455,10 +455,10 @@ Resources.prototype.initUI = function() {
packButtons.appendChild(enableAll);
packButtons.appendChild(invert);
packButtons.appendChild(disableAll);
var totalCounts = document.createElement("div");
totalCounts.id = "res-countscontainer";
var totalSongsCont = document.createElement("div");
var totalSongsLabel = document.createElement("span");
totalSongsLabel.textContent = "Total Songs:";
@ -474,10 +474,10 @@ Resources.prototype.initUI = function() {
totalImages.className = "res-counts";
totalImagesCont.appendChild(totalImagesLabel);
totalImagesCont.appendChild(totalImages);
totalCounts.appendChild(totalSongsCont);
totalCounts.appendChild(totalImagesCont);
this.packView.name = packName;
this.packView.creator = packCreatorText;
this.packView.size = packSize;
@ -489,17 +489,17 @@ Resources.prototype.initUI = function() {
this.packView.packButtons = packButtons;
this.packView.totalSongs = totalSongs;
this.packView.totalImages = totalImages;
indivView.appendChild(packName);
indivView.appendChild(packInfo);
indivView.appendChild(packDesc);
indivView.appendChild(packTabs);
indivView.appendChild(packButtons);
indivView.appendChild(totalCounts);
this.root.appendChild(packsContainer);
this.root.appendChild(indivView);
this.listView = document.createElement("div");
this.enabledSongList = document.createElement("div");
this.enabledSongList.id = "res-enabledsonglist";
@ -507,7 +507,7 @@ Resources.prototype.initUI = function() {
this.enabledImageList = document.createElement("div");
this.enabledImageList.id = "res-enabledimagelist";
this.enabledImageList.className = "hidden";
this.listView.appendChild(this.enabledSongList);
this.listView.appendChild(this.enabledImageList);
};
@ -549,10 +549,10 @@ Resources.prototype.truncateNum = function(num) {
Resources.prototype.selectPack = function(id) {
var pack = this.resourcePacks[id];
this.packView.pack = pack;
this.packView.packButtons.className = "res-buttons";
this.packsView.loadRemote.className = "res-button hidden";
this.packView.name.textContent = pack.name;
this.packView.creator.textContent = pack.author;
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.songCount.textContent = "Songs: " + pack.songs.length;
this.packView.imageCount.textContent = "Images: " + pack.images.length;
var songList = this.packView.songList;
var imageList = this.packView.imageList;
while (songList.firstElementChild) {
songList.removeChild(songList.firstElementChild);
}
}
while (imageList.firstElementChild) {
imageList.removeChild(imageList.firstElementChild);
}
for(var i = 0; i < pack.songs.length; i++) {
var song = pack.songs[i];
this.appendListItem("songs", song.title, "song" + i, songList,
@ -582,7 +582,7 @@ Resources.prototype.selectPack = function(id) {
this.clickResourceCallback(song, true),
song.enabled);
}
for(var i = 0; i < pack.images.length; i++) {
var image = pack.images[i];
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++) {
tab.arr[i].enabled = true;
document.getElementById(tab.elName + i).checked = true;
}
}
this.rebuildEnabled();
};
@ -655,7 +655,7 @@ Resources.prototype.disableAll = function() {
for(var i = 0; i < tab.arr.length; i++) {
tab.arr[i].enabled = false;
document.getElementById(tab.elName + i).checked = false;
}
}
this.rebuildEnabled();
};
@ -666,7 +666,7 @@ Resources.prototype.invert = function() {
for(var i = 0; i < tab.arr.length; i++) {
tab.arr[i].enabled = !tab.arr[i].enabled;
document.getElementById(tab.elName + i).checked = tab.arr[i].enabled;
}
}
this.rebuildEnabled();
};
@ -701,7 +701,7 @@ Resources.prototype.loadRemotes = function() {
remoteList.removeChild(remoteList.firstElementChild);
}
var item = this.appendSimpleListItem("Loading...", remoteList);
var req = new XMLHttpRequest();
req.open('GET', packsURL, true);
req.responseType = 'json';
@ -739,7 +739,7 @@ Resources.prototype.getRemoteCallback = function(index) {
Resources.prototype.selectRemotePack = function(id) {
var pack = this.remotes[id];
this.packView.pack = pack;
this.packView.packButtons.className = "res-buttons hidden";
this.packsView.loadRemote.className = "res-button";
if(pack.loaded) {
@ -748,7 +748,7 @@ Resources.prototype.selectRemotePack = function(id) {
} else {
this.packsView.loadRemote.textContent = "LOAD REMOTE";
}
this.packView.name.textContent = pack.name;
this.packView.creator.textContent = pack.author;
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.songCount.textContent = "Songs: " + pack.songcount;
this.packView.imageCount.textContent = "Images: " + pack.imagecount;
var songList = this.packView.songList;
var imageList = this.packView.imageList;
while (songList.firstElementChild) {
songList.removeChild(songList.firstElementChild);
}
}
while (imageList.firstElementChild) {
imageList.removeChild(imageList.firstElementChild);
}
for(var i = 0; i < pack.songs.length; i++) {
var song = pack.songs[i];
this.appendSimpleListItem(song, songList);
}
for(var i = 0; i < pack.images.length; i++) {
var image = pack.images[i];
this.appendSimpleListItem(image, imageList);
@ -785,12 +785,12 @@ Resources.prototype.selectRemotePack = function(id) {
Resources.prototype.loadCurrentRemote = function() {
var pack = this.packView.pack;
var that = this;
// Not actually a remote, ignore. How did you press this :<
if(pack.loaded === undefined || pack.loaded) {
return;
}
// TODO Error checking on failure
pack.loaded = true;
that.packsView.loadRemote.className = "res-button loaded";
@ -822,7 +822,7 @@ Resources.prototype.remoteComplete = function(progress) {
progStat.textContent = "Complete";
window.setTimeout(function() {progStat.textContent = "Idle";}, 2000);
this.packsView.loadRemote.textContent = "LOADED";
this.packsView.progressBar.style.width = "100%";
this.packsView.progressCurrent.textContent = "0b";
this.packsView.progressTop.textContent = "0b";

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

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

Loading…
Cancel
Save