Changeset 642


Ignore:
Timestamp:
08/10/10 18:57:18 (9 years ago)
Author:
beliar
Message:

Patch by Beliar

  • Better (less hacky) method to get mouse position for picking/scrolling. Instead of catching mouseMoved getX()/getY() of engine.getCursor() is used in updateMouse() of GameSceneController?.
  • Updated svn properts of gamescenecontroller.py
Location:
trunk/game/scripts
Files:
2 edited

Legend:

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

    • Property svn:eol-style set to native
    r641 r642  
    3333                           UnlockBoxAction, LockBoxAction, TalkAction, \ 
    3434                           PickUpAction, DropItemAction 
     35 
     36#For debugging/code analysis 
     37if False: 
     38    from gamesceneview import GameSceneView 
     39    from gamemodel import GameModel 
     40    from parpg import PARPGApplication 
    3541 
    3642class GameSceneController(ControllerBase): 
     
    6066                                                  model, 
    6167                                                  application) 
     68         
     69        #this can be helpful for IDEs code analysis 
     70        if False: 
     71            assert(isinstance(self.engine, fife.Engine)) 
     72            assert(isinstance(self.view, GameSceneView)) 
     73            assert(isinstance(self.view, GameModel)) 
     74            assert(isinstance(self.application, PARPGApplication)) 
     75            assert(isinstance(self.event_manager, fife.EventManager)) 
     76         
    6277        # Last saved mouse coords         
    6378        self.last_mousecoords = None 
     
    219234            # show the menu 
    220235            self.view.hud.showContextMenu(data, (scr_point.x, scr_point.y)) 
    221  
    222     def mouseMoved(self, evt): 
    223         """Called when the mouse is moved 
    224            @type evt: fife.event 
    225            @param evt: The event that fife caught 
    226            @return: None""" 
    227         self.updateMouse(evt.getX(), evt.getY()) 
    228236     
    229     def updateMouse(self, mouse_x, mouse_y): 
    230         """Updates the mouse values 
    231         @param mouseX: X-Position of mouse 
    232         @type mouseX: int 
    233         @param mouseY: Y-Position of mouse 
    234         @type mouseY: int""" 
     237    def updateMouse(self): 
     238        """Updates the mouse values""" 
    235239        if self.paused: 
    236240            return 
    237          
    238         self.last_mousecoords = fife.ScreenPoint(mouse_x, mouse_y)         
     241        cursor = self.engine.getCursor() 
     242        #this can be helpful for IDEs code analysis 
     243        if False: 
     244            assert(isinstance(cursor, fife.Cursor)) 
     245        self.last_mousecoords = fife.ScreenPoint(cursor.getX(),  
     246                                                 cursor.getY())         
    239247        self.view.highlightFrontObject(self.last_mousecoords)        
    240248         
     
    242250        pixle_edge = 20 
    243251         
     252        mouse_x = self.last_mousecoords.x 
    244253        screen_width = self.model.engine.getSettings().getScreenWidth() 
     254        mouse_y = self.last_mousecoords.y 
    245255        screen_height = self.model.engine.getSettings().getScreenHeight() 
    246256         
     
    428438        if self.paused:  
    429439            return 
     440        self.updateMouse() 
    430441        if self.model.active_map: 
    431442            self.view.highlightFrontObject(self.last_mousecoords) 
  • trunk/game/scripts/gui/hud.py

    r640 r642  
    6565        self.quit_window = None 
    6666        self.bottom_panel = self.hud.findChild(name="mainHudWindow") 
    67         self.bottom_panel.capture(self.mouseMoved, event_name="mouseMoved") 
    6867         
    6968        self.actions_box = self.hud.findChild(name="actionsBox") 
     
    129128        self.showHUD() 
    130129         
    131     def mouseMoved(self, event): 
    132         """Called when the mouse was moved on the bottom panel""" 
    133         self.controller.updateMouse(event.getX(),  
    134                                     self.engine.getSettings().getScreenHeight()\ 
    135                                     - (self.bottom_panel.height - event.getY())) 
    136          
    137  
    138130    def refreshActionsBox(self): 
    139131        """Refresh the actions box so that it displays the contents of 
Note: See TracChangeset for help on using the changeset viewer.