-
Notifications
You must be signed in to change notification settings - Fork 1
/
TNHPanel.cs
555 lines (523 loc) · 19.9 KB
/
TNHPanel.cs
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using FistVR;
using FMODUnity;
using UnityEngine;
using UnityEngine.UI;
using Sodalite;
using Sodalite.Api;
using Sodalite.UiWidgets;
using Sodalite.Utilities;
using TNH_BGLoader;
using TNHBGLoader.Sosig;
using TNHBGLoader.Soundtrack;
using Valve.Newtonsoft.Json.Utilities;
namespace TNHBGLoader
{
public class TNHPanel : MonoBehaviour
{
public LockablePanel Panel;
public enum TNHPstates { BGM, Announcer, Sosig_Voicelines }
public TNHPstates TNHPstate = TNHPstates.BGM;
public string GameMode;
public List<BankOrSoundtrack> BGMs;
public bool HasBgms = true;
public bool HasVls = true;
public bool HasAnnouncers = true;
public void Initialize(string gameMode, bool hasBgms = true, bool hasVls = false, bool hasAnnouncers = false) {
PluginMain.DebugLog.LogInfo($"Initializing. Gamemode: {gameMode}, {hasBgms} {hasVls} {hasAnnouncers}");
GameMode = gameMode;
HasBgms = hasBgms;
HasVls = hasVls;
HasAnnouncers = hasAnnouncers;
PluginMain.DebugLog.LogInfo($"Initialized. Gamemode: {GameMode}, {HasBgms} {HasVls} {HasAnnouncers}");
//Set default panel
if (!hasBgms) {
if (!hasAnnouncers)
TNHPstate = TNHPstates.Sosig_Voicelines;
if (!hasVls)
TNHPstate = TNHPstates.Announcer;
}
//Assemble list of BGMs
BGMs = new List<BankOrSoundtrack>();
if (GameMode == "tnh") {
foreach (var bank in BankAPI.LoadedBankLocations) {
var bos = new BankOrSoundtrack();
bos.IsBank = true;
bos.BankGuid = bank;
bos.Name = BankAPI.GetNameFromLocation(bank);
BGMs.Add(bos);
}
}
foreach (var soundtrack in SoundtrackAPI.Soundtracks) {
PluginMain.DebugLog.LogInfo($"Gamemode: {GameMode}, Soundtrack GM: {soundtrack.GameMode} of {soundtrack.Guid}");
if (soundtrack.GameMode != GameMode)
continue;
var bos = new BankOrSoundtrack();
bos.IsBank = false;
bos.SoundtrackGuid = soundtrack.Guid;
bos.Name = soundtrack.Name;
BGMs.Add(bos);
}
for (int i = 0; i < BGMs.Count(); i++) {
PluginMain.DebugLog.LogInfo($"BGM Loaded: {BGMs[i].Name}, index {i}, IsBank {BGMs[i].IsBank}");
}
}
public TNHPanel() {
Panel = new LockablePanel();
Panel.Configure += ConfigurePanel;
Panel.TextureOverride = SodaliteUtils.LoadTextureFromBytes(Assembly.GetExecutingAssembly().GetResource("panel.png"));
}
public struct BankOrSoundtrack {
public bool IsBank;
public string BankGuid;
public string SoundtrackGuid;
public string Name;
}
private TextWidget _bankText;
private TextWidget _volumeText;
private ButtonWidget[] _musicButtons = new ButtonWidget[8];
private ButtonWidget[] _volControls = new ButtonWidget[2];
private ButtonWidget[] _cycleControls = new ButtonWidget[2];
private ButtonWidget _switchstate;
private int _firstMusicIndex;
public RawImage icondisplay;
private int _selectedVLSSet;
private void ConfigurePanel(GameObject panel)
{
GameObject canvas = panel.transform.Find("OptionsCanvas_0_Main/Canvas").gameObject;
UiWidget.CreateAndConfigureWidget(canvas, (GridLayoutWidget widget) =>
{
#region Initialize Panel
// Fill our parent and set pivot to top middle
widget.RectTransform.localScale = new Vector3(0.07f, 0.07f, 0.07f);
widget.RectTransform.localPosition = Vector3.zero;
widget.RectTransform.anchoredPosition = Vector2.zero;
widget.RectTransform.sizeDelta = new Vector2(37f / 0.07f, 24f / 0.07f);
widget.RectTransform.pivot = new Vector2(0.5f, 1f);
widget.RectTransform.localRotation = Quaternion.identity;
// Adjust our grid settings
widget.LayoutGroup.cellSize = new Vector2(171, 50);
widget.LayoutGroup.spacing = Vector2.one * 4;
widget.LayoutGroup.startCorner = GridLayoutGroup.Corner.UpperLeft;
widget.LayoutGroup.startAxis = GridLayoutGroup.Axis.Horizontal;
widget.LayoutGroup.childAlignment = TextAnchor.UpperCenter;
widget.LayoutGroup.constraint = GridLayoutGroup.Constraint.FixedColumnCount;
widget.LayoutGroup.constraintCount = 3;
#endregion
#region Row One
/*Cycle mindex up*/ widget.AddChild((ButtonWidget button) => {
button.ButtonText.text = "Cycle List Up";
button.AddButtonListener(UpdateMusicList);
button.ButtonText.transform.localRotation = Quaternion.identity;
_cycleControls[0] = button;
});
/*First Music Slot*/ widget.AddChild((ButtonWidget button) => {
int index = 0;
button.ButtonText.text = GetNameWithOffset(index);
button.AddButtonListener(SetCurrentItem);
_musicButtons[index] = button;
button.ButtonText.transform.localRotation = Quaternion.identity;
});
/*Second Music Slot*/ widget.AddChild((ButtonWidget button) => {
int index = 1;
button.ButtonText.text = GetNameWithOffset(index);
button.AddButtonListener(SetCurrentItem);
_musicButtons[index] = button;
button.ButtonText.transform.localRotation = Quaternion.identity;
});
#endregion
#region Row Two
/*current mindex*/ widget.AddChild((TextWidget text) => {
text.Text.text = "Selected:\n" + GetCurrentSelectedItemName();
_bankText = text;
text.Text.alignment = TextAnchor.MiddleCenter;
text.Text.fontSize += 0;
text.RectTransform.localRotation = Quaternion.identity;
});
/*Third Music Slot*/ widget.AddChild((ButtonWidget button) => {
int index = 2;
button.ButtonText.text = GetNameWithOffset(index);
button.AddButtonListener(SetCurrentItem);
_musicButtons[index] = button;
button.ButtonText.transform.localRotation = Quaternion.identity;
});
/*Fourth Music Slot*/ widget.AddChild((ButtonWidget button) => {
int index = 3;
button.ButtonText.text = GetNameWithOffset(index);
button.AddButtonListener(SetCurrentItem);
_musicButtons[index] = button;
button.ButtonText.transform.localRotation = Quaternion.identity;
});
#endregion
#region Row Three
/*Cycle mindex down*/ widget.AddChild((ButtonWidget button) => {
button.ButtonText.text = "Cycle List Down";
button.AddButtonListener(UpdateMusicList);
button.ButtonText.transform.localRotation = Quaternion.identity;
_cycleControls[1] = button;
});
/*Fifth Music Slot*/ widget.AddChild((ButtonWidget button) => {
int index = 4;
button.ButtonText.text = GetNameWithOffset(index);
button.AddButtonListener(SetCurrentItem);
_musicButtons[index] = button;
button.ButtonText.transform.localRotation = Quaternion.identity;
});
/*Sixth Music Slot*/ widget.AddChild((ButtonWidget button) => {
int index = 5;
button.ButtonText.text = GetNameWithOffset(index);
button.AddButtonListener(SetCurrentItem);
_musicButtons[index] = button;
button.ButtonText.transform.localRotation = Quaternion.identity;
});
#endregion
#region Row Four
/*None*/ widget.AddChild((TextWidget text) => {
text.Text.text = "";
text.Text.alignment = TextAnchor.MiddleCenter;
text.Text.fontSize += 5;
});
/*Seventh Music Slot*/ widget.AddChild((ButtonWidget button) => {
int index = 6;
button.ButtonText.text = GetNameWithOffset(index);
button.AddButtonListener(SetCurrentItem);
_musicButtons[index] = button;
button.ButtonText.transform.localRotation = Quaternion.identity;
});
/*Eighth Music Slot*/ widget.AddChild((ButtonWidget button) => {
int index = 7;
button.ButtonText.text = GetNameWithOffset(index);
button.AddButtonListener(SetCurrentItem);
_musicButtons[index] = button;
button.ButtonText.transform.localRotation = Quaternion.identity;
});
#endregion
#region Row Five
/*None*/ widget.AddChild((TextWidget text) => {
text.Text.text = "";
text.Text.alignment = TextAnchor.MiddleCenter;
text.Text.fontSize += 5;
});
/*Switch State*/ widget.AddChild((ButtonWidget button) => {
button.ButtonText.text = "BGM";
button.AddButtonListener(SwitchState);
button.ButtonText.transform.localRotation = Quaternion.identity;
_switchstate = button;
});
/*None*/ widget.AddChild((TextWidget text) => {
text.Text.text = "";
text.Text.alignment = TextAnchor.MiddleCenter;
text.Text.fontSize += 5;
});
#endregion
#region Row Six
/*Cycle volume down*/ widget.AddChild((ButtonWidget button) => {
button.ButtonText.text = "Decrease volume";
button.AddButtonListener(UpdateVolume);
button.ButtonText.transform.localRotation = Quaternion.identity;
_volControls[0] = button;
});
/*vol percent*/ widget.AddChild((TextWidget text) => {
text.Text.text = GetVolumePercent();
_volumeText = text;
text.Text.alignment = TextAnchor.MiddleCenter;
text.Text.fontSize += 5;
});
/*Cycle volume up*/ widget.AddChild((ButtonWidget button) => {
button.ButtonText.text = "Increase volume";
button.AddButtonListener(UpdateVolume);
button.ButtonText.transform.localRotation = Quaternion.identity;
_volControls[1] = button;
});
#endregion
});
}
public void SwitchState(object sender, ButtonClickEventArgs args)
{
// There's 100% an easier way to do this. I'm too lazy.
/*
if (TNHPstate == TNHPstates.BGM) {
PluginMain.DebugLog.LogInfo($"Switching from BGM");
if (HasAnnouncers) {
PluginMain.DebugLog.LogInfo($"HasAnnouncers. Switching to announcer.");
TNHPstate = TNHPstates.Announcer;
}
else if (HasVls) {
PluginMain.DebugLog.LogInfo($"HasVLS. Switching to VLS.");
TNHPstate = TNHPstates.Sosig_Voicelines;
} else
PluginMain.DebugLog.LogInfo($"Cannot switch!");
}
if (TNHPstate == TNHPstates.Announcer) {
if(HasAnnouncers)
TNHPstate = TNHPstates.Sosig_Voicelines;
else if(HasVls)
TNHPstate = TNHPstates.BGM;
}
if (TNHPstate == TNHPstates.Sosig_Voicelines) {
if(HasAnnouncers)
TNHPstate = TNHPstates.BGM;
else if(HasVls)
TNHPstate = TNHPstates.Announcer;
}*/
if (TNHPstate == TNHPstates.BGM) {TNHPstate = TNHPstates.Announcer;}
else if (TNHPstate == TNHPstates.Announcer) {TNHPstate = TNHPstates.Sosig_Voicelines;}
else if (TNHPstate == TNHPstates.Sosig_Voicelines) {TNHPstate = TNHPstates.BGM;}
_switchstate.ButtonText.text = TNHPstate.ToString().Replace('_', ' ');
_bankText.Text.text = "Selected:\n" + GetCurrentSelectedItemName();
_firstMusicIndex = 0;
int index = 0;
UpdateMusicList(null, null); //always use null as an arg, kids
UpdateVolume(null, null);
SetIcon();
}
//Updates and changes the BGMs shown
private void UpdateMusicList(object sender, ButtonClickEventArgs args)
{
switch (TNHPstate) {
case TNHPstates.BGM:
if (BGMs.Count <= 4)
return;
break;
case TNHPstates.Announcer:
if (AnnouncerAPI.LoadedAnnouncers.Count <= 4)
return;
break;
case TNHPstates.Sosig_Voicelines:
if (SosigVLSAPI.LoadedSosigVLSs.Count <= 4)
return;
break;
}
int cycleInc = 0;
if (sender != null)
{
if (sender as ButtonWidget == _cycleControls[0])
cycleInc = -1;
else if (sender as ButtonWidget == _cycleControls[1])
cycleInc = 1;
}
int mult = 4;
cycleInc = mult * cycleInc;
int NewFirstMusicIndex = _firstMusicIndex + cycleInc;
bool oob = NewFirstMusicIndex < 0;
switch (TNHPstate) {
case TNHPstates.BGM:
if (NewFirstMusicIndex >= BGMs.Count) oob = true;
break;
case TNHPstates.Announcer:
if (NewFirstMusicIndex >= AnnouncerAPI.LoadedAnnouncers.Count) oob = true;
break;
case TNHPstates.Sosig_Voicelines:
if (NewFirstMusicIndex >= SosigVLSAPI.LoadedSosigVLSs.Count) oob = true;
break;
}
if (oob) {
WristMenuAPI.Instance.Aud.PlayOneShot(WristMenuAPI.Instance.AudClip_Err); //play error audio if ran out of music to play
return;
}
_firstMusicIndex = NewFirstMusicIndex;
//update music buttons
for (int i = 0; i < _musicButtons.Length; i++) _musicButtons[i].ButtonText.text = GetNameWithOffset(i);
}
//When in VLS, the audio volume switches to a "VLS type" option to select the VLS for different
//audio types, such as Zosigs or those funny little robotic men.
private void CycleVLS(object? sender)
{
int[] range = new[] { 0, SosigVLSAPI.VLSGuidOrder.Count - 1 };
//++ if volcontrols 1, -- if volcontrols 0
//then wrap to prevent overflow/underflow
if(sender != null)
_selectedVLSSet = (_selectedVLSSet + (sender as ButtonWidget == _volControls[1] ? 1 : -1)).Wrap(range);
_volumeText.Text.text = SosigVLSAPI.VLSGuidToName[SosigVLSAPI.VLSGuidOrder[_selectedVLSSet]];
_volControls[0].ButtonText.text = SosigVLSAPI.VLSGuidToName[SosigVLSAPI.VLSGuidOrder[(_selectedVLSSet - 1).Wrap(range)]];
_volControls[1].ButtonText.text = SosigVLSAPI.VLSGuidToName[SosigVLSAPI.VLSGuidOrder[(_selectedVLSSet + 1).Wrap(range)]];
PlaySnippet(SosigVLSAPI.GetRandomPreview(SosigVLSAPI.CurrentSosigVlsOfVlsSet(_selectedVLSSet).guid));
}
//Updates and changes the volume amount
private void UpdateVolume(object sender, ButtonClickEventArgs args)
{
if (TNHPstate == TNHPstates.Sosig_Voicelines)
{
CycleVLS(sender);
return;
}
else {
_volControls[0].ButtonText.text = "Decrease volume";
_volControls[1].ButtonText.text = "Increase volume";
}
float inc = 0f;
if (sender != null)
{
if (sender as ButtonWidget == _volControls[0])
inc = -0.05f;
else if (sender as ButtonWidget == _volControls[1])
inc = 0.05f;
}
//this just updates and sets the volume n all that pizzaz.
switch (TNHPstate)
{
case TNHPstates.BGM:
PluginMain.BackgroundMusicVolume.Value += inc;
if (!GeneralAPI.IfIsInRange(PluginMain.BackgroundMusicVolume.Value, 0, 4)) WristMenuAPI.Instance.Aud.PlayOneShot(WristMenuAPI.Instance.AudClip_Err);
PluginMain.BackgroundMusicVolume.Value = Mathf.Clamp(PluginMain.BackgroundMusicVolume.Value, 0, 4);
break;
case TNHPstates.Announcer:
PluginMain.AnnouncerMusicVolume.Value += inc;
if (!GeneralAPI.IfIsInRange(PluginMain.AnnouncerMusicVolume.Value, 0, 20)) WristMenuAPI.Instance.Aud.PlayOneShot(WristMenuAPI.Instance.AudClip_Err);
PluginMain.AnnouncerMusicVolume.Value = Mathf.Clamp(PluginMain.AnnouncerMusicVolume.Value, 0, 20);
break;
/*case TNHPstates.Sosig_Voicelines:
if(inc != 0) WristMenuAPI.Instance.Aud.PlayOneShot(WristMenuAPI.Instance.AudClip_Err);
break;*/
}
_volumeText.Text.text = GetVolumePercent();
}
//Text Getters
private string GetNameWithOffset(int offset)
{
int index = _firstMusicIndex + offset;
switch (TNHPstate) {
case TNHPstates.BGM:
if (index < BGMs.Count)
return $"{index + 1}: {BGMs[index].Name}";
break;
case TNHPstates.Announcer:
if (index < AnnouncerAPI.LoadedAnnouncers.Count)
return (index + 1) + ": " + AnnouncerAPI.LoadedAnnouncers[index].Name;
break;
case TNHPstates.Sosig_Voicelines:
if (index < SosigVLSAPI.LoadedSosigVLSs.Count)
return (index + 1) + ": " + SosigVLSAPI.LoadedSosigVLSs[index].name;
break;
}
return "";
}
private string GetCurrentSelectedItemName() {
switch (TNHPstate)
{
case TNHPstates.BGM:
if(!PluginMain.IsSoundtrack.Value)
return BankAPI.GetNameFromIndex(BankAPI.CurrentBankIndex, true);
return $"{BankAPI.LoadedBankLocations.Count + SoundtrackAPI.SelectedSoundtrackIndex + 1}: {SoundtrackAPI.Soundtracks[SoundtrackAPI.SelectedSoundtrackIndex].Name}";
case TNHPstates.Announcer:
return (AnnouncerAPI.CurrentAnnouncerIndex+1) + ": " + AnnouncerAPI.CurrentAnnouncer.Name;
case TNHPstates.Sosig_Voicelines:
return (SosigVLSAPI.CurrentSosigVlsIndexOfVlsSet(_selectedVLSSet)+1) + ": " + SosigVLSAPI.CurrentSosigVlsOfVlsSet(_selectedVLSSet).name;
} return ""; }
private string GetVolumePercent()
{
float vol = 0;
switch (TNHPstate) {
case TNHPstates.BGM:
vol = PluginMain.BackgroundMusicVolume.Value;
break;
case TNHPstates.Announcer:
vol = PluginMain.AnnouncerMusicVolume.Value;
break;
case TNHPstates.Sosig_Voicelines:
vol = 1;
break;
}
return Mathf.Round(vol * 100).ToString(CultureInfo.InvariantCulture) + "%";
}
private void SetCurrentItem(object sender, ButtonClickEventArgs args)
{
var index = _firstMusicIndex + Array.IndexOf(_musicButtons, sender as ButtonWidget);
if (GM.TNH_Manager != null) WristMenuAPI.Instance.Aud.PlayOneShot(WristMenuAPI.Instance.AudClip_Err);
else
{
int clamp;
switch (TNHPstate)
{
case TNHPstates.BGM:
if(BGMs[index].IsBank && BGMs[index].BankGuid == "Select Random")
index = UnityEngine.Random.Range(0, BGMs.Count);
PluginMain.DebugLog.LogInfo($"Setting song to index {index}, {BGMs[index].Name}");
if (BGMs[index].IsBank) {
// Handle Random option
BankAPI.SwapBank(index);
GameObject go = new GameObject();
if(BankAPI.LoadedBankLocations[index] != "Your Mix" && BankAPI.LoadedBankLocations[index] != "Select Random")
go.AddComponent(typeof(PlayFModSnippet));
PluginMain.DebugLog.LogInfo($"index: {index}, index bank: {BankAPI.LoadedBankLocations[index]}");
if (BankAPI.LoadedBankLocations[index] == "Your Mix")
SoundtrackAPI.IsMix = true;
else
SoundtrackAPI.IsMix = false;
}
else {
PluginMain.IsSoundtrack.Value = true;
SoundtrackAPI.EnableSoundtrackFromGUID(BGMs[index].SoundtrackGuid);
GameObject go = new GameObject();
go.AddComponent(typeof(PlaySoundtrackSnippet));
SoundtrackAPI.IsMix = false;
}
break;
case TNHPstates.Announcer:
clamp = Mathf.Clamp(index, 0, AnnouncerAPI.LoadedAnnouncers.Count);
AnnouncerAPI.SwapAnnouncer(AnnouncerAPI.LoadedAnnouncers[clamp].GUID);
PlaySnippet(AnnouncerAPI.GetRandomPreview(AnnouncerAPI.CurrentAnnouncer.GUID));
break;
case TNHPstates.Sosig_Voicelines:
clamp = Mathf.Clamp(index, 0, SosigVLSAPI.LoadedSosigVLSs.Count);
SosigVLSAPI.SwapSosigVLS(SosigVLSAPI.LoadedSosigVLSs[clamp].guid, SosigVLSAPI.VLSGuidOrder[_selectedVLSSet]);
PlaySnippet(SosigVLSAPI.GetRandomPreview(SosigVLSAPI.CurrentSosigVlsOfVlsSet(_selectedVLSSet).guid));
break;
}
SetIcon();
if(!PluginMain.IsSoundtrack.Value)
_bankText.Text.text = "Selected:\n" + GetCurrentSelectedItemName() + "\n(BANK MOD: NO INSTITUTION SUPPORT)"; //set new bank
else
_bankText.Text.text = "Selected:\n" + GetCurrentSelectedItemName(); //set new bank
}
}
public void PlaySnippet(AudioClip snip)
{
float pitch = 1f;
float vol = 0.6f;
switch (TNHPstate)
{
case TNHPstates.Announcer:
vol = 0.6f * PluginMain.AnnouncerMusicVolume.Value;
break;
case TNHPstates.Sosig_Voicelines:
pitch = SosigVLSAPI.CurrentSosigVlsOfVlsSet(_selectedVLSSet).SpeechSet.BasePitch;
break;
}
//make audioevent
AudioEvent audioEvent = new AudioEvent();
audioEvent.Clips.Add(snip);
audioEvent.PitchRange = new Vector2(pitch, pitch);
audioEvent.VolumeRange = new Vector2(vol, vol);
//play it
SM.PlayGenericSound(audioEvent, GM.CurrentPlayerBody.transform.position);
}
private void SetIcon()
{
if (icondisplay == null) return;
Debug.Log($"IsMix: {SoundtrackAPI.IsMix.ToString()}, CurBank: {GetCurrentSelectedItemName()}, CurSoundtrack: {SoundtrackAPI.Soundtracks[SoundtrackAPI.SelectedSoundtrackIndex].Guid}");
switch (TNHPstate)
{
case TNHPstates.BGM:
if(SoundtrackAPI.IsMix)
icondisplay.texture = BankAPI.GetBankIcon("Your Mix");
else if(!PluginMain.IsSoundtrack.Value)
icondisplay.texture = BankAPI.GetBankIcon(BankAPI.CurrentBankLocation);
else
icondisplay.texture = SoundtrackAPI.GetIcon(SoundtrackAPI.SelectedSoundtrackIndex);
break;
case TNHPstates.Announcer:
icondisplay.texture = AnnouncerAPI.GetAnnouncerIcon(AnnouncerAPI.CurrentAnnouncer);
break;
case TNHPstates.Sosig_Voicelines:
icondisplay.texture = SosigVLSAPI.GetSosigVLSIcon(SosigVLSAPI.CurrentSosigVlsOfVlsSet(_selectedVLSSet));
break;
}
}
}
}