Ignore:
Timestamp:
12/17/09 09:19:30 (10 years ago)
Author:
b0rland_parpg
Message:

Ticket #241: patch by b0rland
*Removed reference from containers to GUI
*Fixed SingleItemContainer? with the new type of exception

Location:
trunk/game/scripts/objects
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/scripts/objects/action.py

    r395 r451  
    6060        try: 
    6161            self.container.open() 
     62            self.engine.view.hud.createBoxGUI(self.container.name, \ 
     63                                              self.container) 
     64 
    6265        except ValueError: 
    6366            self.engine.view.hud.createExamineBox(self.container.name, \ 
  • trunk/game/scripts/objects/base.py

    r449 r451  
    205205        pass 
    206206 
    207     def __init__ (self, 
    208                   events = {}, 
    209                   engine = None, capacity = 0, **kwargs): 
     207    def __init__ (self, capacity = 0, **kwargs): 
    210208        self.is_container = True 
    211209        self.items = {} 
    212         self.events = events 
    213         self.containergui = None 
    214210        self.capacity=capacity 
    215  
    216         if not self.events: 
    217             self.events = {'takeAllButton':self.hideContainer, 
    218                       'closeButton':self.hideContainer} 
    219         if engine : 
    220             self.containergui = engine.view.hud.createBoxGUI(self.name, self, self.events) 
    221211         
    222212    def placeItem (self, item, index=None): 
     
    272262        """Bulk of the container contents""" 
    273263        return sum((item.bulk for item in self.items.values())) 
    274  
    275     def showContainer (self): 
    276         if self.containergui: 
    277             self.containergui.showContainer() 
    278  
    279     def hideContainer(self): 
    280         if self.containergui: 
    281             self.containergui.hideContainer() 
    282264 
    283265    def findItemByID(self, ID): 
  • trunk/game/scripts/objects/composed.py

    r449 r451  
    6161 
    6262    def __repr__(self): 
    63         return "[%s"%self.name +str(reduce((lambda a,b: a +', '+str(b)), self.items,""))+" ]" 
     63        return "[%s"%self.name +str(reduce((lambda a,b: a +', '+ \ 
     64                                    str(self.items[b])), self.items,""))+" ]" 
    6465 
    6566 
     
    7172    def placeItem(self,item, index=None): 
    7273        if len(self.items) > 0 : 
    73             raise ValueError ('%s is already busy' % self) 
     74            raise self.SlotBusy ('%s is already busy' % self) 
    7475        CarryableContainer.placeItem(self, item) 
    7576 
  • trunk/game/scripts/objects/containers.py

    r424 r451  
    3030    def __init__ (self, ID, name = 'Wooden Crate', \ 
    3131            text = 'A battered crate', gfx = 'crate', **kwargs): 
    32         events = {'takeAllButton':self.close, 
    33           'closeButton':self.close} 
    3432        ImmovableContainer.__init__(self, ID = ID, name = name, gfx = gfx, \ 
    35                 text = text, events = events, **kwargs) 
     33                text = text, **kwargs) 
    3634        self.placeItem(CarryableItem(ID=987,name="Dagger456")) 
    37  
    38     def close(self, *args, **kwargs): 
    39         self.hideContainer() 
    40         super (WoodenCrate,self).close() 
    41  
    42     def open(self, *args, **kwargs): 
    43         super (WoodenCrate,self).open(*args,**kwargs) 
    44         self.showContainer() 
    4535         
    4636class Footlocker(ImmovableContainer, fife.InstanceActionListener): 
    4737    def __init__ (self, ID, agent_layer=None, name = 'Footlocker', \ 
    4838               text = 'A Footlocker', gfx = 'lock_box_metal01', **kwargs): 
    49         events = {'takeAllButton':self.close, 
    50                   'closeButton':self.close} 
    5139        ImmovableContainer.__init__(self, ID = ID, name = name, gfx = gfx, \ 
    52                 text = text, events = events, **kwargs) 
     40                text = text, **kwargs) 
    5341        self.placeItem(CarryableItem(ID=987,name="Dagger456")) 
    5442 
     
    7260            self.agent.act('opened', self.agent.getFacingLocation(), True) 
    7361            self.state = _AGENT_STATE_OPENED 
    74             self.showContainer() 
    7562        if self.state == _AGENT_STATE_CLOSING: 
    7663            self.agent.act('closed', self.agent.getFacingLocation(), True) 
     
    8572    def close(self): 
    8673        super (Footlocker,self).close() 
    87         self.hideContainer() 
    8874        if self.state != _AGENT_STATE_CLOSED and self.state != _AGENT_STATE_CLOSING: 
    8975            self.agent.act('close', self.agent.getLocation()) 
Note: See TracChangeset for help on using the changeset viewer.