|
|
@ -68,16 +68,16 @@ HuesEditor.prototype.initUI = function() { |
|
|
|
titleButtons.id = "edit-titlebuttons"; |
|
|
|
titleButtons.id = "edit-titlebuttons"; |
|
|
|
this.root.appendChild(titleButtons); |
|
|
|
this.root.appendChild(titleButtons); |
|
|
|
this.saveBtn = this.createButton("Save XML", titleButtons, true); |
|
|
|
this.saveBtn = this.createButton("Save XML", titleButtons, true); |
|
|
|
this.saveBtn.onclick = this.saveXML.bind(this); |
|
|
|
this.saveBtn.addEventListener("click", this.saveXML.bind(this)); |
|
|
|
this.copyBtn = this.createButton("Copy XML", titleButtons, true); |
|
|
|
this.copyBtn = this.createButton("Copy XML", titleButtons, true); |
|
|
|
this.copyBtn.onclick = this.copyXML.bind(this); |
|
|
|
this.copyBtn.addEventListener("click", this.copyXML.bind(this)); |
|
|
|
this.undoBtn = this.createButton("Undo", titleButtons, true); |
|
|
|
this.undoBtn = this.createButton("Undo", titleButtons, true); |
|
|
|
this.redoBtn = this.createButton("Redo", titleButtons, true); |
|
|
|
this.redoBtn = this.createButton("Redo", titleButtons, true); |
|
|
|
let help = this.createButton("Help?", titleButtons); |
|
|
|
let help = this.createButton("Help?", titleButtons); |
|
|
|
help.style.backgroundColor = "rgba(0,160,0,0.3)"; |
|
|
|
help.style.backgroundColor = "rgba(0,160,0,0.3)"; |
|
|
|
help.onclick = function() { |
|
|
|
help.addEventListener("click", () => { |
|
|
|
window.open("https://github.com/mon/0x40-web/tree/master/docs/Editor.md", '_blank'); |
|
|
|
window.open("https://github.com/mon/0x40-web/tree/master/docs/Editor.md", '_blank'); |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.topBar = document.createElement("div"); |
|
|
|
this.topBar = document.createElement("div"); |
|
|
|
this.topBar.id = "edit-topbar"; |
|
|
|
this.topBar.id = "edit-topbar"; |
|
|
@ -418,17 +418,13 @@ HuesEditor.prototype.clearUndoRedo = function() { |
|
|
|
|
|
|
|
|
|
|
|
HuesEditor.prototype.updateUndoUI = function() { |
|
|
|
HuesEditor.prototype.updateUndoUI = function() { |
|
|
|
this.undoBtn.className = "hues-button disabled"; |
|
|
|
this.undoBtn.className = "hues-button disabled"; |
|
|
|
this.undoBtn.onclick = null; |
|
|
|
|
|
|
|
this.redoBtn.className = "hues-button disabled"; |
|
|
|
this.redoBtn.className = "hues-button disabled"; |
|
|
|
this.redoBtn.onclick = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(this.undoBuffer.length > 0) { |
|
|
|
if(this.undoBuffer.length > 0) { |
|
|
|
this.undoBtn.classList.remove("disabled"); |
|
|
|
this.undoBtn.classList.remove("disabled"); |
|
|
|
this.undoBtn.onclick = this.undo.bind(this); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if(this.redoBuffer.length > 0) { |
|
|
|
if(this.redoBuffer.length > 0) { |
|
|
|
this.redoBtn.classList.remove("disabled"); |
|
|
|
this.redoBtn.classList.remove("disabled"); |
|
|
|
this.redoBtn.onclick = this.redo.bind(this); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -512,6 +508,17 @@ HuesEditor.prototype.createButton = function(label, parent, disabled, extraClass |
|
|
|
if(extraClass) { |
|
|
|
if(extraClass) { |
|
|
|
button.className += " " + extraClass; |
|
|
|
button.className += " " + extraClass; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Automagically make disabled buttons ignore clicks
|
|
|
|
|
|
|
|
button.addEventListener("click", event => { |
|
|
|
|
|
|
|
if(button.classList.contains("disabled")) { |
|
|
|
|
|
|
|
event.preventDefault(); |
|
|
|
|
|
|
|
event.stopPropagation(); |
|
|
|
|
|
|
|
event.stopImmediatePropagation(); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
button.innerHTML = label.toUpperCase(); |
|
|
|
button.innerHTML = label.toUpperCase(); |
|
|
|
parent.appendChild(button); |
|
|
|
parent.appendChild(button); |
|
|
|
return button; |
|
|
|
return button; |
|
|
@ -547,16 +554,16 @@ HuesEditor.prototype.uiCreateImport = function() { |
|
|
|
let songEdits = document.createElement("div"); |
|
|
|
let songEdits = document.createElement("div"); |
|
|
|
imports.appendChild(songEdits); |
|
|
|
imports.appendChild(songEdits); |
|
|
|
let newSongBtn = this.createButton("New song", songEdits, false, "glow"); |
|
|
|
let newSongBtn = this.createButton("New song", songEdits, false, "glow"); |
|
|
|
newSongBtn.onclick = () => { |
|
|
|
newSongBtn.addEventListener("click", () => { |
|
|
|
this.newSong(); |
|
|
|
this.newSong(); |
|
|
|
}; |
|
|
|
}); |
|
|
|
this.newSongBtn = newSongBtn; |
|
|
|
this.newSongBtn = newSongBtn; |
|
|
|
let fromSong = this.createButton("Edit current song", songEdits, false, "glow"); |
|
|
|
let fromSong = this.createButton("Edit current song", songEdits, false, "glow"); |
|
|
|
fromSong.onclick = () => { |
|
|
|
fromSong.addEventListener("click", () => { |
|
|
|
if(this.core.currentSong) { |
|
|
|
if(this.core.currentSong) { |
|
|
|
this.newSong(this.core.currentSong); |
|
|
|
this.newSong(this.core.currentSong); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}); |
|
|
|
this.fromSongBtn = fromSong; |
|
|
|
this.fromSongBtn = fromSong; |
|
|
|
|
|
|
|
|
|
|
|
let songInfos = document.createElement("div"); |
|
|
|
let songInfos = document.createElement("div"); |
|
|
@ -595,7 +602,7 @@ HuesEditor.prototype.uiCreateEditArea = function() { |
|
|
|
this.timeLock.className = "hues-icon"; |
|
|
|
this.timeLock.className = "hues-icon"; |
|
|
|
// CHAIN, use  for CHAIN-BROKEN
|
|
|
|
// CHAIN, use  for CHAIN-BROKEN
|
|
|
|
let locker = this.createButton("", this.timeLock); |
|
|
|
let locker = this.createButton("", this.timeLock); |
|
|
|
locker.onclick = () => { |
|
|
|
locker.addEventListener("click", () => { |
|
|
|
if(!this.song) { |
|
|
|
if(!this.song) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -606,16 +613,16 @@ HuesEditor.prototype.uiCreateEditArea = function() { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.updateInfo(); |
|
|
|
this.updateInfo(); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}); |
|
|
|
this.timeLock._locker = locker; |
|
|
|
this.timeLock._locker = locker; |
|
|
|
|
|
|
|
|
|
|
|
this.buildEdit = this.uiCreateSingleEditor("Buildup", "buildup", "buildupRhythm", "edit-build", editArea); |
|
|
|
this.buildEdit = this.uiCreateSingleEditor("Buildup", "buildup", "buildupRhythm", "edit-build", editArea); |
|
|
|
this.seekStart = this.buildEdit._seek; |
|
|
|
this.seekStart = this.buildEdit._seek; |
|
|
|
// FIRST |<<
|
|
|
|
// FIRST |<<
|
|
|
|
this.seekStart.innerHTML = ""; |
|
|
|
this.seekStart.innerHTML = ""; |
|
|
|
this.seekStart.onclick = () => { |
|
|
|
this.seekStart.addEventListener("click", () => { |
|
|
|
this.core.soundManager.seek(-this.core.soundManager.buildLength); |
|
|
|
this.core.soundManager.seek(-this.core.soundManager.buildLength); |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// drag handle
|
|
|
|
// drag handle
|
|
|
|
let handleContainer = document.createElement("div"); |
|
|
|
let handleContainer = document.createElement("div"); |
|
|
@ -651,9 +658,9 @@ HuesEditor.prototype.uiCreateEditArea = function() { |
|
|
|
this.seekLoop = this.loopEdit._seek; |
|
|
|
this.seekLoop = this.loopEdit._seek; |
|
|
|
// FIRST |<<
|
|
|
|
// FIRST |<<
|
|
|
|
this.seekLoop.innerHTML = ""; |
|
|
|
this.seekLoop.innerHTML = ""; |
|
|
|
this.seekLoop.onclick = () => { |
|
|
|
this.seekLoop.addEventListener("click", () => { |
|
|
|
this.core.soundManager.seek(0); |
|
|
|
this.core.soundManager.seek(0); |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.buildEdit._hilight.textContent = "[none]"; |
|
|
|
this.buildEdit._hilight.textContent = "[none]"; |
|
|
|
this.loopEdit._hilight.innerHTML =
|
|
|
|
this.loopEdit._hilight.innerHTML =
|
|
|
@ -696,23 +703,23 @@ HuesEditor.prototype.uiCreateSingleEditor = function(title, soundName, rhythmNam |
|
|
|
beatCount.className = "beat-count"; |
|
|
|
beatCount.className = "beat-count"; |
|
|
|
beatCount.textContent = "0 beats"; |
|
|
|
beatCount.textContent = "0 beats"; |
|
|
|
container._lockedBtn = this.createButton("", header, false, "hues-icon"); |
|
|
|
container._lockedBtn = this.createButton("", header, false, "hues-icon"); |
|
|
|
container._lockedBtn.onclick = () => { |
|
|
|
container._lockedBtn.addEventListener("click", () => { |
|
|
|
if(container._locked) { |
|
|
|
if(container._locked) { |
|
|
|
this.setLocked(container, 0); |
|
|
|
this.setLocked(container, 0); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
let textLen = this.getText(container).length; |
|
|
|
let textLen = this.getText(container).length; |
|
|
|
this.setLocked(container, textLen); |
|
|
|
this.setLocked(container, textLen); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
let rightHeader = document.createElement("span"); |
|
|
|
let rightHeader = document.createElement("span"); |
|
|
|
rightHeader.className = "edit-area-right-header"; |
|
|
|
rightHeader.className = "edit-area-right-header"; |
|
|
|
header.appendChild(rightHeader); |
|
|
|
header.appendChild(rightHeader); |
|
|
|
|
|
|
|
|
|
|
|
container._halveBtn = this.createButton("Halve", rightHeader); |
|
|
|
container._halveBtn = this.createButton("Halve", rightHeader); |
|
|
|
container._halveBtn.onclick = this.halveBeats.bind(this, container); |
|
|
|
container._halveBtn.addEventListener("click", this.halveBeats.bind(this, container)); |
|
|
|
container._doubleBtn = this.createButton("Double", rightHeader); |
|
|
|
container._doubleBtn = this.createButton("Double", rightHeader); |
|
|
|
container._doubleBtn.onclick = this.doubleBeats.bind(this, container); |
|
|
|
container._doubleBtn.addEventListener("click", this.doubleBeats.bind(this, container)); |
|
|
|
|
|
|
|
|
|
|
|
let fileInput = document.createElement("input"); |
|
|
|
let fileInput = document.createElement("input"); |
|
|
|
fileInput.type ="file"; |
|
|
|
fileInput.type ="file"; |
|
|
@ -720,10 +727,10 @@ HuesEditor.prototype.uiCreateSingleEditor = function(title, soundName, rhythmNam |
|
|
|
fileInput.multiple = false; |
|
|
|
fileInput.multiple = false; |
|
|
|
fileInput.onchange = this.loadAudio.bind(this, container); |
|
|
|
fileInput.onchange = this.loadAudio.bind(this, container); |
|
|
|
let load = this.createButton("Load " + title.replace(/ /g,""), rightHeader); |
|
|
|
let load = this.createButton("Load " + title.replace(/ /g,""), rightHeader); |
|
|
|
load.onclick = () => {fileInput.click();}; |
|
|
|
load.addEventListener("click", () => {fileInput.click();}); |
|
|
|
|
|
|
|
|
|
|
|
container._removeBtn = this.createButton("Remove", rightHeader, true); |
|
|
|
container._removeBtn = this.createButton("Remove", rightHeader, true); |
|
|
|
container._removeBtn.onclick = this.removeAudio.bind(this, container); |
|
|
|
container._removeBtn.addEventListener("click", this.removeAudio.bind(this, container)); |
|
|
|
|
|
|
|
|
|
|
|
let editBox = document.createElement("div"); |
|
|
|
let editBox = document.createElement("div"); |
|
|
|
editBox.className = "edit-box"; |
|
|
|
editBox.className = "edit-box"; |
|
|
@ -776,10 +783,10 @@ HuesEditor.prototype.uiCreateControls = function() { |
|
|
|
|
|
|
|
|
|
|
|
// BACKWARD
|
|
|
|
// BACKWARD
|
|
|
|
let speedDown = this.createButton("", speedControl, false, "hues-icon"); |
|
|
|
let speedDown = this.createButton("", speedControl, false, "hues-icon"); |
|
|
|
speedDown.onclick = changeRate.bind(this, -0.25); |
|
|
|
speedDown.addEventListener("click", changeRate.bind(this, -0.25)); |
|
|
|
// FORWARD
|
|
|
|
// FORWARD
|
|
|
|
let speedUp = this.createButton("", speedControl, false, "hues-icon"); |
|
|
|
let speedUp = this.createButton("", speedControl, false, "hues-icon"); |
|
|
|
speedUp.onclick = changeRate.bind(this, 0.25); |
|
|
|
speedUp.addEventListener("click", changeRate.bind(this, 0.25)); |
|
|
|
|
|
|
|
|
|
|
|
let playRateLab = document.createElement("span"); |
|
|
|
let playRateLab = document.createElement("span"); |
|
|
|
playRateLab.className = "settings-individual"; |
|
|
|
playRateLab.className = "settings-individual"; |
|
|
|