示例#1
0
 public DropTable(IniFileSection section)
 {
     foreach (string key in section.GetKeys())
     {
         string name;
         int    num;
         int    max;
         if (key[0] != '*')
         {
             name = key.Substring(key.IndexOf(' ') + 1);
             if (key.IndexOf('-') > 0)
             {
                 string[] array = key.Split()[0].Split('-');
                 num = Convert.ToInt32(array[0]);
                 max = Convert.ToInt32(array[1]);
             }
             else
             {
                 string value = key.Substring(0, key.IndexOf(' '));
                 num = Convert.ToInt32(value);
                 max = num;
             }
         }
         else
         {
             name = key;
             num  = 0;
             max  = 0;
         }
         float chance = Convert.ToSingle(section[key], CultureInfo.InvariantCulture.NumberFormat);
         Drop  value2 = new Drop(num, max, name, chance);
         drops.Add(value2);
     }
     drops.Sort();
 }
示例#2
0
 protected override void Save(IniFileSection section)
 {
     base.Save(section);
     section.Set("LAPS", LapsCount);
     section.Set("WAIT_TIME", WaitTime.TotalSeconds); // round?
     section.SetIntEnum("IS_OPEN", JoinType);
 }
示例#3
0
 public BlurredObject(IniFileSection section)
 {
     WheelIndex = section.GetInt("WHEEL_INDEX", -1);
     Name       = section.GetNonEmpty("NAME");
     MinSpeed   = section.GetFloat("MIN_SPEED", 0f);
     MaxSpeed   = section.GetFloat("MAX_SPEED", 30f);
 }
        private static bool SetRange(IniFileSection section, string minKey, string maxKey, [CanBeNull] Tuple <double, double> range)
        {
            if (range == null)
            {
                return(false);
            }

            var min = Math.Min(range.Item1, range.Item2);
            var max = Math.Max(range.Item1, range.Item2);

            var changed = false;

            if (!Equals(section.GetDouble(maxKey, 0d), max))
            {
                section.Set(maxKey, max);
                changed = true;
            }

            if (!Equals(section.GetDouble(minKey, 0d), min))
            {
                section.Set(minKey, min);
                changed = true;
            }

            return(changed);
        }
示例#5
0
        public string ReadString(string section, string ident, string def = "")
        {
            string         result   = def;
            IniFileSection oSection = sectionList.SectionByName(section, CaseSensitive);

            if (oSection != null)
            {
                IniFileKey oKey = oSection.KeyList.KeyByName(ident, CaseSensitive);
                if (oKey != null)
                {
                    if (StripQuotes)
                    {
                        int j = oKey.Value.Length;
                        if (j > 1)
                        {
                            result = oKey.Value.Trim('\'', '"');
                        }
                        else
                        {
                            result = oKey.Value;
                        }
                    }
                    else
                    {
                        result = oKey.Value;
                    }
                }
            }
            return(result);
        }
示例#6
0
            public override void Set(IniFile file)
            {
                var section = file["RACE"];

                section.SetId("MODEL", CarId ?? "");
                section.SetId("MODEL_CONFIG", "");
                section.SetId("SKIN", CarSkinId ?? "");
                section.SetId("TRACK", TrackId ?? "");
                section.SetId("CONFIG_TRACK", TrackConfigurationId ?? "");

                if (!section.ContainsKey("AI_LEVEL"))
                {
                    section.Set("AI_LEVEL", 100);
                }

                file["CAR_0"] = new IniFileSection(null)
                {
                    ["SETUP"]        = CarSetupId?.ToLowerInvariant() ?? "",
                    ["SKIN"]         = CarSkinId?.ToLowerInvariant(),
                    ["MODEL"]        = "-",
                    ["MODEL_CONFIG"] = "",
                    ["BALLAST"]      = Ballast,
                    ["RESTRICTOR"]   = Restrictor,
                    ["DRIVER_NAME"]  = DriverName,
                    ["NATION_CODE"]  = DriverNationCode ?? GetNationCode(DriverNationality),
                    ["NATIONALITY"]  = DriverNationality
                };

                file["OPTIONS"].Set("USE_MPH", UseMph);
            }
示例#7
0
 private void MaybeDeleteSection(IniFileSection section)
 {
     if (section.Empty)
     {
         DeleteSection(section);
     }
 }
示例#8
0
            public StrutSuspension(IniFileSection basic, IniFileSection section, bool front, float xOffset, float wheelRadius) : base(front, wheelRadius)
            {
                var baseY      = section.GetFloat("BASEY", 1f);
                var track      = section.GetFloat("TRACK", 1f);
                var wheelbase  = basic.GetFloat("WHEELBASE", 2f);
                var cgLocation = basic.GetFloat("CG_LOCATION", 0.5f);

                StaticCamber = basic.GetFloat("STATIC_CAMBER", 0f);
                RefPoint     = front ?
                               new Vector3(track * 0.5f * xOffset, baseY, wheelbase * (1f - cgLocation)) :
                               new Vector3(track * 0.5f * xOffset, baseY, -wheelbase * cgLocation);

                Points[0] = section.GetSlimVector3("STRUT_CAR");
                Points[1] = section.GetSlimVector3("STRUT_TYRE");
                Points[2] = section.GetSlimVector3("WBCAR_BOTTOM_FRONT");
                Points[3] = section.GetSlimVector3("WBCAR_BOTTOM_REAR");
                Points[5] = section.GetSlimVector3("WBTYRE_BOTTOM");
                Points[6] = section.GetSlimVector3("WBCAR_STEER");
                Points[7] = section.GetSlimVector3("WBTYRE_STEER");

                for (var i = Points.Length - 1; i >= 0; i--)
                {
                    Points[i].X *= -xOffset;
                }
            }
        public ServerPresetDriverEntry Clone()
        {
            var s = new IniFileSection(null);

            SaveTo(s, true);
            return(new ServerPresetDriverEntry(s));
        }
示例#10
0
 internal FlameDescription(string name, IniFileSection fileSection, Matrix graphicMatrix)
 {
     Name      = name;
     Position  = fileSection.GetSlimVector3("POSITION");
     Direction = fileSection.GetSlimVector3("DIRECTION");
     Group     = fileSection.GetInt("GROUP", 0);
 }
示例#11
0
 internal ColliderDescription(string name, IniFileSection fileSection)
 {
     Name         = name;
     Center       = fileSection.GetSlimVector3("CENTRE");
     Size         = fileSection.GetSlimVector3("SIZE");
     GroundEnable = fileSection.GetBool("GROUND_ENABLE", true);
 }
示例#12
0
        /// <summary>
        /// Loads the Parameter Identification entries from the given file.
        /// </summary>
        /// <param name="filePathAndName"> The fully qualified file path and name. </param>
        /// <returns> The list of loaded ParameterIdentification objects. </returns>
        public static List <IniFileEntry> LoadDtcDescriptions(string filePathAndName)
        {
            if (!System.IO.File.Exists(filePathAndName))
            {
                Diagnostics.DiagnosticLogger.Log("Could not find given dtc file " + filePathAndName);
                return(new List <IniFileEntry>());
            }

            List <IniFileEntry> descriptions = new List <IniFileEntry>();

            Utilities.IniFile file = new Utilities.IniFile(filePathAndName);
            file.Read();

            // load all trouble code descriptions, this will get
            // all codes regardless of what type they belong to
            for (int sectionIndex = 0; sectionIndex < file.Sections.Count; sectionIndex++)
            {
                IniFileSection section = file.Sections.ElementAt(sectionIndex).Value;
                for (int entryIndex = 0; entryIndex < section.Entries.Count; entryIndex++)
                {
                    descriptions.Add(section.Entries.ElementAt(entryIndex).Value);
                }
            }

            return(descriptions);
        }
示例#13
0
 public WingAnimation(IniFileSection section) : base(section.GetNonEmpty("FILE"), section.GetFloat("TIME", 1f))
 {
     Id         = section.GetInt("WING", 0);
     Next       = section.GetIntNullable("NEXT");
     StartAngle = section.GetFloat("MIN", 0f);
     AngleRange = section.GetFloat("MAX", 60f) - StartAngle;
 }
示例#14
0
 protected override void Load(IniFileSection section)
 {
     base.Load(section);
     LapsCount = section.GetInt("LAPS", 5);
     WaitTime  = TimeSpan.FromSeconds(section.GetInt("WAIT_TIME", 60));
     JoinType  = section.GetIntEnum("IS_OPEN", ServerPresetRaceJoinType.CloseAtStart);
 }
示例#15
0
        public static string GetTyreName(this IniFileSection section)
        {
            var s = section.GetNonEmpty("SHORT_NAME");
            var n = section.GetNonEmpty("NAME");

            return(n == null ? (s ?? "<Unnamed>") : (s == null ? n : $"{n} ({s})"));
        }
示例#16
0
        public static SettingEntry GetEntry(this IniFileSection section, [LocalizationRequired(false)] string key, IList <SettingEntry> entries,
                                            int defaultValueId)
        {
            var value = section.GetNonEmpty(key);

            return(entries.FirstOrDefault(x => x.Value == value) ?? entries.FirstOrDefault(x => x.IntValue == defaultValueId) ?? entries.First());
        }
示例#17
0
        /// <summary>
        /// セクションコレクションからレイヤーアイテムを作成する。
        /// </summary>
        /// <param name="sections">セクションコレクション。</param>
        /// <param name="baseSection">ベースセクション。</param>
        /// <returns>レイヤーアイテム。</returns>
        private static LayerItem FromSectionsToLayerItem(
            IniFileSectionCollection sections,
            IniFileSection baseSection)
        {
            Debug.Assert(sections != null);
            Debug.Assert(baseSection != null);

            var result = new LayerItem();

            // ベースセクションのプロパティ値設定
            ExoFileItemsConverter.ToProperties(baseSection.Items, ref result);

            // コンポーネント群追加
            var componentSections =
                Enumerable
                .Range(0, int.MaxValue)
                .Select(
                    i =>
                    sections.FirstOrDefault(
                        s => s.Name == baseSection.Name + @"." + i))
                .TakeWhile(s => s != null);

            foreach (var cs in componentSections)
            {
                result.Components.Add(ComponentMaker.FromExoFileItems(cs.Items));
            }

            return(result);
        }
示例#18
0
 public WingDescription(IniFileSection section)
 {
     Name     = section.GetNonEmpty("NAME");
     Chord    = section.GetFloat("CHORD", 1f);
     Span     = section.GetFloat("SPAN", 1f);
     Angle    = section.GetFloat("ANGLE", 0f);
     Position = section.GetSlimVector3("POSITION");
 }
示例#19
0
 protected virtual void SetGroove(IniFile file, int virtualLaps = 10, int maxLaps = 1, int startingLaps = 1)
 {
     file["GROOVE"] = new IniFileSection {
         ["VIRTUAL_LAPS"]  = virtualLaps,
         ["MAX_LAPS"]      = maxLaps,
         ["STARTING_LAPS"] = startingLaps
     };
 }
示例#20
0
 public void SaveTo(IniFileSection section)
 {
     section.Set("GRAPHICS", WeatherId);
     section.Set("BASE_TEMPERATURE_AMBIENT", BaseAmbientTemperature);
     section.Set("BASE_TEMPERATURE_ROAD", BaseRoadTemperature);
     section.Set("VARIATION_AMBIENT", AmbientTemperatureVariation);
     section.Set("VARIATION_ROAD", RoadTemperatureVariation);
 }
示例#21
0
 public ServerWeatherEntry(IniFileSection section)
 {
     WeatherId = section.GetNonEmpty("GRAPHICS");
     BaseAmbientTemperature      = section.GetDouble("BASE_TEMPERATURE_AMBIENT", 18d);
     BaseRoadTemperature         = section.GetDouble("BASE_TEMPERATURE_ROAD", 6d);
     AmbientTemperatureVariation = section.GetDouble("VARIATION_AMBIENT", 2d);
     RoadTemperatureVariation    = section.GetDouble("VARIATION_ROAD", 1d);
 }
示例#22
0
 public static TurboDescription FromIniSection(IniFileSection turboSection) {
     return new TurboDescription {
         MaxBoost = turboSection.GetDouble("MAX_BOOST", 0d),
         Wastegate = turboSection.GetDouble("WASTEGATE", 0d),
         ReferenceRpm = turboSection.GetDouble("REFERENCE_RPM", 1000d),
         Gamma = turboSection.GetDouble("GAMMA", 1d)
     };
 }
示例#23
0
 public void SaveTo(IniFileSection section)
 {
     section.Set("POSX", PosX);
     section.Set("POSY", PosY);
     section.Set("VISIBLE", IsVisible);
     section.Set("BLOCKED", IsBlocked);
     section.Set("SCALE", Scale.ToDoublePercentage());
 }
示例#24
0
 public void LoadFrom(IniFileSection section)
 {
     PosX      = section.GetInt("POSX", 0);
     PosY      = section.GetInt("POSY", 0);
     IsVisible = section.GetBool("VISIBLE", false);
     IsBlocked = section.GetBool("BLOCKED", false);
     Scale     = section.GetDouble("SCALE", 1d).ToIntPercentage();
 }
示例#25
0
        private static void ProcessScripts(WeatherObject weather, IniFile file, int?customTime = null)
        {
            if (customTime.HasValue)
            {
                file = file.Clone();
                file["LIGHTING"].Set("SUN_ANGLE", Game.ConditionProperties.GetSunAngle(customTime.Value));
            }

            WeatherProceduralContext context = null;

            WeatherProceduralContext GetContext()
            {
                return(context ?? (context = new WeatherProceduralContext(file, weather.Location)));
            }

            var destination = customTime.HasValue ? Path.Combine(weather.Location, @"__special", customTime.Value.ToString()) : null;

            ProcessFile(weather, GetContext, @"weather.ini", new[] { @"CLOUDS", @"FOG", @"CAR_LIGHTS", @"__CLOUDS_TEXTURES", @"__CUSTOM_LIGHTING" },
                        (table, ini) => {
                var customClouds = table[@"CLOUDS_TEXTURES"];
                if (customClouds != null)
                {
                    ini[@"__CLOUDS_TEXTURES"].Set("LIST", ToIniFileValue(customClouds));
                }

                var extraParams = table[@"EXTRA_PARAMS"];
                if (extraParams != null)
                {
                    var s = new IniFileSection(null);
                    MapOutputSection(extraParams, s);
                    if (s.ContainsKey(@"TEMPERATURE_COEFF"))
                    {
                        ini[@"LAUNCHER"].Set("TEMPERATURE_COEFF", s.GetNonEmpty("TEMPERATURE_COEFF"));
                    }
                    if (s.ContainsKey(@"DISABLE_SHADOWS"))
                    {
                        ini[@"__LAUNCHER_CM"].Set("DISABLE_SHADOWS", s.GetNonEmpty("DISABLE_SHADOWS"));
                    }
                    if (s.ContainsKey(@"SKYBOX_REFLECTION_GAIN"))
                    {
                        ini[@"__LAUNCHER_CM"].Set("SKYBOX_REFLECTION_GAIN", s.GetNonEmpty("SKYBOX_REFLECTION_GAIN"));
                    }
                }

                MapOutputSection(table[@"LAUNCHER"], ini[@"LAUNCHER"], "TEMPERATURE_COEFF");
                MapOutputSection(table[@"__LAUNCHER_CM"], ini[@"__LAUNCHER_CM"], "DISABLE_SHADOWS", "SKYBOX_REFLECTION_GAIN");
                MapOutputSection(table[@"CUSTOM_LIGHTING"], ini[@"__CUSTOM_LIGHTING"]);
            }, destination);
            ProcessFile(weather, GetContext, @"colorCurves.ini", new[] { @"HEADER", @"HORIZON", @"SKY", @"SUN", @"AMBIENT" }, null, destination);
            ProcessFile(weather, GetContext, @"filter.ini", new[] {
                @"YEBIS", @"OPTIMIZATIONS", @"VARIOUS", @"AUTO_EXPOSURE", @"GODRAYS", @"HEAT_SHIMMER", @"TONEMAPPING", @"DOF", @"CHROMATIC_ABERRATION",
                @"FEEDBACK", @"VIGNETTING", @"DIAPHRAGM", @"AIRYDISC", @"GLARE", @"LENSDISTORTION", @"ANTIALIAS", @"COLOR"
            }, null, destination);
            ProcessFile(weather, GetContext, @"tyre_smoke.ini", new[] { @"SETTINGS", @"TRIGGERS" }, null, destination);
            ProcessFile(weather, GetContext, @"tyre_smoke_grass.ini", new[] { @"SETTINGS" }, null, destination);
            ProcessFile(weather, GetContext, @"tyre_pieces_grass.ini", new[] { @"SETTINGS" }, null, destination);
            ProcessFile(weather, GetContext, @"track_state.ini", new[] { @"TRACK_STATE" }, null, destination);
        }
