From 0adb475173e22229c0eb5c6c79b8a8488894b7c9 Mon Sep 17 00:00:00 2001 From: pin Date: Thu, 15 Apr 2010 06:31:23 +0000 Subject: [PATCH] =?utf8?q?Ajout=20d'un=20=C3=A9v=C3=A9nement=20COLSTATECHA?= =?utf8?q?NGE.=20Ajout=20de=20la=20position=20du=20curseur=20de=20la=20sou?= =?utf8?q?ris=20dans=20les=20=C3=A9v=C3=A9nements=20COLUP,=20COLDOWN=20et?= =?utf8?q?=20COLOVER.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@141 fe552daf-6dbe-4428-90eb-1537e0879342 --- src/app/events.py | 10 +++++++++- src/app/eventutils.py | 3 ++- src/app/widgets/column.py | 4 ++++ src/app/widgets/playingscreen.py | 18 +++++++++--------- 4 files changed, 24 insertions(+), 11 deletions(-) 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) -- 2.20.1