public void FindActivePresetFilesIncludesUnknownCategories() { using var dirOpts = new TestFolder(_gof.FullName); dirOpts.WriteText(@"Bindings\StartPreset.start", "Custom\nCustom2\nKeyboard\nCustom\nCustom2"); var gof = new GameOptionsFolder(dirOpts.Name); Assert.True(gof.IsValid); var files = BindingPreset.FindActivePresetFiles(_gif, gof); Assert.Equal(_bindingCategories + 1, files.Count); var expected = new Dictionary <BindingCategory, string> { [BindingCategory.GeneralControls] = dirOpts.Resolve(@"Bindings\Custom.3.0.binds"), [BindingCategory.ShipControls] = dirOpts.Resolve(@"Bindings\Custom2.3.0.binds"), [BindingCategory.SrvControls] = Path.Combine(_gif.FullName, @"ControlSchemes\Keyboard.binds"), [BindingCategory.OnFootControls] = dirOpts.Resolve(@"Bindings\Custom.3.0.binds"), [(BindingCategory)4] = dirOpts.Resolve(@"Bindings\Custom2.3.0.binds"), }; foreach (var category in expected.Keys) { Assert.Equal(expected[category], files[category]); } }
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(); }
/// <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)); }
public void FindActivePresetFilesReturnsNullWhenNeither1Or4PresetFilesAreDefined() { using var dirOpts = new TestFolder(_gof.FullName); dirOpts.WriteText(@"Bindings\StartPreset.start", "Custom\nCustom2"); var gof = new GameOptionsFolder(dirOpts.Name); Assert.True(gof.IsValid); var files = BindingPreset.FindActivePresetFiles(_gif, gof); Assert.Null(files); }
public void FindActivePresetFilesReturnsNullWhenAPresetFileIsMissing() { using var dirOpts = new TestFolder(_gof.FullName); dirOpts.WriteText(@"Bindings\StartPreset.start", "Custom\nCustom2\nMISSING_PRESET\nKeyboard"); var gof = new GameOptionsFolder(dirOpts.Name); Assert.True(gof.IsValid); var files = BindingPreset.FindActivePresetFiles(_gif, gof); Assert.Null(files); }
/// <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; }
/// <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 void SupportsSingleLineStartPresets() { using var dirOpts = new TestFolder(_gof.FullName); dirOpts.WriteText(@"Bindings\StartPreset.start", "Custom"); var gof = new GameOptionsFolder(dirOpts.Name); Assert.True(gof.IsValid); var files = BindingPreset.FindActivePresetFiles(_gif, gof); Assert.Equal(_bindingCategories, files.Count); var expectedFile = dirOpts.Resolve(@"Bindings\Custom.3.0.binds"); Assert.All(files.Values, x => Assert.Equal(expectedFile, x)); }
public BindingsTests() { _gif = new GameInstallFolder(_gameRootFolder); _gof = new GameOptionsFolder(_gameOptionsFolder); }
public GraphicsTest() { _gif = new GameInstallFolder(_gameRootFolder); _gof = new GameOptionsFolder(_gameOptionsFolder); }