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);
        }
Esempio n. 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);
 }
Esempio n. 3
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);
 }
Esempio n. 4
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());
 }
Esempio n. 5
0
 public void SaveTo(IniFileSection section)
 {
     section.SetOrRemove("MODEL", CarId);
     section.SetOrRemove("SKIN", CarSkinId);
     section.SetOrRemove("SPECTATOR_MODE", SpectatorMode);
     section.SetOrRemove("DRIVERNAME", DriverName);
     section.SetOrRemove("TEAM", TeamName);
     section.SetOrRemove("GUID", Guid);
     section.Set("BALLAST", Ballast);
     section.Set("RESTRICTOR", Restrictor);
 }
Esempio n. 6
0
            public void Set(IniFileSection section)
            {
                if (Preset.HasValue)
                {
                    section.Set("PRESET", Preset);
                }
                else
                {
                    section.Remove("PRESET");
                }

                section.Set("SESSION_START", SessionStart);
                section.Set("RANDOMNESS", Randomness);
                section.Set("LAP_GAIN", LapGain);
                section.Set("SESSION_TRANSFER", SessionTransfer);
            }
Esempio n. 7
0
        private static bool SetRange(IniFileSection section, string key1, string key2, [CanBeNull] Tuple <double, double> range)
        {
            var changed = false;

            if (range != null && !Equals(section.GetDouble(key1, 0d), range.Item1))
            {
                section.Set(key1, range.Item1);
                changed = true;
            }

            if (range != null && !Equals(section.GetDouble(key2, 0d), range.Item2))
            {
                section.Set(key2, range.Item2);
                changed = true;
            }

            return(changed);
        }
Esempio n. 8
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;
        }
Esempio n. 9
0
        public static void SetGenericModDependancies(this IniFileSection section, string key, [CanBeNull] IEnumerable <string> values)
        {
            var v = values?.OrderBy(x => x).Select(x => $"\"{x}\"").JoinToString();

            if (string.IsNullOrWhiteSpace(v))
            {
                section.Remove(key);
            }
            else
            {
                section.Set(key, v);
            }
        }
Esempio n. 10
0
        private static void MapOutputSection(object outputValue, IniFileSection resultSection, [Localizable(false)] params string[] keys)
        {
            switch (outputValue)
            {
            case IniFileSection e:
                foreach (var v in e)
                {
                    if (!(keys?.Length > 0) || keys.Contains(v.Key))
                    {
                        resultSection.Set(v.Key, v.Value);
                    }
                }
                break;

            case LuaIniSection e:
                foreach (var v in e.ToIniValues())
                {
                    if (!(keys?.Length > 0) || keys.Contains(v.Key))
                    {
                        resultSection.Set(v.Key, v.Value);
                    }
                }
                break;

            case Table o:
                foreach (var key in o.Keys)
                {
                    var keyString = key.CastToString();
                    if (!(keys?.Length > 0) || keys.Contains(keyString))
                    {
                        resultSection[keyString] = ToIniFileValue(o[key]);
                    }
                }
                break;
            }
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
 public void SaveTo(IniFileSection section, bool allowCspOptions)
 {
     section.SetOrRemove("MODEL", CarId);
     if (allowCspOptions && CspOptions.Pack(out var packed))
     {
         section.Set("SKIN", CarSkinId + "/" + packed);
     }
     else
     {
         section.SetOrRemove("SKIN", CarSkinId);
     }
     section.Set("SPECTATOR_MODE", SpectatorMode);
     section.Set("DRIVERNAME", DriverName ?? "");
     section.Set("TEAM", TeamName ?? "");
     section.Set("GUID", Guid ?? "");
     section.Set("BALLAST", Ballast);
     section.Set("RESTRICTOR", Restrictor);
 }
Esempio n. 13
0
 protected virtual void Save(IniFileSection session, IniFileSection main)
 {
     session.Set("NAME", string.IsNullOrWhiteSpace(ConfigName) ? DisplayName : ConfigName);
     session.Set("TIME", Time.TotalMinutes); // round?
     session.Set("IS_OPEN", IsOpen);
 }
Esempio n. 14
0
 public static void Set(this IniFileSection section, [LocalizationRequired(false)] string key, SettingEntry entry)
 {
     section.Set(key, entry.Value);
 }
Esempio n. 15
0
 public static void Set(this IniFileSection section, [LocalizationRequired(false)] string key, Color entry, double multipler)
 {
     section.Set(key, $"{entry.R.ToInvariantString()},{entry.G.ToInvariantString()},{entry.B.ToInvariantString()},{multipler.ToInvariantString()}");
 }
Esempio n. 16
0
 protected override void Save(IniFileSection session, IniFileSection main)
 {
     base.Save(session, main);
     main.Set("QUALIFY_MAX_WAIT_PERC", QualifyLimitPercentage);
 }
Esempio n. 17
0
 public static void SetSlimVector3(this IniFileSection section, string key, Vector3 value)
 {
     section.Set(key, value.ToArray());
 }
Esempio n. 18
0
 public static void SetNormalizedColor(this IniFileSection section, [LocalizationRequired(false)] string key, Color entry)
 {
     section.Set(key, $"{(entry.R / 255d).Round(0.001).ToInvariantString()},{(entry.G / 255d).Round(0.001).ToInvariantString()},{(entry.B / 255d).Round(0.001).ToInvariantString()}");
 }