Mercurial > touhou
comparison pytouhou/ui/music.pyx @ 764:d18c0bf11138
Python: Use logger.warning() as logger.warn() is deprecated
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 26 Aug 2022 18:55:39 +0200 |
parents | 4ce3ef053a25 |
children |
comparison
equal
deleted
inserted
replaced
763:468dab1dd683 | 764:d18c0bf11138 |
---|---|
35 posname = bgm[1].replace('bgm/', '').replace('.mid', '.pos') | 35 posname = bgm[1].replace('bgm/', '').replace('.mid', '.pos') |
36 try: | 36 try: |
37 track = resource_loader.get_track(posname) | 37 track = resource_loader.get_track(posname) |
38 except KeyError: | 38 except KeyError: |
39 track = None | 39 track = None |
40 logger.warn('Music description “%s” not found, continuing without looping data.', posname) | 40 logger.warning('Music description “%s” not found, continuing without looping data.', posname) |
41 globname = join(resource_loader.game_dir, bgm[1]).replace('.mid', '.*') | 41 globname = join(resource_loader.game_dir, bgm[1]).replace('.mid', '.*') |
42 filenames = glob(globname) | 42 filenames = glob(globname) |
43 for filename in reversed(filenames): | 43 for filename in reversed(filenames): |
44 try: | 44 try: |
45 source = load_music(filename) | 45 source = load_music(filename) |
52 self.bgms.append(source) | 52 self.bgms.append(source) |
53 logger.debug('Music file “%s” opened.', filename) | 53 logger.debug('Music file “%s” opened.', filename) |
54 break | 54 break |
55 else: | 55 else: |
56 self.bgms.append(None) | 56 self.bgms.append(None) |
57 logger.warn('No working music file for “%s”, disabling bgm.', globname) | 57 logger.warning('No working music file for “%s”, disabling bgm.', globname) |
58 | 58 |
59 cpdef play(self, index): | 59 cpdef play(self, index): |
60 cdef Music bgm | 60 cdef Music bgm |
61 bgm = self.bgms[index] | 61 bgm = self.bgms[index] |
62 if bgm is not None: | 62 if bgm is not None: |
87 if name not in self.sounds: | 87 if name not in self.sounds: |
88 try: | 88 try: |
89 wave_file = self.loader.get_file(name) | 89 wave_file = self.loader.get_file(name) |
90 chunk = load_chunk(wave_file) | 90 chunk = load_chunk(wave_file) |
91 except (KeyError, sdl.SDLError) as error: | 91 except (KeyError, sdl.SDLError) as error: |
92 logger.warn('Sound “%s” not found: %s', name, error) | 92 logger.warning('Sound “%s” not found: %s', name, error) |
93 chunk = None | 93 chunk = None |
94 else: | 94 else: |
95 chunk.set_volume(self.volume) | 95 chunk.set_volume(self.volume) |
96 self.sounds[name] = chunk | 96 self.sounds[name] = chunk |
97 return self.sounds[name] | 97 return self.sounds[name] |