Пример #1
0
        private void HandleStatReaderErrors(IStatisticsReader m_statsReader)
        {
            TextBoxForm form = new TextBoxForm();

            form.StartPosition = FormStartPosition.CenterParent;
            form.Text          = "Statistic Reader Errors";
            form.HeaderText    = string.Concat("The following errors were reported by the statistics reader.",
                                               Environment.NewLine, "The statistics may be incomplete or missing.");

            StringBuilder sb = new StringBuilder();

            foreach (string error in m_statsReader.Errors)
            {
                sb.Append(error);
                sb.Append(Environment.NewLine);
            }

            form.DisplayText = sb.ToString();
            form.ShowDialog(this);
        }
Пример #2
0
        private IStatisticsReader CreateStatisticsReader(ISourcePort sourcePort, IGameFile gameFile)
        {
            IStatisticsReader statsReader = null;

            if (BoomStatsReader.Supported(sourcePort))
            {
                statsReader = BoomStatsReader.CreateDefault(gameFile, sourcePort.Directory.GetFullPath());
            }
            else if (CNDoomStatsReader.Supported(sourcePort))
            {
                statsReader = CNDoomStatsReader.CreateDefault(gameFile, sourcePort.Directory.GetFullPath());
            }
            else if (ZDoomStatsReader.Supported(sourcePort))
            {
                List <IStatsData> existingStats = new List <IStatsData>();
                if (gameFile != null && gameFile.GameFileID.HasValue)
                {
                    existingStats = DataSourceAdapter.GetStats(gameFile.GameFileID.Value).ToList();
                }
                statsReader = ZDoomStatsReader.CreateDefault(gameFile, sourcePort.Directory.GetFullPath(), existingStats);
            }

            return(statsReader);
        }
 public StatisticsController(IStatisticsReader reader)
 {
     _reader = reader ?? throw new ArgumentNullException($"{GetType().Name}.Ctor - parameter {nameof(reader)} cannot be null.");
 }
Пример #4
0
        public string GetLaunchParameters(LauncherPath gameFileDirectory, LauncherPath tempDirectory,
                                          IGameFile gameFile, ISourcePortData sourcePortData, bool isGameFileIwad)
        {
            ISourcePort   sourcePort = SourcePortUtil.CreateSourcePort(sourcePortData);
            StringBuilder sb         = new StringBuilder();

            List <IGameFile> loadFiles = AdditionalFiles.ToList();

            if (isGameFileIwad)
            {
                loadFiles.Remove(gameFile);
            }
            else if (!loadFiles.Contains(gameFile))
            {
                loadFiles.Add(gameFile);
            }

            if (IWad != null)
            {
                if (!AssertFile(gameFileDirectory.GetFullPath(), gameFile.FileName, "game file"))
                {
                    return(null);
                }
                if (!HandleGameFileIWad(IWad, sourcePort, sb, gameFileDirectory, tempDirectory))
                {
                    return(null);
                }
            }

            List <string> launchFiles = new List <string>();

            foreach (IGameFile loadFile in loadFiles)
            {
                if (!AssertFile(gameFileDirectory.GetFullPath(), loadFile.FileName, "game file"))
                {
                    return(null);
                }
                if (!HandleGameFile(loadFile, launchFiles, gameFileDirectory, tempDirectory, sourcePortData, true))
                {
                    return(null);
                }
            }

            string[] extensions = sourcePortData.SupportedExtensions.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            launchFiles = SortParameters(launchFiles, extensions).ToList();

            BuildLaunchString(sb, sourcePort, launchFiles);

            if (Map != null)
            {
                sb.Append(sourcePort.WarpParameter(new SpData(Map)));

                if (Skill != null)
                {
                    sb.Append(sourcePort.SkillParameter(new SpData(Skill)));
                }
            }

            if (Record)
            {
                RecordedFileName = Path.Combine(tempDirectory.GetFullPath(), Guid.NewGuid().ToString());
                sb.Append(sourcePort.RecordParameter(new SpData(RecordedFileName)));
            }

            if (PlayDemo && PlayDemoFile != null)
            {
                if (!AssertFile(PlayDemoFile, "", "demo file"))
                {
                    return(null);
                }
                sb.Append(sourcePort.PlayDemoParameter(new SpData(PlayDemoFile)));
            }

            if (ExtraParameters != null)
            {
                sb.Append(" " + ExtraParameters);
            }

            if (!string.IsNullOrEmpty(sourcePortData.ExtraParameters))
            {
                sb.Append(" " + sourcePortData.ExtraParameters);
            }

            IStatisticsReader statsReader = sourcePort.CreateStatisticsReader(gameFile, new IStatsData[] { });

            if (SaveStatistics && statsReader != null && !string.IsNullOrEmpty(statsReader.LaunchParameter))
            {
                sb.Append(" " + statsReader.LaunchParameter);
            }

            return(sb.ToString());
        }