diff options
author | Treeki <treeki@gmail.com> | 2013-04-08 00:35:12 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2013-04-08 00:35:12 +0200 |
commit | 26fcca821221eba6cf34d5cfdf4779fac2fb7bd8 (patch) | |
tree | a00314a7e0830b8a01764996139a0037da28d107 /tools/MovieSettings.py | |
parent | cb31aede5f07291e67243aa5c69927758253b3db (diff) | |
download | kamek-26fcca821221eba6cf34d5cfdf4779fac2fb7bd8.tar.gz kamek-26fcca821221eba6cf34d5cfdf4779fac2fb7bd8.zip |
update the base MovieSettings.py.. I guess?
Diffstat (limited to '')
-rw-r--r-- | tools/MovieSettings.py | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/tools/MovieSettings.py b/tools/MovieSettings.py index 1269e5c..d9f9ca0 100644 --- a/tools/MovieSettings.py +++ b/tools/MovieSettings.py @@ -4,15 +4,21 @@ class Settings(object): class Banner(object): def __init__(self, name): self.name = name - self.sounds = [] + self.commands = [] - def add_sound(self, delay, sound_id): - self.sounds.append((delay, sound_id)) + def play_sound(self, delay, sound_id): + self.commands.append((1, delay, sound_id)) + + def play_looping_sound(self, handle_id, delay, sound_id): + self.commands.append((2, handle_id, delay, sound_id)) + + def stop_looping_sound(self, handle_id, delay, frame_count): + self.commands.append((3, handle_id, delay, frame_count)) def __init__(self, widescreen): self.banners = [] self.widescreen = widescreen - + def add_banner(self, name): b = self.Banner(name) self.banners.append(b) @@ -29,13 +35,29 @@ class Settings(object): banner_offsets.append(offset) b_header1 = 'xxxx' # will be replaced later - b_header2 = struct.pack('>bxxxI', 1 if self.widescreen else 0, len(b.sounds)) - b_sounds = map(lambda x: struct.pack('>II', *x), b.sounds) - - offset += 12 + (len(b_sounds) * 8) + b_header2 = struct.pack('>bxxxI', 1 if self.widescreen else 0, len(b.commands)) + b_commands = [] + b_commands_size = 0 + + for cmd in b.commands: + ctype = cmd[0] + if ctype == 1: + # Play Sound + b_commands.append(struct.pack('>III', 1, cmd[1], cmd[2])) + b_commands_size += 12 + elif ctype == 2: + # Play Looping Sound + b_commands.append(struct.pack('>IIII', 2, cmd[1], cmd[2], cmd[3])) + b_commands_size += 16 + elif ctype == 3: + # Stop Looping Sound + b_commands.append(struct.pack('>IIII', 3, cmd[1], cmd[2], cmd[3])) + b_commands_size += 16 + + offset += 12 + b_commands_size b_data = [b_header1, b_header2] - b_data.extend(b_sounds) + b_data.extend(b_commands) banner_data.append(b_data) # now build a string table @@ -68,6 +90,9 @@ class Settings(object): s = Settings(widescreen=False) b = s.add_banner('/CS/Opening1.arc') +b.play_sound(delay=10, sound_id=740) +b.play_looping_sound(handle_id=0, delay=100, sound_id=500) +b.stop_looping_sound(handle_id=0, delay=1000, frame_count=15) b = s.add_banner('/CS/Opening3.arc') b = s.add_banner('/CS/Opening4.arc') b = s.add_banner('/CS/Opening5.arc') |