forked from oahassan/way-of-the-stick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
volume.py
128 lines (112 loc) · 3.53 KB
/
volume.py
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
import sys
import pygame
import gamestate
import wotsuievents
import wotsui
import settingsdata
from volumeui import VolumeControl
from button import Label, ExitButton
import music
sound_label = None
sound_control = None
music_label = None
music_control = None
exit_button = None
exit_indicator = False
loaded = False
def load():
global exit_button
global exit_indicator
global loaded
global sound_label
global sound_control
global music_label
global music_control
exit_button = ExitButton()
exit_indicator = False
loaded = True
#Create control labels and controls
sound_label_position = (20,20)
sound_label = Label(
sound_label_position,
'Effects Volume',
(255,255,255),
40
)
sound_control = VolumeControl()
sound_control_position = (
sound_label_position[0],
sound_label_position[1] + sound_label.height + 20
)
sound_control.create_children()
sound_control.set_layout_data(sound_control_position, 300)
sound_control.set_scroll_percent(settingsdata.get_sound_volume())
music_label_position = sound_control_position = (
sound_control.position[0],
sound_control.position[1] + sound_control.height + 40
)
music_label = Label(
music_label_position,
'Music Volume',
(255,255,255),
40
)
music_control = VolumeControl()
music_control.create_children()
music_control_position = (
music_label_position[0],
music_label_position[1] + music_label.height + 20
)
music_control.set_layout_data(music_control_position, 300)
music_control.set_scroll_percent(settingsdata.get_music_volume())
def unload():
global exit_button
global exit_indicator
global loaded
global sound_label
global sound_control
global music_label
global music_control
settingsdata.save_sound_volume(sound_control.get_scroll_percent())
settingsdata.save_music_volume(music_control.get_scroll_percent())
exit_button = None
exit_indicator = False
loaded = False
sound_label = None
sound_control = None
music_label = None
music_control = None
def handle_events():
global exit_button
global exit_indicator
global sound_label
global sound_control
global music_label
global music_control
if not loaded:
load()
sound_control.handle_events()
music_control.handle_events()
music.set_volume(music_control.get_scroll_percent())
if pygame.MOUSEBUTTONDOWN in wotsuievents.event_types:
if exit_button.contains(wotsuievents.mouse_pos):
exit_indicator = True
exit_button.handle_selected()
elif pygame.MOUSEBUTTONUP in wotsuievents.event_types:
if exit_indicator == True:
exit_indicator = False
exit_button.handle_deselected()
if exit_button.contains(wotsuievents.mouse_pos):
unload()
gamestate.mode = gamestate.Modes.MAINMENU
if gamestate.mode == gamestate.Modes.ONLINEVERSUSMOVESETSELECT:
if host_match_button.contains(wotsuievents.mouse_pos):
gamestate.hosting = True
elif join_match_button.contains(wotsuievents.mouse_pos):
versusclient.load()
if loaded:
exit_button.draw(gamestate.screen)
sound_label.draw(gamestate.screen)
sound_control.draw(gamestate.screen)
music_label.draw(gamestate.screen)
music_control.draw(gamestate.screen)