From: pin Date: Thu, 15 Apr 2010 06:31:23 +0000 (+0000) Subject: Ajout d'un événement COLSTATECHANGE. Ajout de la position du curseur de la souris... X-Git-Url: https://scm.cri.mines-paristech.fr/git/minwii.git/commitdiff_plain/0adb475173e22229c0eb5c6c79b8a8488894b7c9?ds=sidebyside;hp=62d5191553d75c84d63ace49f6f5173a35773c88 Ajout d'un événement COLSTATECHANGE. Ajout de la position du curseur de la souris dans les événements COLUP, COLDOWN et COLOVER. git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@141 fe552daf-6dbe-4428-90eb-1537e0879342 --- diff --git a/src/app/events.py b/src/app/events.py index 8e13a85..eee6445 100755 --- a/src/app/events.py +++ b/src/app/events.py @@ -1,7 +1,15 @@ import pygame from sys import modules -events = ['TIMEOUT', 'NOTEON', 'NOTEOFF', 'NOTEEND', 'COLDOWN', 'COLUP', 'COLOVER'] +events = ['TIMEOUT', + 'NOTEON', + 'NOTEOFF', + 'NOTEEND', + 'COLDOWN', + 'COLUP', + 'COLOVER', + 'COLSTATECHANGE'] + eventNames = {} self = modules[__name__] diff --git a/src/app/eventutils.py b/src/app/eventutils.py index 3ce142d..f95a828 100755 --- a/src/app/eventutils.py +++ b/src/app/eventutils.py @@ -62,7 +62,8 @@ class _EventDispatcher : events = pygame.event.get() for event in events : listeners = self.registry.get(event.type, {}) - if listeners and not hiddenEvents.has_key(event.type) : + if not hiddenEvents.has_key(event.type): + #if listeners and not hiddenEvents.has_key(event.type) : eventLog.info(pprinters[event.type](event)) for listener in listeners.keys() : listener(event) diff --git a/src/app/widgets/column.py b/src/app/widgets/column.py index 94fddcc..31266c8 100755 --- a/src/app/widgets/column.py +++ b/src/app/widgets/column.py @@ -20,6 +20,7 @@ from config import ON_COLUMN_OVERSIZING from config import ON_COLUMN_ALPHA from config import LYRICS_FONT, NOTES_FONT from config import FONT_COLOR +import events class Column(pygame.sprite.DirtySprite) : @@ -95,6 +96,9 @@ class Column(pygame.sprite.DirtySprite) : group.change_layer(self, BACKGROUND_LAYER) self.image = self.surOff self.rect = self.rectOff + self.state = state self.dirty = 1 + evt = pygame.event.Event(events.COLSTATECHANGE, col=self, state=state, syllabus=syllabus) + pygame.event.post(evt) diff --git a/src/app/widgets/playingscreen.py b/src/app/widgets/playingscreen.py index 4638267..ec96536 100755 --- a/src/app/widgets/playingscreen.py +++ b/src/app/widgets/playingscreen.py @@ -113,33 +113,33 @@ class _PlayingScreenBase(pygame.sprite.LayeredDirty, EventHandlerMixin) : # parce qu'il s'agit du curseur for col in reversed(self.sprites()[:-1]) : if col.rect.collidepoint(*event.pos): - self.raiseColDown(col) + self.raiseColDown(col, event.pos) break @event_handler(pygame.MOUSEBUTTONUP) def onMouseUp(self, event) : for col in reversed(self.sprites()[:-1]) : if col.rect.collidepoint(*event.pos) : - self.raiseColUp(col) + self.raiseColUp(col, event.pos) break @event_handler(pygame.MOUSEMOTION) def onMouseMove(self, event) : for col in reversed(self.sprites()[:-1]) : if col.rect.collidepoint(*event.pos) : - self.raiseColOver(col) + self.raiseColOver(col, event.pos) break - def raiseColDown(self, col) : - evt = pygame.event.Event(events.COLDOWN, column=col) + def raiseColDown(self, col, pos) : + evt = pygame.event.Event(events.COLDOWN, column=col, pos=pos) pygame.event.post(evt) - def raiseColUp(self, col) : - evt = pygame.event.Event(events.COLUP, column=col) + def raiseColUp(self, col, pos) : + evt = pygame.event.Event(events.COLUP, column=col, pos=pos) pygame.event.post(evt) - def raiseColOver(self, col) : - evt = pygame.event.Event(events.COLOVER, column=col) + def raiseColOver(self, col, pos) : + evt = pygame.event.Event(events.COLOVER, column=col, pos=pos) pygame.event.post(evt)