public GamePreferences(UISettings parentSettings, UserPreferences parentPrefs) { InitializeComponent(); ScreenResolution myScreens = new ScreenResolution(); List <ScreenResolution.AvailableScreen> lstRes = myScreens.GetScreenResolutions(); theSettings = parentSettings; myPrefs = parentPrefs; this.Loaded += new RoutedEventHandler(GamePreferences_Loaded); }
private void LoadValues(ValuesToLoad theValuesToLoad) { isInitialising = true; //open the ini files and check the current values IniFiles myFiles = new IniFiles(SWGANHPAth + "swg2uu_opt.cfg"); switch (theValuesToLoad) { case ValuesToLoad.Graphics: #region Graphics Options chkWindowedMode.IsChecked = myFiles.GetInt32("ClientGraphics", "windowed", 0) == 1; chkSafeRenderer.IsChecked = myFiles.GetInt32("ClientGraphics", "rasterMajor", 7) == 5 && myFiles.GetInt32("ClientGraphics", "useSafeRenderer", 0) == 1; chkBorderlessWindow.IsChecked = myFiles.GetInt32("ClientGraphics", "borderlessWindow", 0) == 1; chkDisableFastMouseCursor.IsChecked = myFiles.GetInt32("ClientUserInterface", "alwaysSetMouseCursor", 0) == 1; chkDisableHardwareMouseCursor.IsChecked = myFiles.GetInt32("ClientGraphics", "useHardwareMouseCursor", 0) == 0; chkDisableVSynch.IsChecked = myFiles.GetInt32("Direct3d9", "allowTearing", 0) == 1; chkUseLowDetailNormalMaps.IsChecked = myFiles.GetInt32("ClientGraphics", "discardHighestNormalMipMapLevels", 0) == 1; chkUseLowDetailTextures.IsChecked = myFiles.GetInt32("ClientGraphics", "discardHighestMipMapLevels", 0) == 1; chkConstrainMouseCursor.IsChecked = myFiles.GetInt32("ClientGraphics", "constrainMouseCursorToWindow", 1) == 1; chkShowDebugWindow.IsChecked = myFiles.GetInt32("ClientGame", "debugPrint", 0) == 1; //some keys are special //these use the same key name in the same section List <KeyValuePair <string, string> > lstKeys = myFiles.GetSectionValuesAsList("ClientGraphics"); chkDisableMultiPassRendering.IsChecked = lstKeys.Any(kvp => kvp.Key.Equals("disableOptionTag", StringComparison.InvariantCultureIgnoreCase) && kvp.Value.Equals("HIQL")); chkDisableBumpMapping.IsChecked = lstKeys.Any(kvp => kvp.Key.Equals("disableOptionTag", StringComparison.InvariantCultureIgnoreCase) && kvp.Value.Equals("DOT3")); //load the available screen resolutions ScreenResolution myScreenReses = new ScreenResolution(); List <ScreenResolution.AvailableScreen> lstScreenRes = myScreenReses.GetScreenResolutions(); //what is it currently set to? int nAdapter = myFiles.GetInt32("Direct3d9", "adapter", 0); int nWidth = myFiles.GetInt32("ClientGraphics", "screenWidth", 1024); int nHeight = myFiles.GetInt32("ClientGraphics", "screenHeight", 768); int nFrequency = myFiles.GetInt32("Direct3d9", "fullscreenRefreshRate", 60); ScreenResolution.ScreenRes theCurrentScreenRes = new ScreenResolution.ScreenRes { Frequency = 60, Width = 1024, Height = 768 }; //people can remvoe monitors if (!lstScreenRes.Any(sr => sr.AdapterNumber == nAdapter)) { nAdapter = 0; myFiles.WriteValue("Direct3d9", "adapter", 0); } var currentRes = lstScreenRes.Where(sr => sr.AdapterNumber == nAdapter).First().AvailableResolutions.Where(sr => sr.Width == nWidth && sr.Height == nHeight && sr.Frequency == nFrequency); if (currentRes.Count() > 0) { theCurrentScreenRes = currentRes.First(); } var currentAdapter = lstScreenRes.Where(sr => sr.AdapterNumber == nAdapter).First(); cboResolution.ItemsSource = currentAdapter.AvailableResolutions; cboResolution.SelectedItem = theCurrentScreenRes; cboAdapter.ItemsSource = lstScreenRes; cboAdapter.SelectedItem = currentAdapter; if (lstScreenRes.Count == 1) { //can't change it anyway lblAdapter.IsEnabled = false; cboAdapter.IsEnabled = false; } //and add the shader versions cboShaderVersion.ItemsSource = ShaderVersions; cboShaderVersion.SelectedItem = CurrentShaderVersion; #endregion break; case ValuesToLoad.Sound: #region Sound Options //get the miles version lblMilesVersion.Text = FileVersionInfo.GetVersionInfo(SWGANHPAth + "Mss32.dll").FileVersion; this.Dispatcher.BeginInvoke(new Action(delegate { //Audio Enabled chkDisableAudio.IsChecked = myFiles.GetInt32("ClientAudio", "disableMiles", 0) == 1; }), System.Windows.Threading.DispatcherPriority.ContextIdle); cboSpeakers.ItemsSource = SoundVersions; cboSpeakers.SelectedItem = myFiles.GetString("ClientAudio", "soundProvider", "Windows Speaker Configuration"); #endregion break; case ValuesToLoad.Game: #region Game Options cboLanguage.ItemsSource = Languages; cboLanguage.SelectedItem = CurrentLanguage; this.Dispatcher.BeginInvoke(new Action(delegate { chkSkipIntroSequence.IsChecked = myFiles.GetInt32("ClientGame", "skipIntro", 0) == 1; }), System.Windows.Threading.DispatcherPriority.ContextIdle); this.Dispatcher.BeginInvoke(new Action(delegate { chkDisableCharSLOD.IsChecked = myFiles.GetInt32("ClientSkeletalAnimation", "lodManagerEnable", 1) == 0; }), System.Windows.Threading.DispatcherPriority.ContextIdle); this.Dispatcher.BeginInvoke(new Action(delegate { chkAllowMultipleInstances.IsChecked = myFiles.GetInt32("SwgClient", "allowMultipleInstances", 0) == 1; }), System.Windows.Threading.DispatcherPriority.ContextIdle); #endregion break; case ValuesToLoad.Advanced: #region Advanced Options this.Dispatcher.BeginInvoke(new Action(delegate { chkDisableWorldPreloading.IsChecked = myFiles.GetInt32("ClientGame", "preloadWorldSnapshot", 1) == 0; }), System.Windows.Threading.DispatcherPriority.ContextIdle); this.Dispatcher.BeginInvoke(new Action(delegate { chkUseLowDetailCharacters.IsChecked = myFiles.GetInt32("ClientSkeletalAnimation", "skipL0", 0) == 1; }), System.Windows.Threading.DispatcherPriority.ContextIdle); this.Dispatcher.BeginInvoke(new Action(delegate { chkUseLowDetailMeshes.IsChecked = myFiles.GetInt32("ClientObject/DetailAppearanceTemplate", "skipL0", 0) == 1; }), System.Windows.Threading.DispatcherPriority.ContextIdle); this.Dispatcher.BeginInvoke(new Action(delegate { chkDisableTextureBaking.IsChecked = myFiles.GetInt32("ClientTextureRenderer", "disableTextureBaking", 0) == 1; }), System.Windows.Threading.DispatcherPriority.ContextIdle); this.Dispatcher.BeginInvoke(new Action(delegate { chkDisableFileCaching.IsChecked = myFiles.GetInt32("SharedUtility", "disableFileCaching", 0) == 1; }), System.Windows.Threading.DispatcherPriority.ContextIdle); this.Dispatcher.BeginInvoke(new Action(delegate { chkDisableAsynchronousLoader.IsChecked = myFiles.GetInt32("SharedFile", "enableAsynchronousLoader", 1) == 0; }), System.Windows.Threading.DispatcherPriority.ContextIdle); #endregion break; } isInitialising = false; }