示例#26
0
 public static TurboDescription FromIniSection(IniFileSection turboSection)
 {
     return(new TurboDescription {
         MaxBoost = turboSection.GetDouble("MAX_BOOST", 0d),
         Wastegate = turboSection.GetDouble("WASTEGATE", 0d),
         ReferenceRpm = turboSection.GetDouble("REFERENCE_RPM", 1000d),
         Gamma = turboSection.GetDouble("GAMMA", 1d)
     });
 }
示例#27
0
 private SurfaceDescription(IniFileSection section)
 {
     Key          = section.GetNonEmpty("KEY") ?? "";
     IsValidTrack = section.GetBool("IS_VALID_TRACK", false);
     IsPitlane    = section.GetBool("IS_PITLANE", false);
     DirtAdditive = section.GetDouble("DIRT_ADDITIVE", 0.0);
     Friction     = section.GetDouble("FRICTION", 0.8);
     AudioEffect  = section.GetNonEmpty("WAV");
 }
示例#28
0
 protected override void SetSessions(IniFile file)
 {
     file["SESSION_0"] = new IniFileSection {
         ["NAME"]             = "Track Day",
         ["DURATION_MINUTES"] = 720,
         ["SPAWN_SET"]        = StartType.Pit.Id,
         ["TYPE"]             = UsePracticeSessionType ? SessionType.Practice : SessionType.Qualification
     };
 }
示例#29
0
 protected virtual void SetSessions(IniFile file)
 {
     file["SESSION_0"] = new IniFileSection {
         ["NAME"]      = SessionName,
         ["TYPE"]      = SessionType.Drag,
         ["SPAWN_SET"] = StartType.Id,
         ["MATCHES"]   = MatchesCount
     };
 }
 public static TurboControllerDescription FromIniSection(IniFileSection controllerSection) {
     return new TurboControllerDescription {
         UpLimit = controllerSection.GetDouble("UP_LIMIT", double.NaN),
         DownLimit = controllerSection.GetDouble("DOWN_LIMIT", double.NaN),
         Filter = controllerSection.GetDouble("FILTER", 0.99d),
         Combinator = controllerSection.GetEnum("COMBINATOR", Combinator.None),
         Input = controllerSection.GetEnum("INPUT", ControllerInput.None),
         Lut = controllerSection.GetLut("LUT")
     };
 }
示例#31
0
        private static string GetMissingLutName(DataWrapper data, IniFileSection section, string key)
        {
            var v = section.GetNonEmpty(key);

            if (v == null)
            {
                return(null);
            }
            return(!Lut.IsInlineValue(v) && (!data.Contains(v) || data.GetLutFile(v).Values.Count == 0) ? v : null);
        }
示例#32
0
 public static TrackProperties Load(IniFileSection section)
 {
     return(new TrackProperties {
         Preset = section.GetIntNullable("Preset"),
         SessionStart = section.GetInt("SESSION_START", 95),
         Randomness = section.GetInt("RANDOMNESS", 2),
         LapGain = section.GetInt("LAP_GAIN", 10),
         SessionTransfer = section.GetInt("SESSION_TRANSFER", 90)
     });
 }
示例#33
0
        private bool FixShadowMapBias(IniFileSection section) {
            var result = false;
            if (!section.ContainsKey("SHADOW_MAP_BIAS_0")) {
                result = true;
                section.Set("SHADOW_MAP_BIAS_0", "0.000002");
            }

            if (!section.ContainsKey("SHADOW_MAP_BIAS_1")) {
                result = true;
                section.Set("SHADOW_MAP_BIAS_1", "0.000015");
            }

            if (!section.ContainsKey("SHADOW_MAP_BIAS_2")) {
                result = true;
                section.Set("SHADOW_MAP_BIAS_2", "0.0003");
            }

            return result;
        }
示例#34
0
 public virtual void Initialize(CarLightType type, Kn5RenderableList main, IniFileSection section) {
     Type = type;
     Name = section.GetNonEmpty("NAME");
     Emissive = section.GetVector3("COLOR").Select(y => (float)y).ToArray().ToVector3();
     Node = main.GetByName(Name);
 }