示例#1
0
        public void GetsTheListOfAlternateGameInstallFolders()
        {
            var paths = GameInstallFolder.GetAlternatePaths().ToList();

            Assert.True(paths.Count >= 0);
            Assert.All(GameInstallFolder.DefaultPaths, x => x.EndsWith(@"\Products\elite-dangerous-64", StringComparison.Ordinal));
        }
示例#2
0
        internal GameStateWatcher(string gameInstallFolder, string gameOptionsFolder, string journalFolder, INativeMethods nativeMethods)
        {
            var gif = new GameInstallFolder(gameInstallFolder);
            var gof = new GameOptionsFolder(gameOptionsFolder);
            var jf  = new JournalFolder(journalFolder);

            _journalWatcher             = new JournalWatcher(jf);
            _journalWatcher.Started    += JournalWatcher_Started;
            _journalWatcher.EntryAdded += JournalWatcher_EntryAdded;

            _statusWatcher          = new StatusWatcher(jf);
            _statusWatcher.Changed += StatusWatcher_Changed;

            _bindingsWatcher          = new BindingsWatcher(gif, gof);
            _bindingsWatcher.Changed += BindingsWatcher_Changed;

            _graphicsConfig          = new GraphicsConfigWatcher(gif, gof);
            _graphicsConfig.Changed += GraphicsConfig_Changed;

            _modifierKeysWatcher          = new ModifierKeysWatcher(nativeMethods);
            _modifierKeysWatcher.Changed += ModifierKeysWatcher_Changed;

            _gameProcessWatcher          = new GameProcessWatcher(gif, nativeMethods);
            _gameProcessWatcher.Changed += GameProcessWatcher_Changed;

            _gameState = new GameState();
        }
示例#3
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));
        }
示例#4
0
        private bool ValidateFolders()
        {
            var settings = AppSettings.Default;

            var gameInstall = settings.GameInstallFolder;
            var gameOptions = settings.GameOptionsFolder;
            var journal     = settings.JournalFolder;

            var firstTimeRun = string.IsNullOrEmpty(gameInstall) &&
                               string.IsNullOrEmpty(gameOptions) &&
                               string.IsNullOrEmpty(journal);

            if (firstTimeRun)
            {
                gameInstall = GetPossibleGameInstallFolders().FirstOrDefault(Directory.Exists);
                gameOptions = GameOptionsFolder.DefaultPath;
                journal     = JournalFolder.DefaultPath;
            }

            var allValid = new GameInstallFolder(gameInstall).IsValid &&
                           new GameOptionsFolder(gameOptions).IsValid &&
                           new JournalFolder(journal).IsValid;

            if (!allValid)
            {
                MessageBox.Show(
                    Resources.MsgBox_UnableToIdentifyFolders,
                    FrmAboutBox.AssemblyTitle,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation);

                using var frm = new FrmAppSettings();

                frm.txtGameInstall.Text = gameInstall;
                frm.txtGameOptions.Text = gameOptions;
                frm.txtJournal.Text     = journal;

                if (frm.ShowDialog(ContextMenu) != DialogResult.OK)
                {
                    return(false);
                }

                gameInstall = frm.txtGameInstall.Text;
                gameOptions = frm.txtGameOptions.Text;
                journal     = frm.txtJournal.Text;
            }

            settings.GameInstallFolder = gameInstall;
            settings.GameOptionsFolder = gameOptions;
            settings.JournalFolder     = journal;
            settings.Save();

            return(true);
        }
        public GameProcessWatcher(GameInstallFolder gameInstallFolder)
        {
            _mainExePath = gameInstallFolder.MainExecutable.FullName;

            _timer = new Timer
            {
                Interval  = 200,
                AutoReset = true,
                Enabled   = false,
            };
            _timer.Elapsed += Timer_Elapsed;
        }
        /// <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;
        }
示例#7
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;
        }
        public GameProcessWatcher(GameInstallFolder gameInstallFolder, INativeMethods nativeMethods)
            : base(nativeMethods)
        {
            _mainExePath        = gameInstallFolder.MainExecutable.FullName;
            _gameProcessTracker = new GameProcessTracker(_mainExePath, nativeMethods);

            _timer = new Timer
            {
                Interval  = _gameForegroundCheckInterval,
                AutoReset = true,
                Enabled   = false,
            };
            _timer.Elapsed += Timer_Elapsed;
        }
示例#9
0
 public BindingsTests()
 {
     _gif = new GameInstallFolder(_gameRootFolder);
     _gof = new GameOptionsFolder(_gameOptionsFolder);
 }
示例#10
0
 public EffectLayerTest()
 {
     _gif = new GameInstallFolder(_gameRootFolder);
 }
示例#11
0
 public GraphicsTest()
 {
     _gif = new GameInstallFolder(_gameRootFolder);
     _gof = new GameOptionsFolder(_gameOptionsFolder);
 }
示例#12
0
        public void GetsTheListOfAlternateGameInstallFolders()
        {
            var paths = GameInstallFolder.GetAlternatePaths().ToList();

            Assert.True(paths.Count >= 0);
        }