Esempio n. 1
0
        public void WriteLegacy(string iniFile)
        {
            InitializationFile ini = new InitializationFile(iniFile, CultureInfo.InvariantCulture, false);

            foreach (KeyValuePair <string, VehicleData> item in Data)
            {
                // Write overloads don't use the format provider passed in the constructor, so use ToString instead
                ini.Write(item.Key, VehicleData.IniKeyX, item.Value.Offset.X.ToString(CultureInfo.InvariantCulture));
                ini.Write(item.Key, VehicleData.IniKeyY, item.Value.Offset.Y.ToString(CultureInfo.InvariantCulture));
                ini.Write(item.Key, VehicleData.IniKeyZ, item.Value.Offset.Z.ToString(CultureInfo.InvariantCulture));

                if (item.Value.DisableTurretSpecified)
                {
                    ini.Write(item.Key, VehicleData.IniKeyDisableTurret, item.Value.DisableTurret.ToString(CultureInfo.InvariantCulture));
                }
                else if (ini.DoesKeyExist(item.Key, VehicleData.IniKeyDisableTurret))
                {
                    ini.DeleteKey(item.Key, VehicleData.IniKeyDisableTurret);
                }
            }
            ini.Layout();

            //using (StreamWriter writer = new StreamWriter(iniFile, false))
            //{
            //    foreach (KeyValuePair<string, VehicleData> item in Data)
            //    {
            //        writer.WriteLine($"[{item.Key}]");
            //        writer.WriteLine($"{VehicleData.IniKeyX} = {item.Value.Offset.X.ToString(CultureInfo.InvariantCulture)}");
            //        writer.WriteLine($"{VehicleData.IniKeyY} = {item.Value.Offset.Y.ToString(CultureInfo.InvariantCulture)}");
            //        writer.WriteLine($"{VehicleData.IniKeyZ} = {item.Value.Offset.Z.ToString(CultureInfo.InvariantCulture)}");
            //        if (item.Value.DisableTurretSpecified)
            //        {
            //            writer.WriteLine($"{VehicleData.IniKeyDisableTurret} = {item.Value.DisableTurret.ToString(CultureInfo.InvariantCulture)}");
            //        }
            //        writer.WriteLine();
            //    }
            //}
        }