def setUp(self): BmpFileAccess = byteaccess.open_file(os.path.join(this_folder, 'test.bmp')) BmpHeader = define_basic_struct(struct_size=14, id=Ascii(offset=0x0, length=2, docs="should be `BM`", reverse=False), filesize=UInt32(offset=0x2), pixels_offset=UInt32(offset=0xA)) DibHeader = define_basic_struct(struct_size=40, header_size=UInt32(offset=0), width=UInt32(offset=4), height=UInt32(offset=8), num_color_panes=UInt16(offset=12), bits_per_pixel=UInt16(offset=14), buffer=RawData(offset=16, length=4), bmp_size=UInt32(offset=20, docs="includes padding"), dpi_horizontal=UInt32(offset=24), dpi_vertical=UInt32(offset=28), num_palette_colors=UInt32(offset=32), num_important_colors=UInt32(offset=36)) PixelArray = define_basic_struct(struct_size=14, red_pixel=RawData(offset=0, length=3), white_pixel=RawData(offset=3, length=3), blue_pixel=RawData(offset=8, length=3), green_pixel=RawData(offset=11, length=3)) self.bmp_header = BmpHeader(BmpFileAccess, 0) self.dib_header = DibHeader(BmpFileAccess, 14) self.pixel_array = PixelArray(BmpFileAccess, 54)
def setUp(self): TextFileAccess = byteaccess.open_file(os.path.join(this_folder, 'testfile.bin')) TextStruct = define_basic_struct(struct_size=0x30, char_array=Ascii(offset=0, length=4, reverse=True), char_array2=Ascii(offset=0, length=4, reverse=False), char_array3=Ascii(offset=4, length=1), c_string=Asciiz(offset=5, maxlength=19), bytes=RawData(offset=0x20, length=8)) self.struct = TextStruct(TextFileAccess, 0)
def from_file(map_path): """Load a map from a local mapfile. Changes immediately take effect; keep backups of your map files! Parameters ---------- map_path : string Location of the map on disk to open for editing. """ return HaloMap(open_file(map_path))
def setUp(self): this_folder = os.path.dirname(os.path.realpath(__file__)) self.ByteAccess = byteaccess.open_file(os.path.join(this_folder, 'testfile.bin')) self.offset = 0