private void preferencesToolStripMenuItem_Click(object sender, EventArgs e) { PreferencesForm preferences = new PreferencesForm(_config); DialogResult result = preferences.ShowDialog(); if (result == DialogResult.OK) { _config = preferences.Config; _config.Serialize(Path.Combine(_appDataFolder, _configName)); } preferences.Dispose(); }
/// <summary> /// Checks if everything is in place for launcher to work properly /// </summary> private void SanityCheck() { if (!Directory.Exists(Path.Combine(_config.ParentPath, _config.Name))) { MessageBox.Show(String.Format("Could not find mod {0} in {1}. Application will now exit.", _config.Name, _config.ParentPath), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } // Adding check for widescreen argument here. Best place for now if (_config.Arguments.ContainsKey("+szx") && !_config.Arguments.ContainsKey("+widescreen")) { int width = int.Parse(_config.Arguments["+szx"]); int height = int.Parse(_config.Arguments["+szy"]); float aspect = width / height; if (aspect < 1.3f || aspect > 1.4f) { _config.Arguments["+widescreen"] = "1"; _config.Serialize(Path.Combine(_appDataFolder, _configName)); } } }
/// <summary> /// Loads the config, either supplied through command line argument, the default config.xml, or creates a new one if none exists /// </summary> private void LoadConfig() { try { if (_args.ContainsKey("config") && _args["config"] != null) { _configName = _args["config"]; } _config = Config.Deserialize(Path.Combine(_appDataFolder, _configName)); } catch (Exception) { _config = CreateDefaultConfig(); try { _config.Serialize(Path.Combine(_appDataFolder, _configName)); } catch (Exception ex) { MessageBox.Show("There's a problem creating a new config file.\n\n" + ex.Message + "\n\nShutting down application.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); Log.LogInfo(ex); Application.Exit(); } } if (string.IsNullOrEmpty(_config.ParentPath)) { _config.ParentPath = GetParentPath(); } if (_config == null) { Application.Exit(); } }
private void preferencesToolStripMenuItem_Click(object sender, EventArgs e) { PreferencesForm preferences = new PreferencesForm(_config); DialogResult result = preferences.ShowDialog(); if (result == DialogResult.OK) { _config = preferences.Config; _config.Serialize(Path.Combine(_appDataFolder, _configName)); } preferences.Dispose(); }
/// <summary> /// Loads the config, either supplied through command line argument, the default config.xml, or creates a new one if none exists /// </summary> private void LoadConfig() { try { if (_args.ContainsKey("config") && _args["config"] != null) _configName = _args["config"]; _config = Config.Deserialize(Path.Combine(_appDataFolder, _configName)); } catch (Exception) { _config = CreateDefaultConfig(); try { _config.Serialize(Path.Combine(_appDataFolder, _configName)); } catch (Exception ex) { MessageBox.Show("There's a problem creating a new config file.\n\n" + ex.Message + "\n\nShutting down application.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); Log.LogInfo(ex); Application.Exit(); } } if (string.IsNullOrEmpty(_config.ParentPath)) _config.ParentPath = GetParentPath(); if (_config == null) Application.Exit(); }