comparison gamelib/gameboard.py @ 154:3afdefacb07f

Neaten up toolbar.
author Simon Cross <hodgestar@gmail.com>
date Thu, 03 Sep 2009 21:09:49 +0000
parents 065f43e19e09
children baf857805867
comparison
equal deleted inserted replaced
153:065f43e19e09 154:3afdefacb07f
46 self.add_counter(mklabel("Day:"), self.day_counter) 46 self.add_counter(mklabel("Day:"), self.day_counter)
47 self.add_counter(mklabel("Groats:"), self.cash_counter) 47 self.add_counter(mklabel("Groats:"), self.cash_counter)
48 self.add_counter(mklabel("Eggs:"), self.egg_counter) 48 self.add_counter(mklabel("Eggs:"), self.egg_counter)
49 self.add_counter(icons.CHKN_ICON, self.chicken_counter) 49 self.add_counter(icons.CHKN_ICON, self.chicken_counter)
50 self.add_counter(icons.KILLED_FOX, self.killed_foxes) 50 self.add_counter(icons.KILLED_FOX, self.killed_foxes)
51 self.add_spacer() 51 self.add_spacer(20)
52 52
53 self.add_tool_button("Move Animals", constants.TOOL_PLACE_ANIMALS) 53 self.add_tool_button("Move Hen", constants.TOOL_PLACE_ANIMALS)
54 self.add_tool_button("Sell chicken", constants.TOOL_SELL_CHICKEN) 54 self.add_tool_button("Cut Trees", constants.TOOL_LOGGING)
55 self.add_tool_button("Sell egg", constants.TOOL_SELL_EGG) 55 self.add_spacer(20)
56 self.add_tool_button("Sell building", constants.TOOL_SELL_BUILDING) 56
57 self.add_tool_button("Lumberjack", constants.TOOL_LOGGING) 57 self.add_heading("Sell ...")
58 self.add_tool_button("Buy fence", constants.TOOL_BUY_FENCE) 58 self.add_tool_button("Chicken", constants.TOOL_SELL_CHICKEN)
59 self.add_tool_button("Egg", constants.TOOL_SELL_EGG)
60 self.add_tool_button("Building", constants.TOOL_SELL_BUILDING)
61 self.add_spacer(20)
62
63 self.add_heading("Buy ...")
64 self.add_tool_button("Fence", constants.TOOL_BUY_FENCE)
59 for building_cls in buildings.BUILDINGS: 65 for building_cls in buildings.BUILDINGS:
60 self.add_tool_button("Buy %s" % (building_cls.NAME,), building_cls) 66 self.add_tool_button(building_cls.NAME.title(), building_cls)
61 for equipment_cls in equipment.EQUIPMENT: 67 for equipment_cls in equipment.EQUIPMENT:
62 self.add_tool_button("Buy %s" % (equipment_cls.NAME,), equipment_cls) 68 self.add_tool_button(equipment_cls.NAME.title(), equipment_cls)
63 self.add_spacer() 69 self.add_spacer()
64 70
65 self.add_button("Finished Day", self.day_done) 71 self.add_button("Finished Day", self.day_done)
66 72
67 def day_done(self): 73 def day_done(self):
76 82
77 def add_spacer(self, height=30): 83 def add_spacer(self, height=30):
78 self.tr() 84 self.tr()
79 self.td(gui.Spacer(0, height), colspan=2) 85 self.td(gui.Spacer(0, height), colspan=2)
80 86
87 def add_heading(self, text):
88 self.tr()
89 self.td(mklabel(text), colspan=2)
90
81 def add_tool_button(self, text, tool): 91 def add_tool_button(self, text, tool):
82 self.add_button(text, lambda: self.gameboard.set_selected_tool(tool)) 92 self.add_button(text, lambda: self.gameboard.set_selected_tool(tool))
83 93
84 def add_button(self, text, func): 94 def add_button(self, text, func):
85 button = gui.Button(text, width=self.rect.w) 95 button = gui.Button(text, width=self.rect.w, style={"padding_left": 0})
86 button.connect(gui.CLICK, func) 96 button.connect(gui.CLICK, func)
87 self.tr() 97 self.tr()
88 self.td(button, align=-1, colspan=2) 98 self.td(button, align=-1, colspan=2)
89 99
90 def add_counter(self, icon, label): 100 def add_counter(self, icon, label):