-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSoundPanelLayer.angelscript
56 lines (49 loc) · 1.36 KB
/
SoundPanelLayer.angelscript
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
class SoundPanelLayer : UILayer
{
private SoundPanelProperties@ m_soundPanelProps;
SoundPanelLayer(SoundPanelProperties@ soundPanelProps)
{
@m_soundPanelProps = @soundPanelProps;
if (m_soundPanelProps.showSoundSwitch)
{
addGlobalSoundSwitch("sound_switch", m_soundPanelProps.soundSwitchOn, m_soundPanelProps.soundSwitchOff,
m_soundPanelProps.soundSwitchPos, m_soundPanelProps.soundSwitchOrigin);
}
}
private void manageMusicSwitch()
{
if (!m_soundPanelProps.showMusicSwitch || !m_soundPanelProps.showSoundSwitch)
return;
UISwitch@ soundSwitch = cast<UISwitch@>(getButton("sound_switch"));
if (soundSwitch is null)
return;
UISwitch@ musicSwitch = cast<UISwitch@>(getButton("music_switch"));
// if the music switch is there
if (musicSwitch !is null)
{
// if sound switch is off, dismiss the music switch
if (!soundSwitch.isEnabled())
{
musicSwitch.dismiss();
}
}
else // if the music switch ain't there
{
// if sound switch is on, add a music switch
if (soundSwitch.isEnabled())
{
addGlobalMusicSwitch("music_switch", m_soundPanelProps.musicSwitchOn, m_soundPanelProps.musicSwitchOff,
m_soundPanelProps.musicSwitchPos, m_soundPanelProps.musicSwitchOrigin);
}
}
}
void update()
{
UILayer::update();
manageMusicSwitch();
}
string getName() const
{
return "SoundPanelLayer";
}
}