-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoS_BGMsave.js
287 lines (275 loc) · 6.92 KB
/
GoS_BGMsave.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
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
/*:
* @plugindesc Save multiple BGMs
* @author GamesOfShadows
* @help
* With this plugin (for RPGmaker MV & MZ) you can save multiple BGMs.
* To save a BGM use the saveBGM plugin-command and set an "ID",
* to play it later at the saved spot use the playBGM plugin-command and use the same "ID".
*
* ------------------------------------------------------------
*
* - Plugin-Commands (MV):
*
* change_fadeInTime <number>
*
* saveBGM <id>
*
* playBGM <id>
*
*
* Examples:
*
* change_fadeInTime 3
*
* saveBGM Area1
*
* playBGM Area1
*
* - Plugin-Commands (MZ) - Change the settings later ingame:
* Same as MV, but without entering the commands.
* You have to select them and just input the values.
*
* ------------------------------------------------------------
*
* Version: 1.0
*
* - You can do everything you want with this plugin
* - You can use it commercially
* - You DON'T need to credit me
*
* It's just a short & simple plugin. ^^
*
* @target MZ
*
* @command change_fadeInTime
* @text Change fade-in time (in seconds)
* @desc 0 = no fade-in
*
* @arg fadeInTime
* @text Change fade-in time
* @desc Input a Number
* @type number
* @default 1
*
* @command saveBGM
* @text Save current playing BGM
* @desc Use a simple ID like "area1"
*
* @arg ID
* @text ID
* @desc Input an ID e.g. "area1"
* @type string
*
* @command playBGM
* @text Play a saved BGM
* @desc Use the same ID you used at saving
*
* @arg ID
* @text ID
* @desc Input a saved ID e.g. "area1"
* @type string
*
* @arg FadeIn
* @text Fade-in time in seconds
* @desc Input a Number (empty = default, 0 = deactive)
* @type number
*
* @arg AltMusic
* @text Alternative play BGM
* @desc If selected "ID" wasn't saved before, then play this BGM.
* @type file
* @dir audio/bgm
*
* @arg AltMusic_Volume
* @text AltMusic: Volume
* @desc Input a Number (Volume of alternative BGM)
* @type number
* @min 0
* @decimals 0
* @default 100
*
* @arg AltMusic_Pitch
* @text AltMusic: Pitch
* @desc Input a Number (Pitch of alternative BGM)
* @type number
* @min 0
* @decimals 0
* @default 100
*
* @arg AltMusic_Pan
* @text AltMusic: Pan
* @desc Input a Number (Pan of alternative BGM / -100 to 100)
* @type number
* @min -100
* @max 100
* @decimals 0
* @default 0
*
* @arg AltMusic_FadeIn
* @text AltMusic: Fade-in time in seconds
* @desc Input a Number (empty = default, 0 = deactive)
* @type number
* @min 0
* @max 60
* @decimals 0
* @default 0
*
* @command playBGMatPOS
* @text Play a BGM at
* @desc Play a BGM at position 'x', use -1 for current playing BGM position.
*
* @arg atPos_Music
* @text Alternative play BGM
* @desc If selected "ID" wasn't saved before, then play this BGM.
* @type file
* @dir audio/bgm
*
* @arg atPos_Volume
* @text Volume
* @desc Input a Number
* @type number
* @min 0
* @decimals 0
* @default 100
*
* @arg atPos_Pitch
* @text Pitch
* @desc Input a Number
* @type number
* @min 0
* @decimals 0
* @default 100
*
* @arg atPos_Pan
* @text Pan
* @desc Input a Number (-100 to 100)
* @type number
* @min -100
* @max 100
* @decimals 0
* @default 0
*
* @arg atPos_FadeIn
* @text Fade-in time in seconds
* @desc Input a Number (empty = default, 0 = deactive)
* @type number
* @min 0
* @max 60
* @decimals 0
* @default 0
*
* @command reset_BGMsaves
* @text Remove all BGMsaves
* @desc Use it for example before a map-transfer
*
* @target MV
*
* @param fadeInTime
* @text Set fade-in time
* @type number
* @min 0
* @max 60
* @decimals 0
* @desc Set the fade-in time (in seconds) / 0 = no fade-in
* @default 1
*/
var GoS_BGMsaveArray = [];
(() => {
const pluginName = "GoS_BGMsave";
let GoS_BGMfadeIn = Number(PluginManager.parameters(pluginName).fadeInTime);
//Plugin Commands (MZ)
if (Utils.RPGMAKER_NAME == "MZ") {
PluginManager.registerCommand(pluginName, "change_fadeInTime", args => {
GoS_BGMfadeIn = Number(args.fadeInTime);
});
PluginManager.registerCommand(pluginName, "saveBGM", args => {
BGMsave(args.ID);
});
PluginManager.registerCommand(pluginName, "playBGM", args => {
BGMplay(args.ID, args.AltMusic, args.AltMusic_Volume, args.AltMusic_Pitch);
});
PluginManager.registerCommand(pluginName, "playBGMatPOS", args => {
BGMplayAtPOS(args);
});
PluginManager.registerCommand(pluginName, "reset_BGMsaves", args => {
GoS_BGMsaveArray = [];
});
};
//Plugin Commands (MV)
if (Utils.RPGMAKER_NAME == "MV") {
let _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
if (command === 'change_fadeInTime') {
if (args.length >= 1) {
GoS_BGMfadeIn = Number(args[0]);
};
} else if (command === 'saveBGM') {
if (args.length >= 1) {
BGMsave(args[0]);
};
} else if (command === 'playBGM') {
if (args.length >= 1) {
BGMplay(args[0], args[1], args[2], args[3]);
};
} else if (command === 'playBGMatPOS') {
if (args.length >= 1) {
BGMplayAtPOS(args);
};
} else if (command === 'reset_BGMsaves') {
GoS_BGMsaveArray = [];
};
};
};
//Functions
function BGMsave(ID) {
if (AudioManager._currentBgm != null) {
let InArray = false;
let GetIndex = 0;
if (GoS_BGMsaveArray.length > 0) {
GoS_BGMsaveArray.forEach(function(currentValue, index, arr) {
if (currentValue[0] == ID) {
InArray = true;
GetIndex = index;
};
});
};
if (!InArray) {
GoS_BGMsaveArray.push([ID, AudioManager._currentBgm.name, AudioManager._currentBgm.volume, AudioManager._currentBgm.pitch, AudioManager._currentBgm.pan, AudioManager.saveBgm().pos]);
} else {
GoS_BGMsaveArray[GetIndex][1] = AudioManager._currentBgm.name;
GoS_BGMsaveArray[GetIndex][2] = AudioManager._currentBgm.volume;
GoS_BGMsaveArray[GetIndex][3] = AudioManager._currentBgm.pitch;
GoS_BGMsaveArray[GetIndex][4] = AudioManager._currentBgm.pan;
GoS_BGMsaveArray[GetIndex][5] = AudioManager.saveBgm().pos;
};
};
};
function BGMplay(A, B, C, D) {
console.log(A, B, C, D);
if (GoS_BGMsaveArray.length > 0) {
let InArray = false;
let GetIndex = 0;
GoS_BGMsaveArray.forEach(function(currentValue, index, arr) {
if (currentValue[0] == ID) {
InArray = true;
GetIndex = index;
};
});
if (InArray) {
AudioManager.playBgm({ name: GoS_BGMsaveArray[GetIndex][1], volume: GoS_BGMsaveArray[GetIndex][2], pitch: GoS_BGMsaveArray[GetIndex][3], pan: GoS_BGMsaveArray[GetIndex][4] }, GoS_BGMsaveArray[GetIndex][5]);
if (GoS_BGMfadeIn > 0) {
AudioManager.fadeInBgm(GoS_BGMfadeIn);
};
} else {
BGMplayAltMusic(args);
};
} else {
BGMplayAltMusic(args);
};
};
function BGMplayAltMusic(args) {
};
function BGMplayAtPOS(args) {
};
})();