Mercurial > rinkhals
comparison gamelib/mainmenu.py @ 312:dd1ffee5ccf5
Use different score tables fot the different modes. Refactor game modes code as a result
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 05 Sep 2009 18:30:51 +0000 |
parents | 245ee075f2ae |
children | 6baf8b5beb5c |
comparison
equal
deleted
inserted
replaced
311:245ee075f2ae | 312:dd1ffee5ccf5 |
---|---|
30 pygame.display.toggle_fullscreen() | 30 pygame.display.toggle_fullscreen() |
31 | 31 |
32 def quit_pressed(): | 32 def quit_pressed(): |
33 pygame.event.post(engine.QUIT) | 33 pygame.event.post(engine.QUIT) |
34 | 34 |
35 def fortnight_pressed(): | 35 def start_game(mode): |
36 constants.TURN_LIMIT = 14 | 36 constants.TURN_LIMIT = constants.TURN_LIMITS[mode] |
37 pygame.event.post(engine.START_DAY) | |
38 | |
39 def quarter_pressed(): | |
40 constants.TURN_LIMIT = 90 | |
41 pygame.event.post(engine.START_DAY) | |
42 | |
43 def unlimited_pressed(): | |
44 constants.TURN_LIMIT = 0 | |
45 pygame.event.post(engine.START_DAY) | 37 pygame.event.post(engine.START_DAY) |
46 | 38 |
47 def help_pressed(): | 39 def help_pressed(): |
48 pygame.event.post(engine.GO_HELP_SCREEN) | 40 pygame.event.post(engine.GO_HELP_SCREEN) |
49 | 41 |
50 fortnight_button = gui.Button("Two weeks") | 42 style = { |
51 fortnight_button.connect(gui.CLICK, fortnight_pressed) | 43 "padding_bottom": 15, |
52 | 44 } |
53 quarter_button = gui.Button("Three months") | 45 td_kwargs = { |
54 quarter_button.connect(gui.CLICK, quarter_pressed) | 46 "align": 0, |
55 | 47 "style": style, |
56 unlim_button = gui.Button("Unlimited") | 48 } |
57 unlim_button.connect(gui.CLICK, unlimited_pressed) | 49 |
50 for mode in constants.TURN_LIMITS: | |
51 button = gui.Button(mode) | |
52 button.connect(gui.CLICK, start_game, mode) | |
53 self.tr() | |
54 self.td(button, **td_kwargs) | |
58 | 55 |
59 quit_button = gui.Button("Quit") | 56 quit_button = gui.Button("Quit") |
60 quit_button.connect(gui.CLICK, quit_pressed) | 57 quit_button.connect(gui.CLICK, quit_pressed) |
61 | 58 |
62 help_button = gui.Button("Instructions") | 59 help_button = gui.Button("Instructions") |
63 help_button.connect(gui.CLICK, help_pressed) | 60 help_button.connect(gui.CLICK, help_pressed) |
64 | 61 |
65 fullscreen_toggle = gui.Button("Toggle Fullscreen") | 62 fullscreen_toggle = gui.Button("Toggle Fullscreen") |
66 fullscreen_toggle.connect(gui.CLICK, fullscreen_toggled) | 63 fullscreen_toggle.connect(gui.CLICK, fullscreen_toggled) |
67 | 64 |
68 style = { | |
69 "padding_bottom": 15, | |
70 } | |
71 td_kwargs = { | |
72 "align": 0, | |
73 "style": style, | |
74 } | |
75 | |
76 self.tr() | |
77 self.td(fortnight_button, **td_kwargs) | |
78 | |
79 self.tr() | |
80 self.td(quarter_button, **td_kwargs) | |
81 | |
82 self.tr() | |
83 self.td(unlim_button, **td_kwargs) | |
84 | |
85 self.tr() | 65 self.tr() |
86 self.td(help_button, **td_kwargs) | 66 self.td(help_button, **td_kwargs) |
87 | 67 |
88 self.tr() | 68 self.tr() |
89 self.td(fullscreen_toggle, **td_kwargs) | 69 self.td(fullscreen_toggle, **td_kwargs) |