示例#1
0
        public string GenerateTree(string template, ClassDef c)
        {
            string t   = template;
            string rep = "";

            foreach (PropDef p in c.props)
            {
                string type = PropertyReader.TypeToString(p.type);
                switch (type)
                {
                case "Object Property":
                case "Integer Property":
                case "Bool Property":
                case "Float Property":
                    rep += "\t\t\tres.Nodes.Add(\"" + p.name + " : \" + " + p.name + ");\r\n";
                    break;

                case "Name Property":
                case "Byte Property":
                    rep += "\t\t\tres.Nodes.Add(\"" + p.name + " : \" + pcc.getNameEntry(" + p.name + "));\r\n";
                    break;
                }
            }
            return(t.Replace("**TREEGEN**", rep));
        }
示例#2
0
        public string GenerateLoadSwitch(string template, ClassDef c)
        {
            string t   = template;
            string rep = "";

            foreach (PropDef p in c.props)
            {
                string type = PropertyReader.TypeToString(p.type);
                switch (type)
                {
                case "Bool Property":
                    rep += "\t\t\t\t\tcase \"" + p.name + "\":\r\n";
                    rep += "\t\t\t\t\t\tif (p.raw[p.raw.Length - 1] == 1)\r\n";
                    rep += "\t\t\t\t\t\t" + p.name + " = true;\r\n";
                    rep += "\t\t\t\t\t\tbreak;\r\n";
                    break;

                case "Integer Property":
                case "Object Property":
                case "Name Property":
                case "Byte Property":
                    rep += "\t\t\t\t\tcase \"" + p.name + "\":\r\n";
                    rep += "\t\t\t\t\t\t" + p.name + " = p.Value.IntValue;\r\n";
                    rep += "\t\t\t\t\t\tbreak;\r\n";
                    break;

                case "Float Property":
                    rep += "\t\t\t\t\tcase \"" + p.name + "\":\r\n";
                    rep += "\t\t\t\t\t\t" + p.name + " = BitConverter.ToSingle(p.raw, p.raw.Length - 4);\r\n";
                    rep += "\t\t\t\t\t\tbreak;\r\n";
                    break;
                }
            }
            return(t.Replace("**LOADINGSWITCH**", rep));
        }
示例#3
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            ClassDef c = Classes[n];

            listBox2.Items.Clear();
            foreach (PropDef p in c.props)
            {
                listBox2.Items.Add(p.name + " : " + PropertyReader.TypeToString(p.type) + " ff#" + p.ffidx + " ffFile: " + p.ffpath);
            }
        }
示例#4
0
        public TreeNode MakeDefaultPropNode(PropertyReader.Property p)
        {
            string tp = PropertyReader.TypeToString((int)p.TypeVal);

            switch (tp)
            {
            case "Byte Property":
                return(new TreeNode(pcc.GetName(p.Name) + " (" + tp + ") : (" + pcc.GetName(BitConverter.ToInt32(p.raw, 24)) + ") " + pcc.GetName(BitConverter.ToInt32(p.raw, 32))));

            case "Bool Property":
                return(new TreeNode(pcc.GetName(p.Name) + " (" + tp + ") : " + (p.Value.IntValue == 1)));

            case "Object Property":
                string s = " ";
                if (p.Value.IntValue != 0)
                {
                    s = pcc.GetObject(p.Value.IntValue);
                }
                return(new TreeNode(pcc.GetName(p.Name) + " (" + tp + ") : " + p.Value.IntValue + s));

            case "Integer Property":
                return(new TreeNode(pcc.GetName(p.Name) + " (" + tp + ") : " + p.Value.IntValue));

            case "Name Property":
                return(new TreeNode(pcc.GetName(p.Name) + " (" + tp + ") : " + pcc.GetName(p.Value.IntValue)));

            case "Float Property":
                return(new TreeNode(pcc.GetName(p.Name) + " (" + tp + ") : " + BitConverter.ToSingle(p.raw, 24)));

            case "String Property":
                return(new TreeNode(pcc.GetName(p.Name) + " (" + tp + ") : " + p.Value.StringValue));

            default:
                return(new TreeNode(pcc.GetName(p.Name) + " (" + tp + ")"));
            }
        }
