X-Git-Url: https://svn.cri.ensmp.fr/git/minwii.git/blobdiff_plain/a1cb64098e2a34d115378fdced1044da37e94395..c9bd8f475f8fb2bce0e96a300d50c3c7e3ffd23b:/src/app/widgets/playingscreen.py diff --git a/src/app/widgets/playingscreen.py b/src/app/widgets/playingscreen.py index 23f2643..248f0bb 100755 --- a/src/app/widgets/playingscreen.py +++ b/src/app/widgets/playingscreen.py @@ -10,7 +10,7 @@ import pygame from colorsys import hls_to_rgb from gradients import gradients from cursors import WarpingCursor -from eventutils import event_handler, EventHandlerMixin +from eventutils import event_handler, EventDispatcher, EventHandlerMixin from math import floor import types # TODO : positionner cette constance en fonction de la résolution d'affichage @@ -32,6 +32,7 @@ class _PlayingScreenBase(pygame.sprite.OrderedUpdates, EventHandlerMixin) : distinctNotes : notes disctinctes présentes dans la chanson triées du plus grave au plus aigu. """ + print '__init__ _PlayingScreenBase' super(_PlayingScreenBase, self).__init__() self.distinctNotes = distinctNotes self.keyboardLength = 0 @@ -76,7 +77,6 @@ class _PlayingScreenBase(pygame.sprite.OrderedUpdates, EventHandlerMixin) : hueStep = FIRST_HUE / (self.keyboardLength - 1) for i, rect in enumerate(self.keyboardRects) : hue = FIRST_HUE - hueStep * i - print hue c = Column(hue, rect) self.add(c) @@ -92,15 +92,11 @@ class _PlayingScreenBase(pygame.sprite.OrderedUpdates, EventHandlerMixin) : def run(self): self._running = True + clock = pygame.time.Clock() while self._running : pygame.display.flip() - events = pygame.event.get() - for event in events: - self.input(event) - - def input(self, event) : - handler = getattr(self, 'eventHandler%s' % event.type, lambda e:None) - handler(event) + EventDispatcher.dispatchEvents() + clock.tick(50) @event_handler(pygame.KEYDOWN) def handleKeyDown(self, event) : @@ -126,6 +122,7 @@ class SongPlayingScreen(_PlayingScreenBase) : class SongPlayingScreenTest(_PlayingScreenBase) : def __init__(self) : + print '__init__ SongPlayingScreenTest' class C:pass o = C() o.midi=1