Mercurial > rinkhals
annotate gamelib/helpscreen.py @ 447:f04a2490c35f
The sub-toolbar rewrite, the finally not crashing version
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 21 Nov 2009 19:58:49 +0000 |
parents | 2bcfccb8288e |
children | 263dea6d226b |
rev | line source |
---|---|
179 | 1 """Help screen.""" |
2 | |
3 from pgu import gui | |
4 import pygame | |
5 import constants | |
6 import engine | |
7 import imagecache | |
8 | |
9 HELP="""Welcome to %s | |
10 | |
11 Introduction: | |
12 | |
13 The aim of the game is to make as much money as possible from your chicken | |
14 farm. The problem is the foxes, which want to eat your chickens. Since hiring | |
15 guards is both too expensive and unreliable, the obvious solution is to help | |
16 the chickens defend themselves. | |
17 | |
18 Game mechanics: | |
19 | |
20 You lose if you end a night with no chickens left. | |
21 | |
22 Chickens only lay eggs in henhouses, and must stay on the egg for 2 days to | |
230
fa0e818c3fee
Update instructions to match new chick hatching behaviour.
Simon Cross <hodgestar@gmail.com>
parents:
181
diff
changeset
|
23 hatch a new chicken. Chickens that hatch in already full henhouses are |
fa0e818c3fee
Update instructions to match new chick hatching behaviour.
Simon Cross <hodgestar@gmail.com>
parents:
181
diff
changeset
|
24 moved to just outside. If there is no space outside, they die immediately |
fa0e818c3fee
Update instructions to match new chick hatching behaviour.
Simon Cross <hodgestar@gmail.com>
parents:
181
diff
changeset
|
25 from overcrowding. |
179 | 26 """ % constants.NAME |
27 | |
390
2bcfccb8288e
Make help screen use goal from the level
Neil Muller <drnlmuller@gmail.com>
parents:
309
diff
changeset
|
28 LEVEL_TEXT="""The currently selected level is %(name)s |
2bcfccb8288e
Make help screen use goal from the level
Neil Muller <drnlmuller@gmail.com>
parents:
309
diff
changeset
|
29 |
2bcfccb8288e
Make help screen use goal from the level
Neil Muller <drnlmuller@gmail.com>
parents:
309
diff
changeset
|
30 The goal is: |
2bcfccb8288e
Make help screen use goal from the level
Neil Muller <drnlmuller@gmail.com>
parents:
309
diff
changeset
|
31 %(goal)s |
2bcfccb8288e
Make help screen use goal from the level
Neil Muller <drnlmuller@gmail.com>
parents:
309
diff
changeset
|
32 """ |
2bcfccb8288e
Make help screen use goal from the level
Neil Muller <drnlmuller@gmail.com>
parents:
309
diff
changeset
|
33 |
2bcfccb8288e
Make help screen use goal from the level
Neil Muller <drnlmuller@gmail.com>
parents:
309
diff
changeset
|
34 def make_help_screen(level): |
179 | 35 """Create a main menu""" |
390
2bcfccb8288e
Make help screen use goal from the level
Neil Muller <drnlmuller@gmail.com>
parents:
309
diff
changeset
|
36 help_screen = HelpScreen(level, width=600) |
179 | 37 |
38 c = HelpContainer(align=0, valign=0) | |
39 c.add(help_screen, 0, 0) | |
40 | |
41 return c | |
42 | |
43 class HelpContainer(gui.Container): | |
44 def paint(self, s): | |
45 pygame.display.set_caption('Instructions') | |
181
7e556ef40100
Lighten help screen. Fix some oddities in darken modifier.
Simon Cross <hodgestar@gmail.com>
parents:
179
diff
changeset
|
46 splash = imagecache.load_image("images/splash.png", ["lighten_most"]) |
179 | 47 pygame.display.get_surface().blit(splash, (0, 0)) |
48 gui.Container.paint(self, s) | |
49 | |
50 class HelpScreen(gui.Document): | |
390
2bcfccb8288e
Make help screen use goal from the level
Neil Muller <drnlmuller@gmail.com>
parents:
309
diff
changeset
|
51 def __init__(self, level, **params): |
179 | 52 gui.Document.__init__(self, **params) |
53 | |
54 def done_pressed(): | |
55 pygame.event.post(engine.GO_MAIN_MENU) | |
56 | |
57 done_button = gui.Button("Return to Main Menu") | |
58 done_button.connect(gui.CLICK, done_pressed) | |
59 | |
60 space = self.style.font.size(" ") | |
61 | |
390
2bcfccb8288e
Make help screen use goal from the level
Neil Muller <drnlmuller@gmail.com>
parents:
309
diff
changeset
|
62 full_text = HELP + '\n\n' + LEVEL_TEXT % { |
2bcfccb8288e
Make help screen use goal from the level
Neil Muller <drnlmuller@gmail.com>
parents:
309
diff
changeset
|
63 'name' : level.level_name, |
2bcfccb8288e
Make help screen use goal from the level
Neil Muller <drnlmuller@gmail.com>
parents:
309
diff
changeset
|
64 'goal' : level.goal |
2bcfccb8288e
Make help screen use goal from the level
Neil Muller <drnlmuller@gmail.com>
parents:
309
diff
changeset
|
65 } |
2bcfccb8288e
Make help screen use goal from the level
Neil Muller <drnlmuller@gmail.com>
parents:
309
diff
changeset
|
66 |
2bcfccb8288e
Make help screen use goal from the level
Neil Muller <drnlmuller@gmail.com>
parents:
309
diff
changeset
|
67 for paragraph in full_text.split('\n\n'): |
179 | 68 self.block(align=-1) |
69 for word in paragraph.split(): | |
70 self.add(gui.Label(word)) | |
71 self.space(space) | |
72 self.br(space[1]) | |
73 self.br(space[1]) | |
74 self.block(align=0) | |
75 self.add(done_button, align=0) |