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
         run_ref_time: 1
13
         run_ref_time: 1
14
         crawl_ref_time: 10
14
         crawl_ref_time: 10
15
 global:
15
 global:
16
+    include_path:
17
+      maps:
18
+        - "maps"
19
+      graphics:
20
+        - "medias/images"
21
+      sounds:
22
+        - "medias/sounds"
16
     logging_level: DEBUG
23
     logging_level: DEBUG
17
     debug: true
24
     debug: true

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

1
 # coding: utf-8
1
 # coding: utf-8
2
 import pyglet
2
 import pyglet
3
+from synergine2.config import Config
3
 
4
 
4
 from synergine2.simulation import Subject
5
 from synergine2.simulation import Subject
5
 from synergine2_cocos2d.actor import Actor
6
 from synergine2_cocos2d.actor import Actor
37
 
38
 
38
     def __init__(
39
     def __init__(
39
         self,
40
         self,
41
+        config: Config,
40
         subject: Subject,
42
         subject: Subject,
41
     ) -> None:
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
 from cocos.audio.pygame.mixer import Sound
15
 from cocos.audio.pygame.mixer import Sound
16
 from synergine2_cocos2d.interaction import InteractionManager
16
 from synergine2_cocos2d.interaction import InteractionManager
17
 from synergine2_cocos2d.middleware import MapMiddleware
17
 from synergine2_cocos2d.middleware import MapMiddleware
18
+from synergine2_cocos2d.util import PathManager
18
 
19
 
19
 from opencombat.simulation.interior import InteriorManager
20
 from opencombat.simulation.interior import InteriorManager
20
 from opencombat.simulation.tmx import TileMap
21
 from opencombat.simulation.tmx import TileMap
155
         'gunshot_default': '204010__duckduckpony__homemade-gunshot-2.ogg',
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
         self._sounds = {}
162
         self._sounds = {}
161
 
163
 
162
     def get_sound(self, name: str) -> Sound:
164
     def get_sound(self, name: str) -> Sound:
184
             read_queue_interval=read_queue_interval,
186
             read_queue_interval=read_queue_interval,
185
             map_dir_path=map_dir_path,
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
         self.terminal.register_event_handler(
191
         self.terminal.register_event_handler(
190
             FinishMoveEvent,
192
             FinishMoveEvent,

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

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