Ignore:
Timestamp:
09/01/13 13:18:11 (8 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Phase:
public
Message:

Hook up area.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/events.py

    r18 r20  
    11"""Events to post."""
    22
    3 from pygame import event
    4 import pygame.locals as pyl
     3import pygame
    54
    65
     
    109    @classmethod
    1110    def post(cls, **data):
    12         ev = event.Event(cls.TYPE, **data)
    13         event.post(ev)
     11        ev = pygame.event.Event(cls.TYPE, **data)
     12        pygame.event.post(ev)
     13
     14    @classmethod
     15    def matches(cls, ev):
     16        return ev.type == cls.TYPE
    1417
    1518
    1619class QuitEvent(Event):
    17     TYPE = pyl.QUIT
     20    TYPE = pygame.locals.QUIT
     21
     22
     23class UserEvent(Event):
     24    TYPE = pygame.locals.USEREVENT
     25
     26    @classmethod
     27    def post(cls, **data):
     28        super(UserEvent, cls).post(user_type=cls.__name__, **data)
     29
     30    @classmethod
     31    def matches(cls, ev):
     32        return (super(UserEvent, cls).matches(ev)
     33                and ev.user_type == cls.__name__)
     34
     35
     36class ScreenChange(UserEvent):
     37    @classmethod
     38    def post(cls, new_screen):
     39        super(ScreenChange, cls).post(screen=new_screen)
Note: See TracChangeset for help on using the changeset viewer.