Changeset 639


Ignore:
Timestamp:
08/09/10 17:00:04 (9 years ago)
Author:
beliar
Message:

Patch by Beliar

  • Enabled of Hud is now a property that gets/sets the enabled status of the hud and its children using real_widget. This makes it possible to really disable the widgets instead of making them do nothing.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/scripts/gui/hud.py

    r638 r639  
    1818from fife.extensions import pychan 
    1919from fife.extensions.pychan.tools import callbackWithArguments as cbwa 
    20 from fife.fife import MouseEvent 
    2120 
    2221from scripts.gui.filebrowser import FileBrowser 
     
    4342               quitGame: called when the user clicks on Quit 
    4443           @return: None""" 
    45         self.enabled = False 
    4644        pychan.init(controller.engine, debug = True) 
    4745 
     
    7977        self.initializeEvents() 
    8078        self.initializeQuitDialog() 
    81  
     79     
     80    def _getEnabled(self): 
     81        """"Returns whether the gui widget is enabled or not""" 
     82        return self.hud.real_widget.isEnabled() 
     83     
     84    def _setEnabled(self, enabled): 
     85        """"Sets whether the gui widget is enabled or not""" 
     86        self.hud.real_widget.setEnabled(enabled) 
     87        childs = self.hud.getNamedChildren() 
     88        for child_list in childs.itervalues(): 
     89            for child in child_list: 
     90                child.real_widget.setEnabled(enabled) 
     91     
     92    enabled = property(_getEnabled, _setEnabled) 
     93         
    8294    def initializeHud(self): 
    8395        """Initialize and show the main HUD 
     
    118130         
    119131    def mouseMoved(self, event): 
     132        """Called when the mouse was moved on the bottom panel""" 
    120133        self.controller.updateMouse(event.getX(),  
    121                                     self.engine.getSettings().getScreenHeight() - \ 
    122                                     (self.bottom_panel.height - event.getY())) 
     134                                    self.engine.getSettings().getScreenHeight()\ 
     135                                    - (self.bottom_panel.height - event.getY())) 
    123136         
    124137 
     
    163176            'toggleInventoryButton': self.toggleInventoryButton, 
    164177        } 
    165         self.inventory_storage = self.model.game_state.player_character.inventory 
     178        self.inventory_storage = \ 
     179            self.model.game_state.player_character.inventory 
    166180        if self.inventory == None: 
    167181            self.inventory = inventorygui.InventoryGUI(self.controller, 
     
    204218        """Displays the main in-game menu. 
    205219           @return: None""" 
    206         if not self.enabled: 
    207             return 
    208220        self.stopActions() 
    209221        if (self.menu_displayed == False): 
     
    260272        """ Called when the user wants to save the game. 
    261273            @return: None""" 
    262         if not self.enabled: 
    263             return 
    264274        self.stopActions() 
    265275        save_browser = FileBrowser(self.engine, 
     
    272282 
    273283    def stopActions(self): 
    274         """This method stops/resets actions that are currently performed like dragging an item. 
    275         This is done to be able to savely perform other actions that might interfere with current running ones.""" 
     284        """This method stops/resets actions that are currently performed  
     285        like dragging an item. 
     286        This is done to be able to savely perform other actions that might  
     287        interfere with current running ones.""" 
    276288        #Reset dragging - move item back to its old container 
    277289        if data_drag.dragging: 
     
    285297        """Called when user request to start a new game. 
    286298           @return: None""" 
    287         if not self.enabled: 
    288             return 
    289299        self.stopActions() 
    290300        print 'new game' 
     
    293303        """ Called when the user wants to load a game. 
    294304            @return: None""" 
    295         if not self.enabled: 
    296             return 
    297305        self.stopActions() 
    298306        load_browser = FileBrowser(self.engine, 
     
    336344        """Called when user requests to quit game. 
    337345           @return: None""" 
    338         if not self.enabled: 
    339             return 
    340346        self.stopActions() 
    341347        self.quit_window.show() 
     
    353359        """Displays the inventory screen 
    354360           @return: None""" 
    355         if not self.enabled: 
    356             return 
    357361        if self.inventory == None: 
    358362            self.initializeInventory() 
     
    427431    def readyAction(self, ready_button): 
    428432        """ Called when the user selects a ready button from the HUD """ 
    429         if not self.enabled: 
    430             return 
    431433        text = "Used the item from %s" % ready_button         
    432434        self.addAction(text) 
Note: See TracChangeset for help on using the changeset viewer.