Ejemplo n.º 1
0
        public void fetchData()
        {
            JSONfile = opClass.LoadJSON(tempPath + "\\06_bioinput.json");
            allBinds = opClass.ReadAllEntries(JSONfile, "sfxgame.sfxgamemodedefault", "bindings");
            Application.DoEvents();

            TreeNode t1 = new TreeNode("Binded game keys");
            TreeNode defaultSection = new TreeNode("sfxgame.sfxgamemodedefault");
            int counter = 0;

            string[] temp1 = new string[allBinds.Count()];
            string[] temp2 = new string[allBinds.Count()];

            foreach (Entry key in allBinds)
            {
                string[] temp = key.Value.Split(forSplitting);
                temp1[counter] = temp[1];
                temp2[counter] = temp[3];
                defaultSection.Nodes.Add(counter.ToString(), temp1[counter] + " =  "+ temp2[counter]);
                counter++;
            }

            bindKeyDefault = temp1;
            bindCommandDefault = temp2;
            t1.Nodes.Add(defaultSection);
            

            TreeNode baseSection = new TreeNode("sfxgame.sfxgamemodebase");
            counter = 0;
            allBinds = opClass.ReadAllEntries(JSONfile, "sfxgame.sfxgamemodebase", "bindings");

            temp1 = new string[allBinds.Count()];
            temp2 = new string[allBinds.Count()];

            foreach (Entry key in allBinds)
            {
                string[] temp = key.Value.Split(forSplitting);
                temp1[counter] = temp[1];
                temp2[counter] = temp[3];
                baseSection.Nodes.Add(counter.ToString(), temp1[counter] + " =  " + temp2[counter]);
                counter++;
            }
            t1.Nodes.Add(baseSection);
            treeView1.Nodes.Add(t1);
            bindKeyBase = temp1;
            bindCommandBase = temp2;



        }
Ejemplo n.º 2
0
        //This class contains two sets of tools:
        //for manipulation of FileWrapper file stored in memory, 
        //and for decompiling/recompiling Coalesced.bin to/from JSON files

        //you need to load the FileWrapper yourself, use this:
        /*
            var input = System.IO.File.OpenRead(pathToJSONfile);
            var reader = new StreamReader(input);
            var text = reader.ReadToEnd();

            file = JsonConvert.DeserializeObject<FileWrapper>(text);
            Dictionary<string, Dictionary<string, List<string>>> d = file.Sections;

            reader.Close();
         
         
         */
        // pathToJSONfile is a string, and can be, example "tempPath + "\\10_bioweapon.json""

        //For manipulation of FileWrapper, use Read and Write entries functions

        //After manipulation of FileWrapper variable, you need to write it out on the 
        //disk before it can be compiled into Coalesced.bin!

        //To do that, use: 
        /*
                var outputFile = JsonConvert.SerializeObject(file, Formatting.Indented);
                File.WriteAllText(pathToJSONfile, outputFile);
          
        *to write out your loaded JSON file into the disk.
         *pathToJSONFile can be, for example: tempPath + "\\10_bioweapon.json"
         

        */

        #endregion

        #region Read and Write functions

        //This is the ReadEntry function, which will return one string at specified place in FileWrapper

        // For example, use:
        //      string neededValue = opClass.ReadEntry(file, "sfxgame.sfxinventorymanager", "fuelefficiency", 0);

        //          this will return "1.5" in unmodified Coalesced.bin which is the fuel efficiency used when 
        //          travelling with Normandy around the galaxy map 

        /// <summary>
        /// Returns a string which is a value of entry of given Index, in Key2, in Key1 of a FileWrapper variable
        /// </summary>
        /// <param name="file">FileWrapper variable deserialized from JSON</param>
        /// <param name="Key1">First Key to look for (section), example: "sfxgame.sfxinventorymanager"</param>
        /// <param name="Key2">Second Key within first Key, example: "fuelefficiency"</param>
        /// <param name="Index">Index of one value in Second Key's entries, example: 0</param>
        /// <returns>Returns value under given Index, example: "1.5" </returns>
        public static string ReadEntry(FileWrapper file, string Key1, string Key2, int Index)
        {
            string needed = "";
            foreach (KeyValuePair<string, Dictionary<string, List<Entry>>> firstKey in file.Sections)
            {
                if (firstKey.Key == Key1)
                {
                    foreach (KeyValuePair<string, List<Entry>> secondKey in firstKey.Value)
                    {
                        if (secondKey.Key == Key2)
                        {
                            if (Index >= 0 && Index < secondKey.Value.Count())
                                needed = secondKey.Value[Index].Value;
                        }
                    }

                }
            }
            return needed;
        }
Ejemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (label1.Text == "Weapons")
            {
                if (checkBox1.Checked) opClass.WriteEntry(file, weaponLocation + "_" + weaponClass + "_" + name[1], "binfiniteammo", 0, "true");
                else opClass.WriteEntry(file, weaponLocation + "_" + weaponClass + "_" + name[1], "binfiniteammo", 0, "false");

                DebugOutput.PrintLn("Infinite ammo sorted: ");
                if (checkBox1.Checked) DebugOutput.PrintLn("True");
                else DebugOutput.PrintLn("False");

                opClass.WriteEntry(file, weaponLocation + "_" + weaponClass + "_" + name[1], "damage", 0, textBox2.Text);
                opClass.WriteEntry(file, weaponLocation + "_" + weaponClass + "_" + name[1], "magsize", 0, textBox3.Text);
                opClass.WriteEntry(file, weaponLocation + "_" + weaponClass + "_" + name[1], "rateoffire", 0, textBox4.Text);
                opClass.WriteEntry(file, weaponLocation + "_" + weaponClass + "_" + name[1], "maxspareammo", 0, textBox5.Text);
                opClass.WriteEntry(file, weaponLocation + "_" + weaponClass + "_" + name[1], "encumbranceweight", 0, textBox6.Text);
                opClass.WriteEntry(file, weaponLocation + "_" + weaponClass + "_" + name[1], "minaimerror", 0, textBox7.Text);
                opClass.WriteEntry(file, weaponLocation + "_" + weaponClass + "_" + name[1], "maxaimerror", 0, textBox8.Text);
                opClass.WriteEntry(file, weaponLocation + "_" + weaponClass + "_" + name[1], "minzoomaimerror", 0, textBox9.Text);
                opClass.WriteEntry(file, weaponLocation + "_" + weaponClass + "_" + name[1], "maxzoomaimerror", 0, textBox10.Text);
                opClass.WriteEntry(file, weaponLocation + "_" + weaponClass + "_" + name[1], "recoil", 0, textBox11.Text);
                opClass.WriteEntry(file, weaponLocation + "_" + weaponClass + "_" + name[1], "zoomrecoil", 0, textBox13.Text);

                opClass.SaveJSON(file, tempPath + "\\" + weaponPrefix + "_bioweapon.json");

                DebugOutput.PrintLn("Saved " + name[1] + "'s properties in bioweapon.ini");

                MessageBox.Show("Changes to " + name[1] + " saved! \n\nWhen you're done with modifying all weapons, use \"Modify!\" button to apply all modifications", "Done");

            }

            if (label1.Text == "Inventory")
            {
                FileWrapper file2 = new FileWrapper();
                file2 = opClass.LoadJSON(tempPath + "\\" + enginePrefix + "_bioengine.json");
                List<Entry> entries = opClass.ReadAllEntries(file2, "fullscreenmovie", "startupmovies").ToList();
                int index = 0;

                if (checkBox1.Checked)
                {
                    foreach (Entry E in entries) if (E.ToString() == "ME_sig_logo") index = entries.IndexOf(E);
                    opClass.WriteEntry(file2, "fullscreenmovie", "startupmovies", index, ";ME3_sig_logo");
                    DebugOutput.PrintLn("Disabled intro movies. Saved in bioengine.ini");
                }

                else
                {
                    foreach (Entry E in entries) if (E.ToString() == ";ME_sig_logo") index = entries.IndexOf(E);
                    opClass.WriteEntry(file2, "fullscreenmovie", "startupmovies", index, "ME3_sig_logo");
                    DebugOutput.PrintLn("Enabled intro movies. Saved in bioengine.ini");
                }

                opClass.SaveJSON(file2, tempPath + "\\" + enginePrefix + "_bioengine.json");

                opClass.WriteEntry(file, "sfxgame.sfxinventorymanager", "fuelefficiency", 0, textBox2.Text);
                opClass.WriteEntry(file, "sfxgame.sfxinventorymanager", "maxfuel", 0, textBox3.Text);
                opClass.WriteEntry(file, "sfxgame.sfxinventorymanager", "maxgrenades", 0, textBox4.Text);
                opClass.WriteEntry(file, "sfxgame.sfxinventorymanager", "maxmedigel", 0, textBox5.Text);

                opClass.SaveJSON(file, tempPath + "\\" + weaponPrefix + "_bioweapon.json");

                DebugOutput.PrintLn("Saved inventory changes in bioweapon.ini");

                MessageBox.Show("Stored changes made to inventory properties! \n\nMake sure to use the \"Modify!\" button to apply them! ", "Done");

            }
        }
