Exemplo n.º 1
0
        /// <summary>
        /// Parses and reads the Mod.ini file for an individual mod loader mod.
        /// </summary>
        /// <param name="Mod_Loader_INI_Path"></param>
        /// <returns></returns>
        private Mod_Loader_Mod_INI_Entry Parse_Mod_Loader_INI_Entry(string Mod_Loader_INI_Path)
        {
            Mod_Loader_Mod_INI_Entry Mod_Loader_Entry = new Mod_Loader_Mod_INI_Entry();

            Mod_Loader_Entry.Mod_Directory = Path.GetDirectoryName(Mod_Loader_INI_Path);

            // Read the file line by line.
            string Current_Line;

            System.IO.StreamReader Mod_Loader_INI_File = new System.IO.StreamReader(Mod_Loader_INI_Path);
            while ((Current_Line = Mod_Loader_INI_File.ReadLine()) != null)
            {
                if (Current_Line.StartsWith("Name"))
                {
                    Mod_Loader_Entry.Mod_Name = Current_Line.Substring(Current_Line.IndexOf("=") + 1);
                }
                else if (Current_Line.StartsWith("Version"))
                {
                    Mod_Loader_Entry.Mod_Version = Current_Line.Substring(Current_Line.IndexOf("=") + 1);
                }
                else if (Current_Line.StartsWith("Description"))
                {
                    Mod_Loader_Entry.Mod_Description = Current_Line.Substring(Current_Line.IndexOf("=") + 1);
                }
                else if (Current_Line.StartsWith("Author"))
                {
                    Mod_Loader_Entry.Mod_Author = Current_Line.Substring(Current_Line.IndexOf("=") + 1);
                }
                else if (Current_Line.StartsWith("Options"))
                {
                    Mod_Loader_Entry.Options_ExecutableName = Current_Line.Substring(Current_Line.IndexOf("=") + 1);
                }
            }
            Mod_Loader_INI_File.Close();

            return(Mod_Loader_Entry);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Iterates over each character and reads all settings.
        /// </summary>
        public void Load_All_Character_Settings(bool Read_Default_Configuration)
        {
            try
            {
                // Mod Directory
                string Mod_Folder = Path.GetDirectoryName(System.Reflection.Assembly.GetCallingAssembly().Location);

                // Read the file.
                StreamReader Character_Ball_Config_Stream;
                if (Read_Default_Configuration)
                {
                    Character_Ball_Config_Stream = new StreamReader(Mod_Folder + "\\Default-Ball-Configuration.txt");
                }
                else
                {
                    Character_Ball_Config_Stream = new StreamReader(Mod_Folder + "\\Character-Ball-Configuration.txt");
                }

                // Current Line
                string Current_Line;

                // Current Character Array Index
                int Current_Character_Index = 0;

                // Temporary copy of all characters.
                Characters[] Temp_Heroes_Characters = Sonic_Heroes_Characters.ToArray();

                // Read the file
                while ((Current_Line = Character_Ball_Config_Stream.ReadLine()) != null)
                {
                    // Value of the individual element
                    string value = Current_Line.Substring(Current_Line.IndexOf("=") + 1);

                    if (Current_Line.StartsWith("#"))
                    {
                    }
                    // Get index of character
                    else if (Current_Line.StartsWith("Character Name"))
                    {
                        Current_Character_Index = Sonic_Heroes_Characters.TakeWhile(x => x.Character_Name != value).Count();
                    }
                    else if (Current_Line.StartsWith("Jump Ball Colour | R"))
                    {
                        Temp_Heroes_Characters[Current_Character_Index].Character_Ball_Colours.Jump_Ball.R = Convert.ToByte(value);
                    }
                    else if (Current_Line.StartsWith("Jump Ball Colour | G"))
                    {
                        Temp_Heroes_Characters[Current_Character_Index].Character_Ball_Colours.Jump_Ball.G = Convert.ToByte(value);
                    }
                    else if (Current_Line.StartsWith("Jump Ball Colour | B"))
                    {
                        Temp_Heroes_Characters[Current_Character_Index].Character_Ball_Colours.Jump_Ball.B = Convert.ToByte(value);
                    }
                    else if (Current_Line.StartsWith("Jump Ball Colour | A"))
                    {
                        Temp_Heroes_Characters[Current_Character_Index].Character_Ball_Colours.Jump_Ball.A = Convert.ToByte(value);
                    }
                    else if (Current_Line.StartsWith("Tornado Colour | R"))
                    {
                        Temp_Heroes_Characters[Current_Character_Index].Character_Ball_Colours.Tornado.R = Convert.ToByte(value);
                    }
                    else if (Current_Line.StartsWith("Tornado Colour | G"))
                    {
                        Temp_Heroes_Characters[Current_Character_Index].Character_Ball_Colours.Tornado.G = Convert.ToByte(value);
                    }
                    else if (Current_Line.StartsWith("Tornado Colour | B"))
                    {
                        Temp_Heroes_Characters[Current_Character_Index].Character_Ball_Colours.Tornado.B = Convert.ToByte(value);
                    }
                    else if (Current_Line.StartsWith("Tornado Colour | A"))
                    {
                        Temp_Heroes_Characters[Current_Character_Index].Character_Ball_Colours.Tornado.A = Convert.ToByte(value);
                    }
                    else if (Current_Line.StartsWith("Trail Colour | R"))
                    {
                        Temp_Heroes_Characters[Current_Character_Index].Character_Ball_Colours.Trail.R = Convert.ToByte(value);
                    }
                    else if (Current_Line.StartsWith("Trail Colour | G"))
                    {
                        Temp_Heroes_Characters[Current_Character_Index].Character_Ball_Colours.Trail.G = Convert.ToByte(value);
                    }
                    else if (Current_Line.StartsWith("Trail Colour | B"))
                    {
                        Temp_Heroes_Characters[Current_Character_Index].Character_Ball_Colours.Trail.B = Convert.ToByte(value);
                    }
                    else if (Current_Line.StartsWith("Trail Colour | A"))
                    {
                        Temp_Heroes_Characters[Current_Character_Index].Character_Ball_Colours.Trail.A = Convert.ToByte(value);
                    }
                    else if (Current_Line.StartsWith("Misc Colour | R"))
                    {
                        Temp_Heroes_Characters[Current_Character_Index].Character_Ball_Colours.Misc.R = Convert.ToByte(value);
                    }
                    else if (Current_Line.StartsWith("Misc Colour | G"))
                    {
                        Temp_Heroes_Characters[Current_Character_Index].Character_Ball_Colours.Misc.G = Convert.ToByte(value);
                    }
                    else if (Current_Line.StartsWith("Misc Colour | B"))
                    {
                        Temp_Heroes_Characters[Current_Character_Index].Character_Ball_Colours.Misc.B = Convert.ToByte(value);
                    }
                    else if (Current_Line.StartsWith("Misc Colour | A"))
                    {
                        Temp_Heroes_Characters[Current_Character_Index].Character_Ball_Colours.Misc.A = Convert.ToByte(value);
                    }
                }

                // Close FileStream
                Character_Ball_Config_Stream.Close();

                // Retrieve List
                Sonic_Heroes_Characters = Temp_Heroes_Characters.ToList();

                // Write all colours to memory.
                foreach (Characters Character in Sonic_Heroes_Characters)
                {
                    Write_Character_Colours(Character);
                }
            }
            catch (Exception Ex)
            {
                Program.Sonic_Heroes_Networking_Client.SendData_Alternate(Message_Type.Client_Call_Send_Message, Encoding.ASCII.GetBytes("Tweakbox: Default Character Ball Colour settings are missing or are invalid, your culprit is either Mod-Loader-Mods/Tweakbox/Character-Ball-Configuration.txt or Default-Ball-Configuration.txt"), false);
            }
        }