Ignore:
Timestamp:
09/03/09 02:03:40 (10 years ago)
Author:
orlandov
Message:

Fix Issue #78

  • Fully move the inventory display logic from World to Hud.
  • World will pass Hud an inventory model which will be passed to the Hud's Inventory object at creation time.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/scripts/world.py

    r264 r270  
    2424from sounds import SoundEngine 
    2525from settings import Setting 
    26 from scripts import inventory, hud 
     26from scripts import hud 
    2727from scripts.popups import * 
    2828from pychan.tools import callbackWithArguments as cbwa 
     
    5757        self.mouseCallback = None 
    5858        self.obj_hash={} 
     59 
    5960        # self.map is a Map object, set to none here 
    6061        self.activeMap = None 
    6162        self.maps = {} 
    62         self.hud = hud.Hud(self.engine, self, TDS) 
    63  
     63 
     64        # setup the inventory model 
     65        # make slot 'A1' and 'A3' container daggers 
     66        inv_model = {'A1':'dagger01', 'A3':'dagger01'} 
     67 
     68        hud_callbacks = { 
     69            'saveGame': self.saveGame, 
     70            'loadGame': self.loadGame, 
     71            'quitGame': self.quitGame, 
     72        } 
     73        self.hud = hud.Hud(self.engine, TDS, inv_model, hud_callbacks) 
    6474        self.action_number = 1 
    65         # setup the inventory 
    66         # make slot 'A1' and 'A3' container daggers 
    67         inv_data = {'A1':'dagger01', 'A3':'dagger01'} 
    68         self.inventory = inventory.Inventory(self.engine, inv_data, self.hud.refreshReadyImages, self.hud.toggleInventoryButton) 
    69         self.hud.refreshReadyImages() 
    70          
     75 
    7176        self.boxOpen = False 
    7277        self.boxCreated = False 
     
    8085                self.sounds.playMusic("/music/preciouswasteland.ogg") 
    8186                 
    82     def saveFunction(self, *args, **kwargs): 
    83         """Callback for save game 
     87    def quitGame(self): 
     88        """Quits the game 
     89        @return: None""" 
     90        self.quitFunction() 
     91 
     92    def saveGame(self, *args, **kwargs): 
     93        """Saves the game state 
    8494           @return: None""" 
    8595        self.data.save(*args, **kwargs) 
    8696 
    87     def loadFunction(self, *args, **kwargs): 
    88         """Callback for load game 
     97    def loadGame(self, *args, **kwargs): 
     98        """Loads the game state 
    8999           @return: None""" 
    90100        self.data.load(*args, **kwargs) 
     
    152162        if(keyval == key.I): 
    153163            # I opens and closes the inventory 
    154             self.hud.displayInventory(callFromHud=False) 
     164            self.hud.toggleInventory() 
    155165        if(keyval == key.A): 
    156166            # A adds a test action to the action box 
     
    171181           @param evt: The event that fife caught 
    172182           @return: None""" 
    173         self.hud.context_menu.hide() # hide the context menu in case it is displayed 
     183        self.hud.hideContextMenu() # hide the context menu in case it is displayed 
    174184        scr_point = fife.ScreenPoint(evt.getX(), evt.getY()) 
    175185        if(evt.getButton() == fife.MouseEvent.LEFT): 
     
    194204        """Callback sample for the context menu. 
    195205        """ 
    196         self.hud.context_menu.hide() 
     206        self.hud.hideContainer() 
    197207        self.data.gameState.PC.run(click) 
    198208 
Note: See TracChangeset for help on using the changeset viewer.