private void SetupPlayForm(IGameFile gameFile) { m_currentPlayForm = new PlayForm(AppConfiguration, DataSourceAdapter); m_currentPlayForm.SaveSettings += m_currentPlayForm_SaveSettings; m_currentPlayForm.OnPreviewLaunchParameters += m_currentPlayForm_OnPreviewLaunchParameters; m_currentPlayForm.StartPosition = FormStartPosition.CenterParent; List <ITabView> views = GetAdditionalTabViews(); if (gameFile != null) { gameFile = DataSourceAdapter.GetGameFile(gameFile.FileName); //this file came from the grid, which does not have all info populated to save perfomance } m_currentPlayForm.Initialize(views, gameFile); SetDefaultSelections(); if (gameFile != null) { IIWadData iwad = DataSourceAdapter.GetIWad(gameFile.GameFileID.Value); if (iwad != null) { m_currentPlayForm.SelectedIWad = gameFile; } if (gameFile.SourcePortID.HasValue) { m_currentPlayForm.SelectedSourcePort = DataSourceAdapter.GetSourcePort(gameFile.SourcePortID.Value); } if (gameFile.IWadID.HasValue) { m_currentPlayForm.SelectedIWad = gameFile; m_currentPlayForm.SelectedIWad = DataSourceAdapter.GetGameFileIWads().FirstOrDefault(x => x.IWadID == gameFile.IWadID); } if (!string.IsNullOrEmpty(gameFile.SettingsMap)) { m_currentPlayForm.SelectedMap = gameFile.SettingsMap; } if (!string.IsNullOrEmpty(gameFile.SettingsSkill)) { m_currentPlayForm.SelectedSkill = gameFile.SettingsSkill; } if (!string.IsNullOrEmpty(gameFile.SettingsExtraParams)) { m_currentPlayForm.ExtraParameters = gameFile.SettingsExtraParams; } if (!string.IsNullOrEmpty(gameFile.SettingsSpecificFiles)) { m_currentPlayForm.SpecificFiles = gameFile.SettingsSpecificFiles.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); } } m_currentPlayForm.InitializeComplete(); }
private void HandlePlay(IEnumerable <IGameFile> gameFiles, ISourcePortData sourcePort) { LaunchData launchData = GetLaunchFiles(gameFiles); if (launchData.Success) { if (launchData.GameFile == null) { var iwad = DataSourceAdapter.GetIWad((int)AppConfiguration.GetTypedConfigValue(ConfigType.DefaultIWad, typeof(int))); if (iwad != null) { GameFileGetOptions options = new GameFileGetOptions(new GameFileSearchField(GameFileFieldType.GameFileID, iwad.GameFileID.Value.ToString())); launchData.GameFile = DataSourceAdapter.GetGameFiles(options).FirstOrDefault(); } } if (launchData.GameFile != null) { SetupPlayForm(launchData.GameFile); if (sourcePort != null) { m_currentPlayForm.SelectedSourcePort = sourcePort; } if (m_currentPlayForm.ShowDialog(this) == DialogResult.OK) { try { HandlePlaySettings(m_currentPlayForm, m_currentPlayForm.SelectedGameProfile); if (m_currentPlayForm.SelectedSourcePort != null) { m_playInProgress = StartPlay(launchData.GameFile, m_currentPlayForm.SelectedSourcePort, m_currentPlayForm.ScreenFilter); } ctrlSummary.PauseSlideshow(); } catch (IOException) { MessageBox.Show(this, "The file is in use and cannot be launched. Please close any programs that may be using the file and try again.", "File In Use", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { HandleSelectionChange(GetCurrentViewControl(), true); } } } else if (!string.IsNullOrEmpty(launchData.ErrorTitle)) { MessageBox.Show(this, launchData.ErrorTitle, launchData.ErrorDescription, MessageBoxButtons.OK, MessageBoxIcon.Error); } }