示例#5
0
        public string GenerateProps(string template, ClassDef c)
        {
            string t        = template;
            string rep      = "";
            bool   hadbool  = false;
            bool   hadint   = false;
            bool   hadobj   = false;
            bool   hadname  = false;
            bool   hadbyte  = false;
            bool   hadfloat = false;

            foreach (PropDef p in c.props)
            {
                string type = PropertyReader.TypeToString(p.type);
                switch (type)
                {
                case "Bool Property":
                    if (!hadbool)
                    {
                        rep    += "\t//Bool Properties\r\n\r\n";
                        hadbool = true;
                    }
                    rep += "\tpublic bool " + p.name + " = false;\r\n";
                    break;

                case "Integer Property":
                    if (!hadint)
                    {
                        rep   += "\t//Integer Properties\r\n\r\n";
                        hadint = true;
                    }
                    rep += "\tpublic int " + p.name + ";\r\n";
                    break;

                case "Object Property":
                    if (!hadobj)
                    {
                        rep   += "\t//Object Properties\r\n\r\n";
                        hadobj = true;
                    }
                    rep += "\tpublic int " + p.name + ";\r\n";
                    break;

                case "Name Property":
                    if (!hadname)
                    {
                        rep    += "\t//Name Properties\r\n\r\n";
                        hadname = true;
                    }
                    rep += "\tpublic int " + p.name + ";\r\n";
                    break;

                case "Byte Property":
                    if (!hadbyte)
                    {
                        rep    += "\t//Byte Properties\r\n\r\n";
                        hadbyte = true;
                    }
                    rep += "\tpublic int " + p.name + ";\r\n";
                    break;

                case "Float Property":
                    if (!hadfloat)
                    {
                        rep     += "\t//Float Properties\r\n\r\n";
                        hadfloat = true;
                    }
                    rep += "\tpublic float " + p.name + ";\r\n";
                    break;
                }
            }
            return(t.Replace("**UNEALPROPS**", rep));
        }
示例#6
0
        public void LetsDump2(string classname)
        {
            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;
            }
            string path = ME3Directory.cookedPath;

            string[] files = Directory.GetFiles(path, "*.pcc");
            pb1.Minimum = 0;
            rtb1.Text   = "";
            pauseToolStripMenuItem.Visible = true;
            pb2.Value   = 0;
            pb2.Maximum = files.Length;
            List <string> Names = new List <string>();
            List <string> Types = new List <string>();
            List <string> First = new List <string>();

            DebugOutput.Clear();
            for (int i = 0; i < files.Length; i++)
            {
                try
                {
                    while (pause)
                    {
                        Application.DoEvents();
                    }
                    using (ME3Package pcc = MEPackageHandler.OpenME3Package(files[i]))
                    {
                        DebugOutput.PrintLn(i + "/" + files.Length + " Scanning file : " + Path.GetFileName(files[i]));
                        IReadOnlyList <IExportEntry> Exports = pcc.Exports;
                        pb1.Maximum = Exports.Count;
                        pb2.Value   = i;
                        for (int j = 0; j < Exports.Count; j++)
                        {
                            IExportEntry ent = Exports[j];
                            if (ent.ClassName == classname)
                            {
                                List <PropertyReader.Property> p = PropertyReader.getPropList(ent);
                                for (int k = 0; k < p.Count; k++)
                                {
                                    PropertyReader.Property prop = p[k];
                                    int found = -1;
                                    for (int l = 0; l < Names.Count(); l++)
                                    {
                                        if (pcc.getNameEntry(prop.Name) == Names[l])
                                        {
                                            found = l;
                                        }
                                    }
                                    if (found == -1)
                                    {
                                        Names.Add(pcc.getNameEntry(prop.Name));
                                        Types.Add(PropertyReader.TypeToString((int)prop.TypeVal));
                                        First.Add(Path.GetFileName(files[i]) + " #" + j);
                                    }
                                }
                            }
                            if (j % 500 == 0)
                            {
                                pb1.Value   = j;
                                Status.Text = "State : " + j + " / " + Exports.Count;
                                string s = "Possible properties found so far for class \"" + classname + "\":\n";
                                for (int k = 0; k < Names.Count(); k++)
                                {
                                    s += Types[k] + " : \"" + Names[k] + "\" first found: " + First[k] + "\n";
                                }
                                Action action = () => rtb1.Text = s;
                                rtb1.Invoke(action);
                                action = () => rtb1.SelectionStart = s.Length;
                                rtb1.Invoke(action);
                                action = () => rtb1.ScrollToCaret();
                                rtb1.Invoke(action);
                                Application.DoEvents();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error:\n" + ex.Message);
                    DebugOutput.PrintLn("Could not open  file : " + Path.GetFileName(files[i]));
                }
            }
            Status.Text = "State : Done";
            string t = "Possible properties found for class \"" + classname + "\":\n";

            for (int k = 0; k < Names.Count(); k++)
            {
                t += Types[k] + " : \"" + Names[k] + "\" first found: " + First[k] + "\n";
            }
            rtb1.Text           = t;
            rtb1.SelectionStart = rtb1.TextLength;
            rtb1.ScrollToCaret();
            pb1.Value = 0;
            pauseToolStripMenuItem.Visible = false;
        }