Ejemplo n.º 4
0
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            if (coalescedLoaded)
            {
                file = opClass.LoadJSON(tempPath + "\\" + weaponPrefix + "_bioweapon.json");
                label1.Text = "Inventory";

                tv1.Nodes.Clear();

                checkBox1.Visible = true;
                checkBox1.Text = "Skip intro movie?";

                checkBox2.Visible = false;
                checkBox3.Visible = false;
                checkBox4.Visible = false;
                checkBox5.Visible = false;
                checkBox6.Visible = false;

                textBox2.Text = "";
                textBox3.Text = "";
                textBox4.Text = "";
                textBox5.Text = "";
                textBox6.Text = "";
                textBox7.Text = "";
                textBox8.Text = "";
                textBox9.Text = "";
                textBox10.Text = "";
                textBox11.Text = "";
                textBox13.Text = "";

                tv1.Nodes.Add("General inventory controls");

                label5.Text = "Fuel efficiency"; //textbox2
                label6.Text = "Fuel capacity";
                label7.Text = "Grenades";
                label8.Text = "Medigel";
                label9.Text = "";
                label10.Text = "";
                label11.Text = "";
                label12.Text = "";
                label13.Text = "";

                textBox2.Text = opClass.ReadEntry(file, "sfxgame.sfxinventorymanager", "fuelefficiency", 0);
                textBox3.Text = opClass.ReadEntry(file, "sfxgame.sfxinventorymanager", "maxfuel", 0);
                textBox4.Text = opClass.ReadEntry(file, "sfxgame.sfxinventorymanager", "maxgrenades", 0);
                textBox5.Text = opClass.ReadEntry(file, "sfxgame.sfxinventorymanager", "maxmedigel", 0);
            }
            else MessageBox.Show("Coalesced file not loaded yet!");
        }
