-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathPreferences.ts
More file actions
154 lines (144 loc) · 9.31 KB
/
Copy pathPreferences.ts
File metadata and controls
154 lines (144 loc) · 9.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// Copyright (c) 2012-2022 John Nesky and contributing authors, distributed under the MIT license, see accompanying the LICENSE.md file.
import {Scale, Config} from "../synth/SynthConfig";
import {ColorConfig} from "../editor/ColorConfig";
export class Preferences {
public static readonly defaultVisibleOctaves: number = 4; //slarmoo's: 3
public customTheme: string | null;
public customTheme2: string | null;
public autoPlay: boolean;
public autoFollow: boolean;
public enableNotePreview: boolean;
public showFifth: boolean = true;
public notesOutsideScale: boolean;
public defaultScale: number;
public showLetters: boolean;
public showChannels: boolean;
public showScrollBar: boolean;
public alwaysFineNoteVol: boolean;
public displayVolumeBar: boolean;
public instrumentCopyPaste: boolean;
public instrumentImportExport: boolean;
public instrumentButtonsAtTop: boolean;
public enableChannelMuting: boolean = true;
public colorTheme: string;
public layout: string;
//public displayBrowserUrl: boolean; //comment for testing
public displayBrowserUrl: boolean = false; //uncomment for testing
public volume: number = 75;
public visibleOctaves: number = Preferences.defaultVisibleOctaves;
public pressControlForShortcuts: boolean;
public keyboardLayout: string;
public bassOffset: number;
public enableMidi: boolean;
public showRecordButton: boolean;
public snapRecordedNotesToRhythm: boolean;
public ignorePerformedNotesNotInScale: boolean;
public metronomeCountIn: boolean;
public metronomeWhileRecording: boolean;
public notesFlashWhenPlayed: boolean;
public showOscilloscope: boolean;
public showSampleLoadingStatus: boolean;
public showDescription: boolean;
public showInstrumentScrollbars: boolean;
public closePromptByClickoff: boolean;
public frostedGlassBackground: boolean;
//jukebox
public rollNoveltyPresets: boolean;
public enableTagSearch: boolean;
constructor() {
this.reload();
}
public reload(): void {
this.autoPlay = window.localStorage.getItem("autoPlay") == "true";
this.autoFollow = window.localStorage.getItem("autoFollow") != "false";
this.enableNotePreview = window.localStorage.getItem("enableNotePreview") != "false";
this.showFifth = window.localStorage.getItem("showFifth") != "false";
this.notesOutsideScale = window.localStorage.getItem("notesOutsideScale") == "true";
this.showLetters = window.localStorage.getItem("showLetters") != "false";
this.showChannels = window.localStorage.getItem("showChannels") != "false";
this.showScrollBar = window.localStorage.getItem("showScrollBar") != "false";
this.alwaysFineNoteVol = window.localStorage.getItem("alwaysFineNoteVol") == "true";
this.displayVolumeBar = window.localStorage.getItem("displayVolumeBar") != "false";
this.instrumentCopyPaste = window.localStorage.getItem("instrumentCopyPaste") != "false";
this.instrumentImportExport = window.localStorage.getItem("instrumentImportExport") == "true";
this.instrumentButtonsAtTop = window.localStorage.getItem("instrumentButtonsAtTop") == "true";
this.enableChannelMuting = window.localStorage.getItem("enableChannelMuting") != "false";
//this.displayBrowserUrl = window.localStorage.getItem("displayBrowserUrl") != "false"; //comment for testing
this.pressControlForShortcuts = window.localStorage.getItem("pressControlForShortcuts") == "true";
this.enableMidi = window.localStorage.getItem("enableMidi") != "false";
this.showRecordButton = window.localStorage.getItem("showRecordButton") == "true";
this.snapRecordedNotesToRhythm = window.localStorage.getItem("snapRecordedNotesToRhythm") == "true";
this.ignorePerformedNotesNotInScale = window.localStorage.getItem("ignorePerformedNotesNotInScale") == "true";
this.metronomeCountIn = window.localStorage.getItem("metronomeCountIn") != "false";
this.metronomeWhileRecording = window.localStorage.getItem("metronomeWhileRecording") != "false";
this.notesFlashWhenPlayed = window.localStorage.getItem("notesFlashWhenPlayed") != "flase";
this.showOscilloscope = window.localStorage.getItem("showOscilloscope") == "true";
this.showSampleLoadingStatus = window.localStorage.getItem("showSampleLoadingStatus") != "false";
this.showDescription = window.localStorage.getItem("showDescription") != "false";
this.showInstrumentScrollbars = window.localStorage.getItem("showInstrumentScrollbars") == "true";
this.closePromptByClickoff = window.localStorage.getItem("closePromptByClickoff") == "true";
this.frostedGlassBackground = window.localStorage.getItem("frostedGlassBackground") == "true";
this.keyboardLayout = window.localStorage.getItem("keyboardLayout") || "pianoTransposingC";
this.bassOffset = (+(<any>window.localStorage.getItem("bassOffset"))) || 0;
this.layout = window.localStorage.getItem("layout") || "long";
this.colorTheme = window.localStorage.getItem("colorTheme") || ColorConfig.defaultTheme;
this.customTheme = window.localStorage.getItem("customTheme");
this.customTheme2 = window.localStorage.getItem("customTheme2");
this.visibleOctaves = ((<any>window.localStorage.getItem("visibleOctaves")) >>> 0) || Preferences.defaultVisibleOctaves;
//jukebox
this.rollNoveltyPresets = window.localStorage.getItem("rollNoveltyPresets") == "true";
this.enableTagSearch = window.localStorage.getItem("enableTagSearch") != "false";
const defaultScale: Scale | undefined = Config.scales.dictionary[window.localStorage.getItem("defaultScale")!];
this.defaultScale = (defaultScale != undefined) ? defaultScale.index : 0;
if (window.localStorage.getItem("volume") != null) {
this.volume = Math.min(<any>window.localStorage.getItem("volume") >>> 0, 75);
}
if (window.localStorage.getItem("fullScreen") != null) {
if (window.localStorage.getItem("fullScreen") == "true") this.layout = "long";
window.localStorage.removeItem("fullScreen");
}
}
public save(): void {
window.localStorage.setItem("autoPlay", this.autoPlay ? "true" : "false");
window.localStorage.setItem("autoFollow", this.autoFollow ? "true" : "false");
window.localStorage.setItem("enableNotePreview", this.enableNotePreview ? "true" : "false");
window.localStorage.setItem("showFifth", this.showFifth ? "true" : "false");
window.localStorage.setItem("notesOutsideScale", this.notesOutsideScale ? "true" : "false");
window.localStorage.setItem("defaultScale", Config.scales[this.defaultScale].name);
window.localStorage.setItem("showLetters", this.showLetters ? "true" : "false");
window.localStorage.setItem("showChannels", this.showChannels ? "true" : "false");
window.localStorage.setItem("showScrollBar", this.showScrollBar ? "true" : "false");
window.localStorage.setItem("alwaysFineNoteVol", this.alwaysFineNoteVol ? "true" : "false");
window.localStorage.setItem("displayVolumeBar", this.displayVolumeBar ? "true" : "false");
window.localStorage.setItem("enableChannelMuting", this.enableChannelMuting ? "true" : "false");
window.localStorage.setItem("instrumentCopyPaste", this.instrumentCopyPaste ? "true" : "false");
window.localStorage.setItem("instrumentImportExport", this.instrumentImportExport ? "true" : "false");
window.localStorage.setItem("instrumentButtonsAtTop", this.instrumentButtonsAtTop ? "true" : "false");
window.localStorage.setItem("displayBrowserUrl", this.displayBrowserUrl ? "true" : "false");
window.localStorage.setItem("pressControlForShortcuts", this.pressControlForShortcuts ? "true" : "false");
window.localStorage.setItem("enableMidi", this.enableMidi ? "true" : "false");
window.localStorage.setItem("showRecordButton", this.showRecordButton ? "true" : "false");
window.localStorage.setItem("snapRecordedNotesToRhythm", this.snapRecordedNotesToRhythm ? "true" : "false");
window.localStorage.setItem("ignorePerformedNotesNotInScale", this.ignorePerformedNotesNotInScale ? "true" : "false");
window.localStorage.setItem("metronomeCountIn", this.metronomeCountIn ? "true" : "false");
window.localStorage.setItem("metronomeWhileRecording", this.metronomeWhileRecording ? "true" : "false");
window.localStorage.setItem("notesFlashWhenPlayed", this.notesFlashWhenPlayed ? "true" : "false");
window.localStorage.setItem("showOscilloscope", this.showOscilloscope ? "true" : "false");
window.localStorage.setItem("showSampleLoadingStatus", this.showSampleLoadingStatus ? "true" : "false");
window.localStorage.setItem("showDescription", this.showDescription ? "true" : "false");
window.localStorage.setItem("showInstrumentScrollbars", this.showInstrumentScrollbars ? "true" : "false");
window.localStorage.setItem("closePromptByClickoff", this.closePromptByClickoff ? "true" : "false");
window.localStorage.setItem("frostedGlassBackground", this.frostedGlassBackground ? "true" : "false");
window.localStorage.setItem("keyboardLayout", this.keyboardLayout);
window.localStorage.setItem("bassOffset", String(this.bassOffset));
window.localStorage.setItem("layout", this.layout);
window.localStorage.setItem("colorTheme", this.colorTheme);
window.localStorage.setItem("customTheme", this.customTheme!);
window.localStorage.setItem("customTheme2", this.customTheme2!);
window.localStorage.setItem("volume", String(this.volume));
window.localStorage.setItem("visibleOctaves", String(this.visibleOctaves));
//jukebox
window.localStorage.setItem("rollNoveltyPresets", this.rollNoveltyPresets ? "true" : "false");
window.localStorage.setItem("enableTagSearch", this.enableTagSearch ? "true" : "false");
}
}