Example #1
0
        private void InternalCombinePatches()
        {
            if (ProgressChange != null)
            {
                ProgressChange(this, new ProgressChangeEventArgs(0, 0, 0));
            }

            if (StatusChange != null)
            {
                StatusChange(this, new StatusChangeEventArgs(String.Format("Combining Patches...")));
            }

            _combinedPatchFile = Path.Combine(_patchToFolder, "temp.patch");

            for (int i = 0; i < _patches.Length; i++)
            {
                if (_patches[i].FileID == (int)FileID.Anim_mul)
                {
                    int id        = _patches[i].BlockID;
                    int fileIndex = BodyConverter.Convert(ref id);

                    if (fileIndex == 1)
                    {
                        continue;
                    }
                    else if (fileIndex == 2)
                    {
                        _patches[i].FileID = (int)FileID.Anim2_mul;
                    }
                    else if (fileIndex == 3)
                    {
                        _patches[i].FileID = (int)FileID.Anim3_mul;
                    }
                    else if (fileIndex == 4)
                    {
                        _patches[i].FileID = (int)FileID.Anim4_mul;
                    }
                    else
                    {
                        _patches[i].FileID = (int)FileID.Anim5_mul;
                    }
                }
            }

            PatchWriter.CreateMUO(_combinedPatchFile, _patches, ProgressChange);

            if (ProgressChange != null)
            {
                ProgressChange(this, new ProgressChangeEventArgs(100, 0, 0));
            }

            if (PatchingComplete != null)
            {
                PatchingComplete(this, new OperationCompleteArgs());
            }

            _thread.Join();
        }
Example #2
0
        private static void LoadTable()
        {
            int count = 400 + ((m_FileIndex.Length - 35000) / 175);

            m_Table = new int[count];

            for (int i = 0; i < count; ++i)
            {
                object o = BodyTable.m_Entries[i];

                if (o == null || BodyConverter.Contains(i))
                {
                    m_Table[i] = i;
                }
                else
                {
                    BodyTableEntry bte = (BodyTableEntry)o;

                    m_Table[i] = bte.m_OldID | (1 << 31) | (((bte.m_NewHue ^ 0x8000) & 0xFFFF) << 15);
                }
            }
        }
Example #3
0
        public static Frame[] GetAnimation(int body, int action, int direction, int hue, bool preserveHue)
        {
            if (preserveHue)
            {
                Translate(ref body);
            }
            else
            {
                Translate(ref body, ref hue);
            }

            int       fileType = BodyConverter.Convert(ref body);
            FileIndex fileIndex;

            int index;

            switch (fileType)
            {
            default:
            case 1:
            {
                fileIndex = m_FileIndex;

                if (body < 200)
                {
                    index = body * 110;
                }
                else if (body < 400)
                {
                    index = 22000 + ((body - 200) * 65);
                }
                else
                {
                    index = 35000 + ((body - 400) * 175);
                }

                break;
            }

            case 2:
            {
                fileIndex = m_FileIndex2;

                if (body < 200)
                {
                    index = body * 110;
                }
                else
                {
                    index = 22000 + ((body - 200) * 65);
                }

                break;
            }

            case 3:
            {
                fileIndex = m_FileIndex3;

                if (body < 300)
                {
                    index = body * 65;
                }
                else if (body < 400)
                {
                    index = 33000 + ((body - 300) * 110);
                }
                else
                {
                    index = 35000 + ((body - 400) * 175);
                }

                break;
            }

            case 4:
            {
                fileIndex = m_FileIndex4;

                if (body < 200)
                {
                    index = body * 110;
                }
                else if (body < 400)
                {
                    index = 22000 + ((body - 200) * 65);
                }
                else
                {
                    index = 35000 + ((body - 400) * 175);
                }

                break;
            }

            case 5:
            {
                fileIndex = m_FileIndex5;

                if (body < 200 && body != 34)                                  // looks strange, though it works.
                {
                    index = body * 110;
                }
                else
                {
                    index = 35000 + ((body - 400) * 65);
                }

                break;
            }
            }

            index += action * 5;

            if (direction <= 4)
            {
                index += direction;
            }
            else
            {
                index += direction - (direction - 4) * 2;
            }

            int    length, extra;
            bool   patched;
            Stream stream = fileIndex.Seek(index, out length, out extra, out patched);

            if (stream == null)
            {
                return(null);
            }

            bool flip = (direction > 4);

            BinaryReader bin = new BinaryReader(stream);

            ushort[] palette = new ushort[0x100];

            for (int i = 0; i < 0x100; ++i)
            {
                palette[i] = (ushort)(bin.ReadUInt16() ^ 0x8000);
            }

            int start      = (int)bin.BaseStream.Position;
            int frameCount = bin.ReadInt32();

            int[] lookups = new int[frameCount];

            for (int i = 0; i < frameCount; ++i)
            {
                lookups[i] = start + bin.ReadInt32();
            }

            bool onlyHueGrayPixels = ((hue & 0x8000) == 0);

            hue = (hue & 0x3FFF) - 1;

            Hue hueObject = null;

            if (hue >= 0 && hue < Hues.List.Length)
            {
                hueObject = Hues.List[hue];
            }

            Frame[] frames = new Frame[frameCount];

            for (int i = 0; i < frameCount; ++i)
            {
                bin.BaseStream.Seek(lookups[i], SeekOrigin.Begin);
                frames[i] = new Frame(palette, bin, flip);

                if (hueObject != null)
                {
                    hueObject.ApplyTo(frames[i].Bitmap, onlyHueGrayPixels);
                }
            }

            return(frames);
        }