-
Notifications
You must be signed in to change notification settings - Fork 0
/
settingsscreen.py
79 lines (65 loc) · 2.88 KB
/
settingsscreen.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
import gui
import pygame
from quit import *
from game import *
from gui.dialog import *
from gui.image import *
from gui.checkbox import *
class SettingsScreen(Dialog):
def __init__(self, surface, images, locations, ini_settings):
self.images = images
self.locations = locations
self.player = player
self.ini_settings = ini_settings
Dialog.__init__(self, surface)
def createWidgets(self):
self.surface.blit(self.images['startscreen']['background'],(0,0))
self.wm.register(Image(self.images['settingsscreen']['fullscreen'],
(int(self.locations['settingsscreen']['fullscreen_x']),
int(self.locations['settingsscreen']['fullscreen_y']))
))
self.wm.register(CheckBox(self.images['gui']['checkbox_checked'], self.images['gui']['checkbox_unchecked'],
(int(self.locations['settingsscreen']['fullscreen_toggle_x']),
int(self.locations['settingsscreen']['fullscreen_toggle_y'])),
checked = self.ini_settings.settings['video']['fullscreen'] == 'yes',
callbacks={widget.MOUSEBUTTONUP : self.fullscreen }
))
# If sound system is available
if pygame.mixer.get_init():
self.wm.register(Image(self.images['settingsscreen']['music'],
(int(self.locations['settingsscreen']['music_x']),
int(self.locations['settingsscreen']['music_y']))
))
self.wm.register(CheckBox(self.images['gui']['checkbox_checked'], self.images['gui']['checkbox_unchecked'],
(int(self.locations['settingsscreen']['music_toggle_x']),
int(self.locations['settingsscreen']['music_toggle_y'])),
checked = self.ini_settings.settings['sound']['music'] == 'yes',
callbacks={widget.MOUSEBUTTONUP : self.music }
))
self.wm.register(Button(self.images['settingsscreen']['return'], self.images['settingsscreen']['return'],
(int(self.locations['settingsscreen']['return_x']),
int(self.locations['settingsscreen']['return_y'])),
callbacks={widget.MOUSEBUTTONUP : self.return_to_main }
))
def return_to_main(self, trigger, event):
self.state = 1
return widget.DONE
def fullscreen(self, trigger, event):
if not (self.ini_settings.settings['video']['fullscreen'] == 'yes'):
self.ini_settings.settings['video']['fullscreen'] = 'yes'
pygame.display.toggle_fullscreen()
else:
self.ini_settings.settings['video']['fullscreen'] = 'no'
pygame.display.toggle_fullscreen()
self.ini_settings.save()
self.wm.paint(1,0)
def music(self, trigger, event):
if not (self.ini_settings.settings['sound']['music'] == 'yes'):
self.ini_settings.settings['sound']['music'] = 'yes'
pygame.mixer.music.load( os.path.join(self.ini_settings.settings['path']['data'], 'music', '4stattack.ogg') )
pygame.mixer.music.play(-1)
else:
self.ini_settings.settings['sound']['music'] = 'no'
pygame.mixer.music.stop()
self.ini_settings.save()
self.wm.paint(1,0)