X-Git-Url: https://svn.cri.ensmp.fr/git/minwii.git/blobdiff_plain/46f3ffd7fdde386f41020171b5733e55a8e64a85..3c10e656308bd0f29d8ac4d15f7f95f29aec1697:/src/minwii/widgets/playingscreen.py?ds=sidebyside diff --git a/src/minwii/widgets/playingscreen.py b/src/minwii/widgets/playingscreen.py index 0735825..66c4776 100755 --- a/src/minwii/widgets/playingscreen.py +++ b/src/minwii/widgets/playingscreen.py @@ -7,22 +7,23 @@ $Id$ $URL$ """ import pygame -from cursors import WarpingCursor -from column import Column -import events -from eventutils import event_handler, EventDispatcher, EventHandlerMixin import types -from musicxml import Tone -from config import FRAMERATE -from config import FIRST_HUE -from config import MIDI_VELOCITY_RANGE -from config import MIDI_PAN_RANGE -from config import MIDI_VELOCITY_WRONG_NOTE_ATTN +import minwii.events as events +from minwii.log import eventLogger +from minwii.eventutils import event_handler, EventDispatcher, EventHandlerMixin +from minwii.musicxml import Tone +from minwii.config import FRAMERATE +from minwii.config import FIRST_HUE +from minwii.config import MIDI_VELOCITY_RANGE +from minwii.config import MIDI_PAN_RANGE +from minwii.config import MIDI_VELOCITY_WRONG_NOTE_ATTN +from minwii.globals import BACKGROUND_LAYER +from minwii.globals import CURSOR_LAYER +from minwii.globals import PLAYING_MODES_DICT -from globals import BACKGROUND_LAYER -from globals import CURSOR_LAYER -from globals import PLAYING_MODES_DICT +from cursors import WarpingCursor +from column import Column class PlayingScreenBase(pygame.sprite.LayeredDirty, EventHandlerMixin) : @@ -99,7 +100,9 @@ class PlayingScreenBase(pygame.sprite.LayeredDirty, EventHandlerMixin) : @event_handler(pygame.KEYDOWN) def handleKeyDown(self, event) : - if event.key == pygame.K_q or event.unicode == u'q': + if event.key == pygame.K_q or \ + event.unicode == u'q' or \ + pygame.K_ESCAPE: self.stop() @event_handler(pygame.MOUSEBUTTONDOWN) @@ -292,8 +295,17 @@ class SongPlayingScreen(PlayingScreenBase) : def displayNext(self, event=None) : if self.currentColumn: self.currentColumn.update(False) - note, verseIndex = self.noteIterator.next() - syllabus = note.lyrics[verseIndex].syllabus() + try : + note, verseIndex = self.noteIterator.next() + except StopIteration : + self.noteIterator = self.song.iterNotes() + note, verseIndex = self.noteIterator.next() + eventLogger.info(pygame.event.Event(events.SONGEND)) + try : + syllabus = note.lyrics[verseIndex].syllabus() + except IndexError : + syllabus = u'…' + column = self.columns[note.midi] column.update(True, syllabus) self.currentColumn = column