-
Notifications
You must be signed in to change notification settings - Fork 0
/
bulkadd.js
59 lines (53 loc) · 1.81 KB
/
bulkadd.js
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
studio.menu.addMenuItem({
name: "Bulk Add",
execute: bulkadd,
})
function bulkadd() {
var track = studio.window.editorCurrent();
var parameter = track.event.uiLastParameterSelection;
var files = studio.window.browserSelection();
if (track == null || files.length < 1) {
error("You must select one or more assets and a track.");
return;
}
if (!track.isOfType('GroupTrack')) {
error("You must select a track in the editor pane.");
return;
}
for (var i = 0; i < files.length; i++) {
if (!files[i].isOfType('AudioFile')) {
error("You must select only audio files in the browser");
return;
}
}
for (var i = 0; i < files.length; i++) {
var sound = track.addSound(parameter, 'SingleSound', i + 1, 1);
sound.audioFile = files[i];
}
}
function error(reason) {
studio.ui.showModalDialog({
windowTitle: "Error",
widgetType: studio.ui.widgetType.Layout,
layout: studio.ui.layoutType.VBoxLayout,
items: [
{widgetType: studio.ui.widgetType.Label, text: reason},
{
widgetType: studio.ui.widgetType.Layout,
layout: studio.ui.layoutType.HBoxLayout,
contentsMargins: {left: 0, top: 12, right: 0, bottom: 0},
items: [
{
widgetType: studio.ui.widgetType.Spacer,
sizePolicy: {horizontalPolicy: studio.ui.sizePolicy.MinimumExpanding}
},
{
widgetType: studio.ui.widgetType.PushButton, text: "OK", onClicked: function () {
this.closeDialog();
}
},
],
},
]
})
}