comparison gamelib/gameboard.py @ 522:6f41a565e910

Add 'select all' button
author Neil Muller <drnlmuller@gmail.com>
date Fri, 27 Nov 2009 14:31:44 +0000
parents 787eb032bf8a
children 103b0fc36722
comparison
equal deleted inserted replaced
521:787eb032bf8a 522:6f41a565e910
651 for place in row: 651 for place in row:
652 if place.occupant is not None: 652 if place.occupant is not None:
653 self.unselect_animal(place.occupant) 653 self.unselect_animal(place.occupant)
654 building.selected(False) 654 building.selected(False)
655 655
656 def select_all_callback():
657 self.unselect_all()
658 for chicken in building.occupants():
659 self.select_animal(chicken)
660 update_button(chicken)
661
656 def evict_callback(): 662 def evict_callback():
657 if not self.selected_chickens: 663 if not self.selected_chickens:
658 return 664 return
659 for tile_pos in building.adjacent_tiles(): 665 for tile_pos in building.adjacent_tiles():
660 if self.tv.get(tile_pos) != self.GRASSLAND: 666 if self.tv.get(tile_pos) != self.GRASSLAND:
664 update_button(chicken, empty=True) 670 update_button(chicken, empty=True)
665 # this will place all the chickens 671 # this will place all the chickens
666 self.place_animal(tile_pos) 672 self.place_animal(tile_pos)
667 break 673 break
668 674
675 tbl.tr()
676 select_button = gui.Button('Select All')
677 select_button.connect(gui.CLICK, select_all_callback)
678 tbl.td(select_button, colspan=2, **kwargs)
669 if not sell_callback: 679 if not sell_callback:
670 tbl.tr() 680 evict_button = gui.Button('Evict')
671 button = gui.Button('Evict') 681 evict_button.connect(gui.CLICK, evict_callback)
672 button.connect(gui.CLICK, evict_callback) 682 tbl.td(evict_button, colspan=2, **kwargs)
673 tbl.td(button, colspan=2, **kwargs)
674 683
675 self.open_dialog(tbl, close_callback=close_callback) 684 self.open_dialog(tbl, close_callback=close_callback)
676 685
677 def buy_building(self, tile_pos, building_cls): 686 def buy_building(self, tile_pos, building_cls):
678 building = building_cls(tile_pos) 687 building = building_cls(tile_pos)