Exemplo n.º 1
0
 def from_yml_rep(self, yml_rep):
     super(Door, self).from_yml_rep(yml_rep)
     self.text_pointer.from_yml_rep(get_from_user_dict(yml_rep, "Text Pointer", str))
     self.flag = EbEventFlagTableEntry.from_yml_rep(get_from_user_dict(yml_rep, "Event Flag", int))
     self.destination_x = get_from_user_dict(yml_rep, "Destination X", int)
     self.destination_y = get_from_user_dict(yml_rep, "Destination Y", int)
     self.destination_direction = get_enum_from_user_dict(yml_rep, "Direction", DestinationDirection)
     self.destination_style = get_from_user_dict(yml_rep, "Style", int)
Exemplo n.º 2
0
 def settings_yml_rep(self, include_colors=False):
     out = {EbEventFlagTableEntry.name: EbEventFlagTableEntry.to_yml_rep(self.flag),
            SpritePaletteIdTableEntry.name: SpritePaletteIdTableEntry.to_yml_rep(self.sprite_palette_id),
            FlashEffectTableEntry.name: FlashEffectTableEntry.to_yml_rep(self.flash_effect)}
     if include_colors:
         out["Colors"] = str(self)
     if self.flag != 0:
         out["Event Palette"] = self.flag_palette.settings_yml_rep(include_colors=True)
     return out
Exemplo n.º 3
0
 def settings_yml_rep(self, include_colors=False):
     out = {EbEventFlagTableEntry.name: EbEventFlagTableEntry.to_yml_rep(self.flag),
            SpritePaletteIdTableEntry.name: SpritePaletteIdTableEntry.to_yml_rep(self.sprite_palette_id),
            FlashEffectTableEntry.name: FlashEffectTableEntry.to_yml_rep(self.flash_effect)}
     if include_colors:
         out["Colors"] = str(self)
     if self.flag != 0:
         out["Event Palette"] = self.flag_palette.settings_yml_rep(include_colors=True)
     return out
Exemplo n.º 4
0
    def settings_from_yml_rep(self, yml_rep, include_colors=False):
        self.flag = EbEventFlagTableEntry.from_yml_rep(yml_rep[EbEventFlagTableEntry.name])
        self.sprite_palette_id = SpritePaletteIdTableEntry.from_yml_rep(yml_rep[SpritePaletteIdTableEntry.name])
        self.flash_effect = FlashEffectTableEntry.from_yml_rep(yml_rep[FlashEffectTableEntry.name])

        if include_colors:
            self.from_string(yml_rep["Colors"])

        if self.flag != 0:
            self.flag_palette = EbMapPalette()
            self.flag_palette.settings_from_yml_rep(yml_rep["Event Palette"], include_colors=True)
Exemplo n.º 5
0
    def settings_from_yml_rep(self, yml_rep, include_colors=False):
        self.flag = EbEventFlagTableEntry.from_yml_rep(yml_rep[EbEventFlagTableEntry.name])
        self.sprite_palette_id = SpritePaletteIdTableEntry.from_yml_rep(yml_rep[SpritePaletteIdTableEntry.name])
        self.flash_effect = FlashEffectTableEntry.from_yml_rep(yml_rep[FlashEffectTableEntry.name])

        if include_colors:
            self.from_string(yml_rep["Colors"])

        if self.flag != 0:
            self.flag_palette = EbMapPalette()
            self.flag_palette.settings_from_yml_rep(yml_rep["Event Palette"], include_colors=True)
Exemplo n.º 6
0
 def yml_rep(self):
     out = super(Door, self).yml_rep()
     out["Type"] = DoorType.tostring(DoorType.DOOR)
     out["Text Pointer"] = self.text_pointer.yml_rep()
     out["Event Flag"] = EbEventFlagTableEntry.to_yml_rep(self.flag)
     out["Destination X"] = self.destination_x
     out["Destination Y"] = self.destination_y
     try:
         out["Direction"] = DestinationDirection.tostring(self.destination_direction)
     except InvalidArgumentError:
         raise InvalidUserDataError("Door had invalid destination direction of %#x" % self.destination_direction)
     out["Style"] = self.destination_style
     return out
Exemplo n.º 7
0
    def to_block(cls, block, offset, value):
        data_size = 2  # for the final [00 00] bytes which end each entry
        for _, sub_entries in value:
            data_size += EbEventFlagTableEntry.size
            data_size += 2
            data_size += MapEventSubTableEntry.size * len(sub_entries)
        pointer = block.allocate(size=data_size,
                                 can_write_to=partial(is_in_bank, cls.bank))
        super(MapEventPointerTableEntry, cls).to_block(block, offset, pointer & 0xffff)

        for flag, sub_entries in value:
            EbEventFlagTableEntry.to_block(block, pointer, flag)
            pointer += EbEventFlagTableEntry.size
            block.write_multi(pointer, len(sub_entries), 2)
            pointer += 2

            for sub_entry in sub_entries:
                MapEventSubTableEntry.to_block(block, pointer, sub_entry)
                pointer += MapEventSubTableEntry.size

        block[pointer] = 0
        block[pointer + 1] = 0
Exemplo n.º 8
0
    def from_block(cls, block, offset):
        data_offset = super(MapEventPointerTableEntry, cls).from_block(block, offset)
        data_offset |= (cls.bank << 16)

        value = []
        while block.read_multi(data_offset, 2) != 0:
            flag = EbEventFlagTableEntry.from_block(block, data_offset)
            data_offset += EbEventFlagTableEntry.size
            num_sub_entries = block.read_multi(data_offset, 2)
            data_offset += 2

            sub_entries = [MapEventSubTableEntry.from_block(block, x)
                           for x
                           in range(data_offset,
                                    data_offset + num_sub_entries * MapEventSubTableEntry.size,
                                    MapEventSubTableEntry.size)]
            data_offset += num_sub_entries * MapEventSubTableEntry.size
            value.append((flag, sub_entries))

        return value
Exemplo n.º 9
0
 def yml_rep(self):
     out = super(SwitchDoor, self).yml_rep()
     out["Type"] = DoorType.tostring(DoorType.SWITCH)
     out["Event Flag"] = EbEventFlagTableEntry.to_yml_rep(self.flag)
     out["Text Pointer"] = self.text_pointer.yml_rep()
     return out
Exemplo n.º 10
0
 def from_yml_rep(self, yml_rep):
     super(SwitchDoor, self).from_yml_rep(yml_rep)
     self.flag = EbEventFlagTableEntry.from_yml_rep(get_from_user_dict(yml_rep, "Event Flag", int))
     self.text_pointer.from_yml_rep(get_from_user_dict(yml_rep, "Text Pointer", str))
Exemplo n.º 11
0
 def yml_rep_hex_labels(cls):
     return EbEventFlagTableEntry.yml_rep_hex_labels()
Exemplo n.º 12
0
 def from_yml_rep(cls, yml_rep):
     return [(EbEventFlagTableEntry.from_yml_rep(entry_yml_rep[EbEventFlagTableEntry.name]),
              [MapEventSubTableEntry.from_yml_rep(tile_change)
               for tile_change in entry_yml_rep["Tile Changes"]])
             for entry_yml_rep in yml_rep]
Exemplo n.º 13
0
 def to_yml_rep(cls, value):
     return [{EbEventFlagTableEntry.name: EbEventFlagTableEntry.to_yml_rep(flag),
              "Tile Changes": [MapEventSubTableEntry.to_yml_rep(tile_change)
                               for tile_change in tile_changes]}
             for flag, tile_changes in value]