Example #1
0
 public void addFile(A3CppFile file)
 {
     if (fileList != null)
     {
         fileList.Add(file);
     }
     else
     {
         fileList = new List <A3CppFile> {
             file
         }
     };
 }
Example #2
0
        public static A3CppFile parseFile(String path)//process a cpp file into a A3CppFile object
        {
            A3CppFile file = new A3CppFile();

            file.FilePath           = path;
            file.OriginalCodeString = System.IO.File.ReadAllText(path, System.Text.Encoding.UTF8); //read file contents into String
            file.splitOCode();                                                                     //split string into list by line

            //Parse all Class's
            file = parseFileForClasses(file);//Find and seperate the classes with their content
            //Parse all Variables
            file = parseFileClassesForVariables(file);
            //Build Inheritance Tree -- PERFORMANCE BOTTLENECK
            file.buildTrees();
            return(file);
        }
Example #3
0
        private async void btnProcess_Click(object sender, RoutedEventArgs e)
        {
            String        pboPath      = txtPboPath.Text;
            String        binPath      = txtBinPath.Text;
            String        cppPath      = txtCppPath.Text;
            String        serialPath   = txtSerialized.Text;
            String        outputPath   = txtOutputPath.Text;
            List <String> addColumn    = new List <String>();
            List <String> addToAllRows = new List <String>();
            List <String> temp         = tbExtraColumns.Text.Split(';').ToList();

            if (tbExtraColumns.Text != String.Empty)
            {
                foreach (String x in temp)
                {
                    addColumn.Add(x.Split(':')[0]);
                    addToAllRows.Add(x.Split(':')[1]);
                }
            }
            if (addColumn.Count != addToAllRows.Count)
            {
                addColumn    = null;
                addToAllRows = null;
            }
            //Extract
            List <String> binList = new List <String>();

            if (cbExtractIsNeeded.IsChecked.Value)
            {
                Log("Extracting Files At: " + pboPath);
                binList = GenLib.extract(pboPath, binPath, txtBankRevPath.Text);
                Log("Extracted Files To: " + binPath);
            }
            //Convert
            List <String> cppList = new List <String>();

            if (cbConvertIsNeeded.IsChecked.Value)
            {
                Log("Converting Files At: " + binPath);
                if (!cbExtractIsNeeded.IsChecked.Value)
                {
                    binList = GenLib.binList(binPath);
                }
                cppList = GenLib.convert(binList, cppPath, txtCfgConvertPath.Text);
                Log("Converted Files To: " + cppPath);
            }
            //Serialize
            if (cbSerialize.IsChecked.Value)
            {
                if (cbConvertIsNeeded.IsChecked.Value)
                {
                    ;
                }
                else
                {
                    cppList = GenLib.cppList(cppPath);
                }
                //Data Grab > Objects

                ///MultiThread
                ///
                //Clear null files
                for (int i = 0; i < cppList.Count; i++)
                {
                    if (cppList[i] == null)
                    {
                        cppList.Remove(cppList[i]);
                        i--;
                    }
                }


                A3CppFile[] fileArray = new A3CppFile[cppList.Count];//we need the static length of the array to parallelize, the index's must exist beforehand for async assignment

                Parallel.For(0,
                             (cppList.Count - 1), new ParallelOptions
                {
                    MaxDegreeOfParallelism = 1
                },
                             a =>
                {
                    A3CppFile tempArray = GenLib.parseFile(cppList[a]);
                    fileArray[a]        = tempArray;
                });
                ///SingleThread
                ///

                /*
                 * A3CppFile[] fileArray = new A3CppFile[cppList.Count];//we need the static length of the array to parallelize, the index's must exist beforehand for async assignment
                 * for(int i = 0; i < cppList.Count; i++)
                 *  {
                 *      fileArray[i] = GenLib.parseFile(cppList[i]);
                 *  }
                 */

                //Serialize
                Log("Serializing...");
                GenLib.serialize(fileArray.ToList(), serialPath);
                Log("Serialized");
            }
            ///Parse
            ///
            if (cbProcess.IsChecked.Value)
            {
                Log("Deserializing...");
                //Deserialize objects to parse
                List <A3CppFile> flist = GenLib.deserialize(serialPath);
                Log("Deserialized");
                Log("Parsing...");
                //create list of all classes
                List <A3Class> list = new List <A3Class>();

                if (flist != null)
                {
                    for (int i = 0; i < flist.Count; i++)
                    {
                        if (flist[i] != null)
                        {
                            if (flist[i].A3EntireClassList != null)
                            {
                                foreach (A3Class c in flist[i].A3EntireClassList)
                                {
                                    if (list != null)
                                    {
                                        list.Add(c);
                                    }
                                    else
                                    {
                                        list = new List <A3Class> {
                                            c
                                        }
                                    };
                                }
                            }
                        }
                    }
                }

                list = A3Presentation.includeOnlySelected(list, cbShowCfgVehicles.IsChecked.Value, cbShowCfgAmmo.IsChecked.Value, cbShowCfgWeapons.IsChecked.Value, cbShowCfgMagazines.IsChecked.Value, cbShowLvl1.IsChecked.Value, cbShowLvl2.IsChecked.Value, cbShowTertiary.IsChecked.Value, cbShowOtherCfg.IsChecked.Value);

                //Apply Filters
                List <String> outputList = new List <String>();
                if (txtNotContainPartClass.Text != "")
                {
                    list = A3Presentation.filterOutClassByPartialName(list, txtNotContainPartClass.Text.Split(';'));
                }
                if (txtContainPartClass.Text != "")
                {
                    list = A3Presentation.filterInClassByPartialName(list, txtContainPartClass.Text.Split(';'));
                }
                if (txtHasDirectParent.Text != "")
                {
                    list = A3Presentation.filterInClassByDirectParent(list, txtHasDirectParent.Text.Split(';'));
                }
                if (txtHasParent.Text != "")
                {
                    list = A3Presentation.filterInClassByAnyParent(list, txtHasParent.Text.Split(';'));
                }
                if (txtContainsFields.Text != "")
                {
                    list = A3Presentation.filterOutClassByVariableName(list, txtContainsFields.Text.Split(';'));
                }
                if (txtDisplayFields.Text != "")
                {
                    outputList = A3Presentation.outputSelectedFields(list, txtDisplayFields.Text.Split(';'), cbShowClassName.IsChecked.Value,
                                                                     cbShowParentClass.IsChecked.Value, cbShowBaseClass.IsChecked.Value, cbOutputSource.IsChecked.Value, addColumn, addToAllRows,
                                                                     cbConfigType.IsChecked.Value);
                }
                if (cbDisplayAllFields.IsChecked.Value)
                {
                    outputList = A3Presentation.outputAllFields(list, cbShowClassName.IsChecked.Value,
                                                                cbShowParentClass.IsChecked.Value, cbShowBaseClass.IsChecked.Value, cbOutputSource.IsChecked.Value, addColumn, addToAllRows,
                                                                cbConfigType.IsChecked.Value);
                }

                Log("Parsed");
                //Build Output
                Log("Creating File...");
                StringBuilder output = new StringBuilder(5000);
                using (StreamWriter sw = File.CreateText(txtOutputPath.Text))
                {
                    foreach (String s in outputList)
                    {
                        if (output.Capacity >= (output.MaxCapacity / 8))
                        {
                            sw.Write(output);
                            output = new StringBuilder(5000);
                        }
                        else
                        {
                            output.Append(s);
                        }
                    }
                    sw.Write(output);
                }

                //Create Output File
                Log("File Created At: " + txtOutputPath.Text);
            }


            //Add code to update tvClassList treeview with classes
            //if serialized path exists and is valid, load it
        }
    }
Example #4
0
 public static A3CppFile processFileClassesForInheritanceTree(A3CppFile file)//build the nested and extended tree lists and combine into inheritance tree
 {
     file.buildTrees();
     return(file);
 }
Example #5
0
 public static A3CppFile parseFileClassesForVariables(A3CppFile file)//build list of variables
 {
     file.stripVariables();
     return(file);
 }
Example #6
0
 public static A3CppFile parseFileForClasses(A3CppFile file)//process a filepath listed in a file for all the classes and sort them into the file
 {
     file.stripClasses();
     return(file);
 }