/// <summary>
        /// Sets options from ini file.
        /// </summary>
        private void SetOptions()
        {
            // Add display modes to combo box
            enumeratedDisplayModes = DeepCore.EnumerateDisplayModes();
            foreach (var mode in enumeratedDisplayModes)
            {
                ResolutionComboBox.Items.Add(mode.ResolutionText);
            }

            // Set selected inex
            SetPreferredDisplayMode();

            // Set rendering options
            EnableFXAACheckBox.IsChecked   = bool.Parse(ini.GetValue("Renderer", "fxaaEnabled"));
            EnableBloomCheckBox.IsChecked  = bool.Parse(ini.GetValue("Renderer", "bloomEnabled"));
            WindowedModeCheckBox.IsChecked = bool.Parse(ini.GetValue("Renderer", "windowedMode"));

            // Set mouse options
            MouseSensitivitySlider.Value          = float.Parse(ini.GetValue("Controls", "mouseLookSpeed"));
            InvertMouseVerticalCheckBox.IsChecked = bool.Parse(ini.GetValue("Controls", "invertMouseVertical"));
        }
Пример #2
0
        private void ReadINISettings()
        {
            try
            {
                // Open config file
                string appName      = "Ruins of Hill Deep Playgrounds";
                string configName   = "config.ini";
                string defaultsName = "default_config.ini";
                ini.LoadFile(appName, configName, defaultsName);

                arena2Path          = ini.GetValue("Daggerfall", "arena2Path");
                mouseLookSpeed      = float.Parse(ini.GetValue("Controls", "mouseLookSpeed"));
                invertMouseVertical = bool.Parse(ini.GetValue("Controls", "invertMouseVertical"));
                fxaaEnabled         = bool.Parse(ini.GetValue("Renderer", "fxaaEnabled"));
                bloomEnabled        = bool.Parse(ini.GetValue("Renderer", "bloomEnabled"));
                windowedMode        = bool.Parse(ini.GetValue("Renderer", "windowedMode"));
                string displayResolution = ini.GetValue("Renderer", "displayResolution");

                // Get preferred resolution width and height
                displayResolution.Replace(" ", string.Empty);
                string[] split = displayResolution.Split('x');
                if (split.Length != 2)
                {
                    throw new Exception("Invalid resolution specified.");
                }

                // Get width and height of desired reolution
                int width, height;
                try
                {
                    width  = int.Parse(split[0]);
                    height = int.Parse(split[1]);
                }
                catch (Exception e)
                {
                    throw new Exception("Invalid resolution specified. " + e.Message);
                }

                // Validate arena2 path
                DFValidator.ValidationResults results;
                DFValidator.ValidateArena2Folder(arena2Path, out results);
                if (!results.AppearsValid)
                {
                    throw new Exception("The specified Arena2 path is invalid or incomplete.");
                }

                // Get current display mode information
                displayMode = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode;

                // Attempt to set preferred resolution
                List <DeepCore.DisplayModeDesc> displayModes = DeepCore.EnumerateDisplayModes();
                foreach (var mode in displayModes)
                {
                    if (mode.Mode.Width == width && mode.Mode.Height == height)
                    {
                        displayMode = mode.Mode;
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message, "Error Parsing INI File", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                this.Exit();
            }
        }