# HG changeset patch # User Thibaut Girka # Date 1315320032 -7200 # Node ID 3ac41b966fedbadb3c6d789f2de6bbed654368c0 # Parent e93a7ed4f2037975fddd720a5e193b43dd0dac7c Add writing support to pytouhou.formats.std! diff --git a/pytouhou/formats/std.py b/pytouhou/formats/std.py --- a/pytouhou/formats/std.py +++ b/pytouhou/formats/std.py @@ -13,7 +13,7 @@ ## -from struct import pack, unpack +from struct import pack, unpack, calcsize from pytouhou.utils.helpers import read_string, get_logger logger = get_logger(__name__) @@ -29,6 +29,12 @@ class Model(object): class Stage(object): + _instructions = {0: ('fff', 'set_viewpos'), + 1: ('BBBBff', 'set_fog'), + 2: ('fff', 'set_viewpos2'), + 3: ('III', 'start_interpolating_viewpos2'), + 4: ('III', 'start_interpolating_fog')} + def __init__(self): self.name = '' self.bgms = (('', ''), ('', ''), ('', '')) @@ -46,12 +52,12 @@ class Stage(object): if file.read(4) != b'\x00\x00\x00\x00': raise Exception #TODO - stage.name = read_string(file, 128, 'shift-jis') + stage.name = read_string(file, 128, 'shift_jis') - bgm_a = read_string(file, 128, 'shift-jis') - bgm_b = read_string(file, 128, 'shift-jis') - bgm_c = read_string(file, 128, 'shift-jis') - bgm_d = read_string(file, 128, 'shift-jis') + bgm_a = read_string(file, 128, 'shift_jis') + bgm_b = read_string(file, 128, 'shift_jis') + bgm_c = read_string(file, 128, 'shift_jis') + bgm_d = read_string(file, 128, 'shift_jis') bgm_a_path = read_string(file, 128, 'ascii') bgm_b_path = read_string(file, 128, 'ascii') @@ -73,8 +79,7 @@ class Stage(object): break if size != 0x1c: raise Exception #TODO - script_index, _padding, x, y, z, width, height = unpack('