95d931a0b761227ccdb8822da5a090269658ef37
[naja.git] / naja / scenes / win.py
1 """
2 Win scene.
3 """
4
5 import pygame.locals as pgl
6
7 from naja.constants import KEYS, PALETTE
8 from naja.events import QuitGameEvent
9 from naja.scenes.scene import Scene
10 from naja.widgets.image_box import ImageBox
11 from naja.widgets.text import TextWidget, TextBoxWidget
12
13
14 class WinScene(Scene):
15     """
16     Congratulations.
17     """
18
19     def __init__(self, state):
20         super(WinScene, self).__init__(state)
21
22         background = ImageBox(
23             (0, 0), "screens/you_won.png")
24         self.add(background)
25
26         self.add(TextWidget((50, 50), 'You won!', colour=PALETTE.WHITE))
27         if self.state.gameboard.has_cheated:
28             self.add(TextWidget(
29                 (50 + 64, 50), 'CHEATER!', colour=PALETTE.ORANGE))
30         self.add(TextBoxWidget(
31             (50, 100), '\n\n'.join([
32                 "You're great.",
33                 "You did well.",
34                 "You should be proud of yourself.",
35             ]),
36             colour=PALETTE.WHITE, padding=1, border=1,
37             bg_colour=PALETTE.BLACK, border_colour=PALETTE.BLACK,
38             box_width=300))
39
40     def handle_scene_event(self, ev):
41         if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT:
42             QuitGameEvent.post()
43             return