Standardise music volume
[naja.git] / naja / scenes / lose.py
1 """
2 Lose scene.
3 """
4
5 import pygame.locals as pgl
6
7 from naja.constants import KEYS, PALETTE
8 from naja.scenes.scene import Scene
9 from naja.sound import sound
10 from naja.widgets.image_box import ImageBox
11 from naja.widgets.text import TextWidget, TextBoxWidget
12 from naja.events import SceneChangeEvent, LoadGameEvent
13
14
15 class LoseScene(Scene):
16     """
17     Commiserations.
18     """
19
20     def __init__(self, state):
21         super(LoseScene, self).__init__(state)
22
23         background = ImageBox(
24             (0, 0), "screens/you_lost.png")
25         self.add(background)
26
27
28         #self.add(TextWidget(
29         #    (50, 50), 'You lost!', colour=PALETTE.WHITE))
30
31         if self.state.gameboard.has_cheated:
32             self.add(TextWidget(
33                 (50, 250), 'Even with cheats on.', colour=PALETTE.ORANGE))
34
35         self.add(TextBoxWidget(
36             (50, 300), '\n\n'.join([
37                 "Something went terribly wrong.",
38                 "You should re-evaluate your life choices.",
39                 "",
40                 "Press ESC to return to the menu",
41             ]), fontsize=32,
42             colour='white', padding=1, border=1,
43             bg_colour='black', border_colour='black',
44             box_width=300))
45         sound.play_music('lost.ogg', 0.25)
46
47     def handle_scene_event(self, ev):
48         from naja.scenes.menu import MenuScene
49         if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT:
50             sound.stop()
51             # drop current state
52             LoadGameEvent.post(None)
53             SceneChangeEvent.post(MenuScene)
54             return