From 59666b86997c35b7b492fbcfe629de30fe8e339e Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Wed, 23 Jan 2019 10:06:30 -0800 Subject: [PATCH] [WIP] --- js/components/MilkdropWindow/Milkdrop.js | 16 ++++++++++++++-- js/reducers/milkdrop.ts | 5 ++++- js/selectors.ts | 7 ++++++- js/types.ts | 6 ++++++ 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/js/components/MilkdropWindow/Milkdrop.js b/js/components/MilkdropWindow/Milkdrop.js index bcd1508c..d1f21875 100644 --- a/js/components/MilkdropWindow/Milkdrop.js +++ b/js/components/MilkdropWindow/Milkdrop.js @@ -8,6 +8,17 @@ const USER_PRESET_TRANSITION_SECONDS = 5.7; const PRESET_TRANSITION_SECONDS = 2.7; const MILLISECONDS_BETWEEN_PRESET_TRANSITIONS = 15000; +function transitionTimeFromTransitionType(transitionType) { + switch (transitionType) { + case "DEFAULT": + return PRESET_TRANSITION_SECONDS; + case "IMMEDIATE": + return 0; + case "USER_PRESET": + return USER_PRESET_TRANSITION_SECONDS; + } +} + class Milkdrop extends React.Component { constructor(props) { super(props); @@ -195,7 +206,7 @@ class Milkdrop extends React.Component { this.selectPreset(await this.props.presets.previous(), blendTime); } - selectPreset(preset, blendTime = 0) { + selectPreset(preset, blendTime) { if (preset != null) { this.visualizer.loadPreset(preset, blendTime); this._restartCycling(); @@ -265,7 +276,8 @@ class Milkdrop extends React.Component { const mapStateToProps = state => ({ trackTitle: Selectors.getCurrentTrackDisplayName(state), presets: Selectors.getPresets(state), - butterchurn: Selectors.getButterchurn(state) + butterchurn: Selectors.getButterchurn(state), + transitionType: Selectors.getPresetTransitionType(state) }); export default connect(mapStateToProps)(Milkdrop); diff --git a/js/reducers/milkdrop.ts b/js/reducers/milkdrop.ts index 41b9e63b..6a694466 100644 --- a/js/reducers/milkdrop.ts +++ b/js/reducers/milkdrop.ts @@ -4,17 +4,20 @@ import { INITIALIZE_PRESETS, GOT_BUTTERCHURN } from "../actionTypes"; +import { TransitionType } from "../types"; export interface MilkdropState { desktop: boolean; presets: any; butterchurn: any; + transitionType: TransitionType; } const defaultMilkdropState = { desktop: false, presets: null, - butterchurn: null + butterchurn: null, + transitionType: TransitionType.DEFAULT }; export const milkdrop = ( diff --git a/js/selectors.ts b/js/selectors.ts index de11668e..c8b6ed0c 100644 --- a/js/selectors.ts +++ b/js/selectors.ts @@ -6,7 +6,8 @@ import { WindowInfo, LoadedURLTrack, WindowPositions, - PlaylistStyle + PlaylistStyle, + TransitionType } from "./types"; import { createSelector } from "reselect"; import * as Utils from "./utils"; @@ -620,3 +621,7 @@ export function getPresets(state: AppState): any { export function getButterchurn(state: AppState): any { return state.milkdrop.butterchurn; } + +export function getPresetTransitionType(state: AppState): TransitionType { + return state.milkdrop.transitionType; +} diff --git a/js/types.ts b/js/types.ts index 3cf11660..7f8ac4f4 100644 --- a/js/types.ts +++ b/js/types.ts @@ -146,6 +146,12 @@ export interface EqfPreset { preamp: number; } +export enum TransitionType { + IMMEDIATE, + DEFAULT, + USER_PRESET +} + export type Action = | { type: "@@init";