Changeset 302:01c1682dc250


Ignore:
Timestamp:
Sep 5, 2009, 5:18:14 PM (11 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Convert:
svn:b4e93282-eac8-4b8b-b765-0f5d36de2b68@303
Message:

Mostly working selling equipment in buildings

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TODO

    r300 r302  
    88
    99* Sell equipment from chickens in buildings (Neil)
     10  - Display bug with multiple equipment to be resolved
    1011
    1112== POST PYWEEK ==
  • gamelib/gameboard.py

    r298 r302  
    551551                self.tv.sprites.remove(chicken)
    552552
    553     def open_dialog(self, widget, close_callback=None):
     553    def open_dialog(self, widget, x=None, y=None, close_callback=None):
    554554        """Open a dialog for the given widget. Add close button."""
    555555        tbl = gui.Table()
     
    570570        tbl.td(close_button, align=1)
    571571
    572         self.disp.open(tbl)
     572        if x:
     573            offset = (self.disp.rect.center[0] +  x,
     574                    self.disp.rect.center[1] + y)
     575        else:
     576            offset = None
     577        self.disp.open(tbl, pos=offset)
    573578        return tbl
    574579
     
    743748
    744749    def sell_equipment(self, tile_pos):
     750        x, y = 0, 0
     751        def do_sell(chicken):
     752            if not chicken.equipment:
     753                return
     754            elif len(chicken.equipment) == 1:
     755                item = chicken.equipment[0]
     756                self.add_cash(item.sell_price())
     757                chicken.unequip(item)
     758            else:
     759                self.open_equipment_dialog(chicken, x, y)
     760            return False
     761
    745762        chicken = self.get_outside_chicken(tile_pos)
    746         if chicken is None or not chicken.equipment:
    747             return
    748         if len(chicken.equipment) == 1:
    749             item = chicken.equipment[0]
    750             self.add_cash(item.sell_price())
    751             chicken.unequip(item)
     763        if chicken is not None:
     764            do_sell(chicken)
    752765        else:
    753             self.open_equipment_dialog(chicken)
    754 
    755     def open_equipment_dialog(self, chicken):
     766            building = self.get_building(tile_pos)
     767            if building is None:
     768                return
     769            x, y = 50, 0
     770            self.open_building_dialog(building, do_sell)
     771
     772    def open_equipment_dialog(self, chicken, x, y):
    756773        tbl = gui.Table()
    757774
     
    773790            tbl.td(button, align=1, **kwargs)
    774791
    775         dialog = self.open_dialog(tbl)
     792        dialog = self.open_dialog(tbl, x=x, y=y)
    776793
    777794    def event(self, e):
Note: See TracChangeset for help on using the changeset viewer.