private void cmdExport_Click(object sender, EventArgs e) { SaveFileDialog dlg = new SaveFileDialog { FileName = "craft_data_xwa.txt", Filter = "Text files (*.txt)|*.txt|All files|*.*" }; string path = CraftDataManager.GetInstance().GetInstallPath(); if (path == "") { path = Environment.CurrentDirectory; } dlg.InitialDirectory = path; if (dlg.ShowDialog() == DialogResult.OK) { string result = CraftDataManager.GetInstance().SaveToFile(dlg.FileName); if (result != "") { MessageBox.Show(result, "Failed to save file.", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <summary>Initialize and load the user's settings</summary> /// <param name="config">The Settings config of the current user</param> public OptionsDialog(Settings config, EventHandler callback) { InitializeComponent(); chkWP[0] = chkSP1; chkWP[1] = chkSP2; chkWP[2] = chkSP3; chkWP[3] = chkSP4; chkWP[4] = chkWP1; chkWP[5] = chkWP2; chkWP[6] = chkWP3; chkWP[7] = chkWP4; chkWP[8] = chkWP5; chkWP[9] = chkWP6; chkWP[10] = chkWP7; chkWP[11] = chkWP8; chkWP[12] = chkRND; chkWP[13] = chkHYP; chkWP[14] = chkBRF; chkWP[15] = chkBRF2; chkWP[16] = chkBRF3; chkWP[17] = chkBRF4; chkWP[18] = chkBRF5; chkWP[19] = chkBRF6; chkWP[20] = chkBRF7; chkWP[21] = chkBRF8; _config = config; switch (_config.Startup) { case Settings.StartupMode.Normal: optStartNormal.Checked = true; break; case Settings.StartupMode.LastPlatform: optStartPlat.Checked = true; break; case Settings.StartupMode.LastMission: optStartMiss.Checked = true; break; default: optStartNormal.Checked = true; break; } chkRestrict.Checked = _config.RestrictPlatforms; chkExit.Checked = _config.ConfirmExit; chkSave.Checked = _config.ConfirmSave; chkVerify.Checked = _config.Verify; txtVerify.Text = _config.VerifyLocation; chkXWInstall.Checked = _config.XwingInstalled; txtXW.Text = _config.XwingPath; txtXW.Enabled = chkXWInstall.Checked; cboXWCraft.Items.AddRange(Platform.Xwing.Strings.CraftType); cboXWCraft.SelectedIndex = _config.XwingCraft; cboXWIFF.SelectedIndex = _config.XwingIff; chkTIEInstall.Checked = _config.TieInstalled; txtTIE.Text = _config.TiePath; txtTIE.Enabled = chkTIEInstall.Checked; cboTIECraft.Items.AddRange(Platform.Tie.Strings.CraftType); cboTIECraft.SelectedIndex = _config.TieCraft; cboTIEIFF.SelectedIndex = _config.TieIff; chkXvTInstall.Checked = _config.XvtInstalled; txtXvT.Text = _config.XvtPath; txtXvT.Enabled = chkXvTInstall.Checked; cboXvTCraft.Items.AddRange(Platform.Xvt.Strings.CraftType); cboXvTCraft.SelectedIndex = _config.XvtCraft; cboXvTIFF.SelectedIndex = _config.XvtIff; chkBoPInstall.Checked = _config.BopInstalled; txtBoP.Text = _config.BopPath; txtBoP.Enabled = chkBoPInstall.Checked; chkXWAInstall.Checked = _config.XwaInstalled; txtXWA.Text = _config.XwaPath; txtXWA.Enabled = chkXWAInstall.Checked; cboXWACraft.Items.AddRange(Platform.Xwa.Strings.CraftType); cboXWACraft.SelectedIndex = _config.XwaCraft; cboXWAIFF.SelectedIndex = _config.XwaIff; chkFG.Checked = Convert.ToBoolean(_config.MapOptions & Settings.MapOpts.FGTags); chkTrace.Checked = Convert.ToBoolean(_config.MapOptions & Settings.MapOpts.Traces); chkDeletePilot.Checked = _config.DeleteTestPilots; chkRememberPlatformFolder.Checked = _config.RememberPlatformFolder; //[JB] chkConfirmFGDelete.Checked = _config.ConfirmFGDelete; //[JB] chkTest.Checked = _config.ConfirmTest; chkVerifyTest.Checked = _config.VerifyTest; chkVerifyTest.Enabled = !_config.Verify; chkBackdrops.Enabled = _config.SuperBackdropsInstalled; chkBackdrops.Checked = _config.InitializeUsingSuperBackdrops; int t = _config.Waypoints; for (int i = 0; i < 22; i++) { chkWP[i].Checked = Convert.ToBoolean(t & (1 << i)); } chkColorizeFG.Checked = _config.ColorizedDropDowns; txtColorSelected.Text = (_config.ColorInteractSelected.ToArgb() & 0x00FFFFFF).ToString("X6"); //ARGB values include 0xFF for alpha, trim that out to just display RGB. txtColorNonSelected.Text = (_config.ColorInteractNonSelected.ToArgb() & 0x00FFFFFF).ToString("X6"); txtColorBackground.Text = (_config.ColorInteractBackground.ToArgb() & 0x00FFFFFF).ToString("X6"); cboInteractiveTheme.SelectedIndex = (txtColorBackground.Text == "BC8F8F" ? 0 : txtColorBackground.Text == "BFBFFF" ? 1 : 0); //Select YOGEME or XvTED by looking at background color, otherwise default to YOGEME. What's selected here doesn't actually matter unless the user clicks it, so it's just a matter of display consistency. refreshColors(); numMousewheelZoom.Value = Convert.ToDecimal(_config.MapMouseWheelZoomPercentage); chkWireEnabled.Checked = _config.WireframeEnabled; chkWireIconThreshold.Checked = _config.WireframeIconThresholdEnabled; numWireIconThreshold.Value = _config.WireframeIconThresholdSize; chkWireMeshIcon.Checked = _config.WireframeMeshIconEnabled; numWireMeshIcon.Value = _config.WireframeMeshIconSize; for (int i = 0; i < 32; i++) { lstWireMeshTypes.SetSelected(i, (_config.WireframeMeshTypeVisibility & (1 << i)) != 0); } refreshAllMeshCollectionCheckbox(); chkXwingDetectMission.Checked = _config.XwingDetectMission; chkTieDetectMission.Checked = _config.TieDetectMission; chkXvtDetectMission.Checked = _config.XvtDetectMission; chkXwaDetectMission.Checked = _config.XwaDetectMission; chkXwingOverrideExternal.Checked = _config.XwingOverrideExternal; chkTieOverrideExternal.Checked = _config.TieOverrideExternal; chkXvtOverrideExternal.Checked = _config.XvtOverrideExternal; chkXwaOverrideExternal.Checked = _config.XwaOverrideExternal; chkXwaOverrideScan.Checked = _config.XwaOverrideScan; chkXwaFlagRemappedCraft.Checked = _config.XwaFlagRemappedCraft; bool exportInUse = _config.XwaOverrideExternal && CraftDataManager.GetInstance().XwaInstallSpecificExternalDataLoaded; lblExportWarning.Visible = exportInUse; cboMiddleClickActionSelected.SelectedIndex = (int)_config.MapMiddleClickActionSelected; cboMiddleClickAction.SelectedIndex = (int)_config.MapMiddleClickActionNoneSelected; _closeCallback = callback; }