private bool HandleMetaError(IGameFile localFile) { MessageCheckBox errorForm = new MessageCheckBox("Meta", string.Format("Failed to find {0} from the id games mirror.\n\nIf you are sure this file should exist try chaning your mirror in the Settings menu.", localFile.FileName), "Don't show this error again", SystemIcons.Error); errorForm.StartPosition = FormStartPosition.CenterParent; errorForm.ShowDialog(this); return(!errorForm.Checked); }
private void SetupStatsReader(ISourcePortData sourcePort, IGameFile gameFile) { m_statsReader = CreateStatisticsReader(sourcePort, gameFile); if (m_statsReader != null) { m_statsReader.NewStastics += m_statsReader_NewStastics; m_statsReader.Start(); } }
private void HandleDetectorFiles(GameFilePlayAdapter adapter, IGameFile gameFile) { ScreenshotHandler screenshotHandler = new ScreenshotHandler(DataSourceAdapter, AppConfiguration.ScreenshotDirectory); screenshotHandler.HandleNewScreenshots(adapter.SourcePort, gameFile, GetNewScreenshots()); SaveGameHandler savegameHandler = new SaveGameHandler(DataSourceAdapter, AppConfiguration.SaveGameDirectory); savegameHandler.HandleNewSaveGames(adapter.SourcePort, gameFile, GetNewSaveGames()); savegameHandler.HandleUpdateSaveGames(adapter.SourcePort, gameFile, m_saveGames); }
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; m_currentPlayForm.Initialize(GetAdditionalTabViews(), gameFile); m_currentPlayForm.SetGameProfile(GetGameProfile(gameFile)); }
public void SetDataSource(IGameFile gameFile, IEnumerable <ITagData> tags) { if (!string.IsNullOrEmpty(gameFile.Title)) { txtTitle.Text = gameFile.Title; } else { txtTitle.Text = string.Empty; } if (!string.IsNullOrEmpty(gameFile.Author)) { txtAuthor.Text = gameFile.Author; } else { txtAuthor.Text = string.Empty; } if (!string.IsNullOrEmpty(gameFile.Description)) { txtDescription.Text = Util.CleanDescription(gameFile.Description); } else { txtDescription.Text = string.Empty; } if (!string.IsNullOrEmpty(gameFile.Comments)) { txtComments.Text = gameFile.Comments; } else { txtComments.Text = string.Empty; } if (gameFile.ReleaseDate.HasValue) { dtRelease.Value = gameFile.ReleaseDate.Value; } else { dtRelease.Value = DateTime.Now; } if (gameFile.Rating.HasValue) { ctrlStarRating.SelectedRating = Convert.ToInt32(gameFile.Rating.Value); } else { ctrlStarRating.SelectedRating = 0; } dtRelease.Checked = gameFile.ReleaseDate.HasValue; lblTags.Text = string.Join(", ", tags.Select(x => x.Name).ToArray()); }
private LaunchData GetLaunchFiles(IEnumerable <IGameFile> gameFiles) { IGameFile gameFile = null; if (gameFiles != null) { if (gameFiles.Count() > 1) { bool accepted; gameFile = PromptUserMainFile(gameFiles, out accepted); //ask user which file to tie all stats to if (!accepted) { return(new LaunchData(string.Empty, string.Empty)); } } else { gameFile = gameFiles.First(); } } if (m_playInProgress) { return(new LaunchData("Already Playing", "There is already a game in progress. Please exit that game first.")); } if (!DataSourceAdapter.GetSourcePorts().Any()) { return(new LaunchData("No Source Ports", "You must have at least one source port configured to play! Click the settings menu on the top left and select Source Ports to configure.")); } if (!DataSourceAdapter.GetIWads().Any()) { return(new LaunchData("No IWADs", "You must have at least one IWAD configured to play! Click the settings menu on the top left and select IWads to configure.")); } if (gameFile != null && GetCurrentViewControl() != null) { ITabView tabView = m_tabHandler.TabViewForControl(GetCurrentViewControl()); if (tabView != null) //there's a reason for doing this that I can't remember... { gameFile = DataSourceAdapter.GetGameFile(gameFile.FileName); //need to retrieve all the data for the file } if (gameFiles.Count() > 1) //for when the user selected more than one file { HandleMultiSelectPlay(gameFile, gameFiles.Except(new IGameFile[] { gameFile })); //sets SettingsFiles with all the other game files List <IGameFile> gameFilesList = new List <IGameFile>(); gameFilesList.Add(gameFile); Array.ForEach(gameFiles.Skip(1).ToArray(), x => gameFilesList.Add(x)); gameFiles = gameFilesList; } } return(new LaunchData(gameFile, gameFiles)); }
private void HandlePlaySettings(PlayForm form, IGameFile gameFile) { if (form.RememberSettings && gameFile != null) { gameFile.SourcePortID = gameFile.IWadID = null; if (form.SelectedSourcePort != null) { gameFile.SourcePortID = form.SelectedSourcePort.SourcePortID; } if (form.SelectedIWad != null) { gameFile.IWadID = form.SelectedIWad.IWadID; } if (form.SelectedMap != null) { gameFile.SettingsMap = form.SelectedMap; } else { gameFile.SettingsMap = string.Empty; //this setting can be turned off } if (form.SelectedSkill != null) { gameFile.SettingsSkill = form.SelectedSkill; } if (form.ExtraParameters != null) { gameFile.SettingsExtraParams = form.ExtraParameters; } gameFile.SettingsStat = form.SaveStatistics; if (form.ShouldSaveAdditionalFiles()) { gameFile.SettingsFiles = string.Join(";", form.GetAdditionalFiles().Select(x => x.FileName).ToArray()); gameFile.SettingsFilesIWAD = string.Join(";", form.GetIWadAdditionalFiles().Select(x => x.FileName).ToArray()); gameFile.SettingsFilesSourcePort = string.Join(";", form.GetSourcePortAdditionalFiles().Select(x => x.FileName).ToArray()); if (form.SpecificFiles != null) { gameFile.SettingsSpecificFiles = string.Join(";", form.SpecificFiles); } else { gameFile.SettingsSpecificFiles = string.Empty; //this setting can be turned off } } DataSourceAdapter.UpdateGameFile(gameFile, new GameFileFieldType[] { GameFileFieldType.SourcePortID, GameFileFieldType.IWadID, GameFileFieldType.SettingsMap, GameFileFieldType.SettingsSkill, GameFileFieldType.SettingsFiles, GameFileFieldType.SettingsExtraParams, GameFileFieldType.SettingsSpecificFiles, GameFileFieldType.SettingsStat, GameFileFieldType.SettingsFilesIWAD, GameFileFieldType.SettingsFilesSourcePort }); } }
public override void SetGameFiles(IEnumerable <GameFileSearchField> searchFields) { IEnumerable <IGameFile> items = new IGameFile[0]; foreach (GameFileSearchField sf in searchFields) { items = items.Union(m_tagAdapter.GetGameFiles(new GameFileGetOptions(m_selectFields, sf), TagDataSource)); } base.SetDataSource(items); }
private IStatisticsReader CreateStatisticsReader(ISourcePortData sourcePort, IGameFile gameFile) { List <IStatsData> existingStats = new List <IStatsData>(); if (gameFile != null && gameFile.GameFileID.HasValue) { existingStats = DataSourceAdapter.GetStats(gameFile.GameFileID.Value).ToList(); } return(SourcePortUtil.CreateSourcePort(sourcePort).CreateStatisticsReader(gameFile, existingStats)); }
private void View_GameFileEnter(object sender, GameFileEventArgs e) { if (m_gameFile != e.GameFile) { m_toolTip.Hide(m_form); m_gameFile = e.GameFile; m_toolTipTimer.Interval = TimerDelay; m_toolTipTimer.Start(); m_state = ToolTipState.Waiting; } }
public override bool Equals(object obj) { IGameFile check = obj as IGameFile; if (check != null) { return(((IGameFile)obj).FileName == FileName); } return(false); }
public virtual void SetGameFiles(IEnumerable <GameFileSearchField> searchFields) { IEnumerable <IGameFile> items = new IGameFile[0]; foreach (GameFileSearchField sf in searchFields) { items = items.Union(Adapter.GetGameFiles(new GameFileGetOptions(m_selectFields, sf))); } SetDataSource(items); }
private void DeleteLibraryGameFiles(IEnumerable <string> files) { foreach (string file in files) { IGameFile gameFile = DataSourceAdapter.GetGameFile(file); if (gameFile != null && gameFile.GameFileID.HasValue) { DeleteGameFileAndAssociations(gameFile); } } }
private void HandleIwadSelectionChanged(bool resetAdditionalFiles = true) { SetAdditionalFiles(resetAdditionalFiles); if (GameFile == null || (GameFile != null && string.IsNullOrEmpty(GameFile.Map))) { SetMapsFromIwad(); } m_lastIwad = SelectedIWad; }
private void CopySaveGames(IGameFile gameFile, ISourcePortData sourcePort) { if (gameFile != null) { HandleCopySaveGames(gameFile, sourcePort); } else if (IsGameFileIwad(gameFile)) { gameFile = GetGameFileForIWad(gameFile); HandleCopySaveGames(gameFile, sourcePort); } }
public ITagData[] GetTags(IGameFile gameFile) { if (gameFile != null && gameFile.GameFileID.HasValue && m_fileTagMapping.ContainsKey(gameFile.GameFileID.Value)) { ITagMapping[] tagMapping = m_fileTagMapping[gameFile.GameFileID.Value]; return(tagMapping.Where(k => m_tags.ContainsKey(k.TagID)) .Select(k => m_tags[k.TagID]).OrderBy(x => x.Name).ToArray()); } return(new ITagData[] { }); }
private void CopySaveGames(IGameFile gameFile, ISourcePort sourcePort) { if (gameFile != null) //BUG: what if it's iwad? { HandleCopySaveGames(gameFile, sourcePort); } else if (IsGameFileIwad(gameFile)) { gameFile = GetGameFileForIWad(gameFile); HandleCopySaveGames(gameFile, sourcePort); } }
private void HandleProcessExited(object sender) { if (m_filterForm != null) { m_filterForm.Close(); m_filterForm = null; } GameFilePlayAdapter adapter = sender as GameFilePlayAdapter; DateTime dtExit = DateTime.Now; Directory.SetCurrentDirectory(m_workingDirectory); m_playInProgress = false; if (adapter.SourcePort != null) { IGameFile gameFile = adapter.GameFile; if (gameFile != null) { SetMinutesPlayed(dtExit, gameFile); } if (!string.IsNullOrEmpty(adapter.RecordedFileName)) { HandleRecordedDemo(adapter, gameFile); } HandleDetectorFiles(adapter, gameFile); if (m_statsReader != null) { m_statsReader.Stop(); if (m_statsReader.ReadOnClose) { m_statsReader.ReadNow(); } if (m_statsReader.Errors.Length > 0) { HandleStatReaderErrors(m_statsReader); } m_statsReader = null; } } IGameFileView view = GetCurrentViewControl(); view.UpdateGameFile(adapter.GameFile); HandleSelectionChange(view, true); }
public IGameFile[] Parse(string fileText) { m_errors.Clear(); List <IGameFile> gameFiles = new List <IGameFile>(); fileText = fileText.Replace("\r\n", "\n");; if (!fileText.StartsWith("[zdl.save]")) { m_errors.Add("Not a valid zdl file"); return(new IGameFile[] {}); } string zdlFilePath = null; int zdlFileNum = 0; do { zdlFilePath = FindValue(fileText, string.Format("file{0}", zdlFileNum), s_regexFull).Trim(); zdlFileNum++; if (!string.IsNullOrEmpty(zdlFilePath)) { GameFile gameFile = new GameFile(); gameFile.FileName = zdlFilePath; gameFiles.Add(gameFile); } } while (!string.IsNullOrEmpty(zdlFilePath)); if (gameFiles.Count > 0) { string skill = FindValue(fileText, "skill", s_regexFull); string port = FindValue(fileText, "port", s_regexFull); string warp = FindValue(fileText, "warp", s_regexFull); string iwad = FindValue(fileText, "iwad", s_regexFull); string parameters = FindValue(fileText, "extra", s_regexFull); IGameFile gameFile = gameFiles[0]; gameFile.SettingsSkill = skill; gameFile.SettingsMap = warp; gameFile.Map = warp; gameFile.SettingsExtraParams = parameters; gameFile.SourcePortID = GetSourcePort(port); gameFile.IWadID = GetIWad(iwad); } else { m_errors.Add("Did not contain any files (e.g. file=0)"); } return(gameFiles.ToArray()); }
private string GetLoadLatestSave(IGameFile gameFile, ISourcePortData sourcePortData) { var saveFile = DataSourceAdapter.GetFiles(gameFile, FileType.SaveGame).Where(x => x.SourcePortID == sourcePortData.SourcePortID) .OrderByDescending(x => x.DateCreated).FirstOrDefault(); if (saveFile != null) { return(Path.Combine(sourcePortData.GetSavePath().GetFullPath(), saveFile.OriginalFileName)); } return(string.Empty); }
private IGameProfile GetGameProfile(IGameFile gameFile) { if (gameFile.SettingsGameProfileID.HasValue) { var profile = DataSourceAdapter.GetGameProfiles(gameFile.GameFileID.Value).FirstOrDefault(x => x.GameProfileID == gameFile.SettingsGameProfileID.Value); if (profile != null) { return(profile); } } return((GameFile)gameFile); }
private List <IGameFile> GetIWadFilesFromGameFile(IGameFile gameFile) { if (gameFile.IWadID.HasValue) { var gameFileIwad = m_adapter.GetGameFileIWads().FirstOrDefault(x => x.IWadID == gameFile.IWadID.Value); if (gameFileIwad != null) { return(GetAdditionalFiles(AddFilesType.IWAD, gameFileIwad, null)); } } return(Util.GetIWadAdditionalFiles(m_adapter, gameFile)); }
public void SetData(IGameFile gameFile) { if (gameFile != null && gameFile.GameFileID.HasValue) { IEnumerable <IStatsData> stats = DataSourceAdapter.GetStats(gameFile.GameFileID.Value); dgvMain.DataSource = new BindingListView <StatsBind>(GetStatsBind(stats)); dgvMain.ContextMenuStrip = m_menu; } else { dgvMain.DataSource = null; } }
public LaunchData(IGameFile gameFile, IEnumerable <IGameFile> additionalGameFiles) { GameFile = gameFile; if (additionalGameFiles == null) { AdditionalGameFiles = new List <IGameFile>(); } else { AdditionalGameFiles = additionalGameFiles.ToList(); } Success = true; }
public override void SetGameFiles(IEnumerable <GameFileSearchField> searchFields) { IEnumerable <IGameFile> items = new IGameFile[0]; var untaggedFiles = Adapter.GetUntaggedGameFiles(); foreach (GameFileSearchField sf in searchFields) { var search = Adapter.GetGameFiles(new GameFileGetOptions(m_selectFields, sf)); items = items.Union(untaggedFiles.Intersect(search)); } SetDataSource(items); }
private bool StartPlay(IGameFile gameFile, ISourcePortData sourcePort, bool screenFilter) { GameFilePlayAdapter playAdapter = CreatePlayAdapter(m_currentPlayForm, playAdapter_ProcessExited, AppConfiguration); m_saveGames = new IFileData[] { }; if (AppConfiguration.CopySaveFiles) { CopySaveGames(gameFile, sourcePort); } CreateFileDetectors(sourcePort); if (m_currentPlayForm.PreviewLaunchParameters) { ShowLaunchParameters(playAdapter, gameFile, sourcePort); } bool isGameFileIwad = IsGameFileIwad(gameFile); if (m_currentPlayForm.SaveStatistics) { SetupStatsReader(sourcePort, gameFile); } if (playAdapter.Launch(AppConfiguration.GameFileDirectory, AppConfiguration.TempDirectory, gameFile, sourcePort, isGameFileIwad)) { m_currentPlayFile = gameFile; if (gameFile != null) { gameFile.LastPlayed = DateTime.Now; m_dtStartPlay = DateTime.Now; DataSourceAdapter.UpdateGameFile(gameFile, new GameFileFieldType[] { GameFileFieldType.LastPlayed }); UpdateDataSourceViews(gameFile); } } else { MessageBox.Show(this, playAdapter.LastError, "Launch Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (screenFilter) { m_filterForm = new FilterForm(Screen.FromControl(this), m_currentPlayForm.GetFilterSettings()); m_filterForm.Show(this); } return(true); }
public string ExportMeshSimple(IGameFile file, string FilePath, string v) { using var meshStream = new MemoryStream(); file.Extract(meshStream); meshStream.Seek(0, SeekOrigin.Begin); var cr2w = _wolvenkitFileService.TryReadRED4File(meshStream); if (cr2w == null || !cr2w.Chunks.Select(_ => _.Data).OfType <rendRenderMeshBlob>().Any() || !cr2w.Chunks.Select(_ => _.Data).OfType <CMesh>().Any()) { return(""); } var ms = GetMeshBufferStream(meshStream, cr2w); var meshinfo = GetMeshesinfo(cr2w); var expMeshes = ContainRawMesh(ms, meshinfo, true); if (!Directory.Exists(v)) { Directory.CreateDirectory(v); } if (Directory.GetFiles(v).Length > 5) { foreach (var f in Directory.GetFiles(v)) { try { File.Delete(f); } catch { } } } ModelRoot model = RawMeshesToMinimalGLTF(expMeshes); string outfile; if (true) { outfile = Path.Combine(v, Path.GetFileNameWithoutExtension(FilePath) + ".glb"); model.SaveGLB(outfile); } meshStream.Dispose(); meshStream.Close(); return(outfile); }
public List <GameFileFieldType> UpdateDataSource(IGameFile gameFile) { List <GameFileFieldType> fields = new List <GameFileFieldType>(); if (AssertSet(chkTitle, fields, GameFileFieldType.Title)) { gameFile.Title = txtTitle.Text; } if (AssertSet(chkAuthor, fields, GameFileFieldType.Author)) { gameFile.Author = txtAuthor.Text; } if (AssertSet(chkDescription, fields, GameFileFieldType.Description)) { gameFile.Description = txtDescription.Text; } if (AssertSet(chkComments, fields, GameFileFieldType.Comments)) { gameFile.Comments = txtComments.Text; } if (AssertSet(chkReleaseDate, fields, GameFileFieldType.ReleaseDate)) { if (dtRelease.Checked) { gameFile.ReleaseDate = new DateTime(dtRelease.Value.Year, dtRelease.Value.Month, dtRelease.Value.Day); } else { gameFile.ReleaseDate = null; } } if (AssertSet(chkRating, fields, GameFileFieldType.Rating)) { if (ctrlStarRating.SelectedRating == 0) { gameFile.Rating = null; } else { gameFile.Rating = ctrlStarRating.SelectedRating; } } if (AssertSet(chkMaps, fields, GameFileFieldType.Map)) { fields.Add(GameFileFieldType.MapCount); gameFile.Map = m_maps; gameFile.MapCount = DataSources.GameFile.GetMaps(gameFile).Length; } return(fields); }
private void SetExtraAdditionalFilesFromSettings(IGameFile iwad, ISourcePort sourcePort) { m_iwadAdditionalFiles.Clear(); m_sourcePortAdditionalFiles.Clear(); if (iwad != null) { if (!iwad.Equals(m_gameFile)) { m_iwadAdditionalFiles = GetAdditionalFiles(AddFilesType.IWAD, iwad, sourcePort); } m_sourcePortAdditionalFiles = GetAdditionalFiles(AddFilesType.SourcePort, iwad, sourcePort); } }
void dgvMain_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { if (m_datasource != null && m_datasource.Count > e.RowIndex) { IGameFile gameFile = m_datasource[e.RowIndex].Object; if (!m_properties.ContainsKey(e.ColumnIndex)) { m_properties.Add(e.ColumnIndex, gameFile.GetType().GetProperty(dgvMain.Columns[e.ColumnIndex].DataPropertyName)); } e.Value = m_properties[e.ColumnIndex].GetValue(gameFile); } }