Browse Source

USe PathManager

Bastien Sevajol 6 years ago
parent
commit
7967c40644
4 changed files with 16 additions and 5 deletions
  1. 7 0
      config.yaml
  2. 3 1
      opencombat/gui/actor.py
  3. 5 3
      opencombat/gui/base.py
  4. 1 1
      opencombat/terminal/base.py

+ 7 - 0
config.yaml View File

@@ -13,5 +13,12 @@ game:
13 13
         run_ref_time: 1
14 14
         crawl_ref_time: 10
15 15
 global:
16
+    include_path:
17
+      maps:
18
+        - "maps"
19
+      graphics:
20
+        - "medias/images"
21
+      sounds:
22
+        - "medias/sounds"
16 23
     logging_level: DEBUG
17 24
     debug: true

+ 3 - 1
opencombat/gui/actor.py View File

@@ -1,5 +1,6 @@
1 1
 # coding: utf-8
2 2
 import pyglet
3
+from synergine2.config import Config
3 4
 
4 5
 from synergine2.simulation import Subject
5 6
 from synergine2_cocos2d.actor import Actor
@@ -37,6 +38,7 @@ class Man(Actor):
37 38
 
38 39
     def __init__(
39 40
         self,
41
+        config: Config,
40 42
         subject: Subject,
41 43
     ) -> None:
42
-        super().__init__(pyglet.resource.image('actors/man.png'), subject=subject)
44
+        super().__init__('actors/man.png', subject=subject, config=config)

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

@@ -15,6 +15,7 @@ from cocos.actions import MoveTo as BaseMoveTo
15 15
 from cocos.audio.pygame.mixer import Sound
16 16
 from synergine2_cocos2d.interaction import InteractionManager
17 17
 from synergine2_cocos2d.middleware import MapMiddleware
18
+from synergine2_cocos2d.util import PathManager
18 19
 
19 20
 from opencombat.simulation.interior import InteriorManager
20 21
 from opencombat.simulation.tmx import TileMap
@@ -155,8 +156,9 @@ class AudioLibrary(object):
155 156
         'gunshot_default': '204010__duckduckpony__homemade-gunshot-2.ogg',
156 157
     }
157 158
 
158
-    def __init__(self, sound_dir_path: str) -> None:
159
-        self._sound_dir_path = sound_dir_path
159
+    def __init__(self, config: Config) -> None:
160
+        self.config = config
161
+        self._path_manager = PathManager(config.resolve('global.include_path.sounds'))
160 162
         self._sounds = {}
161 163
 
162 164
     def get_sound(self, name: str) -> Sound:
@@ -184,7 +186,7 @@ class Game(TMXGui):
184 186
             read_queue_interval=read_queue_interval,
185 187
             map_dir_path=map_dir_path,
186 188
         )
187
-        self.sound_lib = AudioLibrary('opencombat/sounds/')
189
+        self.sound_lib = AudioLibrary(self.config)
188 190
 
189 191
         self.terminal.register_event_handler(
190 192
             FinishMoveEvent,

+ 1 - 1
opencombat/terminal/base.py View File

@@ -61,7 +61,7 @@ class CocosTerminal(GameTerminal):
61 61
         # TODO: Defind on some other place ?
62 62
         self.gui.subject_mapper_factory.register_mapper(
63 63
             ManSubject,
64
-            SubjectMapper(ManActor),
64
+            SubjectMapper(self.config, ManActor),
65 65
         )
66 66
 
67 67
         self.gui.run()