public BioAnimSetData(PCCObject Pcc, int Index)
        {
            pcc = Pcc;
            MyIndex = Index;
            if (pcc.isExport(Index))
                data = pcc.Exports[Index].Data;
            Props = PropertyReader.getPropList(pcc, data);
            BitConverter.IsLittleEndian = true;
            TrackBoneNames = new List<string>();
            UseTranslationBoneNames = new List<string>();
            foreach (PropertyReader.Property p in Props)
                switch (pcc.getNameEntry(p.Name))
                {

                    case "bAnimRotationOnly":
                        if (p.raw[p.raw.Length - 1] == 1)
                            bAnimRotationOnly = true;
                        break;
                    case "TrackBoneNames":
                        ReadTBN(p.raw);
                        break;
                    case "UseTranslationBoneNames":
                        ReadUTBN(p.raw);
                        break;
                }
        }
Example #2
0
        private static Type getType(PCCObject pcc, int type)
        {
            switch (pcc.getNameEntry(type))
            {
            case "None": return(Type.None);

            case "StructProperty": return(Type.StructProperty);

            case "IntProperty": return(Type.IntProperty);

            case "FloatProperty": return(Type.FloatProperty);

            case "ObjectProperty": return(Type.ObjectProperty);

            case "NameProperty": return(Type.NameProperty);

            case "BoolProperty": return(Type.BoolProperty);

            case "ByteProperty": return(Type.ByteProperty);

            case "ArrayProperty": return(Type.ArrayProperty);

            case "DelegateProperty": return(Type.DelegateProperty);

            case "StrProperty": return(Type.StrProperty);

            case "StringRefProperty": return(Type.StringRefProperty);

            default:
                return(Type.Unknown);
            }
        }
Example #3
0
        public static List <Property> getPropList(PCCObject pcc, PCCObject.ExportEntry export)
        {
            Application.DoEvents();
            int start = detectStart(pcc, export.Data, export.ObjectFlags);

            return(ReadProp(pcc, export.Data, start));
        }
Example #4
0
        public AnimNodeSlot(PCCObject Pcc, int Index)
        {
            pcc = Pcc;
            MyIndex = Index;
            if (pcc.isExport(Index))
                data = pcc.Exports[Index].Data;
            Props = PropertyReader.getPropList(pcc, data);
            BitConverter.IsLittleEndian = true;
            Children = new List<ChildrenEntry>();            
            foreach (PropertyReader.Property p in Props)
                switch (pcc.getNameEntry(p.Name))
                {

                    case "bSkipTickWhenZeroWeight":
                        if (p.raw[p.raw.Length - 1] == 1)
                            bSkipTickWhenZeroWeight = true;
                        break;
                    case "NodeName":
                        NodeName = p.Value.IntValue;
                        break;
                    case "NodeTotalWeight":
                        NodeTotalWeight = BitConverter.ToSingle(p.raw, p.raw.Length - 4);
                        break;
                    case "Children":
                        ReadChildren(p.raw);
                        break;
                }
        }
 private void openGUIDCacheToolStripMenuItem_Click(object sender, EventArgs e)
 {
     BitConverter.IsLittleEndian = true;
     pcc = new PCCObject(ME3Directory.cookedPath + "GuidCache.pcc");
     ReadGUIDs(pcc.Exports[0].Data);
     RefreshLists();
 }
Example #6
0
 public string DumpArray(PCCObject pcc,byte [] raw, int pos, string s, int depth)
 {
     string res = "";
     List<PropertyReader.Property> p = PropertyReader.ReadProp(pcc, raw, pos);
     for (int i = 0; i < p.Count; i++)
     {
         if (p[i].TypeVal == PropertyReader.Type.StringRefProperty)
         {
             for (int j = 0; j < depth; j++)
                 res += "\t";
             res += i + " : " + PropertyReader.PropertyToText(p[i], pcc) + "\n";
         }
         if (p[i].TypeVal == PropertyReader.Type.ArrayProperty)
         {
             //for (int j = 0; j < depth; j++)
             //    res += "\t";
             //res += "in Property #" + i + " : " + PropertyReader.PropertyToText(p[i], pcc) + "\n";
             res += DumpArray(pcc, raw, p[i].offsetval + 4, res, depth + 1);
         }
         if (p[i].TypeVal == PropertyReader.Type.StructProperty)
         {
             //for (int j = 0; j < depth; j++)
             //    res += "\t";
             //res += "in Property #" + i + " : " + PropertyReader.PropertyToText(p[i], pcc) + "\n";
             res += DumpArray(pcc, raw, p[i].offsetval + 8, res, depth + 1);
         }
     }
     return res;
 }
        public WwiseAmbientSound(PCCObject Pcc, int Index)
        {
            pcc = Pcc;
            MyIndex = Index;
            if (pcc.isExport(Index))
                data = pcc.Exports[Index].Data;
            Props = PropertyReader.getPropList(pcc, data);
            BitConverter.IsLittleEndian = true;
            foreach (PropertyReader.Property p in Props)
                switch (pcc.getNameEntry(p.Name))
                {

                    case "bAutoPlay":
                        if (p.raw[p.raw.Length - 1] == 1)
                            bAutoPlay = true;
                        break;
                    case "Tag":
                        Tag = p.Value.IntValue;
                        break;
                    case "UniqueTag":
                        UniqueTag = p.Value.IntValue;
                        break;
                    case "location":
                        location = new Vector3(BitConverter.ToSingle(p.raw, p.raw.Length - 12),
                                              BitConverter.ToSingle(p.raw, p.raw.Length - 8),
                                              BitConverter.ToSingle(p.raw, p.raw.Length - 4));
                        break;
                }
            MyMatrix = Matrix.Translation(location);
            GenerateMesh();
        }
