comparison gamelib/scenes/bridge.py @ 315:7b07ffc37ec0

Suspend background sound for bridge computer detail
author Neil Muller <neil@dip.sun.ac.za>
date Sat, 28 Aug 2010 12:11:42 +0200
parents 6d93e04036c9
children 4a7aa7fcd191
comparison
equal deleted inserted replaced
314:63e702d93e0e 315:7b07ffc37ec0
5 from albow.music import change_playlist, get_music, PlayList 5 from albow.music import change_playlist, get_music, PlayList
6 from albow.resource import get_image 6 from albow.resource import get_image
7 7
8 from gamelib.cursor import CursorSprite 8 from gamelib.cursor import CursorSprite
9 from gamelib.state import Scene, Item, Thing, Result 9 from gamelib.state import Scene, Item, Thing, Result
10 from gamelib.sound import get_current_playlist
10 11
11 from gamelib.scenes.scene_widgets import (Door, InteractText, InteractNoImage, 12 from gamelib.scenes.scene_widgets import (Door, InteractText, InteractNoImage,
12 InteractRectUnion, InteractImage, 13 InteractRectUnion, InteractImage,
13 InteractAnimated, GenericDescThing) 14 InteractAnimated, GenericDescThing)
14 15
35 'accessible': True, 36 'accessible': True,
36 } 37 }
37 38
38 def __init__(self, state): 39 def __init__(self, state):
39 super(Bridge, self).__init__(state) 40 super(Bridge, self).__init__(state)
41 self.background_playlist = None
40 self.add_item(Superconductor('superconductor')) 42 self.add_item(Superconductor('superconductor'))
41 self.add_item(Stethoscope('stethoscope')) 43 self.add_item(Stethoscope('stethoscope'))
42 self.add_thing(ToMap()) 44 self.add_thing(ToMap())
43 self.add_thing(MassageChair()) 45 self.add_thing(MassageChair())
44 self.add_thing(StethoscopeThing()) 46 self.add_thing(StethoscopeThing())
65 self.add_thing(self.doctor) 67 self.add_thing(self.doctor)
66 68
67 69
68 def enter(self): 70 def enter(self):
69 pieces = [get_music(x, prefix='sounds') for x in self.MUSIC] 71 pieces = [get_music(x, prefix='sounds') for x in self.MUSIC]
70 background_playlist = PlayList(pieces, random=True, repeat=True) 72 self.background_playlist = PlayList(pieces, random=True, repeat=True)
71 change_playlist(background_playlist) 73 change_playlist(self.background_playlist)
72 return Result("The bridge is in a sorry, shabby state.") 74 return Result("The bridge is in a sorry, shabby state.")
73 75
74 def leave(self): 76 def leave(self):
75 change_playlist(None) 77 change_playlist(None)
76 78
352 354
353 self.add_thing(LogTab()) 355 self.add_thing(LogTab())
354 self.add_thing(AlertTab()) 356 self.add_thing(AlertTab())
355 self.add_thing(CompUpButton()) 357 self.add_thing(CompUpButton())
356 self.add_thing(CompDownButton()) 358 self.add_thing(CompDownButton())
359 self._scene_playlist = None
357 self._alert = get_image(self.FOLDER, self.ALERT) 360 self._alert = get_image(self.FOLDER, self.ALERT)
358 self._logs = [get_image(self.FOLDER, x) for x in self.LOGS] 361 self._logs = [get_image(self.FOLDER, x) for x in self.LOGS]
362
363 def enter(self):
364 self._scene_playlist = get_current_playlist()
365 change_playlist(None)
366
367 def leave(self):
368 change_playlist(self._scene_playlist)
359 369
360 def draw_background(self, surface): 370 def draw_background(self, surface):
361 if self.get_data('tab') == 'alert': 371 if self.get_data('tab') == 'alert':
362 self._background = self._alert 372 self._background = self._alert
363 else: 373 else: