Пример #1
0
        //private void PreviewProps(int n)
        //{
        //    PCCObject.ExportEntry ent = pcc.Exports[n];
        //    List<SaltPropertyReader.Property> props = SaltPropertyReader.getPropList(pcc, ent.Data);
        //    rtb1.Visible = true;
        //    string s = "";
        //    s += "ObjectName : " + ent.ObjectName + "\n";
        //    s += "Class : " + ent.ClassName + "\n";
        //    s += "Data size : 0x" + ent.DataSize.ToString("X8") + "\n";
        //    s += "Data offset : 0x" + ent.DataOffset.ToString("X8") + "\n\nProperties: \n";
        //    foreach (SaltPropertyReader.Property p in props)
        //        s += SaltPropertyReader.PropertyToText(p, pcc) + "\n";

        //    if (ent.ClassName == "Texture2D" || ent.ClassName == "LightMapTexture2D" || ent.ClassName == "TextureFlipBook")
        //    {
        //        s += "\nImage Info: \n";
        //        try
        //        {
        //            Texture2D tex2D = new Texture2D(pcc, n, Path.Combine(ME2Directory.gamePath, "BIOGame"));
        //            for (int i = 0; i < tex2D.imgList.Count; i++)
        //            {
        //                s += i + ": Location: " + tex2D.imgList[i].storageType + ", Offset: " + tex2D.imgList[i].offset + ", ImgSize: " + tex2D.imgList[i].imgSize.ToString() + ", CprSize = " + tex2D.imgList[i].cprSize + ", UncSize = " + tex2D.imgList[i].uncSize + "\n";
        //            }
        //        }
        //        catch { }
        //    }

        //    rtb1.Text = s;
        //    Status.Text = ent.ClassName + " Offset: " + ent.DataOffset + " - " + (ent.DataOffset + ent.DataSize);
        //}

        public void PreviewProps()
        {
            int n = GetSelected();

            if (n == -1 || !(CurrentView == 2 || CurrentView == 3))
            {
                return;
            }
            List <SaltPropertyReader.Property> p;

            //propGrid.Visible = true;
            //hb1.Visible = false;
            //rtb1.Visible = false;
            //treeView1.Visible = false;
            switch (pcc.Exports[n].ClassName)
            {
            default:
                byte[] buff = pcc.Exports[n].Data;
                p = SaltPropertyReader.getPropList(pcc, buff);
                break;
            }
            pg = new PropGrid();
            propGrid.SelectedObject = pg;
            pg.Add(new CustomProperty("Name", "_Meta", pcc.Exports[n].ObjectName, typeof(string), true, true));
            pg.Add(new CustomProperty("Class", "_Meta", pcc.Exports[n].ClassName, typeof(string), true, true));
            pg.Add(new CustomProperty("Data Offset", "_Meta", pcc.Exports[n].DataOffset, typeof(int), true, true));
            pg.Add(new CustomProperty("Data Size", "_Meta", pcc.Exports[n].DataSize, typeof(int), true, true));
            for (int l = 0; l < p.Count; l++)
            {
                pg.Add(SaltPropertyReader.PropertyToGrid(p[l], pcc));
            }
            propGrid.Refresh();
            propGrid.ExpandAllGridItems();
            //UpdateStatusEx(n);
        }
Пример #2
0
        public void LoadData()
        {
            Save.ExtractME1Package(0, "temp.upk");
            PCCObject pcc = new PCCObject("temp.upk");

            File.Delete("temp.upk");
            byte[] buff = pcc.Exports[1].Data;
            List <SaltPropertyReader.Property> props = SaltPropertyReader.getPropList(pcc, buff);

            foreach (SaltPropertyReader.Property p in props)
            {
                string name = p.Name;
                switch (name)
                {
                case "m_nResourceCredits":
                    textBox1.Text = BitConverter.ToInt32(buff, p.offend - 4).ToString();
                    break;

                case "m_nResourceGrenades":
                    textBox2.Text = BitConverter.ToInt32(buff, p.offend - 4).ToString();
                    break;

                case "m_fResourceMedigel":
                    textBox3.Text = BitConverter.ToSingle(buff, p.offend - 4).ToString();
                    break;

                case "m_fResourceSalvage":
                    textBox4.Text = BitConverter.ToSingle(buff, p.offend - 4).ToString();
                    break;
                }
            }
            textBox5.Text = BitConverter.ToInt32(Save.Files[1].memory.ToArray(), 0x4A7).ToString(); //Paragon
            textBox6.Text = BitConverter.ToInt32(Save.Files[1].memory.ToArray(), 0x4A3).ToString(); //Renegade
        }
Пример #3
0
        public void LoadObjectsAlt(int index)
        {
            string   s = pcc.Exports[index].ObjectName;
            int      x = 0, y = 0;
            SaveData savedInfo;

            if (RefOrRefChild)
            {
                savedInfo = SavedPositions.FirstOrDefault(p => CurrentObjects.IndexOf(index) == p.index);
            }
            else
            {
                savedInfo = SavedPositions.FirstOrDefault(p => index == p.index);
            }

            List <SaltPropertyReader.Property> props = SaltPropertyReader.getPropList(pcc, pcc.Exports[index].Data);

            foreach (SaltPropertyReader.Property prop in props)
            {
                if (prop.Name == "ObjPosX")
                {
                    x = prop.Value.IntValue;
                }
                else if (prop.Name == "ObjPosY")
                {
                    y = prop.Value.IntValue;
                }
            }
            if (s.StartsWith("BioSeqEvt_") || s.StartsWith("SeqEvt_") || s.StartsWith("SFXSeqEvt_") || s.StartsWith("SeqEvent_"))
            {
                if (savedInfo.index == (RefOrRefChild ? CurrentObjects.IndexOf(index) : index))
                {
                    Objects.Add(new SEvent(index, savedInfo.X, savedInfo.Y, pcc, graphEditor));
                }
                else
                {
                    Objects.Add(new SEvent(index, x, y, pcc, graphEditor));
                }
            }
            else if (s.StartsWith("SeqVar_") || s.StartsWith("BioSeqVar_") || s.StartsWith("SFXSeqVar_") || s.StartsWith("InterpData"))
            {
                if (savedInfo.index == (RefOrRefChild ? CurrentObjects.IndexOf(index) : index))
                {
                    Objects.Add(new SVar(index, savedInfo.X, savedInfo.Y, pcc, graphEditor));
                }
                else
                {
                    Objects.Add(new SVar(index, x, y, pcc, graphEditor));
                }
            }
            else if (pcc.Exports[index].ClassName == "SequenceFrame")
            {
                Objects.Add(new SFrame(index, x, y, pcc, graphEditor));
            }
            else //if (s.StartsWith("BioSeqAct_") || s.StartsWith("SeqAct_") || s.StartsWith("SFXSeqAct_") || s.StartsWith("SeqCond_") || pcc.Exports[index].ClassName == "Sequence" || pcc.Exports[index].ClassName == "SequenceReference")
            {
                Objects.Add(new SAction(index, x, y, pcc, graphEditor));
            }
        }
Пример #4
0
        public TreeNode FindSequences(PCCObject pcc, int index, bool wantFullName = false, bool refSeq = false)
        {
            string objectName = "";

            if (refSeq)
            {
                List <SaltPropertyReader.Property> p = SaltPropertyReader.getPropList(pcc, pcc.Exports[index].Data);
                for (int i = 0; i < p.Count(); i++)
                {
                    if (p[i].Name == "ObjName")
                    {
                        objectName = p[i].Value.StringValue;
                        break;
                    }
                }
            }
            else
            {
                objectName = pcc.Exports[index].ObjectName;
            }
            TreeNode ret = new TreeNode("#" + index.ToString() + ": " + (wantFullName ? pcc.Exports[index].GetFullPath : objectName));

            ret.Name = index.ToString();
            Sequence seq = new Sequence(pcc, index);

            if (seq.SequenceObjects != null)
            {
                for (int i = 0; i < seq.SequenceObjects.Count(); i++)
                {
                    if (pcc.Exports[seq.SequenceObjects[i] - 1].ClassName == "Sequence" || pcc.Exports[seq.SequenceObjects[i] - 1].ClassName.StartsWith("PrefabSequence"))
                    {
                        TreeNode t = FindSequences(pcc, seq.SequenceObjects[i] - 1, wantFullName);
                        ret.Nodes.Add(t);
                    }
                    else if (pcc.Exports[seq.SequenceObjects[i] - 1].ClassName == "SequenceReference")
                    {
                        var props = SaltPropertyReader.getPropList(pcc, pcc.Exports[seq.SequenceObjects[i] - 1].Data);
                        var propSequenceReference = props.FirstOrDefault(p => p.Name.Equals("oSequenceReference"));
                        if (propSequenceReference != null)
                        {
                            int n = propSequenceReference.Value.IntValue;
                            if (propSequenceReference.Value.IntValue < 0)
                            {
                                n += 1;
                                TreeNode t = new TreeNode("#" + n.ToString() + ": " + pcc.Imports[-n].Name + "(Import)");
                                t.Name = n.ToString();
                                ret.Nodes.Add(t);
                            }
                            else
                            {
                                TreeNode t = FindSequences(pcc, propSequenceReference.Value.IntValue - 1, wantFullName, true);
                                ret.Nodes.Add(t);
                            }
                        }
                    }
                }
            }
            return(ret);
        }
Пример #5
0
        public void SaveData()
        {
            Save.ExtractME1Package(0, "temp.upk");
            PCCObject pcc = new PCCObject("temp.upk");

            File.Delete("temp.upk");
            byte[] buff = pcc.Exports[1].Data;
            List <SaltPropertyReader.Property> props = SaltPropertyReader.getPropList(pcc, buff);
            int   v;
            float f;

            foreach (SaltPropertyReader.Property p in props)
            {
                string name = p.Name;
                switch (name)
                {
                case "m_nResourceCredits":
                    v    = Convert.ToInt32(textBox1.Text);
                    buff = WriteInt(buff, p.offend - 4, v);
                    break;

                case "m_nResourceGrenades":
                    v    = Convert.ToInt32(textBox2.Text);
                    buff = WriteInt(buff, p.offend - 4, v);
                    break;

                case "m_fResourceMedigel":
                    f    = Convert.ToSingle(textBox3.Text);
                    buff = WriteFloat(buff, p.offend - 4, f);
                    break;

                case "m_fResourceSalvage":
                    f    = Convert.ToSingle(textBox4.Text);
                    buff = WriteFloat(buff, p.offend - 4, f);
                    break;
                }
            }
            pcc.Exports[1].Data = buff;
            pcc.SaveToFile("temp.upk");
            Save.ImportME1Package(0, "temp.upk");
            File.Delete("temp.upk");
            v    = Convert.ToInt32(textBox5.Text);
            buff = Save.Files[1].memory.ToArray();
            buff = WriteInt(buff, 0x4A7, v); //Paragon
            v    = Convert.ToInt32(textBox6.Text);
            buff = WriteInt(buff, 0x4A3, v); //Renegade
            SaveGame.SaveFileEntry e = Save.Files[1];
            e.memory      = new MemoryStream(buff);
            Save.Files[1] = e;
        }
Пример #6
0
        private void SetupJSON(int index)
        {
            string objectName = System.Text.RegularExpressions.Regex.Replace(pcc.Exports[index].ObjectName, @"[<>:""/\\|?*]", "");

            if (useGlobalSequenceRefSavesToolStripMenuItem.Checked && pcc.Exports[index].PackageFullName.Contains("SequenceReference"))
            {
                string packageName = pcc.Exports[index].PackageFullName.Substring(pcc.Exports[index].PackageFullName.LastIndexOf("SequenceReference"));
                packageName = packageName.Replace("SequenceReference", "");
                int    idx     = index;
                string ObjName = "";
                while (idx > 0)
                {
                    if (pcc.Exports[pcc.Exports[idx].LinkID - 1].ClassName == "SequenceReference")
                    {
                        List <SaltPropertyReader.Property> p = SaltPropertyReader.getPropList(pcc, pcc.Exports[idx].Data);
                        for (int i = 0; i < p.Count(); i++)
                        {
                            if (p[i].Name == "ObjName")
                            {
                                ObjName = p[i].Value.StringValue;
                                goto LoopOver;
                            }
                        }
                    }
                    idx = pcc.Exports[idx].LinkID - 1;
                }
LoopOver:
                if (objectName == "Sequence")
                {
                    objectName  = ObjName;
                    packageName = "." + packageName;
                }
                else
                {
                    packageName = packageName.Replace("Sequence", ObjName) + ".";
                }
                JSONpath      = ME2Directory.cookedPath + @"\SequenceViews\SequenceReference" + packageName + objectName + ".JSON";
                RefOrRefChild = true;
            }
            else
            {
                JSONpath      = ME2Directory.cookedPath + @"\SequenceViews\" + CurrentFile.Substring(CurrentFile.LastIndexOf(@"\") + 1) + ".#" + SequenceIndex + objectName + ".JSON";
                RefOrRefChild = false;
            }
        }