public PaletteCollection(BinaryReader pa6File, PilFileReader pilFile) { this.pilFile = pilFile; ReadResource(pa6File); paletteFileOffset = HeaderSize; palette = new Palette(((int)pa6File.BaseStream.Length - HeaderSize) / 2); palette.Read16BitPalette(pa6File, HeaderSize); }
/// <summary> /// Temporary function to remove the DIL and JIL "feature" - turns out, the game uses it for more than palette informations /// </summary> public void RemoveDILDependence() { //Prepare the colors for the palette generation ImageData[] colorData = new ImageData[images.Length]; for (int j = 0; j < images.Length; j++) { colorData[j] = images[j].GetImageData(); uint[] colorsToBeAdded = colorData[j].GetUsedColors(); } PilFileReader pil = paletteCollection.GetPilFile(); pil.Resize(images.Length); paletteCollection.SetPalette(new Palette((256 * images.Length + 20) * 2)); //maximum size for a palette. We could shrink it to size, but we don't have to for (int j = 0; j < images.Length; j++) { GfxImage i = images[j]; int newPaletteOffset = 255 * j + 20; //Set according to JIL/normal palette offset. i.paletteOffset = newPaletteOffset; i.palette = paletteCollection.GetPalette(); //RecreatePalette(j, 255 * j + 20, colorData[j]); //Skip repeating JIL entries. They share the same palette i.buffer = i.CreateImageData(colorData[j]); i.DataOffset = 0; //Hack, the data is still at the same offset, but the way the we handle the reading forces us to set it to 0, as we write the new image data to buffer[0...] instead of buffer[DataOffset...] } byte[] gfxDataBuffer = GetData(); byte[] pilDataBuffer = paletteCollection.GetPilFile().GetData(); byte[] paletteDataBuffer = paletteCollection.GetData(); //directionIndexList.FakeLookupOffset(images.Length, jobIndexList); //Make every DIL entry point to itself. Doesnt work though in game //jobIndexList.FakeLookupOffset(images.Length); File.WriteAllBytes("3.gfx", gfxDataBuffer); //TODO! Change file name! File.WriteAllBytes("3.pi4", pilDataBuffer); //TODO! Change file name! File.WriteAllBytes("3.p46", paletteDataBuffer); //TODO! Change file name! File.WriteAllBytes("3.pi2", pilDataBuffer); //TODO! Change file name! File.WriteAllBytes("3.p26", paletteDataBuffer); //TODO! Change file name! File.WriteAllBytes("3.dil", directionIndexList.GetData()); //TODO! Change file name! File.WriteAllBytes("3.jil", jobIndexList.GetData()); //TODO! Change file name! }