Example #8
0
 private void startScanToolStripMenuItem_Click(object sender, EventArgs e)
 {
     string pathcook = ME3Directory.cookedPath;
     DebugOutput.StartDebugger("ScriptDB");
     string[] files = Directory.GetFiles(pathcook, "*.pcc");
     int count = 1;
     database = new List<ScriptEntry>();
     foreach (string file in files)
     {
         DebugOutput.PrintLn(count + "\\" + files.Length + " : Scanning " + Path.GetFileName(file) + " ...");
         PCCObject pcc = new PCCObject(file);
         int count2 = 0;
         foreach (PCCObject.ExportEntry ent in pcc.Exports)
         {
             if (ent.ClassName == "Function")
             {
                 Function f = new Function(ent.Data, pcc);
                 ScriptEntry n = new ScriptEntry();
                 n.file = Path.GetFileName(file);
                 n.name = ent.PackageFullName + "." + ent.ObjectName;
                 n.script = f.ToRawText(false);
                 database.Add(n);
                 DebugOutput.PrintLn("\tFound \"" + n.name + "\"",false);
             }
             count2++;
         }
         {
             pb1.Maximum = files.Length;
             pb1.Value = count;
         }
         count++;
     }
     RefreshList();
 }
Example #9
0
 public ExportEntry(PCCObject pccFile, byte[] importData, uint exportOffset)
 {
     pccRef     = pccFile;
     info       = (byte[])importData.Clone();
     offset     = exportOffset;
     hasChanged = false;
 }
Example #10
0
 public string ToString(PCCObject p)
 {
     if (val == -1)
         return enumName + ", " + values[0];
     else
         return p.getNameEntry(type) + ", " + p.getNameEntry(val);
 }
Example #11
0
        public AnimSet(PCCObject Pcc, int Index)
        {
            pcc = Pcc;
            MyIndex = Index;
            if (pcc.isExport(Index))
                data = pcc.Exports[Index].Data;
            Props = PropertyReader.getPropList(pcc, data);
            BitConverter.IsLittleEndian = true;
            Sequences = new List<int>();
            foreach (PropertyReader.Property p in Props)
                switch (pcc.getNameEntry(p.Name))
                {

                    case "PreviewSkelMeshName":
                        PreviewSkelMeshName = p.Value.IntValue;
                        break;
                    case "m_pBioAnimSetData":
                        m_pBioAnimSetData = p.Value.IntValue;
                        if (pcc.isExport(m_pBioAnimSetData - 1) && pcc.Exports[m_pBioAnimSetData - 1].ClassName == "BioAnimSetData")
                            SetData = new BioAnimSetData(pcc, m_pBioAnimSetData - 1);
                        break;
                    case "Sequences":
                        ReadSequences(p.raw);
                        break;
                }
        }
Example #12
0
 public Level(PCCObject Pcc, int index, bool SimpleRead = false)
 {
     memory = Pcc.Exports[index].Data;
     memlength = memory.Length;
     pcc = Pcc;
     Deserialize(SimpleRead);
 }
Example #13
0
        public AnimTree(PCCObject Pcc, int Index)
        {
            pcc = Pcc;
            MyIndex = Index;
            if (pcc.isExport(Index))
                data = pcc.Exports[Index].Data;
            Props = PropertyReader.getPropList(pcc, data);
            BitConverter.IsLittleEndian = true;
            AnimGroups = new List<AnimGroupEntry>();
            ComposePrePassBoneNames = new List<string>();
            SkelControlLists = new List<SkelControlListEntry>();
            Children = new List<ChildrenEntry>();
            BitConverter.IsLittleEndian = true;
            foreach (PropertyReader.Property p in Props)
                switch (pcc.getNameEntry(p.Name))
                {

                    case "NodeTotalWeight":
                        NodeTotalWeight = BitConverter.ToSingle(p.raw, p.raw.Length - 4);
                        break;
                    case "AnimGroups":
                        ReadAnimGroups(p.raw);
                        break;
                    case "ComposePrePassBoneNames":
                        ReadPrePassBoneNames(p.raw);
                        break;
                    case "SkelControlLists":
                        ReadSkelControlLists(p.raw);
                        break;
                    case "Children":
                        ReadChildren(p.raw);
                        break;
                }
        }
Example #14
0
        public static List <Property> getPropList(PCCObject pcc, byte[] raw)
        {
            Application.DoEvents();
            int start = detectStart(pcc, raw);

            return(ReadProp(pcc, raw, start));
        }
Example #15
0
 public WwiseStream(PCCObject Pcc, byte[] Raw)
 {
     pcc = Pcc;
     memory = Raw;
     memsize = memory.Length;
     Deserialize();
 }
        public StaticMeshCollectionActor(PCCObject Pcc, int Index)
        {
            pcc = Pcc;
            MyIndex = Index;
            if (pcc.isExport(Index))
                data = pcc.Exports[Index].Data;
            Props = PropertyReader.getPropList(pcc, data);
            BitConverter.IsLittleEndian = true;
            foreach (PropertyReader.Property p in Props)
                switch (pcc.getNameEntry(p.Name))
                {

                    case "bCanStepUpOn":
                        if (p.raw[p.raw.Length - 1] == 1)
                            bCanStepUpOn = true;
                        break;
                    case "Tag":
                        Tag = p.Value.IntValue;
                        break;
                    case "CreationTime":
                        CreationTime = BitConverter.ToSingle(p.raw, p.raw.Length - 4);
                        break;
                }
            ReadObjects();
            ReadMatrices();
        }