Ejemplo n.º 5
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (coalescedLoaded)
            {
                tv1.Nodes.Clear();

                label1.Text = "Weapons";

                checkBox1.Visible = true;
                checkBox2.Visible = true;
                checkBox1.Text = "Unlimited ammo";
                checkBox2.Text = "No reloads";

                checkBox3.Visible = false;
                checkBox4.Visible = false;
                checkBox5.Visible = false;
                checkBox6.Visible = false;

                label5.Text = "Damage";
                label6.Text = "Mag size";
                label7.Text = "Rate of fire";
                label8.Text = "Spare ammo";
                label9.Text = "Weight";
                label10.Text = "Hip fire accuracy";
                label11.Text = "Aiming accuracy";
                label12.Text = "Hip fire recoil";
                label13.Text = "Aiming recoil";

                //here opening Json file which contains good stuff

                file = opClass.LoadJSON(tempPath + "\\" + weaponPrefix + "_bioweapon.json");

                Dictionary<string, Dictionary<string, List<Entry>>> d = file.Sections;

                //here defining treenodes that will be added later
                TreeNode t = new TreeNode("Weapons");
                TreeNode categoryAssault = new TreeNode("Assault rifles");
                TreeNode categorySMG = new TreeNode("Submachine guns");
                TreeNode categoryShotguns = new TreeNode("Shotguns");
                TreeNode categorySniper = new TreeNode("Sniper Rifles");
                TreeNode categoryPistols = new TreeNode("Pistols");

                #region weapon sorting by categories
                //here scanning through JSON file and sorting out weapons in treeview catergories

                bool found = false;

                DebugOutput.PrintLn("Scanning for weapons and sorting in categories.");

                foreach (KeyValuePair<string, Dictionary<string, List<Entry>>> d2 in d)
                {

                    string[] names = d2.Key.Split('.');

                    if (names.Length > 1)
                    {

                        string[] gun = names[1].Split('_');

                        if (gun.Length >= 2)
                        {
                            if (gun[0] == "sfxweapon")
                            {

                                if (gun[1] == "assaultrifle")
                                {
                                    if (gun[2] != "base")
                                    {
                                        TreeNode t2 = new TreeNode(gun[2]);
                                        if (gun.Length == 4) t2.Text += "_" + gun[3];
                                        categoryAssault.Nodes.Add(t2);
                                        DebugOutput.PrintLn("Found assault rifle: \t" + gun[2]);

                                        if (!found)
                                        {
                                            weaponLocation = names[0] + "." + gun[0];
                                            found = true;

                                        }

                                    }
                                }
                                if (gun[1] == "smg")
                                {

                                    if (gun[2] != "base")
                                    {
                                        TreeNode t2 = new TreeNode(gun[2]);
                                        if (gun.Length == 4) t2.Text += "_" + gun[3];
                                        categorySMG.Nodes.Add(t2);
                                        DebugOutput.PrintLn("Found submachine gun: \t" + gun[2]);

                                        if (!found)
                                        {
                                            weaponLocation = names[0] + "." + gun[0];
                                            found = true;
                                        }
                                    }
                                }
                                if (gun[1] == "shotgun")
                                {
                                    if (gun[2] != "base")
                                    {
                                        TreeNode t2 = new TreeNode(gun[2]);
                                        if (gun.Length == 4) t2.Text += "_" + gun[3];
                                        categoryShotguns.Nodes.Add(t2);
                                        DebugOutput.PrintLn("Found shotgun: \t\t" + gun[2]);

                                        if (!found)
                                        {
                                            weaponLocation = names[0] + "." + gun[0];
                                            found = true;
                                        }
                                    }
                                }
                                if (gun[1] == "sniperrifle")
                                {
                                    if (gun[2] != "base")
                                    {
                                        TreeNode t2 = new TreeNode(gun[2]);
                                        if (gun.Length == 4) t2.Text += "_" + gun[3];
                                        categorySniper.Nodes.Add(t2);
                                        DebugOutput.PrintLn("Found sniper rifle: \t" + gun[2]);

                                        if (!found)
                                        {
                                            weaponLocation = names[0] + "." + gun[0];
                                            found = true;
                                        }
                                    }
                                }
                                if (gun[1] == "pistol")
                                {
                                    if (gun[2] != "base")
                                    {
                                        TreeNode t2 = new TreeNode(gun[2]);
                                        if (gun.Length == 4) t2.Text += "_" + gun[3];
                                        categoryPistols.Nodes.Add(t2);
                                        DebugOutput.PrintLn("Found pistol: \t\t" + gun[2]);

                                        if (!found)
                                        {
                                            weaponLocation = names[0] + "." + gun[0];
                                            found = true;
                                        }
                                    }
                                }
                            }
                        }

                    }

                }

                #endregion

                DebugOutput.PrintLn("Found weapon prefix: " + weaponLocation);

                t.Nodes.Add(categoryAssault);
                t.Nodes.Add(categorySMG);
                t.Nodes.Add(categoryShotguns);
                t.Nodes.Add(categorySniper);
                t.Nodes.Add(categoryPistols);
                tv1.Nodes.Clear();
                tv1.Nodes.Add(t);
            }
            else MessageBox.Show("Coalesced file not yet loaded! Please use the load button up there.");
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Will create a JSON file pointed at path, serialized from a FileWrapper variable
        /// </summary>
        /// <param name="file">FileWrapper variable in memory</param>
        /// <param name="pathToJSON">String ending in "\\[...].JSON";</param>
        public static void SaveJSON(FileWrapper file, string pathToJSON)
        {
            var outputFile = JsonConvert.SerializeObject(file, Formatting.Indented);
            System.IO.File.WriteAllText(pathToJSON, outputFile);


        }
