示例#1
0
        /// <summary>
        /// Gets the path of the currently active binding preset file.
        /// </summary>
        /// <param name="gameInstallFolder">The path to the game installation folder.</param>
        /// <param name="gameOptionsFolder">The path to the game options folder.</param>
        /// <param name="isCustom"><c>true</c> if the returned file is a custom preset; <c>false</c> if it's a game preset file.</param>
        /// <returns>The path to the file, or <c>null</c> if no active preset could be found.</returns>
        public static string FindActivePresetFile(GameInstallFolder gameInstallFolder, GameOptionsFolder gameOptionsFolder, out bool isCustom)
        {
            GameInstallFolder.AssertValid(gameInstallFolder);
            GameOptionsFolder.AssertValid(gameOptionsFolder);

            string bindsName;

            using (var fs = gameOptionsFolder.BindingsStartPreset.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                using (var sr = new StreamReader(fs))
                {
                    bindsName = sr.ReadToEnd();
                }
            }

            var customBindsFile = TryGetBindingsFilePath(gameOptionsFolder.Bindings, bindsName);

            if (customBindsFile != null)
            {
                isCustom = true;
                return(customBindsFile);
            }

            isCustom = false;
            return(TryGetBindingsFilePath(gameInstallFolder.ControlSchemes, bindsName));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsConfigWatcher"/> class
        /// with the given game installation folder and game options folder paths.
        /// </summary>
        /// <param name="gameInstallFolder">The path to the game installation folder.</param>
        /// <param name="gameOptionsFolder">The path to the game options folder.</param>
        public GraphicsConfigWatcher(GameInstallFolder gameInstallFolder, GameOptionsFolder gameOptionsFolder)
        {
            GameInstallFolder.AssertValid(gameInstallFolder);
            GameOptionsFolder.AssertValid(gameOptionsFolder);

            _mainFile             = gameInstallFolder.GraphicsConfiguration;
            _mainWatcher          = new EliteFileSystemWatcher(_mainFile);
            _mainWatcher.Changed += GraphicsConfig_Changed;

            _overrideFile             = gameOptionsFolder.GraphicsConfigurationOverride;
            _overrideWatcher          = new EliteFileSystemWatcher(_overrideFile);
            _overrideWatcher.Changed += GraphicsConfig_Changed;
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BindingsWatcher"/> class
        /// with the given game installation folder and game options folder paths.
        /// </summary>
        /// <param name="gameInstallFolder">The path to the game installation folder.</param>
        /// <param name="gameOptionsFolder">The path to the game options folder.</param>
        public BindingsWatcher(GameInstallFolder gameInstallFolder, GameOptionsFolder gameOptionsFolder)
        {
            _gameInstallFolder = GameInstallFolder.AssertValid(gameInstallFolder);
            _gameOptionsFolder = GameOptionsFolder.AssertValid(gameOptionsFolder);

            var customBindingsPath = gameOptionsFolder.Bindings.FullName;

            _startPresetWatcher          = new EliteFileSystemWatcher(customBindingsPath, gameOptionsFolder.BindingsStartPreset.Name);
            _startPresetWatcher.Changed += Bindings_Changed;

            _customBindsWatcher          = new EliteFileSystemWatcher(customBindingsPath);
            _customBindsWatcher.Changed += Bindings_Changed;
        }