Ejemplo n.º 1
0
def shift_hardcoded_darknut_colors(self, h_shift, v_shift):
    # Update the RGB values for Darknut armor destroyed particles.
    rel = self.get_rel("files/rels/d_a_tn.rel")
    offset = 0xE2AC
    for i in range(12):
        shift_hardcoded_color_in_rel(rel, offset + i * 4, h_shift, v_shift)

    # Update the Darknut's cape colors
    rel = self.get_rel("files/rels/d_a_mant.rel")
    for palette_offset in [0x4540, 0x6560, 0x8580, 0xA5A0, 0xC5C0]:
        palette_data = BytesIO(rel.read_data(read_bytes, palette_offset, 0x20))
        colors = texture_utils.decode_palettes(
            palette_data, texture_utils.PaletteFormat.RGB5A3, 16,
            texture_utils.ImageFormat.C4)

        colors = texture_utils.hsv_shift_palette(colors, h_shift, v_shift)

        encoded_colors = texture_utils.generate_new_palettes_from_colors(
            colors, texture_utils.PaletteFormat.RGB5A3)
        palette_data = texture_utils.encode_palette(
            encoded_colors, texture_utils.PaletteFormat.RGB5A3,
            texture_utils.ImageFormat.C4)
        assert data_len(palette_data) == 0x20
        rel.write_data(write_bytes, palette_offset,
                       read_all_bytes(palette_data))
Ejemplo n.º 2
0
def shift_all_colors_in_tex1(self, file_name, j3d_file, h_shift, v_shift):
    for texture_name in j3d_file.tex1.textures_by_name:
        if "toon" in texture_name:
            # Special texture related to lighting
            continue

        textures = j3d_file.tex1.textures_by_name[texture_name]
        first_texture = textures[0]

        if first_texture.image_format in texture_utils.GREYSCALE_IMAGE_FORMATS:
            continue

        #if not os.path.isdir("./wip/enemy recolors/%s" % file_name):
        #  os.mkdir("./wip/enemy recolors/%s" % file_name)
        #first_texture.render().save("./wip/enemy recolors/%s/%s orig.png" % (file_name, texture_name))

        if first_texture.image_format in texture_utils.IMAGE_FORMATS_THAT_USE_PALETTES:
            if first_texture.palette_format in texture_utils.GREYSCALE_PALETTE_FORMATS:
                continue

            # Only modify the palette data without touching the image data.
            colors = first_texture.render_palette()
            colors = texture_utils.hsv_shift_palette(colors, h_shift, v_shift)
            for texture in textures:
                texture.replace_palette(colors)
        else:
            # Does not use palettes. Must modify the image data.
            image = first_texture.render()
            image = texture_utils.hsv_shift_image(image, h_shift, v_shift)
            for texture in textures:
                texture.replace_image(image)
Ejemplo n.º 3
0
def shift_all_colors_in_bti(self, texture_name, texture, h_shift, v_shift):
    if texture.image_format in texture_utils.GREYSCALE_IMAGE_FORMATS:
        return

    if texture.image_format in texture_utils.IMAGE_FORMATS_THAT_USE_PALETTES:
        if texture.palette_format in texture_utils.GREYSCALE_PALETTE_FORMATS:
            return

        # Only modify the palette data without touching the image data.
        colors = texture.render_palette()
        colors = texture_utils.hsv_shift_palette(colors, h_shift, v_shift)
        texture.replace_palette(colors)
    else:
        # Does not use palettes. Must modify the image data.
        image = texture.render()
        image = texture_utils.hsv_shift_image(image, h_shift, v_shift)
        texture.replace_image(image)