Ejemplo n.º 7
0
        //will write new array of strings as values of Key2 of Key1 of file.Sections

        /// <summary>
        /// Will write an entire value set from string array into section
        /// </summary>
        /// <param name="file">FileWrapper variable in memory into which you will write</param>
        /// <param name="Key1">First key to look for, section, example: "sfxgame.sfxplayersquadloadoutdata"</param>
        /// <param name="Key2">Second key to look for in section, example: "shotguns"</param>
        /// <param name="newValue">A string array containing all values you wish to write</param>
        public static  void WriteAllEntries(FileWrapper file, string Key1, string Key2, string[] newValue)
        {
            foreach (KeyValuePair<string, Dictionary<string, List<Entry>>> firstKey in file.Sections)
            {
                if (firstKey.Key == Key1)
                {
                    foreach (KeyValuePair<string, List<Entry>> secondKey in firstKey.Value)
                    {
                        if (secondKey.Key == Key2)
                        {
                            for (int Index = 0; Index < secondKey.Value.Count(); Index++)
                            {
                                Entry e = secondKey.Value[Index];
                                e.Value = newValue[Index];
                                secondKey.Value[Index] = e;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
0
         //This will write a value into the FileWrapper which is currently in the memory

         // How to use

         //   opClass.WriteEntry(file, "sfxgame.sfxinventorymanager", "fuelefficiency", 0, textBox2.Text);
         
         //         This will write a string contained in TextBox2 into the JSON file under entry fuel efficiency
         
         // Remember, to apply any of this, you still need to write the FileWrapper into JSON on the disk

        /// <summary>
        /// Writes an entry into FileWrapper file in memory. Nothing will be written if section doesn't already exist.
        /// </summary>
        /// <param name="file">FileWrapper variable deserialized from JSON</param>
        /// <param name="Key1">First key to look for (section), example: "sfxgame.sfxinventorymanager"</param>
        /// <param name="Key2">Second key to look for in given section, example: "fuelefficiency"</param>
        /// <param name="Index">Index of value in Second Key to overwrite, example : 0</param>
        /// <param name="newValue">Value to write into Index, example: "1.0" </param>
        public static  void WriteEntry(FileWrapper file, string Key1, string Key2, int Index, string newValue)
        {
            foreach (KeyValuePair<string, Dictionary<string, List<Entry>>> firstKey in file.Sections)
            {
                if (firstKey.Key == Key1)
                {
                    foreach (KeyValuePair<string, List<Entry>> secondKey in firstKey.Value)
                    {
                        if (secondKey.Key == Key2)
                        {
                            if (Index >= 0 && Index < secondKey.Value.Count())
                            {
                                Entry e = secondKey.Value[Index];
                                e.Value = newValue;
                                secondKey.Value[Index] = e;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
0
        //similar to above, this will return ALL entries of a given section (weapon or whatever)
        //as an array of strings at specified entry - without index, it will return ALL indexes' values

        /// <summary>
        /// Returns a string array containing all values of a given entry
        /// </summary>
        /// <param name="file">FileWrapper variable deserialized from JSON</param>
        /// <param name="Key1">First key to look for (section), example: "sfxgame.sfxplayersquadloadoutdata"</param>
        /// <param name="Key2">Second key to look for in section, example: "shotguns"</param>
        /// <returns>Returns a string array containing all entries under "shotgun" entry in given section</returns>
        public static Entry[] ReadAllEntries(FileWrapper file, string Key1, string Key2)
        {
            Entry[] neededArray = { };
            foreach (KeyValuePair<string, Dictionary<string, List<Entry>>> firstKey in file.Sections)
            {
                if (firstKey.Key == Key1)
                {
                    foreach (KeyValuePair<string, List<Entry>> secondKey in firstKey.Value)
                    {
                        if (secondKey.Key == Key2) neededArray = secondKey.Value.ToArray();
                    }
                }
            }
            return neededArray;
        }