changeset 454:30e6d6097b12

Make selling things sub-toolbar
author Neil Muller <drnlmuller@gmail.com>
date Sun, 22 Nov 2009 17:55:28 +0000
parents 4bce845fbe6c
children fef4b1686d6c
files gamelib/toolbar.py
diffstat 1 files changed, 30 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/toolbar.py	Sat Nov 21 20:32:26 2009 +0000
+++ b/gamelib/toolbar.py	Sun Nov 22 17:55:28 2009 +0000
@@ -252,16 +252,7 @@
 
         self.add_spacer(5)
 
-        self.add_heading("Sell ...")
-        self.add_tool_button("Chicken", constants.TOOL_SELL_CHICKEN,
-                self.gameboard.level.sell_price_chicken, cursors.cursors['sell'])
-        self.add_tool_button("Egg", constants.TOOL_SELL_EGG,
-                self.gameboard.level.sell_price_egg, cursors.cursors['sell'])
-        self.add_tool_button("Building", constants.TOOL_SELL_BUILDING,
-                None, cursors.cursors['sell'])
-        self.add_tool_button("Equipment", constants.TOOL_SELL_EQUIPMENT,
-                None, cursors.cursors['sell'])
-        self.add_spacer(5)
+        self.add_tool('Sell stuff', self.add_sell_toolbar)
 
         self.add_heading(" ")
 
@@ -292,6 +283,10 @@
         self.gameboard.change_toolbar(BuildingToolBar(self.gameboard,
                 width=self.style.width))
 
+    def add_sell_toolbar(self):
+        self.gameboard.change_toolbar(SellToolBar(self.gameboard,
+                width=self.style.width))
+
     def add_equipment_toolbar(self):
         self.gameboard.change_toolbar(EquipmentToolBar(self.gameboard,
                 width=self.style.width))
@@ -340,3 +335,28 @@
         self.gameboard.change_toolbar(DefaultToolBar(self.gameboard,
                 width=self.style.width))
 
+class SellToolBar(BaseToolBar):
+    def __init__(self, gameboard, **params):
+        BaseToolBar.__init__(self, gameboard, **params)
+        self.group = gui.Group(name='building_toolbar', value=None)
+        self.make_toolbar()
+
+    def make_toolbar(self):
+        self.gameboard.set_cursor(cursors.cursors['arrow'], None)
+
+        self.add_heading("Sell ...")
+        self.add_tool_button("Chicken", constants.TOOL_SELL_CHICKEN,
+                self.gameboard.level.sell_price_chicken, cursors.cursors['sell'])
+        self.add_tool_button("Egg", constants.TOOL_SELL_EGG,
+                self.gameboard.level.sell_price_egg, cursors.cursors['sell'])
+        self.add_tool_button("Building", constants.TOOL_SELL_BUILDING,
+                None, cursors.cursors['sell'])
+        self.add_tool_button("Equipment", constants.TOOL_SELL_EQUIPMENT,
+                None, cursors.cursors['sell'])
+        self.add_spacer(15)
+        self.add_tool('Done', self.add_default_toolbar)
+
+    def add_default_toolbar(self):
+        self.gameboard.change_toolbar(DefaultToolBar(self.gameboard,
+                width=self.style.width))
+