Changeset 630


Ignore:
Timestamp:
08/06/10 21:06:40 (9 years ago)
Author:
beliar
Message:

Patch by Beliar.

  • added source_container to drag_drop_data.py. This is to store the container from which the item was taken.
  • InventoryGUI and ContainerGUI now store the container when dragging an item
  • Added stopActions method to Hud. This is to stop actions that maybe running to prepar to run other actions. Currently it resets the dragging and places the item back to its source container.
  • Added stopActions call to menu action methods.
Location:
trunk/game/scripts/gui
Files:
4 edited

Legend:

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

    r610 r630  
    7575            data_drag.dragging = True 
    7676            data_drag.dragged_widget = drag_widget 
     77            data_drag.source_container = self.container 
    7778 
    7879            self.container.takeItem(drag_widget.item) 
  • trunk/game/scripts/gui/drag_drop_data.py

    r605 r630  
    2525dragged_item = None 
    2626dragged_widget = None 
     27source_container = None 
  • trunk/game/scripts/gui/hud.py

    r621 r630  
    2626from scripts.gui.containergui import ContainerGUI 
    2727from scripts.gui.dialoguegui import DialogueGUI 
     28from scripts.gui import drag_drop_data as data_drag 
    2829 
    2930class Hud(object): 
     
    197198        """Displays the main in-game menu. 
    198199           @return: None""" 
     200        self.stopActions() 
    199201        if (self.menu_displayed == False): 
    200202            self.main_menu.show() 
     
    248250        """ Called when the user wants to save the game. 
    249251            @return: None""" 
     252        self.stopActions() 
    250253        save_browser = FileBrowser(self.engine, 
    251254                                   self.save_game_callback, 
     
    254257                                   extensions = ('.dat')) 
    255258        save_browser.showBrowser() 
    256              
     259 
     260    def stopActions(self): 
     261        """This method stops/resets actions that are currently performed like dragging an item. 
     262        This is done to be able to savely perform other actions that might interfere with current running ones.""" 
     263        #Reset dragging - move item back to its old container 
     264        if data_drag.dragging: 
     265            data_drag.source_container.placeItem(data_drag.dragged_item) 
     266            data_drag.dragging = False 
     267            data_drag.dragged_item = None             
     268         
    257269    def newGame(self): 
    258270        """Called when user request to start a new game. 
    259271           @return: None""" 
     272        self.stopActions() 
    260273        print 'new game' 
    261274 
     
    263276        """ Called when the user wants to load a game. 
    264277            @return: None""" 
     278        self.stopActions() 
    265279        load_browser = FileBrowser(self.engine, 
    266280                                   self.load_game_callback, 
     
    302316        """Called when user requests to quit game. 
    303317           @return: None""" 
    304  
     318        self.stopActions() 
    305319        self.quit_window.show() 
    306320 
     
    439453           @param npc: the npc that we are having a dialogue with 
    440454           @return: None""" 
     455        self.stopActions() 
    441456        dialogue = DialogueGUI( 
    442457                    self.controller, 
  • trunk/game/scripts/gui/inventorygui.py

    r610 r630  
    170170            data_drag.dragging = True 
    171171            data_drag.dragged_widget = drag_widget 
     172            data_drag.source_container = self.inventory_storage 
     173             
    172174            self.inventory_storage.takeItem(drag_widget.item) 
    173175            # after dragging the 'item', set the widgets' images 
Note: See TracChangeset for help on using the changeset viewer.