Mercurial > sypikslang
annotate gamelib/gamegui.py @ 192:57bf6a5e31cb
A rival appears on the scene
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 12 May 2012 15:18:28 +0200 |
parents | 4f5de85fd1af |
children | eb4516169b3c |
rev | line source |
---|---|
53
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
2 # vim:fileencoding=utf-8 ai ts=4 sts=4 et sw=4 |
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
3 |
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
4 """Gui for the actual game""" |
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
5 |
57 | 6 from pygame import image |
88 | 7 try: |
8 import simplejson | |
9 json = simplejson | |
10 except ImportError: | |
11 import json | |
12 | |
57 | 13 |
14 from gamelib.data import filepath | |
88 | 15 from gamelib.game_base import get_save_filename |
120
a79bba0dfcd8
Use TextBoxes for some stuff
Neil Muller <drnlmuller@gmail.com>
parents:
109
diff
changeset
|
16 from gamelib.gui_base import (Window, TextLabel, TextBox, font_small, |
a79bba0dfcd8
Use TextBoxes for some stuff
Neil Muller <drnlmuller@gmail.com>
parents:
109
diff
changeset
|
17 font_medium, font_large) |
145
53277724645b
Science button juggling.
Jeremy Thurgood <firxen@gmail.com>
parents:
139
diff
changeset
|
18 from gamelib.gui import BigButton, ImageDrawable, IconTextButton |
98 | 19 from gamelib.engine import PopWindow, AddWindow, GameOver |
138
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
134
diff
changeset
|
20 from gamelib.constants import WIDTH, HEIGHT, FAILURE, SUCCESS, GAME_WIN, INFO |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
21 from gamelib.gamestate import Game |
53
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
22 |
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
23 |
109
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
24 def _lookup_reputation(rep): |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
25 """Turn reputation in a nice string""" |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
26 |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
27 if rep < 0: |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
28 return 'Mindless Thug' |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
29 if rep < 10: |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
30 return 'Fringe Lunatic' |
173 | 31 if rep < 20: |
32 return 'Batty Experimenter' | |
33 if rep < 50: | |
34 return 'Demented Analyst' | |
35 if rep < 70: | |
36 return 'Deranged Researcher' | |
37 if rep < 150: | |
109
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
38 return 'Mad Scientist' |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
39 return 'Major Threat to World Peace' |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
40 |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
41 |
122
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
42 class PopWindowButton(BigButton): |
53
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
43 |
125
c224057befff
put 'End Turn' & 'Next Turn' buttons in the same place. Move 'Exit' button away from the action
Neil Muller <drnlmuller@gmail.com>
parents:
124
diff
changeset
|
44 def __init__(self, pos, text): |
c224057befff
put 'End Turn' & 'Next Turn' buttons in the same place. Move 'Exit' button away from the action
Neil Muller <drnlmuller@gmail.com>
parents:
124
diff
changeset
|
45 super(PopWindowButton, self).__init__(pos, text) |
53
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
46 |
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
47 def on_click(self): |
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
48 PopWindow.post() |
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
49 |
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
50 |
122
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
51 class ExitGameButton(PopWindowButton): |
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
52 def __init__(self): |
125
c224057befff
put 'End Turn' & 'Next Turn' buttons in the same place. Move 'Exit' button away from the action
Neil Muller <drnlmuller@gmail.com>
parents:
124
diff
changeset
|
53 super(ExitGameButton, self).__init__((WIDTH - 128, HEIGHT - 60), |
c224057befff
put 'End Turn' & 'Next Turn' buttons in the same place. Move 'Exit' button away from the action
Neil Muller <drnlmuller@gmail.com>
parents:
124
diff
changeset
|
54 'Exit') |
122
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
55 |
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
56 |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
57 class EndTurnButton(BigButton): |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
58 |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
59 def __init__(self, parent): |
125
c224057befff
put 'End Turn' & 'Next Turn' buttons in the same place. Move 'Exit' button away from the action
Neil Muller <drnlmuller@gmail.com>
parents:
124
diff
changeset
|
60 super(EndTurnButton, self).__init__(((WIDTH - 128), 10), 'End Turn') |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
61 self.parent = parent |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
62 |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
63 def on_click(self): |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
64 self.parent.end_turn() |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
65 |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
66 |
122
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
67 class NextTurnButton(PopWindowButton): |
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
68 def __init__(self): |
125
c224057befff
put 'End Turn' & 'Next Turn' buttons in the same place. Move 'Exit' button away from the action
Neil Muller <drnlmuller@gmail.com>
parents:
124
diff
changeset
|
69 super(NextTurnButton, self).__init__(((WIDTH - 128), 10), 'Next Turn') |
122
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
70 |
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
71 |
156 | 72 class AssignButton(PopWindowButton): |
73 def __init__(self, parent): | |
74 super(AssignButton, self).__init__(((WIDTH - 128), 10), | |
169
a6ca82fa9c4c
Rename several UI elements
Neil Muller <drnlmuller@gmail.com>
parents:
168
diff
changeset
|
75 'Assign Scheme') |
156 | 76 self.parent = parent |
77 | |
78 def on_click(self): | |
79 self.parent.accept() | |
80 super(AssignButton, self).on_click() | |
81 | |
82 | |
83 class CancelButton(PopWindowButton): | |
84 def __init__(self, parent): | |
85 super(CancelButton, self).__init__(((WIDTH - 256), 10), | |
169
a6ca82fa9c4c
Rename several UI elements
Neil Muller <drnlmuller@gmail.com>
parents:
168
diff
changeset
|
86 'Cancel Scheme') |
156 | 87 self.parent = parent |
88 | |
89 def on_click(self): | |
90 self.parent.cancel() | |
91 super(CancelButton, self).on_click() | |
127
591a85a4edac
Use 'done' rather than exit in equipment selection screen
Neil Muller <drnlmuller@gmail.com>
parents:
126
diff
changeset
|
92 |
591a85a4edac
Use 'done' rather than exit in equipment selection screen
Neil Muller <drnlmuller@gmail.com>
parents:
126
diff
changeset
|
93 |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
94 class ResetButton(BigButton): |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
95 |
169
a6ca82fa9c4c
Rename several UI elements
Neil Muller <drnlmuller@gmail.com>
parents:
168
diff
changeset
|
96 def __init__(self, parent, text='Clear calendars'): |
a6ca82fa9c4c
Rename several UI elements
Neil Muller <drnlmuller@gmail.com>
parents:
168
diff
changeset
|
97 super(ResetButton, self).__init__((10, 10), text) |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
98 self.parent = parent |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
99 |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
100 def on_click(self): |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
101 self.parent.do_reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
102 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
103 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
104 class SwitchWinButton(BigButton): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
105 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
106 def __init__(self, pos, text, new_window): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
107 super(SwitchWinButton, self).__init__(pos, text) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
108 self.new_window = new_window |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
109 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
110 def on_click(self): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
111 PopWindow.post() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
112 # Refresh state |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
113 self.new_window.update() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
114 AddWindow.post(self.new_window) |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
115 |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
116 |
145
53277724645b
Science button juggling.
Jeremy Thurgood <firxen@gmail.com>
parents:
139
diff
changeset
|
117 class ScienceWidget(IconTextButton): |
57 | 118 |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
119 def __init__(self, science, pos, parent): |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
120 self.science = science |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
121 self.points = 0 |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
122 self.parent = parent |
145
53277724645b
Science button juggling.
Jeremy Thurgood <firxen@gmail.com>
parents:
139
diff
changeset
|
123 super(ScienceWidget, self).__init__( |
53277724645b
Science button juggling.
Jeremy Thurgood <firxen@gmail.com>
parents:
139
diff
changeset
|
124 pos, science.get_image_name(), self.make_text(), font_small) |
53277724645b
Science button juggling.
Jeremy Thurgood <firxen@gmail.com>
parents:
139
diff
changeset
|
125 |
53277724645b
Science button juggling.
Jeremy Thurgood <firxen@gmail.com>
parents:
139
diff
changeset
|
126 def make_text(self): |
53277724645b
Science button juggling.
Jeremy Thurgood <firxen@gmail.com>
parents:
139
diff
changeset
|
127 name = self.science.NAME[:4] |
53277724645b
Science button juggling.
Jeremy Thurgood <firxen@gmail.com>
parents:
139
diff
changeset
|
128 text = '%s: %d' % (name, self.science.points) |
53277724645b
Science button juggling.
Jeremy Thurgood <firxen@gmail.com>
parents:
139
diff
changeset
|
129 if self.points > 0: |
53277724645b
Science button juggling.
Jeremy Thurgood <firxen@gmail.com>
parents:
139
diff
changeset
|
130 text = "%s + %d" % (text, self.points) |
53277724645b
Science button juggling.
Jeremy Thurgood <firxen@gmail.com>
parents:
139
diff
changeset
|
131 return text |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
132 |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
133 def on_click(self): |
63
364ff3479ef2
Remove duplicate point tracking. Rename classes for future refactoring
Neil Muller <drnlmuller@gmail.com>
parents:
62
diff
changeset
|
134 if (self.parent.game.get_available_points() > 0 and |
59
977224a5c663
Check can_spend in science button
Neil Muller <drnlmuller@gmail.com>
parents:
57
diff
changeset
|
135 self.science.can_spend(self.parent.game.lab, self.points + 1)): |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
136 self.points += 1 |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
137 self.parent.game.cur_allocation.append(self.science) |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
138 self.parent.update_labels() |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
139 self.set_text() |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
140 |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
141 def set_text(self): |
145
53277724645b
Science button juggling.
Jeremy Thurgood <firxen@gmail.com>
parents:
139
diff
changeset
|
142 self.text = self.make_text() |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
143 self._draw_text() |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
144 |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
145 def reset(self): |
63
364ff3479ef2
Remove duplicate point tracking. Rename classes for future refactoring
Neil Muller <drnlmuller@gmail.com>
parents:
62
diff
changeset
|
146 while self.points > 0: |
364ff3479ef2
Remove duplicate point tracking. Rename classes for future refactoring
Neil Muller <drnlmuller@gmail.com>
parents:
62
diff
changeset
|
147 self.parent.game.cur_allocation.remove(self.science) |
364ff3479ef2
Remove duplicate point tracking. Rename classes for future refactoring
Neil Muller <drnlmuller@gmail.com>
parents:
62
diff
changeset
|
148 self.points -= 1 |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
149 self.set_text() |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
150 self.parent.update_labels() |
65 | 151 |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
152 def restore_selection(self, old_selection): |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
153 points = old_selection.count(self.science) |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
154 # We skip things we cannot allocate enoigh points to (temp points |
128
6a847f22a312
Don't restore selections if they're illegal
Neil Muller <drnlmuller@gmail.com>
parents:
127
diff
changeset
|
155 # boosts, etc.) or we cannot currently develop further |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
156 if (points != self.points and |
128
6a847f22a312
Don't restore selections if they're illegal
Neil Muller <drnlmuller@gmail.com>
parents:
127
diff
changeset
|
157 points <= self.parent.game.get_available_points() and |
6a847f22a312
Don't restore selections if they're illegal
Neil Muller <drnlmuller@gmail.com>
parents:
127
diff
changeset
|
158 self.science.can_spend(self.parent.game.lab, |
6a847f22a312
Don't restore selections if they're illegal
Neil Muller <drnlmuller@gmail.com>
parents:
127
diff
changeset
|
159 self.points + points)): |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
160 self.points = points |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
161 self.parent.game.cur_allocation.extend([self.science] * points) |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
162 self.parent.update_labels() |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
163 self.set_text() |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
164 |
65 | 165 |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
166 class MissionWidget(BigButton): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
167 |
187 | 168 WIDTH = 260 |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
169 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
170 BG_IMAGE_NORMAL = image.load(filepath('images/science_normal.png')) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
171 BG_IMAGE_DOWN = image.load(filepath('images/science_down.png')) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
172 BG_IMAGE_SELECTED = image.load(filepath('images/mission_selected.png')) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
173 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
174 def __init__(self, mission, pos, parent): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
175 self.mission = mission |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
176 self.parent = parent |
124
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
177 self.game = self.parent.game |
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
178 self.minions = 0 |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
179 super(MissionWidget, self).__init__(pos, '%s' % mission.NAME, |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
180 font_small) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
181 selected = ImageDrawable((0, 0, self.WIDTH, self.HEIGHT), |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
182 self.BG_IMAGE_SELECTED) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
183 self.add_state('SELECTED', selected) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
184 self.mode = 'NORMAL' |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
185 self.equipment = [] |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
186 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
187 def on_mouse_cancel(self, pos): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
188 self.set_state(self.mode) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
189 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
190 def on_mouse_up(self, pos): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
191 self.set_state(self.mode) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
192 self.on_click() |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
193 |
156 | 194 def select(self): |
195 if not self.selected(): | |
196 self.game.minions -= self.minions | |
197 self.mode = 'SELECTED' | |
198 self.set_state(self.mode) | |
199 self.parent.update_labels() | |
200 | |
201 def unselect(self): | |
202 if self.selected(): | |
203 # Unassign the minions from the main game | |
204 self.game.minions += self.minions | |
205 self.reset() | |
206 | |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
207 def on_click(self): |
156 | 208 # select mission and equipment |
209 if self.game.minions > 0 or self.selected(): | |
210 if not self.selected(): | |
211 # Assign the minions automatically | |
212 self.minions = self.mission.MINIONS_REQUIRED | |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
213 equip = EquipWindow(self.parent.screen, self.mission, |
124
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
214 self.game, self) |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
215 AddWindow.post(equip) |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
216 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
217 def selected(self): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
218 return self.mode == 'SELECTED' |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
219 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
220 def get_equipment(self): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
221 return self.equipment |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
222 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
223 def reset(self): |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
224 for equip in self.equipment: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
225 # Release funds |
124
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
226 self.game.money += equip.COST |
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
227 self.minions = 0 |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
228 self.parent.update() |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
229 self.equipment = [] |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
230 self.mode = 'NORMAL' |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
231 self.set_state('NORMAL') |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
232 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
233 |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
234 class EquipWidget(BigButton): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
235 |
187 | 236 WIDTH = 260 |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
237 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
238 BG_IMAGE_NORMAL = image.load(filepath('images/science_normal.png')) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
239 BG_IMAGE_DOWN = image.load(filepath('images/science_down.png')) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
240 BG_IMAGE_UNAVAILABLE = image.load(filepath('images/equip_grey.png')) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
241 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
242 def __init__(self, equip, pos, parent, copies, available): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
243 self.equip = equip |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
244 self.parent = parent |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
245 self.available = available |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
246 super(EquipWidget, self).__init__(pos, '[%s : %d] - %d (x %d)' |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
247 % (equip.NAME, equip.points, equip.COST, copies), font_small) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
248 if not self.available: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
249 unavailable = ImageDrawable((0, 0, self.WIDTH, self.HEIGHT), |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
250 self.BG_IMAGE_UNAVAILABLE) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
251 # Override the default |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
252 self.add_state('NORMAL', unavailable) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
253 self.set_state('NORMAL') |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
254 self.equipment = [] |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
255 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
256 def on_mouse_down(self, pos): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
257 if self.available: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
258 super(EquipWidget, self).on_mouse_down(pos) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
259 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
260 def on_mouse_up(self, pos): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
261 if self.available: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
262 super(EquipWidget, self).on_mouse_up(pos) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
263 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
264 def on_click(self): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
265 self.parent.buy(self.equip) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
266 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
267 |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
268 class ValueLabel(TextLabel): |
65 | 269 |
161
6fdc985429a7
Display research advice.
Jeremy Thurgood <firxen@gmail.com>
parents:
156
diff
changeset
|
270 def __init__(self, pos, description, width=300): |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
271 self.description = description |
161
6fdc985429a7
Display research advice.
Jeremy Thurgood <firxen@gmail.com>
parents:
156
diff
changeset
|
272 rect = (pos[0], pos[1], width, 20) |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
273 super(ValueLabel, self).__init__(rect, |
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
274 '%s : 0' % description, font_medium, (255, 255, 0)) |
65 | 275 |
276 def set_value(self, value): | |
97
069a2d34b8b5
I shall pretend I did not touch the GUI, even though I added a myriad copies of some extra widgets.
Jeremy Thurgood <firxen@gmail.com>
parents:
93
diff
changeset
|
277 self.text = '%s : %s' % (self.description, value) |
65 | 278 self._draw_text() |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
279 |
60 | 280 |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
281 class EquipWindow(Window): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
282 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
283 def __init__(self, screen, mission, game, parent): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
284 super(EquipWindow, self).__init__(screen) |
156 | 285 assign = AssignButton(self) |
286 self.add_child(assign) | |
287 cancel = CancelButton(self) | |
288 self.add_child(cancel) | |
169
a6ca82fa9c4c
Rename several UI elements
Neil Muller <drnlmuller@gmail.com>
parents:
168
diff
changeset
|
289 reset = ResetButton(self, 'Clear inventory') |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
290 self.add_child(reset) |
187 | 291 title = TextBox((170, 20, 370, 50), "Choose equipment for %s" |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
292 % mission.NAME, font_medium, (255, 255, 255)) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
293 self.add_child(title) |
156 | 294 self.description = TextBox((10, 70, 790, 20), |
192
57bf6a5e31cb
A rival appears on the scene
Neil Muller <drnlmuller@gmail.com>
parents:
187
diff
changeset
|
295 mission.get_description(), font_medium, (255, 255, 255)) |
156 | 296 self.add_child(self.description) |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
297 self.parent = parent |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
298 self.game = game |
156 | 299 self.money = ValueLabel((10, self.description.rect.height + 75), |
300 'Money') | |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
301 self.money.set_value(self.game.money) |
156 | 302 self.minions = ValueLabel((310, self.description.rect.height + 75), |
303 'Minions Assigned') | |
304 self.minions.set_value(self.parent.minions) | |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
305 self.add_child(self.money) |
156 | 306 self.add_child(self.minions) |
307 inventory = TextLabel((10, self.description.rect.height + 90, 400, 20), | |
308 'Current Inventory', font_medium, (255, 255, 255)) | |
309 self.add_child(inventory) | |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
310 self._equip = [] |
156 | 311 self._inventory = [] |
312 self._update_widgets() | |
313 | |
314 def cancel(self): | |
315 self.do_reset() | |
316 self.parent.unselect() | |
317 | |
318 def accept(self): | |
319 self.parent.select() | |
320 | |
321 def _update_widgets(self): | |
322 self._make_inventory() | |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
323 self._make_equip_widgets() |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
324 |
156 | 325 def _make_inventory(self): |
326 for widget in self._inventory: | |
327 self.remove_child(widget) | |
328 self._inventory = [] | |
329 x = 10 | |
330 y = 110 + self.description.rect.height | |
331 # collections.Counter is python 2.7. This is a bother | |
332 equipment = sorted(set(self.parent.equipment), key=lambda x: x.NAME) | |
333 for equip in equipment: | |
334 count = self.parent.equipment.count(equip) | |
335 widget = TextLabel((x, y, 700, 15), '%s x %s' | |
336 % (equip.NAME, count), font_small, (255, 255, 255)) | |
337 y += 15 | |
338 self._inventory.append(widget) | |
339 self.add_child(widget) | |
340 | |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
341 def _make_equip_widgets(self): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
342 for widget in self._equip: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
343 self.remove_child(widget) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
344 self._equip = [] |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
345 x = 0 |
156 | 346 y = max(250, 130 + self.description.rect.height + |
347 20 * len(self._inventory)) | |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
348 available = self.game.get_available_equipment() |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
349 for equip in self.game.get_all_equipment(): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
350 copies = self.parent.equipment.count(equip) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
351 widget = EquipWidget(equip, (x, y), self, copies, |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
352 equip in available) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
353 self._equip.append(widget) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
354 self.add_child(widget) |
187 | 355 x += widget.WIDTH + 10 |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
356 if x >= WIDTH: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
357 x = 0 |
187 | 358 y += 65 |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
359 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
360 def buy(self, equip): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
361 self.game.money -= equip.COST |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
362 self.money.set_value(self.game.money) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
363 self.parent.equipment.append(equip) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
364 self.parent.parent.update() |
156 | 365 self._update_widgets() |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
366 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
367 def do_reset(self): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
368 for equip in self.parent.equipment: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
369 # Release funds |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
370 self.game.money += equip.COST |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
371 self.money.set_value(self.game.money) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
372 self.parent.equipment = [] |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
373 self.parent.parent.update() |
156 | 374 self._update_widgets() |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
375 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
376 |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
377 class ResultsWindow(Window): |
139 | 378 message_colours = { |
379 INFO: (60, 60, 255), | |
380 FAILURE: (255, 60, 60), | |
381 SUCCESS: (60, 255, 60), | |
382 } | |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
383 |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
384 def __init__(self, screen, messages, turn): |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
385 super(ResultsWindow, self).__init__(screen) |
122
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
386 nextbut = NextTurnButton() |
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
387 self.add_child(nextbut) |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
388 title = TextLabel((200, 20, 400, 50), "Results for turn %d" % turn, |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
389 font_medium, (255, 255, 255)) |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
390 self.add_child(title) |
98 | 391 self.is_game_over = False |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
392 if not messages: |
120
a79bba0dfcd8
Use TextBoxes for some stuff
Neil Muller <drnlmuller@gmail.com>
parents:
109
diff
changeset
|
393 results = TextBox((200, 200, 400, 50), |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
394 "Nothing of interest happened", font_medium, |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
395 (255, 255, 255)) |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
396 self.add_child(results) |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
397 else: |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
398 y = 200 |
138
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
134
diff
changeset
|
399 for msg_type, msg, loot in messages: |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
400 # FIXME: Better widgets |
139 | 401 if msg_type == GAME_WIN: |
98 | 402 self._make_win_screen(turn, msg) |
403 self.is_game_over = True | |
404 break | |
139 | 405 colour = self.message_colours.get(msg_type, (255, 255, 255)) |
406 y = self.display_message(y, msg, loot, colour) | |
138
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
134
diff
changeset
|
407 |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
134
diff
changeset
|
408 def display_message(self, y, msg, loot, colour, font=font_medium): |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
134
diff
changeset
|
409 text = TextBox((50, y, 700, 25), msg, font, colour) |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
134
diff
changeset
|
410 y += text.rect.height + 5 |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
134
diff
changeset
|
411 self.add_child(text) |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
134
diff
changeset
|
412 for kind, value in loot.items(): |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
134
diff
changeset
|
413 y += self.display_loot_item(y, kind, value) |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
134
diff
changeset
|
414 return y + 5 |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
134
diff
changeset
|
415 |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
134
diff
changeset
|
416 def display_loot_item(self, y, kind, value): |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
134
diff
changeset
|
417 if hasattr(value, 'NAME'): |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
134
diff
changeset
|
418 value = value.NAME |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
134
diff
changeset
|
419 msg = "* %s: %s" % (kind, value) |
139 | 420 text = TextBox((80, y, 670, 25), msg, font_medium, (255, 255, 60)) |
138
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
134
diff
changeset
|
421 self.add_child(text) |
14917385a0fd
Better handling of mission results and turn-end messages.
Jeremy Thurgood <firxen@gmail.com>
parents:
134
diff
changeset
|
422 return text.rect.height + 5 |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
423 |
98 | 424 def _make_win_screen(self, turn, msg): |
425 # Clear existing widgets, and turn this into a won screen | |
426 for child in self.children[:]: | |
427 self.remove_child(child) | |
428 exitbut = ExitGameButton() | |
429 self.add_child(exitbut) | |
430 title = TextLabel((200, 20, 400, 50), "Results for turn %d" % turn, | |
431 font_medium, (255, 255, 255)) | |
432 self.add_child(title) | |
120
a79bba0dfcd8
Use TextBoxes for some stuff
Neil Muller <drnlmuller@gmail.com>
parents:
109
diff
changeset
|
433 won = TextBox((200, 200, 400, 50), "You've succeeded in your quest", |
98 | 434 font_large, (255, 255, 255)) |
435 self.add_child(won) | |
120
a79bba0dfcd8
Use TextBoxes for some stuff
Neil Muller <drnlmuller@gmail.com>
parents:
109
diff
changeset
|
436 won = TextBox((200, 250, 400, 50), msg, font_large, |
98 | 437 (255, 255, 255)) |
438 self.add_child(won) | |
439 | |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
440 |
106
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
441 class GameStateWindow(Window): |
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
442 """Base class for windows that show a lot of game state info""" |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
443 |
106
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
444 def __init__(self, screen, game): |
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
445 super(GameStateWindow, self).__init__(screen) |
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
446 self.game = game |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
447 self.screen = screen |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
448 exitbut = ExitGameButton() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
449 self.add_child(exitbut) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
450 end_turn = EndTurnButton(self) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
451 self.add_child(end_turn) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
452 reset = ResetButton(self) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
453 self.add_child(reset) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
454 |
169
a6ca82fa9c4c
Rename several UI elements
Neil Muller <drnlmuller@gmail.com>
parents:
168
diff
changeset
|
455 self.points = ValueLabel((10, 75), 'Blue-Sky Research Projects') |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
456 self.add_child(self.points) |
161
6fdc985429a7
Display research advice.
Jeremy Thurgood <firxen@gmail.com>
parents:
156
diff
changeset
|
457 self.minions = ValueLabel((310, 75), 'Minions available') |
124
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
458 self.add_child(self.minions) |
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
459 self.money = ValueLabel((510, 75), 'Money') |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
460 self.add_child(self.money) |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
461 |
97
069a2d34b8b5
I shall pretend I did not touch the GUI, even though I added a myriad copies of some extra widgets.
Jeremy Thurgood <firxen@gmail.com>
parents:
93
diff
changeset
|
462 self.milestone = ValueLabel((10, 95), 'Currently taken over') |
069a2d34b8b5
I shall pretend I did not touch the GUI, even though I added a myriad copies of some extra widgets.
Jeremy Thurgood <firxen@gmail.com>
parents:
93
diff
changeset
|
463 self.add_child(self.milestone) |
069a2d34b8b5
I shall pretend I did not touch the GUI, even though I added a myriad copies of some extra widgets.
Jeremy Thurgood <firxen@gmail.com>
parents:
93
diff
changeset
|
464 self.reputation = ValueLabel((310, 95), 'Reputation') |
069a2d34b8b5
I shall pretend I did not touch the GUI, even though I added a myriad copies of some extra widgets.
Jeremy Thurgood <firxen@gmail.com>
parents:
93
diff
changeset
|
465 self.add_child(self.reputation) |
069a2d34b8b5
I shall pretend I did not touch the GUI, even though I added a myriad copies of some extra widgets.
Jeremy Thurgood <firxen@gmail.com>
parents:
93
diff
changeset
|
466 |
161
6fdc985429a7
Display research advice.
Jeremy Thurgood <firxen@gmail.com>
parents:
156
diff
changeset
|
467 self.advice = ValueLabel((10, 115), 'Research advice', width=780) |
6fdc985429a7
Display research advice.
Jeremy Thurgood <firxen@gmail.com>
parents:
156
diff
changeset
|
468 self.add_child(self.advice) |
6fdc985429a7
Display research advice.
Jeremy Thurgood <firxen@gmail.com>
parents:
156
diff
changeset
|
469 |
106
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
470 def update_labels(self): |
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
471 self.points.set_value(self.game.get_available_points()) |
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
472 self.money.set_value(self.game.money) |
124
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
473 self.minions.set_value(self.game.minions) |
106
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
474 self.milestone.set_value(self.game.milestone) |
109
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
475 self.reputation.set_value(_lookup_reputation(self.game.reputation)) |
161
6fdc985429a7
Display research advice.
Jeremy Thurgood <firxen@gmail.com>
parents:
156
diff
changeset
|
476 self.advice.set_value(self.game.advice) |
106
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
477 |
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
478 |
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
479 class ActivityWindow(GameStateWindow): |
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
480 |
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
481 def __init__(self, screen, lab, develop): |
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
482 super(ActivityWindow, self).__init__(screen, lab.game) |
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
483 self.lab = lab |
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
484 self.develop = develop |
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
485 |
169
a6ca82fa9c4c
Rename several UI elements
Neil Muller <drnlmuller@gmail.com>
parents:
168
diff
changeset
|
486 labbut = SwitchWinButton((150, 10), 'SCIENCE!!', lab) |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
487 self.add_child(labbut) |
169
a6ca82fa9c4c
Rename several UI elements
Neil Muller <drnlmuller@gmail.com>
parents:
168
diff
changeset
|
488 devbut = SwitchWinButton((300, 10), 'Engineering', develop) |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
489 self.add_child(devbut) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
490 |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
491 self.update_labels() |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
492 self._missions = [] |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
493 self._make_widgets() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
494 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
495 def _make_widgets(self): |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
496 for widget in self._missions: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
497 self.remove_child(widget) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
498 self._missions = [] |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
499 x = 0 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
500 y = 150 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
501 for mission in self.game.get_available_missions(): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
502 widget = MissionWidget(mission, (x, y), self) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
503 self._missions.append(widget) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
504 self.add_child(widget) |
187 | 505 x += widget.WIDTH + 10 |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
506 if x >= WIDTH: |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
507 x = 0 |
186 | 508 y += 65 |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
509 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
510 def end_turn(self): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
511 # Drop back to the research screen |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
512 PopWindow.post() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
513 self.lab.update() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
514 AddWindow.post(self.lab) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
515 self.lab.end_turn() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
516 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
517 def update_widgets(self): |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
518 self._make_widgets() |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
519 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
520 def update(self): |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
521 self.update_labels() |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
522 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
523 def do_reset(self): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
524 self.lab.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
525 self.develop.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
526 self.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
527 |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
528 def get_mission_list(self): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
529 selected_missions = [] |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
530 for widget in self._missions: |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
531 if widget.selected(): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
532 equipment = widget.get_equipment() |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
533 mission = widget.mission |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
534 selected_missions.append((mission, equipment)) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
535 return selected_missions |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
536 |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
537 def reset(self): |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
538 for widget in self._missions: |
168
be346a080548
Fix bug in resetting activity window
Neil Muller <drnlmuller@gmail.com>
parents:
161
diff
changeset
|
539 widget.unselect() |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
540 widget.reset() |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
541 self.update_labels() |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
542 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
543 |
106
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
544 class DevelopmentWindow(GameStateWindow): |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
545 """Window for handling schematics research""" |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
546 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
547 def __init__(self, screen, lab): |
106
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
548 super(DevelopmentWindow, self).__init__(screen, lab.game) |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
549 self.lab = lab |
97
069a2d34b8b5
I shall pretend I did not touch the GUI, even though I added a myriad copies of some extra widgets.
Jeremy Thurgood <firxen@gmail.com>
parents:
93
diff
changeset
|
550 |
169
a6ca82fa9c4c
Rename several UI elements
Neil Muller <drnlmuller@gmail.com>
parents:
168
diff
changeset
|
551 labbut = SwitchWinButton((150, 10), 'SCIENCE!!', lab) |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
552 self.add_child(labbut) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
553 self.activity = None |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
554 |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
555 self.update_labels() |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
556 self._sciences = [] |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
557 self._make_science_widgets() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
558 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
559 def set_activity_window(self, activity): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
560 # Oh, what tangled webs we weave |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
561 if not self.activity: |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
562 self.activity = activity |
169
a6ca82fa9c4c
Rename several UI elements
Neil Muller <drnlmuller@gmail.com>
parents:
168
diff
changeset
|
563 actbut = SwitchWinButton((300, 10), 'Schemes', activity) |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
564 self.add_child(actbut) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
565 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
566 def _make_science_widgets(self): |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
567 for widget in self._sciences: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
568 self.remove_child(widget) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
569 self._sciences = [] |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
570 x = 0 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
571 y = 150 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
572 for science in self.game.lab.science: |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
573 if science.SCIENCE_TYPE == 'schematic': |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
574 widget = ScienceWidget(science, (x, y), self) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
575 self.add_child(widget) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
576 self._sciences.append(widget) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
577 x += 200 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
578 if x >= WIDTH: |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
579 x = 0 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
580 y += 100 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
581 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
582 def end_turn(self): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
583 # Drop back to the research screen |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
584 PopWindow.post() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
585 self.lab.update() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
586 AddWindow.post(self.lab) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
587 self.lab.end_turn() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
588 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
589 def update_widgets(self): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
590 self._make_science_widgets() |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
591 self.update_labels() |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
592 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
593 def update(self): |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
594 self.update_labels() |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
595 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
596 def do_reset(self): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
597 self.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
598 self.lab.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
599 self.activity.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
600 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
601 def reset(self): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
602 for widget in self._sciences: |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
603 widget.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
604 |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
605 def restore_selection(self, old_selection): |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
606 for widget in self._sciences: |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
607 widget.restore_selection(old_selection) |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
608 |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
609 |
106
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
610 class LabWindow(GameStateWindow): |
63
364ff3479ef2
Remove duplicate point tracking. Rename classes for future refactoring
Neil Muller <drnlmuller@gmail.com>
parents:
62
diff
changeset
|
611 """Window for the research lab""" |
53
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
612 |
88 | 613 def __init__(self, screen, game_dict): |
614 self.game = Game(game_dict) | |
106
5977a709f8c8
Refactor out a bunch of common gui code stuff (since Jermery's not touching this)
Neil Muller <drnlmuller@gmail.com>
parents:
98
diff
changeset
|
615 super(LabWindow, self).__init__(screen, self.game) |
88 | 616 self.autosave = get_save_filename() |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
617 |
134
208a79a49c26
Fix a ordering bug triggered when restoring a game
Neil Muller <drnlmuller@gmail.com>
parents:
133
diff
changeset
|
618 # Ensure we setup everything with the correct state set |
208a79a49c26
Fix a ordering bug triggered when restoring a game
Neil Muller <drnlmuller@gmail.com>
parents:
133
diff
changeset
|
619 self.game.start_turn() |
208a79a49c26
Fix a ordering bug triggered when restoring a game
Neil Muller <drnlmuller@gmail.com>
parents:
133
diff
changeset
|
620 |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
621 self.develop = DevelopmentWindow(screen, self) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
622 self.activity = ActivityWindow(screen, self, self.develop) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
623 self.develop.set_activity_window(self.activity) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
624 |
169
a6ca82fa9c4c
Rename several UI elements
Neil Muller <drnlmuller@gmail.com>
parents:
168
diff
changeset
|
625 devbut = SwitchWinButton((150, 10), 'Engineering', self.develop) |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
626 self.add_child(devbut) |
169
a6ca82fa9c4c
Rename several UI elements
Neil Muller <drnlmuller@gmail.com>
parents:
168
diff
changeset
|
627 actbut = SwitchWinButton((300, 10), 'Schemes', self.activity) |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
628 self.add_child(actbut) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
629 |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
630 self._sciences = [] |
65 | 631 # Setup for the first turn |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
632 self.update_labels() |
60 | 633 self._make_science_widgets() |
634 | |
635 def _make_science_widgets(self): | |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
636 # FIXME: Horrible hackery |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
637 for widget in self._sciences: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
638 self.remove_child(widget) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
639 self._sciences = [] |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
640 x = 0 |
57 | 641 y = 150 |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
642 for science in self.game.lab.science: |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
643 if science.SCIENCE_TYPE == 'research': |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
644 widget = ScienceWidget(science, (x, y), self) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
645 self.add_child(widget) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
646 self._sciences.append(widget) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
647 x += 200 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
648 if x >= WIDTH: |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
649 x = 0 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
650 y += 100 |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
651 |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
652 def update_widgets(self): |
60 | 653 self._make_science_widgets() |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
654 |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
655 def restore_selection(self, old_selection): |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
656 for widget in self._sciences: |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
657 widget.restore_selection(old_selection) |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
658 |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
659 def end_turn(self): |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
660 self.game.cur_missions = self.activity.get_mission_list() |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
661 old_allocation = self.game.cur_allocation |
80
a40a76012bd7
Refactor message handling so we can deal with in the gui
Neil Muller <drnlmuller@gmail.com>
parents:
72
diff
changeset
|
662 messages = self.game.end_turn() |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
663 results = ResultsWindow(self.screen, messages, self.game.turn) |
98 | 664 if results.is_game_over: |
665 PopWindow.post() | |
666 GameOver.post(results) | |
667 return | |
107
bdd11db41124
Save at the right place.
Jeremy Thurgood <firxen@gmail.com>
parents:
106
diff
changeset
|
668 self.save_game() |
60 | 669 self.game.start_turn() |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
670 self.update_widgets() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
671 self.develop.update_widgets() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
672 self.activity.update_widgets() |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
673 # restore previous allocation |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
674 self.restore_selection(old_allocation) |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
675 self.develop.restore_selection(old_allocation) |
133
e1142e2289d8
Ensure labels in the correct state
Neil Muller <drnlmuller@gmail.com>
parents:
128
diff
changeset
|
676 self.update_labels() |
e1142e2289d8
Ensure labels in the correct state
Neil Muller <drnlmuller@gmail.com>
parents:
128
diff
changeset
|
677 self.develop.update_labels() |
107
bdd11db41124
Save at the right place.
Jeremy Thurgood <firxen@gmail.com>
parents:
106
diff
changeset
|
678 AddWindow.post(results) |
bdd11db41124
Save at the right place.
Jeremy Thurgood <firxen@gmail.com>
parents:
106
diff
changeset
|
679 |
bdd11db41124
Save at the right place.
Jeremy Thurgood <firxen@gmail.com>
parents:
106
diff
changeset
|
680 def save_game(self): |
88 | 681 game_data = self.game.save_data() |
682 if self.autosave: | |
90
0823e2529c23
Add robustness around the savefile stuff
Neil Muller <drnlmuller@gmail.com>
parents:
88
diff
changeset
|
683 # Don't corrupt the savefile if json crashes |
0823e2529c23
Add robustness around the savefile stuff
Neil Muller <drnlmuller@gmail.com>
parents:
88
diff
changeset
|
684 data = json.dumps(game_data) |
88 | 685 savefile = open(self.autosave, 'w') |
90
0823e2529c23
Add robustness around the savefile stuff
Neil Muller <drnlmuller@gmail.com>
parents:
88
diff
changeset
|
686 savefile.write(data) |
88 | 687 savefile.close() |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
688 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
689 def update(self): |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
690 self.update_labels() |
65 | 691 |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
692 def do_reset(self): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
693 self.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
694 self.develop.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
695 self.activity.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
696 |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
697 def reset(self): |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
698 for widget in self._sciences: |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
699 widget.reset() |