Mercurial > sypikslang
annotate gamelib/gamegui.py @ 135:8d1cf98e39b5
Reputation decays over time
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Thu, 10 May 2012 17:07:06 +0200 |
parents | 208a79a49c26 |
children | 14917385a0fd |
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) |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
18 from gamelib.gui import BigButton, ImageDrawable |
98 | 19 from gamelib.engine import PopWindow, AddWindow, GameOver |
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
|
20 from gamelib.constants import (WIDTH, HEIGHT, FAILURE, SUCCESS, NEW_SCIENCE, |
98 | 21 NEW_SCHEMATIC, GAME_WIN) |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
22 from gamelib.gamestate import Game |
53
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
23 |
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
24 |
109
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
25 def _lookup_reputation(rep): |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
26 """Turn reputation in a nice string""" |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
27 |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
28 if rep < 0: |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
29 return 'Mindless Thug' |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
30 if rep < 10: |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
31 return 'Fringe Lunatic' |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
32 if rep < 100: |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
33 return 'Mad Scientist' |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
34 return 'Major Threat to World Peace' |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
35 |
5bb711cdc569
Display strings for reputation (needs more levels)
Neil Muller <drnlmuller@gmail.com>
parents:
107
diff
changeset
|
36 |
122
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
37 class PopWindowButton(BigButton): |
53
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
38 |
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
|
39 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
|
40 super(PopWindowButton, self).__init__(pos, text) |
53
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
41 |
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
42 def on_click(self): |
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
43 PopWindow.post() |
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
44 |
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
45 |
122
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
46 class ExitGameButton(PopWindowButton): |
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
47 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
|
48 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
|
49 'Exit') |
122
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
50 |
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
51 |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
52 class EndTurnButton(BigButton): |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
53 |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
54 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
|
55 super(EndTurnButton, self).__init__(((WIDTH - 128), 10), 'End Turn') |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
56 self.parent = parent |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
57 |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
58 def on_click(self): |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
59 self.parent.end_turn() |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
60 |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
61 |
122
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
62 class NextTurnButton(PopWindowButton): |
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
63 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
|
64 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
|
65 |
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
66 |
127
591a85a4edac
Use 'done' rather than exit in equipment selection screen
Neil Muller <drnlmuller@gmail.com>
parents:
126
diff
changeset
|
67 class DoneButton(PopWindowButton): |
591a85a4edac
Use 'done' rather than exit in equipment selection screen
Neil Muller <drnlmuller@gmail.com>
parents:
126
diff
changeset
|
68 def __init__(self): |
591a85a4edac
Use 'done' rather than exit in equipment selection screen
Neil Muller <drnlmuller@gmail.com>
parents:
126
diff
changeset
|
69 super(DoneButton, self).__init__(((WIDTH - 128), 10), 'Done') |
591a85a4edac
Use 'done' rather than exit in equipment selection screen
Neil Muller <drnlmuller@gmail.com>
parents:
126
diff
changeset
|
70 |
591a85a4edac
Use 'done' rather than exit in equipment selection screen
Neil Muller <drnlmuller@gmail.com>
parents:
126
diff
changeset
|
71 |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
72 class ResetButton(BigButton): |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
73 |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
74 def __init__(self, parent): |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
75 super(ResetButton, self).__init__((10, 10), 'Reset points') |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
76 self.parent = parent |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
77 |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
78 def on_click(self): |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
79 self.parent.do_reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
80 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
81 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
82 class SwitchWinButton(BigButton): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
83 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
84 def __init__(self, pos, text, new_window): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
85 super(SwitchWinButton, self).__init__(pos, text) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
86 self.new_window = new_window |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
87 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
88 def on_click(self): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
89 PopWindow.post() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
90 # Refresh state |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
91 self.new_window.update() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
92 AddWindow.post(self.new_window) |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
93 |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
94 |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
95 class ScienceWidget(BigButton): |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
96 |
57 | 97 WIDTH = 200 |
98 | |
99 BG_IMAGE_NORMAL = image.load(filepath('images/science_normal.png')) | |
100 BG_IMAGE_DOWN = image.load(filepath('images/science_down.png')) | |
101 | |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
102 def __init__(self, science, pos, parent): |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
103 self.science = science |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
104 self.points = 0 |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
105 self.parent = parent |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
106 super(ScienceWidget, self).__init__(pos, '%s: %d' % (science.NAME, |
62
38f41d046c6f
Make button font a parameter. Tweak indication of points to be spent
Neil Muller <drnlmuller@gmail.com>
parents:
60
diff
changeset
|
107 science.points), font_small) |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
108 |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
109 def on_click(self): |
63
364ff3479ef2
Remove duplicate point tracking. Rename classes for future refactoring
Neil Muller <drnlmuller@gmail.com>
parents:
62
diff
changeset
|
110 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
|
111 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
|
112 self.points += 1 |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
113 self.parent.game.cur_allocation.append(self.science) |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
114 self.parent.update_labels() |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
115 self.set_text() |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
116 |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
117 def set_text(self): |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
118 if self.points > 0: |
62
38f41d046c6f
Make button font a parameter. Tweak indication of points to be spent
Neil Muller <drnlmuller@gmail.com>
parents:
60
diff
changeset
|
119 self.text = '%s: %d + %d' % (self.science.NAME, |
38f41d046c6f
Make button font a parameter. Tweak indication of points to be spent
Neil Muller <drnlmuller@gmail.com>
parents:
60
diff
changeset
|
120 self.science.points, self.points) |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
121 else: |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
122 self.text = '%s: %d' % (self.science.NAME, self.science.points) |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
123 self._draw_text() |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
124 |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
125 def reset(self): |
63
364ff3479ef2
Remove duplicate point tracking. Rename classes for future refactoring
Neil Muller <drnlmuller@gmail.com>
parents:
62
diff
changeset
|
126 while self.points > 0: |
364ff3479ef2
Remove duplicate point tracking. Rename classes for future refactoring
Neil Muller <drnlmuller@gmail.com>
parents:
62
diff
changeset
|
127 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
|
128 self.points -= 1 |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
129 self.set_text() |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
130 self.parent.update_labels() |
65 | 131 |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
132 def restore_selection(self, old_selection): |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
133 points = old_selection.count(self.science) |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
134 # 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
|
135 # boosts, etc.) or we cannot currently develop further |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
136 if (points != self.points and |
128
6a847f22a312
Don't restore selections if they're illegal
Neil Muller <drnlmuller@gmail.com>
parents:
127
diff
changeset
|
137 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
|
138 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
|
139 self.points + points)): |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
140 self.points = points |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
141 self.parent.game.cur_allocation.extend([self.science] * points) |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
142 self.parent.update_labels() |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
143 self.set_text() |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
144 |
65 | 145 |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
146 class MissionWidget(BigButton): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
147 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
148 WIDTH = 200 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
149 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
150 BG_IMAGE_NORMAL = image.load(filepath('images/science_normal.png')) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
151 BG_IMAGE_DOWN = image.load(filepath('images/science_down.png')) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
152 BG_IMAGE_SELECTED = image.load(filepath('images/mission_selected.png')) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
153 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
154 def __init__(self, mission, pos, parent): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
155 self.mission = mission |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
156 self.parent = parent |
124
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
157 self.game = self.parent.game |
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
158 self.minions = 0 |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
159 super(MissionWidget, self).__init__(pos, '%s' % mission.NAME, |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
160 font_small) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
161 selected = ImageDrawable((0, 0, self.WIDTH, self.HEIGHT), |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
162 self.BG_IMAGE_SELECTED) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
163 self.add_state('SELECTED', selected) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
164 self.mode = 'NORMAL' |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
165 self.equipment = [] |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
166 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
167 def on_mouse_cancel(self, pos): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
168 self.set_state(self.mode) |
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 def on_mouse_up(self, pos): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
171 self.set_state(self.mode) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
172 self.on_click() |
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 on_click(self): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
175 if self.mode == 'SELECTED': |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
176 # unselect mission |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
177 self.reset() |
124
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
178 elif self.mission.can_attempt(self.game): |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
179 # select mission and equipment |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
180 self.mode = 'SELECTED' |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
181 self.set_state('SELECTED') |
124
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
182 self.minions = self.mission.MINIONS_REQUIRED |
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
183 self.game.minions -= self.minions |
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
184 self.parent.update_labels() |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
185 equip = EquipWindow(self.parent.screen, self.mission, |
124
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
186 self.game, self) |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
187 AddWindow.post(equip) |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
188 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
189 def selected(self): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
190 return self.mode == 'SELECTED' |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
191 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
192 def get_equipment(self): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
193 return self.equipment |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
194 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
195 def reset(self): |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
196 for equip in self.equipment: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
197 # Release funds |
124
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
198 self.game.money += equip.COST |
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
199 self.game.minions += self.minions |
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
200 self.minions = 0 |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
201 self.parent.update() |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
202 self.equipment = [] |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
203 self.mode = 'NORMAL' |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
204 self.set_state('NORMAL') |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
205 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
206 |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
207 class EquipWidget(BigButton): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
208 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
209 WIDTH = 200 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
210 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
211 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
|
212 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
|
213 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
|
214 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
215 def __init__(self, equip, pos, parent, copies, available): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
216 self.equip = equip |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
217 self.parent = parent |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
218 self.available = available |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
219 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
|
220 % (equip.NAME, equip.points, equip.COST, copies), font_small) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
221 if not self.available: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
222 unavailable = ImageDrawable((0, 0, self.WIDTH, self.HEIGHT), |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
223 self.BG_IMAGE_UNAVAILABLE) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
224 # Override the default |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
225 self.add_state('NORMAL', unavailable) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
226 self.set_state('NORMAL') |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
227 self.equipment = [] |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
228 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
229 def on_mouse_down(self, pos): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
230 if self.available: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
231 super(EquipWidget, self).on_mouse_down(pos) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
232 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
233 def on_mouse_up(self, pos): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
234 if self.available: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
235 super(EquipWidget, self).on_mouse_up(pos) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
236 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
237 def on_click(self): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
238 self.parent.buy(self.equip) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
239 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
240 |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
241 class ValueLabel(TextLabel): |
65 | 242 |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
243 def __init__(self, pos, description): |
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
244 self.description = description |
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
245 rect = (pos[0], pos[1], 300, 50) |
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
246 super(ValueLabel, self).__init__(rect, |
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
247 '%s : 0' % description, font_medium, (255, 255, 0)) |
65 | 248 |
249 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
|
250 self.text = '%s : %s' % (self.description, value) |
65 | 251 self._draw_text() |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
252 |
60 | 253 |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
254 class EquipWindow(Window): |
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 __init__(self, screen, mission, game, parent): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
257 super(EquipWindow, self).__init__(screen) |
127
591a85a4edac
Use 'done' rather than exit in equipment selection screen
Neil Muller <drnlmuller@gmail.com>
parents:
126
diff
changeset
|
258 donebut = DoneButton() |
591a85a4edac
Use 'done' rather than exit in equipment selection screen
Neil Muller <drnlmuller@gmail.com>
parents:
126
diff
changeset
|
259 self.add_child(donebut) |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
260 reset = ResetButton(self) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
261 self.add_child(reset) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
262 title = TextLabel((200, 20, 400, 50), "Choose equipment for %s" |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
263 % mission.NAME, font_medium, (255, 255, 255)) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
264 self.add_child(title) |
120
a79bba0dfcd8
Use TextBoxes for some stuff
Neil Muller <drnlmuller@gmail.com>
parents:
109
diff
changeset
|
265 description = TextBox((10, 70, 790, 20), mission.LONG_DESCRIPTION, |
93
f0bf77787d1e
Display long ddescription on mission screen
Neil Muller <drnlmuller@gmail.com>
parents:
90
diff
changeset
|
266 font_medium, (255, 255, 255)) |
f0bf77787d1e
Display long ddescription on mission screen
Neil Muller <drnlmuller@gmail.com>
parents:
90
diff
changeset
|
267 self.add_child(description) |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
268 self.parent = parent |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
269 self.game = game |
120
a79bba0dfcd8
Use TextBoxes for some stuff
Neil Muller <drnlmuller@gmail.com>
parents:
109
diff
changeset
|
270 self.money = ValueLabel((10, description.rect.height + 75), 'Money') |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
271 self.money.set_value(self.game.money) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
272 self.add_child(self.money) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
273 self._equip = [] |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
274 self._make_equip_widgets() |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
275 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
276 def _make_equip_widgets(self): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
277 for widget in self._equip: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
278 self.remove_child(widget) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
279 self._equip = [] |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
280 x = 0 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
281 y = 150 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
282 available = self.game.get_available_equipment() |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
283 for equip in self.game.get_all_equipment(): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
284 copies = self.parent.equipment.count(equip) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
285 widget = EquipWidget(equip, (x, y), self, copies, |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
286 equip in available) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
287 self._equip.append(widget) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
288 self.add_child(widget) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
289 x += 200 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
290 if x >= WIDTH: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
291 x = 0 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
292 y += 100 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
293 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
294 def buy(self, equip): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
295 self.game.money -= equip.COST |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
296 self.money.set_value(self.game.money) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
297 self.parent.equipment.append(equip) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
298 self.parent.parent.update() |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
299 self._make_equip_widgets() |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
300 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
301 def do_reset(self): |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
302 for equip in self.parent.equipment: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
303 # Release funds |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
304 self.game.money += equip.COST |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
305 self.money.set_value(self.game.money) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
306 self.parent.equipment = [] |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
307 self.parent.parent.update() |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
308 self._make_equip_widgets() |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
309 |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
310 |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
311 class ResultsWindow(Window): |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
312 |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
313 def __init__(self, screen, messages, turn): |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
314 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
|
315 nextbut = NextTurnButton() |
acf3af761bbc
Rename 'Exit' button on results view to 'Next Turn' for clarity.
Simon Cross <hodgestar@gmail.com>
parents:
120
diff
changeset
|
316 self.add_child(nextbut) |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
317 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
|
318 font_medium, (255, 255, 255)) |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
319 self.add_child(title) |
98 | 320 self.is_game_over = False |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
321 if not messages: |
120
a79bba0dfcd8
Use TextBoxes for some stuff
Neil Muller <drnlmuller@gmail.com>
parents:
109
diff
changeset
|
322 results = TextBox((200, 200, 400, 50), |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
323 "Nothing of interest happened", font_medium, |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
324 (255, 255, 255)) |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
325 self.add_child(results) |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
326 else: |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
327 y = 200 |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
328 for msg_type, msg in messages: |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
329 # FIXME: Better widgets |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
330 if msg_type in [NEW_SCHEMATIC, NEW_SCIENCE]: |
120
a79bba0dfcd8
Use TextBoxes for some stuff
Neil Muller <drnlmuller@gmail.com>
parents:
109
diff
changeset
|
331 text = TextBox((50, y, 750, 25), |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
332 msg, font_medium, (60, 60, 255)) |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
333 elif msg_type == FAILURE: |
120
a79bba0dfcd8
Use TextBoxes for some stuff
Neil Muller <drnlmuller@gmail.com>
parents:
109
diff
changeset
|
334 text = TextBox((50, y, 750, 25), |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
335 msg, font_medium, (255, 60, 60)) |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
336 elif msg_type == SUCCESS: |
120
a79bba0dfcd8
Use TextBoxes for some stuff
Neil Muller <drnlmuller@gmail.com>
parents:
109
diff
changeset
|
337 text = TextBox((50, y, 750, 25), |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
338 msg, font_medium, (60, 255, 60)) |
98 | 339 elif msg_type == GAME_WIN: |
340 self._make_win_screen(turn, msg) | |
341 self.is_game_over = True | |
342 break | |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
343 else: |
120
a79bba0dfcd8
Use TextBoxes for some stuff
Neil Muller <drnlmuller@gmail.com>
parents:
109
diff
changeset
|
344 text = TextBox((50, y, 750, 25), |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
345 msg, font_medium, (255, 255, 0)) |
120
a79bba0dfcd8
Use TextBoxes for some stuff
Neil Muller <drnlmuller@gmail.com>
parents:
109
diff
changeset
|
346 y += text.rect.height + 10 |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
347 self.add_child(text) |
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
348 |
98 | 349 def _make_win_screen(self, turn, msg): |
350 # Clear existing widgets, and turn this into a won screen | |
351 for child in self.children[:]: | |
352 self.remove_child(child) | |
353 exitbut = ExitGameButton() | |
354 self.add_child(exitbut) | |
355 title = TextLabel((200, 20, 400, 50), "Results for turn %d" % turn, | |
356 font_medium, (255, 255, 255)) | |
357 self.add_child(title) | |
120
a79bba0dfcd8
Use TextBoxes for some stuff
Neil Muller <drnlmuller@gmail.com>
parents:
109
diff
changeset
|
358 won = TextBox((200, 200, 400, 50), "You've succeeded in your quest", |
98 | 359 font_large, (255, 255, 255)) |
360 self.add_child(won) | |
120
a79bba0dfcd8
Use TextBoxes for some stuff
Neil Muller <drnlmuller@gmail.com>
parents:
109
diff
changeset
|
361 won = TextBox((200, 250, 400, 50), msg, font_large, |
98 | 362 (255, 255, 255)) |
363 self.add_child(won) | |
364 | |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
365 |
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
|
366 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
|
367 """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
|
368 |
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
|
369 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
|
370 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
|
371 self.game = game |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
372 self.screen = screen |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
373 exitbut = ExitGameButton() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
374 self.add_child(exitbut) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
375 end_turn = EndTurnButton(self) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
376 self.add_child(end_turn) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
377 reset = ResetButton(self) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
378 self.add_child(reset) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
379 |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
380 self.points = ValueLabel((10, 75), 'Available Human Resources') |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
381 self.add_child(self.points) |
124
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
382 self.minions = ValueLabel((310, 75), 'Minions available: ') |
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
383 self.add_child(self.minions) |
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
384 self.money = ValueLabel((510, 75), 'Money') |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
385 self.add_child(self.money) |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
386 |
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
|
387 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
|
388 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
|
389 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
|
390 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
|
391 |
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
|
392 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
|
393 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
|
394 self.money.set_value(self.game.money) |
124
685301e35f88
Add a minion cost to missions
Neil Muller <drnlmuller@gmail.com>
parents:
122
diff
changeset
|
395 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
|
396 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
|
397 self.reputation.set_value(_lookup_reputation(self.game.reputation)) |
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
|
398 |
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
|
399 |
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
|
400 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
|
401 |
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
|
402 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
|
403 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
|
404 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
|
405 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
|
406 |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
407 labbut = SwitchWinButton((150, 10), 'Research', lab) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
408 self.add_child(labbut) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
409 devbut = SwitchWinButton((300, 10), 'Development', develop) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
410 self.add_child(devbut) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
411 |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
412 self.update_labels() |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
413 self._missions = [] |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
414 self._make_widgets() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
415 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
416 def _make_widgets(self): |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
417 for widget in self._missions: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
418 self.remove_child(widget) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
419 self._missions = [] |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
420 x = 0 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
421 y = 150 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
422 for mission in self.game.get_available_missions(): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
423 widget = MissionWidget(mission, (x, y), self) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
424 self._missions.append(widget) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
425 self.add_child(widget) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
426 x += 200 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
427 if x >= WIDTH: |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
428 x = 0 |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
429 y += 100 |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
430 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
431 def end_turn(self): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
432 # Drop back to the research screen |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
433 PopWindow.post() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
434 self.lab.update() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
435 AddWindow.post(self.lab) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
436 self.lab.end_turn() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
437 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
438 def update_widgets(self): |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
439 self._make_widgets() |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
440 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
441 def update(self): |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
442 self.update_labels() |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
443 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
444 def do_reset(self): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
445 self.lab.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
446 self.develop.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
447 self.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
448 |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
449 def get_mission_list(self): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
450 selected_missions = [] |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
451 for widget in self._missions: |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
452 if widget.selected(): |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
453 equipment = widget.get_equipment() |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
454 mission = widget.mission |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
455 selected_missions.append((mission, equipment)) |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
456 return selected_missions |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
457 |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
458 def reset(self): |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
459 for widget in self._missions: |
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
460 widget.reset() |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
461 self.update_labels() |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
462 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
463 |
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
|
464 class DevelopmentWindow(GameStateWindow): |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
465 """Window for handling schematics research""" |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
466 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
467 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
|
468 super(DevelopmentWindow, self).__init__(screen, lab.game) |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
469 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
|
470 |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
471 labbut = SwitchWinButton((150, 10), 'Research', lab) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
472 self.add_child(labbut) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
473 self.activity = None |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
474 |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
475 self.update_labels() |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
476 self._sciences = [] |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
477 self._make_science_widgets() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
478 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
479 def set_activity_window(self, activity): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
480 # Oh, what tangled webs we weave |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
481 if not self.activity: |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
482 self.activity = activity |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
483 actbut = SwitchWinButton((300, 10), 'Activities', activity) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
484 self.add_child(actbut) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
485 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
486 def _make_science_widgets(self): |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
487 for widget in self._sciences: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
488 self.remove_child(widget) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
489 self._sciences = [] |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
490 x = 0 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
491 y = 150 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
492 for science in self.game.lab.science: |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
493 if science.SCIENCE_TYPE == 'schematic': |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
494 widget = ScienceWidget(science, (x, y), self) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
495 self.add_child(widget) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
496 self._sciences.append(widget) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
497 x += 200 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
498 if x >= WIDTH: |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
499 x = 0 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
500 y += 100 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
501 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
502 def end_turn(self): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
503 # Drop back to the research screen |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
504 PopWindow.post() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
505 self.lab.update() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
506 AddWindow.post(self.lab) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
507 self.lab.end_turn() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
508 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
509 def update_widgets(self): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
510 self._make_science_widgets() |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
511 self.update_labels() |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
512 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
513 def update(self): |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
514 self.update_labels() |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
515 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
516 def do_reset(self): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
517 self.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
518 self.lab.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
519 self.activity.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
520 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
521 def reset(self): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
522 for widget in self._sciences: |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
523 widget.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
524 |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
525 def restore_selection(self, old_selection): |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
526 for widget in self._sciences: |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
527 widget.restore_selection(old_selection) |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
528 |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
529 |
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
|
530 class LabWindow(GameStateWindow): |
63
364ff3479ef2
Remove duplicate point tracking. Rename classes for future refactoring
Neil Muller <drnlmuller@gmail.com>
parents:
62
diff
changeset
|
531 """Window for the research lab""" |
53
655a6912e0ae
Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
532 |
88 | 533 def __init__(self, screen, game_dict): |
534 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
|
535 super(LabWindow, self).__init__(screen, self.game) |
88 | 536 self.autosave = get_save_filename() |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
537 |
134
208a79a49c26
Fix a ordering bug triggered when restoring a game
Neil Muller <drnlmuller@gmail.com>
parents:
133
diff
changeset
|
538 # 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
|
539 self.game.start_turn() |
208a79a49c26
Fix a ordering bug triggered when restoring a game
Neil Muller <drnlmuller@gmail.com>
parents:
133
diff
changeset
|
540 |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
541 self.develop = DevelopmentWindow(screen, self) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
542 self.activity = ActivityWindow(screen, self, self.develop) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
543 self.develop.set_activity_window(self.activity) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
544 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
545 devbut = SwitchWinButton((150, 10), 'Development', self.develop) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
546 self.add_child(devbut) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
547 actbut = SwitchWinButton((300, 10), 'Activities', self.activity) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
548 self.add_child(actbut) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
549 |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
550 self._sciences = [] |
65 | 551 # Setup for the first turn |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
552 self.update_labels() |
60 | 553 self._make_science_widgets() |
554 | |
555 def _make_science_widgets(self): | |
82
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
556 # FIXME: Horrible hackery |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
557 for widget in self._sciences: |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
558 self.remove_child(widget) |
b0d97d51df51
Hook up simplistic equipment screen
Neil Muller <drnlmuller@gmail.com>
parents:
81
diff
changeset
|
559 self._sciences = [] |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
560 x = 0 |
57 | 561 y = 150 |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
562 for science in self.game.lab.science: |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
563 if science.SCIENCE_TYPE == 'research': |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
564 widget = ScienceWidget(science, (x, y), self) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
565 self.add_child(widget) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
566 self._sciences.append(widget) |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
567 x += 200 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
568 if x >= WIDTH: |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
569 x = 0 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
570 y += 100 |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
571 |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
572 def update_widgets(self): |
60 | 573 self._make_science_widgets() |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
574 |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
575 def restore_selection(self, old_selection): |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
576 for widget in self._sciences: |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
577 widget.restore_selection(old_selection) |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
578 |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
579 def end_turn(self): |
72
8b06b07a1477
Very basic mission support
Neil Muller <drnlmuller@gmail.com>
parents:
67
diff
changeset
|
580 self.game.cur_missions = self.activity.get_mission_list() |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
581 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
|
582 messages = self.game.end_turn() |
81
59afe9f92383
Hook up basic results screen
Neil Muller <drnlmuller@gmail.com>
parents:
80
diff
changeset
|
583 results = ResultsWindow(self.screen, messages, self.game.turn) |
98 | 584 if results.is_game_over: |
585 PopWindow.post() | |
586 GameOver.post(results) | |
587 return | |
107
bdd11db41124
Save at the right place.
Jeremy Thurgood <firxen@gmail.com>
parents:
106
diff
changeset
|
588 self.save_game() |
60 | 589 self.game.start_turn() |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
590 self.update_widgets() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
591 self.develop.update_widgets() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
592 self.activity.update_widgets() |
126
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
593 # restore previous allocation |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
594 self.restore_selection(old_allocation) |
0f205b1384db
Make science allocation sticky
Neil Muller <drnlmuller@gmail.com>
parents:
125
diff
changeset
|
595 self.develop.restore_selection(old_allocation) |
133
e1142e2289d8
Ensure labels in the correct state
Neil Muller <drnlmuller@gmail.com>
parents:
128
diff
changeset
|
596 self.update_labels() |
e1142e2289d8
Ensure labels in the correct state
Neil Muller <drnlmuller@gmail.com>
parents:
128
diff
changeset
|
597 self.develop.update_labels() |
107
bdd11db41124
Save at the right place.
Jeremy Thurgood <firxen@gmail.com>
parents:
106
diff
changeset
|
598 AddWindow.post(results) |
bdd11db41124
Save at the right place.
Jeremy Thurgood <firxen@gmail.com>
parents:
106
diff
changeset
|
599 |
bdd11db41124
Save at the right place.
Jeremy Thurgood <firxen@gmail.com>
parents:
106
diff
changeset
|
600 def save_game(self): |
88 | 601 game_data = self.game.save_data() |
602 if self.autosave: | |
90
0823e2529c23
Add robustness around the savefile stuff
Neil Muller <drnlmuller@gmail.com>
parents:
88
diff
changeset
|
603 # Don't corrupt the savefile if json crashes |
0823e2529c23
Add robustness around the savefile stuff
Neil Muller <drnlmuller@gmail.com>
parents:
88
diff
changeset
|
604 data = json.dumps(game_data) |
88 | 605 savefile = open(self.autosave, 'w') |
90
0823e2529c23
Add robustness around the savefile stuff
Neil Muller <drnlmuller@gmail.com>
parents:
88
diff
changeset
|
606 savefile.write(data) |
88 | 607 savefile.close() |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
608 |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
609 def update(self): |
67
06c8539df478
Tweak label handling. Show money as well
Neil Muller <drnlmuller@gmail.com>
parents:
66
diff
changeset
|
610 self.update_labels() |
65 | 611 |
66
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
612 def do_reset(self): |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
613 self.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
614 self.develop.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
615 self.activity.reset() |
43b34b013462
Add development and activity screens
Neil Muller <drnlmuller@gmail.com>
parents:
65
diff
changeset
|
616 |
56
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
617 def reset(self): |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
618 for widget in self._sciences: |
78dfd429b9a6
Start adding science buttons
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
619 widget.reset() |