Changeset 262:d508248041ff


Ignore:
Timestamp:
Sep 5, 2009, 1:36:00 PM (11 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Convert:
svn:b4e93282-eac8-4b8b-b765-0f5d36de2b68@263
Message:

avoid passing events in twice

Location:
gamelib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gamelib/engine.py

    r254 r262  
    5252
    5353    def event(self, e):
    54         if not Game.event(self, e) and self.gameboard:
    55             self.gameboard.event(e)
     54        if not Game.event(self, e):
     55            if self.gameboard:
     56                return self.gameboard.event(e)
     57            return False
     58        return True
    5659       
    5760
  • gamelib/gameboard.py

    r258 r262  
    22
    33import pygame
    4 from pygame.locals import MOUSEBUTTONDOWN, MOUSEMOTION, KEYDOWN, K_UP, K_DOWN, K_LEFT, K_RIGHT
     4from pygame.locals import MOUSEBUTTONDOWN, MOUSEMOTION, KEYDOWN, K_UP, K_DOWN, \
     5        K_LEFT, K_RIGHT
    56from pgu import gui
    67
     
    561562            building.selected(False)
    562563
     564        def evict_callback():
     565            print 'evict called', self.animal_to_place
     566
     567        if not sell_callback:
     568            tbl.tr()
     569            button = gui.Button('Evict')
     570            button.connect(gui.CLICK, evict_callback)
     571            tbl.td(button, colspan=2, **kwargs)
     572
    563573        self.open_dialog(tbl, close_callback=close_callback)
    564574
     
    665675
    666676    def event(self, e):
    667         if e.type == KEYDOWN:
     677        if e.type == KEYDOWN and e.key in [K_UP, K_DOWN, K_LEFT, K_RIGHT]:
    668678            if e.key == K_UP:
    669679                self.tvw.move_view(0, -self.TILE_DIMENSIONS[1])
     
    674684            if e.key == K_RIGHT:
    675685                self.tvw.move_view(self.TILE_DIMENSIONS[0], 0)
    676         else:
    677             self.disp.event(e)
     686            return True
     687        return False
    678688
    679689    def advance_day(self):
Note: See TracChangeset for help on using the changeset viewer.