-
Notifications
You must be signed in to change notification settings - Fork 190
/
Copy pathPreferences.ts
103 lines (94 loc) · 5.85 KB
/
Preferences.ts
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
// Copyright (c) John Nesky and contributing authors, distributed under the MIT license, see accompanying the LICENSE.md file.
import {Scale, Config} from "../synth/SynthConfig.js";
export class Preferences {
public static readonly defaultVisibleOctaves: number = 3;
public autoPlay: boolean;
public autoFollow: boolean;
public enableNotePreview: boolean;
public showFifth: boolean;
public notesOutsideScale: boolean;
public defaultScale: number;
public showLetters: boolean;
public showChannels: boolean;
public showScrollBar: boolean;
public alwaysShowSettings: boolean;
public instrumentCopyPaste: boolean;
public enableChannelMuting: boolean;
public colorTheme: string;
public layout: string;
public displayBrowserUrl: boolean;
public volume: number = 75;
public visibleOctaves: number = Preferences.defaultVisibleOctaves;
public pressControlForShortcuts: boolean;
public keyboardLayout: string;
public enableMidi: boolean;
public showRecordButton: boolean;
public snapRecordedNotesToRhythm: boolean;
public ignorePerformedNotesNotInScale: boolean;
public metronomeCountIn: boolean;
public metronomeWhileRecording: 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") == "true";
this.notesOutsideScale = window.localStorage.getItem("notesOutsideScale") == "true";
this.showLetters = window.localStorage.getItem("showLetters") == "true";
this.showChannels = window.localStorage.getItem("showChannels") == "true";
this.showScrollBar = window.localStorage.getItem("showScrollBar") == "true";
this.alwaysShowSettings = window.localStorage.getItem("alwaysShowSettings") == "true";
this.instrumentCopyPaste = window.localStorage.getItem("instrumentCopyPaste") == "true";
this.enableChannelMuting = window.localStorage.getItem("enableChannelMuting") == "true";
this.displayBrowserUrl = window.localStorage.getItem("displayBrowserUrl") != "false";
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.keyboardLayout = window.localStorage.getItem("keyboardLayout") || "wickiHayden";
this.layout = window.localStorage.getItem("layout") || "small";
this.colorTheme = window.localStorage.getItem("colorTheme") || "dark classic";
this.visibleOctaves = ((<any>window.localStorage.getItem("visibleOctaves")) >>> 0) || Preferences.defaultVisibleOctaves;
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("alwaysShowSettings", this.alwaysShowSettings ? "true" : "false");
window.localStorage.setItem("enableChannelMuting", this.enableChannelMuting ? "true" : "false");
window.localStorage.setItem("instrumentCopyPaste", this.instrumentCopyPaste ? "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("keyboardLayout", this.keyboardLayout);
window.localStorage.setItem("layout", this.layout);
window.localStorage.setItem("colorTheme", this.colorTheme);
window.localStorage.setItem("volume", String(this.volume));
window.localStorage.setItem("visibleOctaves", String(this.visibleOctaves));
}
}