import pygame
import copy
import pickle

from pygame.event import Event

class PickleableEvent(object):
    "A pygame.Event that can be serialized."
    
    def __init__(self,type,dict):
        self.__dict__ = copy.copy(dict)
        self.type = type
        self.event = Event(self.type,dict)

    def __getstate__(self):
        d = []
        d.append(self.type)
        d.append(copy.copy(self.event.dict))
        return d

    def __setstate__(self, d):
        self.__dict__ = copy.copy(d[1])
        self.type = d[0]
        self.event = Event(d[0],d[1])