Browse Source

USe audio library from synergine

Bastien Sevajol 6 years ago
parent
commit
c67d7a7365
1 changed files with 3 additions and 16 deletions
  1. 3 16
      opencombat/gui/base.py

+ 3 - 16
opencombat/gui/base.py View File

@@ -12,7 +12,7 @@ from PIL import Image
12 12
 from pyglet.window import key
13 13
 
14 14
 from cocos.actions import MoveTo as BaseMoveTo
15
-from cocos.audio.pygame.mixer import Sound
15
+from synergine2_cocos2d.audio import AudioLibrary as BaseAudioLibrary
16 16
 from synergine2_cocos2d.interaction import InteractionManager
17 17
 from synergine2_cocos2d.middleware import MapMiddleware
18 18
 from synergine2_cocos2d.util import PathManager
@@ -165,24 +165,11 @@ class TileLayerManager(LayerManager):
165 165
         )
166 166
 
167 167
 
168
-# TODO: Move into synergine2cocos2d
169
-class AudioLibrary(object):
168
+class AudioLibrary(BaseAudioLibrary):
170 169
     sound_file_paths = {
171 170
         'gunshot_default': '204010__duckduckpony__homemade-gunshot-2.ogg',
172 171
     }
173 172
 
174
-    def __init__(self, config: Config) -> None:
175
-        self.config = config
176
-        self._path_manager = PathManager(config.resolve('global.include_path.sounds'))
177
-        self._sounds = {}
178
-
179
-    def get_sound(self, name: str) -> Sound:
180
-        if name not in self._sounds:
181
-            sound_file_name = self.sound_file_paths[name]
182
-            sound_file_path = self._path_manager.path(sound_file_name)
183
-            self._sounds[name] = Sound(sound_file_path)
184
-        return self._sounds[name]
185
-
186 173
 
187 174
 class Game(TMXGui):
188 175
     layer_manager_class = TileLayerManager
@@ -202,7 +189,7 @@ class Game(TMXGui):
202 189
             read_queue_interval=read_queue_interval,
203 190
             map_dir_path=map_dir_path,
204 191
         )
205
-        self.sound_lib = AudioLibrary(self.config)
192
+        self.sound_lib = AudioLibrary(config.resolve('global.include_path.sounds'))
206 193
         self.graphic_path_manager = PathManager(self.config.resolve(
207 194
             'global.include_path.graphics',
208 195
         ))