Ejemplo n.º 1
0
    // Deserialize and check Est Entries and add them to the list if they are non-default.
    private void DeserializeEstEntries(MetaFileInfo metaFileInfo, byte[]?data)
    {
        if (data == null)
        {
            return;
        }

        var num = data.Length / 6;

        using var reader = new BinaryReader(new MemoryStream(data));
        for (var i = 0; i < num; ++i)
        {
            var gr    = ( GenderRace )reader.ReadUInt16();
            var id    = reader.ReadUInt16();
            var value = reader.ReadUInt16();
            var type  = (metaFileInfo.SecondaryType, metaFileInfo.EquipSlot) switch
            {
                (BodySlot.Face, _) => EstManipulation.EstType.Face,
                (BodySlot.Hair, _) => EstManipulation.EstType.Hair,
                (_, EquipSlot.Head) => EstManipulation.EstType.Head,
                (_, EquipSlot.Body) => EstManipulation.EstType.Body,
                _ => (EstManipulation.EstType) 0,
            };
            if (!gr.IsValid() || type == 0)
            {
                continue;
            }

            var def = EstFile.GetDefault(type, gr, id);
            if (def != value)
            {
                MetaManipulations.Add(new EstManipulation(gr.Split().Item1, gr.Split().Item2, type, id, value));
            }
        }
Ejemplo n.º 2
0
 public void Write(DirectoryInfo dir)
 {
     byte[] data = Data switch
     {
         EqdpFile eqdp => eqdp.WriteBytes(),
         EqpFile eqp => eqp.WriteBytes(),
         GmpFile gmp => gmp.WriteBytes(),
         EstFile est => est.WriteBytes(),
         ImcFile imc => imc.WriteBytes(),
            _ => throw new NotImplementedException(),
     };
     DisposeFile(CurrentFile);
     CurrentFile = TempFile.WriteNew(dir, data);
     Changed     = false;
 }
Ejemplo n.º 3
0
            public void Write(DirectoryInfo dir, GamePath originalPath)
            {
                var data = Data switch
                {
                    EqdpFile eqdp => eqdp.WriteBytes(),
                    EqpFile eqp => eqp.WriteBytes(),
                    GmpFile gmp => gmp.WriteBytes(),
                    EstFile est => est.WriteBytes(),
                    ImcFile imc => imc.WriteBytes(),
                    CmpFile cmp => cmp.WriteBytes(),
                    _ => throw new NotImplementedException(),
                };

                DisposeFile(CurrentFile);
                CurrentFile = TempFile.WriteNew(dir, data, $"_{originalPath.Filename()}");
                Changed     = false;
            }
Ejemplo n.º 4
0
        public bool RevertMod(EstManipulation m)
        {
#if USE_EST
            if (Manipulations.Remove(m))
            {
                var def   = EstFile.GetDefault(m.Slot, Names.CombinedRace(m.Gender, m.Race), m.SetId);
                var manip = new EstManipulation(m.Gender, m.Race, m.Slot, m.SetId, def);
                var file  = m.Slot switch
                {
                    EstManipulation.EstType.Hair => HairFile !,
                    EstManipulation.EstType.Face => FaceFile !,
                    EstManipulation.EstType.Body => BodyFile !,
                    EstManipulation.EstType.Head => HeadFile !,
                    _ => throw new ArgumentOutOfRangeException(),
                };
                return(manip.Apply(file));
            }
#endif
            return(false);
        }