Example #17
0
        public MantleMarker(PCCObject Pcc, int Index)
        {
            pcc = Pcc;
            MyIndex = Index;
            if (pcc.isExport(Index))
                data = pcc.Exports[Index].Data;
            Props = PropertyReader.getPropList(pcc, data);
            BitConverter.IsLittleEndian = true;
            foreach (PropertyReader.Property p in Props)
                switch (pcc.getNameEntry(p.Name))
                {
                    #region
                    case "bHasCrossLevelPaths":
                        if (p.raw[p.raw.Length - 1] == 1)
                            bHasCrossLevelPaths = true;
                        break;
                    case "Tag":
                        Tag = p.Value.IntValue;
                        break;
                    case "nextNavigationPoint":
                        nextNavigationPoint = p.Value.IntValue;
                        break;
                    case "CylinderComponent":
                        CylinderComponent = p.Value.IntValue;
                        break;
                    case "Owner":
                        Owner = p.Value.IntValue;
                        break;
                    case "Base":
                        Base = p.Value.IntValue;
                        break;
                    case "CollisionComponent":
                        CollisionComponent = p.Value.IntValue;
                        break;
                    case "CreationTime":
                        CreationTime = BitConverter.ToSingle(p.raw, p.raw.Length - 4);
                        break;
                    case "visitedWeight":
                        visitedWeight = p.Value.IntValue;
                        break;
                    case "bestPathWeight":
                        bestPathWeight = p.Value.IntValue;
                        break;
                    case "NetworkID":
                        NetworkID = p.Value.IntValue;
                        break;
                    case "ApproximateLineOfFire":
                        ApproximateLineOfFire = p.Value.IntValue;
                        break;
                    case "location":
                        location = new Vector3(BitConverter.ToSingle(p.raw, p.raw.Length - 12),
                                              BitConverter.ToSingle(p.raw, p.raw.Length - 8),
                                              BitConverter.ToSingle(p.raw, p.raw.Length - 4));
                        break;
#endregion
                }
            MyMatrix = Matrix.Translation(location);
            GenerateMesh();
        }
Example #18
0
 public SAction(int idx, float x, float y, PCCObject p)
     : base(idx, x, y, p)
 {
     GetVarLinks();
     GetOutputLinks();
     originalX = x;
     originalY = y;
 }
Example #19
0
 public SAction(int idx, float x, float y, PCCObject p, GraphEditor grapheditor)
     : base(idx, x, y, p, grapheditor)
 {
     GetVarLinks();
     GetOutputLinks();
     originalX = x;
     originalY = y;
 }
Example #20
0
 public void LoadFile(string path)
 {
     pcc = new PCCObject(path);
     Objects = new List<int>();
     for (int i = 0; i < pcc.Exports.Count; i++)
         if (pcc.Exports[i].ClassName == "Function")
             Objects.Add(i);
     RefreshLists();
 }
Example #21
0
        public static CustomProperty PropertyToGrid(Property p, PCCObject pcc)
        {
            string         cat = p.TypeVal.ToString();
            CustomProperty pg;

            switch (p.TypeVal)
            {
            case Type.BoolProperty:
                pg = new CustomProperty(pcc.Names[p.Name], cat, (p.Value.IntValue == 1), typeof(bool), false, true);
                break;

            case Type.FloatProperty:
                byte[] buff = BitConverter.GetBytes(p.Value.IntValue);
                float  f    = BitConverter.ToSingle(buff, 0);
                pg = new CustomProperty(pcc.Names[p.Name], cat, f, typeof(float), false, true);
                break;

            case Type.ByteProperty:
            case Type.NameProperty:
                NameProp pp = new NameProp();
                pp.name      = pcc.getNameEntry(p.Value.IntValue);
                pp.nameindex = p.Value.IntValue;
                pg           = new CustomProperty(pcc.Names[p.Name], cat, pp, typeof(NameProp), false, true);
                break;

            case Type.ObjectProperty:
                ObjectProp ppo = new ObjectProp();
                ppo.name      = pcc.getObjectName(p.Value.IntValue);
                ppo.nameindex = p.Value.IntValue;
                pg            = new CustomProperty(pcc.Names[p.Name], cat, ppo, typeof(ObjectProp), false, true);
                break;

            case Type.StructProperty:
                StructProp ppp = new StructProp();
                ppp.name      = pcc.getNameEntry(p.Value.IntValue);
                ppp.nameindex = p.Value.IntValue;
                byte[] buf = new byte[p.Value.Array.Count()];
                for (int i = 0; i < p.Value.Array.Count(); i++)
                {
                    buf[i] = (byte)p.Value.Array[i].IntValue;
                }
                List <int> buf2 = new List <int>();
                for (int i = 0; i < p.Value.Array.Count() / 4; i++)
                {
                    buf2.Add(BitConverter.ToInt32(buf, i * 4));
                }
                ppp.data = buf2.ToArray();
                pg       = new CustomProperty(pcc.Names[p.Name], cat, ppp, typeof(StructProp), false, true);
                break;

            default:
                pg = new CustomProperty(pcc.Names[p.Name], cat, p.Value.IntValue, typeof(int), false, true);
                break;
            }
            return(pg);
        }
Example #22
0
 private void openPccToolStripMenuItem_Click(object sender, EventArgs e)
 {
     OpenFileDialog d = new OpenFileDialog();
     d.Filter = "*.pcc|*.pcc";
     if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         pcc = new PCCObject(d.FileName);
         ListRefresh();
     }
 }
Example #23
0
 public void LoadPCC(string fileName)
 {
     objects.Clear();
     pcc = new PCCObject(fileName);
     CurrentFile = fileName;
     for (int i = 0; i < pcc.Exports.Count; i++)
         if (pcc.Exports[i].ClassName == "InterpData")
             objects.Add(i);
     RefreshCombo();
 }
Example #24
0
 public void LoadPCC(string path)
 {
     MeshplorerMode = 0;
     CurrFile = path;
     pcc = new PCCObject(path);
     Materials = new List<int>();
     for (int i = 0; i < pcc.Exports.Count; i++)
         if (pcc.Exports[i].ClassName == "Material" || pcc.Exports[i].ClassName == "MaterialInstanceConstant")
             Materials.Add(i);
     RefreshList1();
 }
