private void SetDefaultSelections() { int port = (int)AppConfiguration.GetTypedConfigValue(ConfigType.DefaultSourcePort, typeof(int)); int iwad = (int)AppConfiguration.GetTypedConfigValue(ConfigType.DefaultIWad, typeof(int)); string skill = (string)AppConfiguration.GetTypedConfigValue(ConfigType.DefaultSkill, typeof(string)); ISourcePort sourcePort = DataSourceAdapter.GetSourcePorts().FirstOrDefault(x => x.SourcePortID == port); if (sourcePort != null) { m_currentPlayForm.SelectedSourcePort = sourcePort; } IIWadData iwadSource = DataSourceAdapter.GetIWads().FirstOrDefault(x => x.IWadID == Convert.ToInt32(iwad)); if (iwadSource != null) { GameFileGetOptions options = new GameFileGetOptions(new GameFileSearchField(GameFileFieldType.GameFileID, iwadSource.GameFileID.Value.ToString())); IEnumerable <IGameFile> gameFileIwad = DataSourceAdapter.GetGameFiles(options); if (gameFileIwad.Any()) { m_currentPlayForm.SelectedIWad = gameFileIwad.First(); } } if (skill != null) { m_currentPlayForm.SelectedSkill = skill; } }
private void SetIWadGameFiles() { IEnumerable <IIWadData> iwads = DataSourceAdapter.GetIWads(); List <IGameFile> gameFileDataUpdate = new List <IGameFile>(); if (iwads.Any()) { IEnumerable <IGameFile> gameFiles = DataSourceAdapter.GetGameFiles(); foreach (IIWadData iwad in iwads) { IGameFile find = gameFiles.FirstOrDefault(x => x.FileName.ToLower() == iwad.FileName.ToLower().Replace(".wad", ".zip")); if (find != null) { if (!find.IWadID.HasValue) //this should mean the file was just added so we should set the pre-defined title { FillIwadData(find); gameFileDataUpdate.Add(find); find.IWadID = iwad.IWadID; DataSourceAdapter.UpdateGameFile(find, new GameFileFieldType[] { GameFileFieldType.IWadID }); } if (!iwad.GameFileID.HasValue) { iwad.GameFileID = find.GameFileID; DataSourceAdapter.UpdateIWad(iwad); } } else { Util.ThrowDebugException("This should not happen"); } } } }
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); } }