diff gamelib/gameboard.py @ 447:f04a2490c35f

The sub-toolbar rewrite, the finally not crashing version
author Neil Muller <drnlmuller@gmail.com>
date Sat, 21 Nov 2009 19:58:49 +0000
parents feb9b7a23ef2
children 938498b8cd03
line wrap: on
line diff
--- a/gamelib/gameboard.py	Sat Nov 21 19:33:12 2009 +0000
+++ b/gamelib/gameboard.py	Sat Nov 21 19:58:49 2009 +0000
@@ -84,6 +84,7 @@
         self.day, self.night = True, False
         # For the level loading case
         if self.disp:
+            self.toolbar = None
             self.create_display()
             self.add_cash(level.starting_cash)
             self.add_wood(level.starting_wood)
@@ -103,12 +104,22 @@
         width, height = self.disp.rect.w, self.disp.rect.h
         tbl = gui.Table()
         tbl.tr()
-        self.toolbar = toolbar.ToolBar(self, width=constants.TOOLBAR_WIDTH)
+        self.toolbar = toolbar.DefaultToolBar(self, width=constants.TOOLBAR_WIDTH)
         tbl.td(self.toolbar, valign=-1)
         self.tvw = VidWidget(self, self.tv, width=width-constants.TOOLBAR_WIDTH, height=height)
         tbl.td(self.tvw)
         self.top_widget = tbl
 
+    def change_toolbar(self, new_toolbar):
+        """Replace the toolbar"""
+        td = self.toolbar.container
+        td.remove(self.toolbar)
+        td.add(new_toolbar, 0, 0)
+        self.toolbar = new_toolbar
+        self.toolbar.rect.size = self.toolbar.resize(height=td.rect.height)
+        td.resize()
+        td.repaint()
+
     def update(self):
         self.tvw.reupdate()