mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-28 12:36:35 +00:00
butterchurn preset cycling
This commit is contained in:
parent
5c8bde3a53
commit
1cc944ffe8
1 changed files with 18 additions and 3 deletions
|
|
@ -56,9 +56,8 @@ class MilkdropWindow extends React.Component {
|
|||
this.presetKeys = Object.keys(this.presets);
|
||||
this.presetHistory = [];
|
||||
this.presetRandomize = true;
|
||||
this.cycleInterval = setInterval(() => {
|
||||
this._nextPreset(PRESET_TRANSITION_SECONDS);
|
||||
}, MILLISECONDS_BETWEEN_PRESET_TRANSITIONS);
|
||||
this.presetCycle = true;
|
||||
this._restartCycling();
|
||||
document.addEventListener("keydown", this._handleKeyboardInput);
|
||||
},
|
||||
e => {
|
||||
|
|
@ -92,6 +91,15 @@ class MilkdropWindow extends React.Component {
|
|||
this.cycleInterval = null;
|
||||
}
|
||||
}
|
||||
_restartCycling() {
|
||||
this._stopCycling();
|
||||
|
||||
if (this.presetCycle) {
|
||||
this.cycleInterval = setInterval(() => {
|
||||
this._nextPreset(PRESET_TRANSITION_SECONDS);
|
||||
}, MILLISECONDS_BETWEEN_PRESET_TRANSITIONS);
|
||||
}
|
||||
}
|
||||
_setRendererSize(width, height) {
|
||||
this._canvasNode.width = width;
|
||||
this._canvasNode.height = height;
|
||||
|
|
@ -125,6 +133,11 @@ class MilkdropWindow extends React.Component {
|
|||
case 82: // R
|
||||
this.presetRandomize = !this.presetRandomize;
|
||||
break;
|
||||
case 145: // scroll lock
|
||||
case 125: // F14 (scroll lock for OS X)
|
||||
this.presetCycle = !this.presetCycle;
|
||||
this._restartCycling();
|
||||
break;
|
||||
}
|
||||
}
|
||||
_nextPreset(blendTime) {
|
||||
|
|
@ -140,6 +153,7 @@ class MilkdropWindow extends React.Component {
|
|||
const preset = this.presets[this.presetKeys[presetIdx]];
|
||||
this.presetHistory.push(presetIdx);
|
||||
this.visualizer.loadPreset(preset, blendTime);
|
||||
this._restartCycling();
|
||||
}
|
||||
}
|
||||
_prevPreset(blendTime) {
|
||||
|
|
@ -151,6 +165,7 @@ class MilkdropWindow extends React.Component {
|
|||
],
|
||||
blendTime
|
||||
);
|
||||
this._restartCycling();
|
||||
}
|
||||
}
|
||||
render() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue