public static bool ValidateArena2Path(string path) { DFValidator.ValidationResults results; DFValidator.ValidateArena2Folder(path, out results); return(results.AppearsValid); }
private void Browser_OnPathChanged() { // Test arena2 exists inside path string pathResult = DaggerfallUnity.TestArena2Exists(browser.CurrentPath); if (string.IsNullOrEmpty(pathResult)) { helpLabel.Text = findArena2Tip; browser.ConfirmEnabled = false; browser.BackgroundColor = Color.clear; arena2Path = string.Empty; return; } // Validate this path DFValidator.ValidationResults validationResults; DFValidator.ValidateArena2Folder(pathResult, out validationResults, true); if (!validationResults.AppearsValid) { helpLabel.Text = GetInvalidPathHelpText(validationResults); browser.ConfirmEnabled = false; browser.BackgroundColor = confirmDisabledBackgroundColor; arena2Path = string.Empty; return; } // Path is valid browser.ConfirmEnabled = true; browser.BackgroundColor = confirmEnabledBackgroundColor; helpLabel.Text = pathValidated; arena2Path = pathResult; }
/// <summary> /// Read INI file settings. /// </summary> 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); // Read settings arena2Path = ini.GetValue("Daggerfall", "arena2Path"); // 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."); } } 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.Close(); } }
/// <summary> /// Sets arena2 path. /// </summary> /// <param name="path">Full path to arena2 folder.</param> private void SetArena2Path(string path) { // Validate path DFValidator.ValidationResults results; DFValidator.ValidateArena2Folder(path, out results); // Set if valid if (results.AppearsValid) { // Display and save path Arena2PathLabel.Content = path; Arena2PathTextBox.Text = path; // Enable play button PlayLabel.Cursor = Cursors.Hand; PlayLabel.Foreground = Brushes.Gold; PlayLabel.IsEnabled = true; playReady = true; } else { // Remove path display Arena2PathLabel.Content = "Not currently set"; Arena2PathTextBox.Text = string.Empty; // Disable play button PlayLabel.Cursor = Cursors.Arrow; PlayLabel.Foreground = Brushes.Gray; PlayLabel.IsEnabled = false; playReady = false; } }
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(); } }