本文整理汇总了Python中mmfparser.bytereader.ByteReader.tell方法的典型用法代码示例。如果您正苦于以下问题:Python ByteReader.tell方法的具体用法?Python ByteReader.tell怎么用?Python ByteReader.tell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mmfparser.bytereader.ByteReader
的用法示例。
在下文中一共展示了ByteReader.tell方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write_data
# 需要导入模块: from mmfparser.bytereader import ByteReader [as 别名]
# 或者: from mmfparser.bytereader.ByteReader import tell [as 别名]
def write_data(self):
header = ByteReader()
data = ByteReader()
header_size = (len(self.images) + len(self.sounds) + len(self.fonts) +
len(self.shaders)) * 4 + len(self.images) * 2
# image preload
self.use_count_offset = header.tell()
for _ in xrange(len(self.images)):
header.writeShort(0, True)
for image in self.images:
header.writeInt(data.tell() + header_size, True)
data.write(image)
for sound in self.sounds:
header.writeInt(data.tell() + header_size, True)
data.write(sound)
for shader in self.shaders:
header.writeInt(data.tell() + header_size, True)
data.write(shader)
self.fp.write(str(header))
self.fp.write(str(data))
self.image_count = len(self.images)
self.sound_count = len(self.sounds)
self.font_count = len(self.fonts)
self.shader_count = len(self.shaders)
self.sounds = self.images = self.fonts = self.shaders = None
示例2: read
# 需要导入模块: from mmfparser.bytereader import ByteReader [as 别名]
# 或者: from mmfparser.bytereader.ByteReader import tell [as 别名]
def read(self, filename):
self.points = []
try:
data = ByteReader(open(filename, 'rb'))
except IOError:
return
while data.tell() < len(data):
count = (data.readInt() - 2) / 2
x = data.readInt()
y = data.readInt()
point = Point(x, y)
self.points.append(point)
for _ in xrange(count):
point_id = data.readInt()
distance = data.readFloat()
connection = Connection(point_id, distance)
point.connections.append(connection)
示例3: write_data
# 需要导入模块: from mmfparser.bytereader import ByteReader [as 别名]
# 或者: from mmfparser.bytereader.ByteReader import tell [as 别名]
def write_data(self):
header = ByteReader()
data = ByteReader()
header_size = ((len(self.images) + len(self.sounds) + len(self.fonts) +
len(self.shaders) + len(self.files)) * 4
+ len(self.images) * 2 + 5 * 4)
# image preload
self.use_count_offset = header.tell()
for _ in xrange(len(self.images)):
header.writeShort(0, True)
start = data.tell()
for image in self.images:
header.writeInt(data.tell() + header_size, True)
data.write(image)
image_size = data.tell() - start
start = data.tell()
for sound in self.sounds:
header.writeInt(data.tell() + header_size, True)
data.write(sound)
sound_size = data.tell() - start
start = data.tell()
for font in self.fonts:
header.writeInt(data.tell() + header_size, True)
data.write(font)
font_size = data.tell() - start
start = data.tell()
for shader in self.shaders:
header.writeInt(data.tell() + header_size, True)
data.write(shader)
shader_size = data.tell() - start
start = data.tell()
for packfile in self.files:
header.writeInt(data.tell() + header_size, True)
data.write(packfile)
packfile_size = data.tell() - start
for size in (image_size, sound_size, font_size, shader_size,
packfile_size):
header.writeInt(size, True)
self.fp.write(str(header))
self.fp.write(str(data))
self.image_count = len(self.images)
self.sound_count = len(self.sounds)
self.font_count = len(self.fonts)
self.shader_count = len(self.shaders)
self.file_count = len(self.files)
self.sounds = self.images = self.fonts = self.shaders = None
self.files = None
示例4: write
# 需要导入模块: from mmfparser.bytereader import ByteReader [as 别名]
# 或者: from mmfparser.bytereader.ByteReader import tell [as 别名]
def write(self, reader):
reader.write(MFA_MAGIC)
reader.writeInt(self.mfaBuild)
reader.writeInt(self.product)
reader.writeInt(self.buildVersion)
if self.languageId is not None:
reader.writeInt(self.languageId)
reader.writeInt(len(self.name))
reader.write(self.name)
reader.writeInt(len(self.description))
reader.write(self.description)
reader.writeInt(len(self.path))
reader.write(self.path)
reader.writeInt(len(self.stamp), True)
reader.write(self.stamp)
reader.write(FONT_BANK)
self.fonts.write(reader)
reader.write(SOUND_BANK)
self.sounds.write(reader)
reader.write(MUSIC_BANK)
self.music.write(reader)
for item in (self.icons, self.images):
reader.write(IMAGE_BANK)
item.write(reader)
reader.writeInt(len(self.name))
reader.write(self.name)
reader.writeInt(len(self.author))
reader.write(self.author)
reader.writeInt(len(self.description))
reader.write(self.description)
reader.writeInt(len(self.copyright))
reader.write(self.copyright)
reader.writeInt(len(self.company))
reader.write(self.company)
reader.writeInt(len(self.version))
reader.write(self.version)
reader.writeInt(self.windowSize[0])
reader.writeInt(self.windowSize[1])
reader.writeColor(self.borderColor)
reader.writeInt(self.displaySettings.getFlags())
reader.writeInt(self.graphicSettings.getFlags())
reader.writeInt(len(self.helpFile)); reader.write(self.helpFile)
reader.writeInt(len(self.vitalizePreview))
reader.write(self.vitalizePreview)
reader.writeInt(self.initialScore, True)
reader.writeInt(self.initialLifes, True)
reader.writeInt(self.frameRate)
reader.writeInt(self.buildType)
reader.writeInt(len(self.buildPath))
reader.write(self.buildPath)
reader.writeInt(0)
reader.writeInt(len(self.commandLine))
reader.write(self.commandLine)
reader.writeInt(len(self.aboutBox))
reader.write(self.aboutBox)
reader.writeInt(0)
reader.writeInt(len(self.binaryFiles))
for item in self.binaryFiles:
reader.writeInt(len(item))
reader.write(item)
self.controls.write(reader)
if self.menu:
menuData = self.menu.generate()
reader.writeInt(len(menuData))
reader.writeReader(menuData)
else:
reader.writeInt(0)
reader.writeInt(self.windowMenuIndex)
reader.writeInt(len(self.menuImages))
for k, v in self.menuImages.iteritems():
reader.writeInt(k)
reader.writeInt(v)
self.globalValues.write(reader)
self.globalStrings.write(reader)
reader.writeInt(len(self.globalEvents))
reader.write(self.globalEvents)
reader.writeInt(self.graphicMode)
reader.writeInt(len(self.iconImages))
for item in self.iconImages:
reader.writeInt(item)
reader.writeInt(len(self.customQualifiers))
for item in self.customQualifiers:
name, handle = item
reader.writeInt(len(name)); reader.write(name)
reader.writeInt(handle)
reader.writeInt(len(self.extensions))
for item in self.extensions:
handle, filename, name, magic, subType = item
reader.writeInt(handle)
reader.writeIntString(filename)
reader.writeIntString(name)
reader.writeInt(magic)
reader.writeIntString(subType)
reader.writeInt(len(self.frames))
startPosition = reader.tell() + 4 * len(self.frames) + 4
newReader = ByteReader()
for frame in self.frames:
reader.writeInt(startPosition + newReader.tell(), True)
frame.write(newReader)
reader.writeInt(startPosition + newReader.tell(), True)
#.........这里部分代码省略.........