Mercurial > boomslang
changeset 567:b84534a1bd2e pyntnclick
Lazily load Result sounds.
author | Simon Cross <hodgestar+bzr@gmail.com> |
---|---|
date | Sat, 11 Feb 2012 15:27:52 +0200 |
parents | ea9dd2b9186a |
children | aae75f7ce7a1 |
files | pyntnclick/state.py |
diffstat | 1 files changed, 7 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/pyntnclick/state.py Sat Feb 11 15:05:18 2012 +0200 +++ b/pyntnclick/state.py Sat Feb 11 15:27:52 2012 +0200 @@ -9,7 +9,6 @@ from pygame.color import Color from pyntnclick import constants -from pyntnclick.sound import get_sound class Result(object): @@ -18,18 +17,20 @@ def __init__(self, message=None, soundfile=None, detail_view=None, style=None, close_detail=False, end_game=False): self.message = message - self.sound = None - if soundfile: - self.sound = get_sound(soundfile) + self.soundfile = soundfile self.detail_view = detail_view self.style = style self.close_detail = close_detail self.end_game = end_game + def play_sound(self, scene_widget): + if self.soundfile: + sound = scene_widget.state.gd.sound.get_sound(self.soundfile) + sound.play() + def process(self, scene_widget): """Helper function to do the right thing with a result object""" - if self.sound: - self.sound.play() + self.play_sound(scene_widget) if self.message: scene_widget.show_message(self.message, self.style) if self.detail_view: