private static void EnsureInitialized() { if (_fsWatcher == null) { var directory = Path.Combine(AcPaths.GetDocumentsDirectory(), @"launcherdata", @"filestore"); Directory.CreateDirectory(directory); _fsWatcher = new FileSystemWatcher { Path = directory, NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName, EnableRaisingEvents = true }; } }
private LapTimesManager() { _sources = new[] { new LapTimesSource(CmSourceId, "Own CM storage", "Filled using shared memory or, if disabled, race results file.", "Settings.LapTimesSettings.SourceCm", true, true, null, null), new LapTimesSource(AcNewSourceId, "New AC storage", "Used by the original launcher. Much faster and more stable.", "Settings.LapTimesSettings.SourceAcNew", true, true, () => new AcLapTimesNewReader(AcPaths.GetDocumentsDirectory(), this), () => TracksManager.Instance.EnsureLoadedAsync()), #if AC_OLD_DB new LapTimesSource(AcOldSourceId, "Old AC database", "Used by the original launcher. Reading is quite wobbly, so I recommend to keep it disabled.", "Settings.LapTimesSettings.SourceAcDb", false, false, () => new AcLapTimesReader(FileUtils.GetDocumentsDirectory()), null), #endif new LapTimesSource(SidekickSourceId, "Sidekick", "Very good source of lap times, accurate and reliable.", "Settings.LapTimesSettings.SourceSidekick", true, false, () => new SidekickLapTimesReader(GetSidekickDirectory(), this), () => TracksManager.Instance.EnsureLoadedAsync()) { DetailsUrl = "http://www.racedepartment.com/downloads/sidekick.11007/", ExtraTools = { CreateSidekickFixTool(GetSidekickDirectory) } }, new LapTimesSource(RaceEssentialsSourceId, "Race Essentials", "Quite good source of lap times as well.", "Settings.LapTimesSettings.SourceRaceEssentials", true, false, () => new SidekickLapTimesReader(GetRaceEssentialsDirectory(), this), () => TracksManager.Instance.EnsureLoadedAsync()) { DetailsUrl = "http://www.racedepartment.com/downloads/sidekick.11007/", ExtraTools = { CreateSidekickFixTool(GetRaceEssentialsDirectory) } }, new LapTimesSource(Ov1InfoSourceId, "Rivali OV1 Info", "Sadly, there is no information about entries date. If you need a patch for 64-bit AC or layouts support, you can get it [url=\"https://acstuff.ru/f/d/15-rivali-ov1-info\"]here[/url].", "Settings.LapTimesSettings.SourceOv1Info", false, false, () => new Ov1InfoLapTimesReader( Path.Combine(AcPaths.GetPythonAppsDirectory(AcRootDirectory.Instance.RequireValue), "OV1Info"), this), () => TracksManager.Instance.EnsureLoadedAsync()), }; Entries = new BetterObservableCollection <LapTimeEntry>(); }
private void UpdateDirectories() { CarsDirectories?.Obsolete(); TracksDirectories?.Obsolete(); ShowroomsDirectories?.Obsolete(); WeatherDirectories?.Obsolete(); PpFiltersDirectories?.Obsolete(); DriverModelsDirectories?.Obsolete(); PythonAppsDirectories?.Obsolete(); LuaAppsDirectories?.Obsolete(); CarsDirectories = Value == null ? null : new AcDirectories(AcPaths.GetCarsDirectory(Value)); TracksDirectories = Value == null ? null : new AcDirectories(AcPaths.GetTracksDirectory(Value)); ShowroomsDirectories = Value == null ? null : new AcDirectories(AcPaths.GetShowroomsDirectory(Value)); WeatherDirectories = Value == null ? null : new AcDirectories(AcPaths.GetWeatherDirectory(Value)); PpFiltersDirectories = Value == null ? null : new AcDirectories(AcPaths.GetPpFiltersDirectory(Value)); DriverModelsDirectories = Value == null ? null : new AcDirectories(AcPaths.GetDriverModelsDirectory(Value)); PythonAppsDirectories = Value == null ? null : new AcDirectories(AcPaths.GetPythonAppsDirectory(Value)); LuaAppsDirectories = Value == null ? null : new AcDirectories(Path.Combine(Value, "apps", "lua")); FontsDirectories = Value == null ? null : new AcDirectories(AcPaths.GetFontsDirectory(Value)); KunosCareerDirectories = Value == null ? null : new AcDirectories(AcPaths.GetKunosCareerDirectory(Value)); FileUtils.EnsureDirectoryExists(AcPaths.GetReplaysDirectory()); ReplaysDirectories = ReplaysDirectories ?? new MultiDirectories(AcPaths.GetReplaysDirectory(), null); var champsDirectory = Path.Combine(AcPaths.GetDocumentsDirectory(), "champs"); if (!Directory.Exists(champsDirectory) && File.Exists(champsDirectory)) { champsDirectory = Path.Combine(AcPaths.GetDocumentsDirectory(), "champs_cm"); } UserChampionshipsDirectories = UserChampionshipsDirectories ?? new AcDirectories(champsDirectory); CarsDirectories?.CreateIfMissing(); TracksDirectories?.CreateIfMissing(); ShowroomsDirectories?.CreateIfMissing(); WeatherDirectories?.CreateIfMissing(); PpFiltersDirectories?.CreateIfMissing(); DriverModelsDirectories?.CreateIfMissing(); PythonAppsDirectories?.CreateIfMissing(); LuaAppsDirectories?.CreateIfMissing(); UserChampionshipsDirectories?.CreateIfMissing(); }
protected void Execute(string command) { if (string.IsNullOrWhiteSpace(command)) { return; } command = VariablesReplacement.Process(command, _properties, null); Logging.Write($"Executing command: “{command}”"); try { var proc = Process.Start(new ProcessStartInfo { FileName = "cmd", Arguments = $"/C \"{command}\"", UseShellExecute = false, WorkingDirectory = AcPaths.GetDocumentsDirectory(), RedirectStandardOutput = true, RedirectStandardError = true, }); if (proc == null) { throw new Exception(ToolsStrings.GameCommand_UnknownProblem); } proc.OutputDataReceived += Process_OutputDataReceived; proc.ErrorDataReceived += Process_ErrorDataReceived; proc.BeginOutputReadLine(); proc.BeginErrorReadLine(); if (!proc.WaitForExit(OptionCommandTimeout)) { proc.Kill(); throw new InformativeException(ToolsStrings.GameCommand_TimeoutExceeded, string.Format(ToolsStrings.GameCommand_TimeoutExceeded_Commentary, (double)OptionCommandTimeout / 1000)); } } catch (Exception e) { NonfatalError.Notify(ToolsStrings.GameCommand_CannotExecute, e); } }
private string ResolvePath(string relativeTo) { return(Environment.ExpandEnvironmentVariables(Regex.Replace(relativeTo, @"%(\w+?)%", m => { if (string.Equals(m.Groups[1].Value, "Documents", StringComparison.OrdinalIgnoreCase)) { return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); } if (string.Equals(m.Groups[1].Value, "ACDocuments", StringComparison.OrdinalIgnoreCase)) { return AcPaths.GetDocumentsDirectory(); } if (string.Equals(m.Groups[1].Value, "ACRoot", StringComparison.OrdinalIgnoreCase)) { return AcRootDirectory.Instance.Value; } if (string.Equals(m.Groups[1].Value, "LocalDir", StringComparison.OrdinalIgnoreCase)) { return FilesRelativeDirectory; } return m.Value; }))); }