How to use the generic.Editable function in generic

To help you get started, we’ve selected a few generic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github projectpokemon / PPRE / ntr / snd / sdat.py View on Github external
self.uint32('num')
        self.entries = []

    def load(self, reader):
        Editable.load(self, reader)
        self.entries = SizedCollection(InfoGROUPEntry().base_struct,
                                       length=self.num)

    def save(self, writer=None):
        self.num = len(self.entries)
        writer = Editable.save(self, writer)
        writer = self.entries.save(writer)
        return writer


class InfoPLAYER2(Editable):
    accelerated = True

    def define(self):
        self.array('u0', self.uint8, length=24)


class InfoSTRM(Editable):
    accelerated = True

    def define(self):
        self.uint16('file_id')
        self.uint16('unknown')
        self.uint8('volume')
        self.uint8('pri')
        self.uint8('ply')
        self.uint8('u7')
github projectpokemon / PPRE / pokemon / poketool / trainer.py View on Github external
self.seal_capsule = reader.readUInt16()
        return self

    def save(self, writer):
        writer = Editable.save(self, writer)
        if self.trainer.hold_items:
            writer.writeUInt16(self.item)
        if self.trainer.movesets:
            for move in self.moves:
                writer.writeUInt16(move)
        if self.trainer.game.is_hgss():
            writer.writeUInt16(self.seal_capsule)
        return writer


class Trainer(Editable):
    def define(self, game):
        self.game = game
        self.uint8('movesets', width=1)
        self.uint8('hold_items', width=1)
        self.uint8('pad0', width=6)
        self.uint8('class')
        self.uint8('battle_type')
        self.uint8('num_pokemon')
        self.array('items', self.uint16, length=4)
        self.uint32('ai')
        self.uint8('battle_type2')
        self.pokemon = None

    def load_pokemon(self, reader):
        reader = BinaryIO.reader(reader)
        self.pokemon = []
github projectpokemon / PPRE / ntr / snd / sdat.py View on Github external
accelerated = True

    def define(self):
        self.uint32('u0')
        self.uint32('u4')


class InfoGROUPEntry(Editable):
    accelerated = True

    def define(self):
        self.uint32('type_')
        self.uint32('entry_id')


class InfoGROUP(Editable):
    def define(self):
        self.uint32('num')
        self.entries = []

    def load(self, reader):
        Editable.load(self, reader)
        self.entries = SizedCollection(InfoGROUPEntry().base_struct,
                                       length=self.num)

    def save(self, writer=None):
        self.num = len(self.entries)
        writer = Editable.save(self, writer)
        writer = self.entries.save(writer)
        return writer
github projectpokemon / PPRE / pokemon / field / zone_events.py View on Github external
from generic import Editable
from util import BinaryIO


class Furniture(Editable):
    """Furniture is like a spriteless overworld. The objects usually exist
    with the models placed on the map"""
    def define(self):
        self.uint16('script')
        self.uint16('u2')  # 2 = dowse-able
        self.uint16('x')  # x
        self.uint16('pad_6', default=0)
        self.uint16('y')  # y
        self.uint16('ua')
        self.uint16('uc')
        self.uint16('ue')
        self.uint16('u10')
        self.uint16('u12')


class Overworld(Editable):
github projectpokemon / PPRE / pokemon / field / mmodel / mmodel.py View on Github external
def save(self):
        with self.game.open('overlays_dez', 'overlay_{0:04}.bin'.format(
                self.game.overworld_sprite_table[0]), mode='r+') as handle:
            writer = BinaryIO.writer(handle)
            writer.seek(self.game.overworld_sprite_table[1])
            Editable.save(self, writer)
github projectpokemon / PPRE / ntr / snd / sdat.py View on Github external
offsets = []
        text_writer = BinaryIO()
        for entry in entries:
            if entry[:-1] == prefix:
                entry_names.append(entry[-1])
        for i in range(len(entry_names)):
            text_writer.writeUInt32(0)
        for entry in entry_names:
            offsets.append(text_writer.tell()+base_offset)
            text_writer.writeString(entry)
        with text_writer.seek(0):
            text_writer.write(array.array('I', offsets).tostring())
        return len(entry_names), text_writer


class InfoSEQ(Editable):
    # accelerated = True

    def define(self):
        self.uint16('file_id')
        self.uint16('u2')
        self.uint16('bank_id')
        self.uint8('volume')
        self.uint8('cpr')
        self.uint8('ppr')
        self.uint8('poly')
        self.uint16('ua')


class InfoARC(Editable):
    """Info for both SEQARC and WAVEARC"""
    accelerated = True
github projectpokemon / PPRE / pokemon / poketool / trainer.py View on Github external
def save(self, writer=None):
        self.update()
        return Editable.save(self, writer)
github projectpokemon / PPRE / pokemon / field / map_matrix.py View on Github external
from generic import Editable
from generic.collection import Collection2d
from util import BinaryIO


class MapMatrix(Editable):
    def define(self):
        self.uint8('width')
        self.uint8('height')
        self.uint8('has_map_definition_ids')
        self.uint8('has_mystery_zone')
        self.uint8('namelen')
        self.name = ''  # pascal string

    def reshape(self, width, height, copy=True):
        """Reshape the world to a new width/height

        Parameters
        ----------
        width : int
            New width
        height : int
github projectpokemon / PPRE / pokemon / poketool / evo.py View on Github external
from generic import Editable
from generic.collection import SizedCollection
from util import BinaryIO


class Evolution(Editable):
    def define(self):
        self.uint16('method')
        self.uint16('param')
        self.uint16('target')


class Evolutions(SizedCollection):
    def define(self):
        SizedCollection.define(self, Evolution().base_struct, length=7,
                               resizable=False)
github projectpokemon / PPRE / pokemon / graphic / font.py View on Github external
def load(self, reader):
        reader = BinaryIO.reader(reader)
        start = reader.tell()
        Editable.load(self, reader)
        self.glyphs = []
        # TODO: glyph reading
        self.glyphs = SizedCollection(Glyph().base_struct, length=self.num)
        self.glyphs.load(reader)
        self.widths = []
        reader.seek(start+self.footer_offset)
        for i in range(self.num):
            self.widths.append(reader.readUInt8())