Exemple #1
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})"));
        }
Exemple #2
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);
        }
Exemple #3
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");
 }
        public ServerPresetDriverEntry(IniFileSection section)
        {
            CarId = section.GetNonEmpty("MODEL") ?? DefaultCarId;

            CarSkinId     = section.GetNonEmpty("SKIN");
            SpectatorMode = section.GetBool("SPECTATOR_MODE", false);
            DriverName    = section.GetNonEmpty("DRIVERNAME");
            TeamName      = section.GetNonEmpty("TEAM");
            Guid          = section.GetNonEmpty("GUID");
            Ballast       = section.GetDouble("BALLAST", 0d);
        }
Exemple #5
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);
 }
Exemple #6
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;
 }
Exemple #7
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());
        }
Exemple #8
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);
 }
Exemple #9
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");
 }
Exemple #10
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);
        }
Exemple #11
0
        public static SettingEntry GetEntry(this IniFileSection section, [LocalizationRequired(false)] string key, IList <SettingEntry> entries,
                                            [LocalizationRequired(false), NotNull] string defaultValueId)
        {
            if (defaultValueId == null)
            {
                throw new ArgumentNullException(nameof(defaultValueId));
            }
            var value = section.GetNonEmpty(key);

            return(entries.FirstOrDefault(x => x.Value == value) ?? entries.GetByIdOrDefault(defaultValueId) ?? entries.First());
        }
 /// <summary>
 /// Create a new AssistsViewModel which will load data from serialized string, but won’t
 /// save any changes if they will occur.
 /// </summary>
 /// <param name="section">INI-file section.</param>
 public static TrackStateViewModelBase CreateBuiltIn([NotNull] IniFileSection section)
 {
     return(new TrackStateViewModelBase(null, false)
     {
         GripStart = section.GetDouble("SESSION_START", 95d) / 100d,
         GripTransfer = section.GetDouble("SESSION_TRANSFER", 90d) / 100d,
         GripRandomness = section.GetDouble("RANDOMNESS", 2d) / 100d,
         LapGain = section.GetInt("LAP_GAIN", 132),
         Description = section.GetNonEmpty("DESCRIPTION")
     });
 }
        public ServerPresetDriverEntry(IniFileSection section)
        {
            CarId = section.GetNonEmpty("MODEL") ?? DefaultCarId;

            var carSkinId = section.GetNonEmpty("SKIN")?.Split('/');

            CarSkinId = carSkinId?[0];
            CspOptions.LoadPacked(carSkinId?.ElementAtOrDefault(1));

            SpectatorMode = section.GetBool("SPECTATOR_MODE", false);
            DriverName    = section.GetNonEmpty("DRIVERNAME");
            TeamName      = section.GetNonEmpty("TEAM");
            Guid          = section.GetNonEmpty("GUID");
            Ballast       = section.GetDouble("BALLAST", 0d);
            Restrictor    = section.GetDouble("RESTRICTOR", 0d);
            CspOptions.PropertyChanged += (sender, args) => {
                Logging.Write($"ARG: {args.PropertyName}");

                // ReSharper disable once NotResolvedInText
                OnPropertyChanged(@"CspOptions.Inner");
            };
        }
Exemple #14
0
        public CarSetupEntry([NotNull] string key, IniFileSection section, [CanBeNull] AcLocaleProvider localeProvider, [NotNull] DataWrapper data)
        {
            Key         = key;
            DisplayName = localeProvider?.GetString("SETUP", section.GetNonEmpty("NAME"))
                          ?? CarSetupObject.FixEntryName(section.GetNonEmpty("NAME"), false) ?? key;
            HelpInformation = localeProvider?.GetString(AcLocaleProvider.CategoryTag, section.GetNonEmpty("HELP")) ?? section.GetNonEmpty("HELP");

            var ratios = section.GetNonEmpty("RATIOS");

            if (ratios != null)
            {
                Values    = data.GetRtoFile(ratios).Values;
                Minimum   = 0;
                Maximum   = Values.Count - 1;
                Step      = 1;
                StepsMode = CarSetupStepsMode.Steps;
                TabKey    = "GEARS";
            }
            else
            {
                Minimum      = section.GetDouble("MIN", 0);
                Maximum      = section.GetDouble("MAX", Minimum + 100);
                Step         = FixedStep(key) ?? section.GetDouble("STEP", 1d);
                StepsMode    = section.GetIntEnum("SHOW_CLICKS", CarSetupStepsMode.ActualValue);
                UnitsPostfix = StepsMode == CarSetupStepsMode.ActualValue ? GetUnitsPostfix(key) : null;
                TabKey       = section.GetNonEmpty("TAB");
            }

            var defaultValue = GetDefaultValue(key, data);

            DefaultValue    = defaultValue ?? (Minimum + Maximum) / 2f;
            HasDefaultValue = defaultValue.HasValue;

            var range = Maximum - Minimum;

            VisualStep = range / Step < 10 ? Step : range / 10;
        }
Exemple #15
0
        public static SettingEntry GetOrCreateEntry(this IniFileSection section, [LocalizationRequired(false)] string key, IList <SettingEntry> entries,
                                                    Func <string, string> nameCallback)
        {
            var value = section.GetNonEmpty(key);
            var entry = entries.FirstOrDefault(x => x.Value == value);

            if (entry != null)
            {
                return(entry);
            }
            if (string.IsNullOrWhiteSpace(value))
            {
                return(entries.First());
            }
            entries.Add(new SettingEntry(value, nameCallback(value)));
            return(entries.Last());
        }
Exemple #16
0
        private static bool Process(string lightingIniFilename, [CanBeNull] IniFileSection replacementSection)
        {
            var lightingIni     = new IniFile(lightingIniFilename);
            var lightingSection = lightingIni["LIGHTING"];
            var changed         = false;

            foreach (var key in Keys)
            {
                var backupKey        = @"__CM_BACKUP_" + key;
                var replacementValue = replacementSection?.GetNonEmpty(key);
                Logging.Debug($"{key}: {replacementValue}");

                if (replacementValue != null)
                {
                    if (!lightingSection.ContainsKey(backupKey))
                    {
                        lightingSection.Set(backupKey, lightingSection.GetPossiblyEmpty(key));
                    }

                    lightingSection.Set(key, replacementValue);
                    LastModified.Value = lightingIni.Filename;
                    changed            = true;
                }
                else if (lightingSection.ContainsKey(backupKey))
                {
                    lightingSection.Set(key, lightingSection.GetPossiblyEmpty(backupKey));
                    lightingSection.Remove(backupKey);
                    changed = true;
                }
            }

            if (changed)
            {
                lightingIni.Save();
            }

            return(changed);
        }
Exemple #17
0
        protected override bool SetOverride(WeatherObject weather, IniFile file)
        {
            WeatherProceduralContext context = null;

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

            var directory = Environment.CurrentDirectory;

            Environment.CurrentDirectory = AcRootDirectory.Instance.RequireValue;

            try {
                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"));
                        }
                    }

                    MapOutputSection(table[@"LAUNCHER"], ini[@"LAUNCHER"], "TEMPERATURE_COEFF");
                    MapOutputSection(table[@"__LAUNCHER_CM"], ini[@"__LAUNCHER_CM"], "DISABLE_SHADOWS");
                    MapOutputSection(table[@"CUSTOM_LIGHTING"], ini[@"__CUSTOM_LIGHTING"]);
                });
                ProcessFile(weather, GetContext, @"colorCurves.ini", new[] { @"HEADER", @"HORIZON", @"SKY", @"SUN", @"AMBIENT" });
                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"
                });
                ProcessFile(weather, GetContext, @"tyre_smoke.ini", new[] { @"SETTINGS", @"TRIGGERS" });
                ProcessFile(weather, GetContext, @"tyre_smoke_grass.ini", new[] { @"SETTINGS" });

                if (_updateRoadTemperature)
                {
                    var section = new IniFile(weather.IniFilename)["LAUNCHER"];
                    if (section.ContainsKey(@"TEMPERATURE_COEFF"))
                    {
                        file["TEMPERATURE"].Set("ROAD", Game.ConditionProperties.GetRoadTemperature(
                                                    Game.ConditionProperties.GetSeconds(file["LIGHTING"].GetDouble("SUN_ANGLE", 0d)),
                                                    file["TEMPERATURE"].GetDouble("AMBIENT", 20d),
                                                    section.GetDouble(@"TEMPERATURE_COEFF", 0d)), "F0");
                    }
                }
            } catch (ScriptRuntimeException e) {
                NonfatalError.NotifyBackground("Can’t run weather script", $"Exception at {e.DecoratedMessage}.", e);
            } catch (Exception e) {
                NonfatalError.NotifyBackground("Can’t run weather script", e);
            } finally {
                Environment.CurrentDirectory = directory;
            }

            return(false);
        }
Exemple #18
0
 protected virtual void Load(IniFileSection session, IniFileSection main)
 {
     ConfigName = session.GetNonEmpty("NAME") ?? DisplayName;
     Time       = TimeSpan.FromMinutes(session.GetDouble("TIME", 10d));
     IsOpen     = session.GetBool("IS_OPEN", true);
 }
Exemple #19
0
 internal LodDescription(IniFileSection fileSection)
 {
     FileName = fileSection.GetNonEmpty("FILE");
     In       = fileSection.GetFloat("IN", 0f);
     Out      = fileSection.GetFloat("OUT", 0f);
 }
Exemple #20
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);
 }
Exemple #21
0
 public static string[] GetGenericModDependancies(this IniFileSection section, string key)
 {
     return(section.GetNonEmpty(key)?.Split(new[] { '"' }, StringSplitOptions.RemoveEmptyEntries));
 }