Example #25
0
 /*
  * This method is called when using the -decompresspcc command line argument
  */
 private int autoDecompressPcc(string sourceFile, string outputFile)
 {
     if (!File.Exists(sourceFile)){
         MessageBox.Show("PCC to decompress does not exist:\n" + sourceFile, "Auto Decompression Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return 1;
     }
     System.Console.WriteLine("Automating Pcc Decompressor: " + sourceFile + " => " + outputFile);
     PCCObject pccObj = new PCCObject(sourceFile);
     pccObj.saveToFile(outputFile,false);
     return 0;
 }
Example #26
0
 private void startScanToolStripMenuItem_Click(object sender, EventArgs e)
 {
     string path = ME3Directory.cookedPath;
     string[] files = Directory.GetFiles(path, "*.pcc");
     pb1.Maximum = files.Length;
     DebugOutput.Clear();
     database = new List<DBEntry>();
     int count = 0;
     foreach (string file in files)
     {
         pb1.Value = count++;
         DebugOutput.PrintLn("Scanning file : " + Path.GetFileName(file) + " ...");
         PCCObject pcc = new PCCObject(file);
         DBEntry ent = new DBEntry();
         ent.filename = Path.GetFileName(file);
         ent.Objects = new List<ObjInf>();
         for (int i = 0; i < pcc.Exports.Count; i++)
         {
             PCCObject.ExportEntry ex = pcc.Exports[i];
             ObjInf obj;
             switch (ex.ClassName)
             {
                 case "StaticMesh":
                     obj = new ObjInf();
                     obj.Index = i;
                     obj.Type = 0;
                     obj.name = ex.ObjectName;
                     ent.Objects.Add(obj);
                     break;
                 case "SkeletalMesh":
                     obj = new ObjInf();
                     obj.Index = i;
                     obj.Type = 1;
                     obj.name = ex.ObjectName;
                     ent.Objects.Add(obj);
                     break;
             }
         }
         if (ent.Objects.Count != 0)
         {
             DebugOutput.PrintLn("Found " + ent.Objects.Count + " Objects:", false);
             //foreach (ObjInf o in ent.Objects)
             //    DebugOutput.PrintLn("\t" + o.Index + " : " + o.name + " (" + TypeToString(o.Type) + ")", false);
             //DebugOutput.Update();
             database.Add(ent);
         }
         else
         {
             DebugOutput.PrintLn("Nothing...", false);
         }
     }
     RefreshLists();
     pb1.Value = 0;
 }
 public SObj(int idx, float x, float y, PCCObject p)
     : base()
 {
     pcc = p;
     index = idx;
     comment = new SText(GetComment(index), commentColor, false);
     comment.X = 0;
     comment.Y = 0 - comment.Height;
     comment.Pickable = false;
     this.AddChild(comment);
     this.Pickable = true;
 }
Example #28
0
 public TreeNode ToTree(string name, PCCObject pcc)
 {
     TreeNode root = new TreeNode(name);
     TreeNode t = new TreeNode("Points");
     if(Points != null)
     {
         for (int i = 0; i < Points.Count; i++)
             t.Nodes.Add(Points[i].ToTree(i, pcc));
     }
     root.Nodes.Add(t);
     return root;
 }
Example #29
0
        private void buttonCompressPCC_Click(object sender, EventArgs e)
        {
            if (openPccDialog.ShowDialog() == DialogResult.OK)
            {
                string fileName = openPccDialog.FileName;
                string backupFile = fileName + ".bak";
                if (File.Exists(fileName))
                {
                    DialogResult dialogResult = MessageBox.Show("Do you want to make a backup file?", "Make Backup", MessageBoxButtons.YesNo);
                    try
                    {
                        if (dialogResult == DialogResult.Yes)
                        {
                            File.Copy(fileName, backupFile);
                        }

                        PCCObject pccObj = new PCCObject(fileName);
                        pccObj.saveToFile(true);

                        //PCCObject pccFile = new PCCObject();
                        //pccFile.LoadFile(fileName);
                        /*main function that compress the file
                        PCCHandler.CompressAndSave(pccFile.SaveFile(),fileName);*/
                        /*byte[] buffer;
                        using (FileStream inputStream = File.OpenRead(fileName))
                        {
                            buffer = new byte[inputStream.Length];
                            inputStream.Read(buffer, 0, buffer.Length);
                        }
                        if (dialogResult == DialogResult.Yes)
                        {
                            File.Copy(fileName, backupFile);
                        }

                        //main function that compress the file
                        PCCHandler.CompressAndSave(buffer,fileName);*/


                        MessageBox.Show("File " + Path.GetFileName(fileName) + " was successfully compressed.", "Succeed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show("An error occurred while compressing " + Path.GetFileName(fileName) + ":\n" + exc.Message, "Exception Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        //recovering backup file
                        if (File.Exists(backupFile))
                        {
                            File.Delete(fileName);
                            File.Move(backupFile, fileName);
                        }
                    }
                }
            }
        }
Example #30
0
        public DecalActor(PCCObject Pcc, int Index)
        {
            pcc = Pcc;
            MyIndex = Index;
            if (pcc.isExport(Index))
                data = pcc.Exports[Index].Data;
            Props = PropertyReader.getPropList(pcc, data);
            BitConverter.IsLittleEndian = true;
            foreach (PropertyReader.Property p in Props)
                switch (pcc.getNameEntry(p.Name))
                {

                    case "bCanStepUpOn":
                        if (p.raw[p.raw.Length - 1] == 1)
                            bCanStepUpOn = true;
                        break;
                    case "Tag":
                        Tag = p.Value.IntValue;
                        break;
                    case "Group":
                        Group = p.Value.IntValue;
                        break;
                    case "Decal":
                        Decal = p.Value.IntValue;
                        break;
                    case "DrawScale":
                        DrawScale = BitConverter.ToSingle(p.raw, p.raw.Length - 4);
                        break;
                    case "DrawScale3D":
                        DrawScale3D = new Vector3(BitConverter.ToSingle(p.raw, p.raw.Length - 12),
                                              BitConverter.ToSingle(p.raw, p.raw.Length - 8),
                                              BitConverter.ToSingle(p.raw, p.raw.Length - 4));
                        break;
                    case "Rotation":
                        Rotator = new Vector3(BitConverter.ToInt32(p.raw, p.raw.Length - 12),
                                              BitConverter.ToInt32(p.raw, p.raw.Length - 8),
                                              BitConverter.ToInt32(p.raw, p.raw.Length - 4));
                        break;
                    case "location":
                        location = new Vector3(BitConverter.ToSingle(p.raw, p.raw.Length - 12),
                                              BitConverter.ToSingle(p.raw, p.raw.Length - 8),
                                              BitConverter.ToSingle(p.raw, p.raw.Length - 4));
                        break;
                }
            if (pcc.isExport(Decal - 1) && pcc.Exports[Decal - 1].ClassName == "DecalComponent")
                DC = new DecalComponent(pcc, Decal - 1);
            MyMatrix = Matrix.Identity;
            MyMatrix *= Matrix.Scaling(DrawScale3D);
            MyMatrix *= Matrix.Scaling(new Vector3(DrawScale, DrawScale, DrawScale));
            Vector3 rot = RotatorToDX(Rotator);
            MyMatrix *= Matrix.RotationYawPitchRoll(rot.X, rot.Y, rot.Z);
            MyMatrix *= Matrix.Translation(location);
        }
Example #31
0
 private void loadToolStripMenuItem_Click(object sender, EventArgs e)
 {
     OpenFileDialog d = new OpenFileDialog();
     d.Filter = "PCC Files(*.pcc)|*.pcc";
     if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         status.Text = "Loaded : " + d.FileName;
         pcc = new PCCObject(d.FileName);
         CurrentFile = d.FileName;
         LoadMaterials();
     }
 }
Example #32
0
 public void CreateDataBase()
 {
     if (String.IsNullOrEmpty(ME3Directory.cookedPath))
     {
         MessageBox.Show("This functionality requires ME3 to be installed. Set its path at:\n Options > Set Custom Path > Mass Effect 3");
         return;
     }
     FileStream fs = new FileStream(DataBaseFile, FileMode.Create, FileAccess.Write);
     string pathcook = ME3Directory.cookedPath;
     DebugOutput.Clear();
     DebugOutput.PrintLn("Levelbase.cs: Loading files from :" + pathcook);
     string[] files = Directory.GetFiles(pathcook, "*.pcc");
     for (int i = 0; i < files.Length; i++)
     {
         string file = files[i];
         DebugOutput.PrintLn(i + "/" + (files.Length - 1) + " Scanning : " + Path.GetFileName(file));
         PCCObject pcc = new PCCObject(file);
         for (int j = 0; j < pcc.Exports.Count(); j++)
         {
             PCCObject.ExportEntry e = pcc.Exports[j];
             if (e.ClassName == "Level")
             {
                 Level l = new Level(pcc, j, true);
                 DBEntry entry = new DBEntry();
                 entry.filepath = file;
                 entry.index = j;
                 entry.count = l.Objects.Count();
                 database.Add(entry);
                 //foreach(int idx in l.Objects)
                 //    if (pcc.isExport(idx) && pcc.Exports[idx].ClassName == "BioPlaypenVolumeAdditive")
                 //        DebugOutput.PrintLn("#############################found");
                 DebugOutput.PrintLn("\tfound Level with " + entry.count + " Objects");
             }
         }
     }
     database.Sort((a,b) => a.filepath.CompareTo(b.filepath));
     BitConverter.IsLittleEndian = true;
     byte[] buff = BitConverter.GetBytes(database.Count());
     fs.Write(buff, 0, 4);
     foreach (DBEntry e in database)
     {
         buff = BitConverter.GetBytes(e.index);
         fs.Write(buff, 0, 4);
         buff = BitConverter.GetBytes(e.count);
         fs.Write(buff, 0, 4);
         buff = BitConverter.GetBytes(e.filepath.Length);
         fs.Write(buff, 0, 4);
         foreach (char c in e.filepath)
             fs.WriteByte((byte)c);
     }
     fs.Close();
 }
Example #33
0
 private void QMapEditor_Activated(object sender, EventArgs e)
 {
     string pathcook = ME3Directory.cookedPath;
     if (!File.Exists(pathcook + "SFXGameInfoSP_SF.pcc"))
     {
         MessageBox.Show("File SFXGameInfoSP_SF.pcc not found!");
         this.Close();
         return;
     }
     pcc = new PCCObject(pathcook + "SFXGameInfoSP_SF.pcc");
     GetEntries();
     RefreshTree();
 }
Example #34
0
 public PCCObject.ExportEntry CopyExport(PCCObject.ExportEntry exp)
 {
     PCCObject.ExportEntry ret = new PCCObject.ExportEntry(pcc, exp.Data, exp.offset);
     //ret.childs = exp.childs;
     //ret.ClassName = exp.ClassName;
     //ret.Data = CopyArray(exp.Data);
     //ret.DataSize = exp.DataSize;
     //ret.Link = exp.Link;
     //ret.ObjectName = exp.ObjectName;
     //ret.off = exp.off;
     //ret.raw = CopyArray(exp.raw);
     return ret;
 }
 public TreeNode ToTree(int MyIndex, TalkFile talk, PCCObject pcc)
 {
     string s = "";
     if (Text.Length != 0)
         s = Text.Substring(0, Text.Length - 1);
     TreeNode res = new TreeNode(MyIndex + " : " + s + "  " + talk.findDataById(refText));
     TreeNode t = new TreeNode("Reply List");
     for (int i = 0; i < ReplyList.Count; i++)
     {
         EntryListReplyListStruct e = ReplyList[i];
         string par = e.Paraphrase;
         if (par.Length != 0 && par[par.Length - 1] == '\0')
             par = par.Substring(0, par.Length - 1);
         t.Nodes.Add(i + " : " 
                       + par
                       + " " 
                       + e.refParaphrase 
                       + " " 
                       + talk.findDataById(e.refParaphrase) 
                       + " " 
                       + e.Index 
                       + " " 
                       + pcc.getNameEntry(e.CategoryType)
                       + " " 
                       + pcc.getNameEntry(e.CategoryValue));
     }
     res.Nodes.Add(t);
     TreeNode t2 = new TreeNode("Speaker List");
     for (int i = 0; i < SpeakerList.Count; i++)
         t2.Nodes.Add(i + " : " + SpeakerList[i]);
     res.Nodes.Add(t2);
     res.Nodes.Add("SpeakerIndex : " + SpeakerIndex);
     res.Nodes.Add("ListenerIndex : " + ListenerIndex);
     res.Nodes.Add("ConditionalFunc : " + ConditionalFunc);
     res.Nodes.Add("ConditionalParam : " + ConditionalParam);
     res.Nodes.Add("StateTransition : " + StateTransition);
     res.Nodes.Add("StateTransitionParam : " + StateTransitionParam);
     res.Nodes.Add("ExportID : " + ExportID);
     res.Nodes.Add("ScriptIndex : " + ScriptIndex);
     res.Nodes.Add("CameraIntimacy : " + CameraIntimacy);
     res.Nodes.Add("Skippable : " + Skippable);
     res.Nodes.Add("FireConditional : " + FireConditional);
     res.Nodes.Add("Ambient : " + Ambient);
     res.Nodes.Add("NonTextline : " + NonTextline);
     res.Nodes.Add("IgnoreBodyGestures : " + IgnoreBodyGestures);
     res.Nodes.Add("AlwaysHideSubtitle : " + AlwaysHideSubtitle);
     res.Nodes.Add("Text : " + Text);
     res.Nodes.Add("refText : " + refText + " " + talk.findDataById(refText));
     res.Nodes.Add("GUIStyle : (" + pcc.getNameEntry(GUIStyleType) + ") " + pcc.getNameEntry(GUIStyleValue));
     return res;
 }
Example #36
0
        public static string PropertyToText(Property p, PCCObject pcc)
        {
            string s = "";

            s  = "Name: " + pcc.Names[p.Name];
            s += " Type: " + TypeToString((int)p.TypeVal);
            s += " Size: " + p.Value.len.ToString();
            switch (p.TypeVal)
            {
            case Type.StructProperty:
                s += " \"" + pcc.getNameEntry(p.Value.IntValue) + "\" with " + p.Value.Array.Count.ToString() + " bytes";
                break;

            case Type.IntProperty:
            case Type.ObjectProperty:
            case Type.BoolProperty:
            case Type.StringRefProperty:
                s += " Value: " + p.Value.IntValue.ToString();
                break;

            case Type.FloatProperty:
                byte[] buff = BitConverter.GetBytes(p.Value.IntValue);
                float  f    = BitConverter.ToSingle(buff, 0);
                s += " Value: " + f.ToString();
                break;

            case Type.NameProperty:
                s += " " + pcc.Names[p.Value.IntValue];
                break;

            case Type.ByteProperty:
                s += " Value: \"" + p.Value.StringValue + "\" with \"" + pcc.getNameEntry(p.Value.IntValue) + "\"";
                break;

            case Type.ArrayProperty:
                s += " bytes";     //Value: " + p.Value.Array.Count.ToString() + " Elements";
                break;

            case Type.StrProperty:
                if (p.Value.StringValue.Length == 0)
                {
                    break;
                }
                s += " Value: " + p.Value.StringValue.Substring(0, p.Value.StringValue.Length - 1);
                break;
            }
            return(s);
        }
Example #37
0
        public static int detectStart(PCCObject pcc, byte[] raw, long flags)
        {
            if ((flags & (long)UnrealFlags.EObjectFlags.HasStack) != 0)
            {
                return(30);
            }
            int result = 8;
            int test1  = BitConverter.ToInt32(raw, 4);
            int test2  = BitConverter.ToInt32(raw, 8);

            if (pcc.isName(test1) && test2 == 0)
            {
                result = 4;
            }
            if (pcc.isName(test1) && pcc.isName(test2) && test2 != 0)
            {
                result = 8;
            }
            return(result);
        }
Example #38
0
        private static PropertyValue ReadValue(PCCObject pcc, byte[] raw, int start, int type)
        {
            PropertyValue v = new PropertyValue();

            switch (pcc.Names[type])
            {
            case "IntProperty":
            case "FloatProperty":
            case "ObjectProperty":
            case "StringRefProperty":
                v.IntValue = BitConverter.ToInt32(raw, start);
                v.len      = 4;
                break;

            case "NameProperty":
                v.IntValue = BitConverter.ToInt32(raw, start);
                var nameRef = new NameReference();
                nameRef.index = v.IntValue;
                nameRef.count = BitConverter.ToInt32(raw, start + 4);
                nameRef.Name  = pcc.getNameEntry(nameRef.index);
                if (nameRef.count > 0)
                {
                    nameRef.Name += "_" + (nameRef.count - 1);
                }
                v.NameValue = nameRef;
                v.len       = 8;
                break;

            case "BoolProperty":
                if (start < raw.Length)
                {
                    v.IntValue = raw[start];
                }
                v.len = 1;
                break;
            }
            return(v);
        }
Example #39
0
        public static int detectStart(PCCObject pcc, byte[] raw)
        {
            int result = 8;
            int test1  = BitConverter.ToInt32(raw, 4);

            if (test1 < 0)
            {
                result = 30;
            }
            else
            {
                int test2 = BitConverter.ToInt32(raw, 8);
                if (pcc.isName(test1) && test2 == 0)
                {
                    result = 4;
                }
                if (pcc.isName(test1) && pcc.isName(test2) && test2 != 0)
                {
                    result = 8;
                }
            }
            return(result);
        }
 public ImportEntry(PCCObject pccFile, Stream importData)
 {
     pccRef = pccFile;
     header = new byte[ImportEntry.byteSize];
     importData.Read(header, 0, header.Length);
 }
Example #41
0
        public static List <Property> ReadProp(PCCObject pcc, byte[] raw, int start)
        {
            Property        p;
            PropertyValue   v;
            int             sname;
            List <Property> result = new List <Property>();
            int             pos    = start;

            if (raw.Length - pos < 8)
            {
                return(result);
            }
            int name = (int)BitConverter.ToInt64(raw, pos);

            if (!pcc.isName(name))
            {
                return(result);
            }
            string t = pcc.Names[name];

            if (pcc.Names[name] == "None")
            {
                p           = new Property();
                p.Name      = name;
                p.TypeVal   = Type.None;
                p.i         = 0;
                p.offsetval = pos;
                p.Size      = 8;
                p.Value     = new PropertyValue();
                p.raw       = BitConverter.GetBytes((Int64)name);
                p.offend    = pos + 8;
                result.Add(p);
                return(result);
            }
            int type = (int)BitConverter.ToInt64(raw, pos + 8);
            int size = BitConverter.ToInt32(raw, pos + 16);
            int idx  = BitConverter.ToInt32(raw, pos + 20);

            if (!pcc.isName(type) || size < 0 || size >= raw.Length)
            {
                return(result);
            }
            string tp = pcc.Names[type];

            switch (tp)
            {
            case "DelegateProperty":
                p           = new Property();
                p.Name      = name;
                p.TypeVal   = Type.DelegateProperty;
                p.i         = 0;
                p.offsetval = pos + 24;
                v           = new PropertyValue();
                v.IntValue  = BitConverter.ToInt32(raw, pos + 28);
                v.len       = size;
                v.Array     = new List <PropertyValue>();
                pos        += 24;
                for (int i = 0; i < size; i++)
                {
                    PropertyValue v2 = new PropertyValue();
                    if (pos < raw.Length)
                    {
                        v2.IntValue = raw[pos];
                    }
                    v.Array.Add(v2);
                    pos++;
                }
                p.Value = v;
                break;

            case "ArrayProperty":
                int count = (int)BitConverter.ToInt64(raw, pos + 24);
                p           = new Property();
                p.Name      = name;
                p.TypeVal   = Type.ArrayProperty;
                p.i         = 0;
                p.offsetval = pos + 24;
                v           = new PropertyValue();
                v.IntValue  = type;
                v.len       = size - 4;
                count       = v.len;//TODO can be other objects too
                v.Array     = new List <PropertyValue>();
                pos        += 28;
                for (int i = 0; i < count; i++)
                {
                    PropertyValue v2 = new PropertyValue();
                    if (pos < raw.Length)
                    {
                        v2.IntValue = raw[pos];
                    }
                    v.Array.Add(v2);
                    pos++;
                }
                p.Value = v;
                break;

            case "StrProperty":
                count       = (int)BitConverter.ToInt64(raw, pos + 24);
                p           = new Property();
                p.Name      = name;
                p.TypeVal   = Type.StrProperty;
                p.i         = 0;
                p.offsetval = pos + 24;
                count      *= -1;
                v           = new PropertyValue();
                v.IntValue  = type;
                v.len       = count;
                pos        += 28;
                string s = "";
                for (int i = 0; i < count; i++)
                {
                    s   += (char)raw[pos];
                    pos += 2;
                }
                v.StringValue = s;
                p.Value       = v;
                break;

            case "StructProperty":
                sname       = (int)BitConverter.ToInt64(raw, pos + 24);
                p           = new Property();
                p.Name      = name;
                p.TypeVal   = Type.StructProperty;
                p.i         = 0;
                p.offsetval = pos + 24;
                v           = new PropertyValue();
                v.IntValue  = sname;
                v.len       = size;
                v.Array     = new List <PropertyValue>();
                pos        += 32;
                for (int i = 0; i < size; i++)
                {
                    PropertyValue v2 = new PropertyValue();
                    if (pos < raw.Length)
                    {
                        v2.IntValue = raw[pos];
                    }
                    v.Array.Add(v2);
                    pos++;
                }
                p.Value = v;
                break;

            case "ByteProperty":
                sname         = (int)BitConverter.ToInt64(raw, pos + 24);
                p             = new Property();
                p.Name        = name;
                p.TypeVal     = Type.ByteProperty;
                p.i           = 0;
                p.offsetval   = pos + 32;
                v             = new PropertyValue();
                v.StringValue = pcc.getNameEntry(sname);
                v.len         = size;
                pos          += 32;
                v.IntValue    = (int)BitConverter.ToInt64(raw, pos);
                pos          += size;
                p.Value       = v;
                break;

            default:
                p           = new Property();
                p.Name      = name;
                p.TypeVal   = getType(pcc, type);
                p.i         = 0;
                p.offsetval = pos + 24;
                p.Value     = ReadValue(pcc, raw, pos + 24, type);
                pos        += p.Value.len + 24;
                break;
            }
            p.raw    = new byte[pos - start];
            p.offend = pos;
            if (pos < raw.Length)
            {
                for (int i = 0; i < pos - start; i++)
                {
                    p.raw[i] = raw[start + i];
                }
            }
            result.Add(p);
            if (pos != start)
            {
                result.AddRange(ReadProp(pcc, raw, pos));
            }
            return(result);
        }
Example #42
0
        public static CustomProperty PropertyToGrid(Property p, PCCObject pcc)
        {
            string         cat = p.TypeVal.ToString();
            CustomProperty pg;

            switch (p.TypeVal)
            {
            case Type.BoolProperty:
                pg = new CustomProperty(pcc.Names[p.Name], cat, (p.Value.IntValue == 1), typeof(bool), false, true);
                break;

            case Type.FloatProperty:
                byte[] buff = BitConverter.GetBytes(p.Value.IntValue);
                float  f    = BitConverter.ToSingle(buff, 0);
                pg = new CustomProperty(pcc.Names[p.Name], cat, f, typeof(float), false, true);
                break;

            case Type.ByteProperty:
            case Type.NameProperty:
                NameProp pp = new NameProp();
                pp.name      = pcc.getNameEntry(p.Value.IntValue);
                pp.nameindex = p.Value.IntValue;
                pg           = new CustomProperty(pcc.Names[p.Name], cat, pp, typeof(NameProp), false, true);
                break;

            case Type.ObjectProperty:
                ObjectProp ppo = new ObjectProp();
                ppo.name      = pcc.getObjectName(p.Value.IntValue);
                ppo.nameindex = p.Value.IntValue;
                pg            = new CustomProperty(pcc.Names[p.Name], cat, ppo, typeof(ObjectProp), false, true);
                break;

            case Type.StrProperty:
                pg = new CustomProperty(pcc.Names[p.Name], cat, p.Value.StringValue, typeof(string), false, true);
                break;

            case Type.ArrayProperty:
                pg = new CustomProperty(pcc.Names[p.Name], cat, BitConverter.ToInt32(p.raw, 24) + " elements", typeof(string), false, true);
                break;

            case Type.StructProperty:
                string structType = pcc.getNameEntry(p.Value.IntValue);
                if (structType == "Color")
                {
                    ColorProp cp = new ColorProp();
                    cp.name      = structType;
                    cp.nameindex = p.Value.IntValue;
                    System.Drawing.Color color = System.Drawing.Color.FromArgb(BitConverter.ToInt32(p.raw, 32));
                    cp.Alpha = color.A;
                    cp.Red   = color.R;
                    cp.Green = color.G;
                    cp.Blue  = color.B;
                    pg       = new CustomProperty(pcc.Names[p.Name], cat, cp, typeof(ColorProp), false, true);
                }
                else if (structType == "Vector")
                {
                    VectorProp vp = new VectorProp();
                    vp.name      = structType;
                    vp.nameindex = p.Value.IntValue;
                    vp.X         = BitConverter.ToSingle(p.raw, 32);
                    vp.Y         = BitConverter.ToSingle(p.raw, 36);
                    vp.Z         = BitConverter.ToSingle(p.raw, 40);
                    pg           = new CustomProperty(pcc.Names[p.Name], cat, vp, typeof(VectorProp), false, true);
                }
                else if (structType == "Rotator")
                {
                    RotatorProp rp = new RotatorProp();
                    rp.name      = structType;
                    rp.nameindex = p.Value.IntValue;
                    rp.Pitch     = (float)BitConverter.ToInt32(p.raw, 32) * 360f / 65536f;
                    rp.Yaw       = (float)BitConverter.ToInt32(p.raw, 36) * 360f / 65536f;
                    rp.Roll      = (float)BitConverter.ToInt32(p.raw, 40) * 360f / 65536f;
                    pg           = new CustomProperty(pcc.Names[p.Name], cat, rp, typeof(RotatorProp), false, true);
                }
                else if (structType == "LinearColor")
                {
                    LinearColorProp lcp = new LinearColorProp();
                    lcp.name      = structType;
                    lcp.nameindex = p.Value.IntValue;
                    lcp.Red       = BitConverter.ToSingle(p.raw, 32);
                    lcp.Green     = BitConverter.ToSingle(p.raw, 36);
                    lcp.Blue      = BitConverter.ToSingle(p.raw, 40);
                    lcp.Alpha     = BitConverter.ToSingle(p.raw, 44);
                    pg            = new CustomProperty(pcc.Names[p.Name], cat, lcp, typeof(VectorProp), false, true);
                }
                else
                {
                    StructProp ppp = new StructProp();
                    ppp.name      = structType;
                    ppp.nameindex = p.Value.IntValue;
                    byte[] buf = new byte[p.Value.Array.Count()];
                    for (int i = 0; i < p.Value.Array.Count(); i++)
                    {
                        buf[i] = (byte)p.Value.Array[i].IntValue;
                    }
                    List <int> buf2 = new List <int>();
                    for (int i = 0; i < p.Value.Array.Count() / 4; i++)
                    {
                        buf2.Add(BitConverter.ToInt32(buf, i * 4));
                    }
                    ppp.data = buf2.ToArray();
                    pg       = new CustomProperty(pcc.Names[p.Name], cat, ppp, typeof(StructProp), false, true);
                }
                break;

            default:
                pg = new CustomProperty(pcc.Names[p.Name], cat, p.Value.IntValue, typeof(int), false, true);
                break;
            }
            return(pg);
        }
Example #43
0
 public ImportEntry(PCCObject pccFile, byte[] importData)
 {
     pccRef = pccFile;
     data   = (byte[])importData.Clone();
 }
Example #44
0
 public ImportEntry(PCCObject pccFile, Stream importData)
 {
     pccRef = pccFile;
     data   = new byte[ImportEntry.byteSize];
     importData.Read(data, 0, data.Length);
 }