private void buttonOK_Click(object sender, RoutedEventArgs e) { // Resolution if (_resolutionGeneralsChanged) { string[] resolution = ((ComboBoxItem)comboBoxGenerals.SelectedItem).Content.ToString().Split('x'); IniHelper.LineChanger(string.Format("Resolution = {0} {1}", resolution[0], resolution[1]), _pathToOptionIniGenerals, _optionIniResolutionGenerals.ResolutionNoLigne); } if (_resolutionHeureHChanged) { string[] resolution = ((ComboBoxItem)comboBoxHeureH.SelectedItem).Content.ToString().Split('x'); IniHelper.LineChanger(string.Format("Resolution = {0} {1}", resolution[0], resolution[1]), _pathToOptionIniHeureH, _optionIniResolutionHeureH.ResolutionNoLigne); } // Scroll if (_scrollChanged) { IniHelper.LineChanger(String.Format("ScrollFactor = {0}", sliderScrollFactor.Value), _pathToOptionIniGenerals, _optionIniResolutionGenerals.ScrollFactorNoLigne); IniHelper.LineChanger(String.Format("ScrollFactor = {0}", sliderScrollFactor.Value), _pathToOptionIniHeureH, _optionIniResolutionHeureH.ScrollFactorNoLigne); } // Settings int newCameraHeight = (int)sliderCameraHeight.Value; double newCameraSpeed = Math.Round(sliderCameraSpeed.Value / 100, 1); bool gregWareFullscreen = (bool)radioButtonFullscreenModeGregware.IsChecked; bool scrollWasd = (bool)checkBoxMiscScrollWasd.IsChecked; Properties.Settings.Default["ZoomMaxCameraHeight"] = newCameraHeight; Properties.Settings.Default["ZoomCameraAdjustSpeed"] = newCameraSpeed; Properties.Settings.Default["FullscreenModeGregware"] = gregWareFullscreen; Properties.Settings.Default["ScrollGregware"] = scrollWasd; Properties.Settings.Default.Save(); // Camera if (newCameraHeight != _zoomCameraHeightInitialValue || newCameraSpeed != _zoomCameraSpeedInitialValue) { ModFactory.AllGamesRefreshForceZoom(); } // Fullscreen mode if (gregWareFullscreen != _fullScreenModeGregwareInitialValue) { ModFactory.AllGamesRefreshFullscreenMode(); } // Fermer la fenêtre Close(); }
public Settings(string pathToOptionIniGenerals, string pathToOptionIniHeureH) { InitializeComponent(); // Initialisation _pathToOptionIniGenerals = pathToOptionIniGenerals; _pathToOptionIniHeureH = pathToOptionIniHeureH; // Lire le fichier option.ini _optionIniResolutionGenerals = IniHelper.GetOptionIni(_pathToOptionIniGenerals); _optionIniResolutionHeureH = IniHelper.GetOptionIni(_pathToOptionIniHeureH); // Trouver les résolutions supportées List <Dimension> resolutionsDispo = new List <Dimension>(); DEVMODE vDevMode = new DEVMODE(); int i = 0; while (EnumDisplaySettings(null, i, ref vDevMode)) { if (vDevMode.dmPelsWidth >= 800 && vDevMode.dmPelsHeight >= 600 && resolutionsDispo.Where(d => d.Width == vDevMode.dmPelsWidth && d.Height == vDevMode.dmPelsHeight).Count() <= 0) { resolutionsDispo.Add(new Dimension { Width = vDevMode.dmPelsWidth, Height = vDevMode.dmPelsHeight }); } i++; } // Initialiser les combobox résolution i = 0; _resolutionsItems = new Dictionary <int, Dimension>(); foreach (Dimension dim in resolutionsDispo.OrderBy(d => d.Width).ThenBy(d => d.Height)) { _resolutionsItems.Add(i, dim); string description = string.Format("{0}x{1}", dim.Width, dim.Height); comboBoxGenerals.Items.Add(new ComboBoxItem { Content = description }); comboBoxHeureH.Items.Add(new ComboBoxItem { Content = description }); i++; } }
private void ActiverGregwareCustomizations() { // Initialisation bool isFullscreenGregware = (bool)Properties.Settings.Default["FullscreenModeGregware"]; bool isScrollGregware = (bool)Properties.Settings.Default["ScrollGregware"]; bool isGentool = (bool)Properties.Settings.Default[string.Format("Current{0}Gentool", _currentGameName)]; int resolutionX = 0; int resolutionY = 0; // Validité if (!isFullscreenGregware && !isScrollGregware) { return; } // Trouver la résolution actuelle if (isFullscreenGregware) { string pathToOptionIni; if (_currentGameName.Equals("Generals", StringComparison.OrdinalIgnoreCase)) { pathToOptionIni = _pathToOptionIniGenerals; } else if (_currentGameName.Equals("HeureH", StringComparison.OrdinalIgnoreCase)) { pathToOptionIni = _pathToOptionIniHeureH; } else { throw new Exception(string.Format("Unknown game name {0}", _currentGameName)); } IniHelper.OptionIni optionIniResolution = IniHelper.GetOptionIni(pathToOptionIni); resolutionX = optionIniResolution.ResolutionX; resolutionY = optionIniResolution.ResolutionY; } // Activer _fullScreenGregware = new GregwareCustomizations(isFullscreenGregware, isScrollGregware, isGentool, resolutionX, resolutionY, _uiScheduler); _fullScreenGregware.Activer(); }