示例#1
0
 public void CopySaveGamesToSourcePort(ISourcePortDataSource sourcePort, IFileDataSource[] files)
 {
     files = (from file in files
              where file.SourcePortID == sourcePort.SourcePortID
              select file).ToArray <IFileDataSource>();
     foreach (IFileDataSource source in files)
     {
         string   destFileName = Path.Combine(sourcePort.Directory.GetFullPath(), source.OriginalFileName);
         FileInfo info         = new FileInfo(Path.Combine(this.SaveGameDirectory.GetFullPath(), source.FileName));
         try
         {
             if (info.Exists)
             {
                 DirectoryInfo info2 = new DirectoryInfo(Path.Combine(sourcePort.Directory.GetFullPath(), source.OriginalFilePath));
                 if (!info2.Exists)
                 {
                     info2.Create();
                 }
                 info.CopyTo(destFileName);
             }
         }
         catch
         {
         }
     }
 }
示例#2
0
        public IEnumerable <IFileDataSource> HandleNewSaveGames(ISourcePortDataSource sourcePort, IGameFileDataSource gameFile, string[] files)
        {
            List <IFileDataSource> list = new List <IFileDataSource>();

            if ((gameFile != null) && gameFile.GameFileID.HasValue)
            {
                foreach (string str in files)
                {
                    try
                    {
                        FileInfo info = new FileInfo(str);
                        string   str2 = Guid.NewGuid().ToString() + info.Extension;
                        info.CopyTo(Path.Combine(this.SaveGameDirectory.GetFullPath(), str2));
                        FileDataSource ds = new FileDataSource {
                            Description      = info.Name,
                            OriginalFileName = info.Name,
                            FileName         = str2,
                            GameFileID       = gameFile.GameFileID.Value,
                            SourcePortID     = sourcePort.SourcePortID,
                            FileTypeID       = 3
                        };
                        this.DataSourceAdapter.InsertFile(ds);
                        list.Add(ds);
                    }
                    catch
                    {
                    }
                }
            }
            return(list);
        }
示例#3
0
 public void UpdateDataSource(ISourcePortDataSource ds)
 {
     ds.Name                = this.txtName.Text;
     ds.Directory           = new LauncherPath(this.m_directory);
     ds.Executable          = this.m_exec;
     ds.SupportedExtensions = this.txtExtensions.Text;
 }
示例#4
0
 private bool AssertTypeObject(AddFilesType type, IGameFileDataSource iwad, ISourcePortDataSource sourcePort)
 {
     if (type != AddFilesType.SourcePort)
     {
         return((type == AddFilesType.IWAD) && (iwad > null));
     }
     return(sourcePort > null);
 }
示例#5
0
 private List <DbParameter> GetSourcePortParams(ISourcePortDataSource ds) =>
 new List <DbParameter>
 {
     this.DataAccess.DbAdapter.CreateParameter("Name", (ds.Name == null) ? string.Empty : ds.Name),
     this.DataAccess.DbAdapter.CreateParameter("Executable", (ds.Executable == null) ? string.Empty : ds.Executable),
     this.DataAccess.DbAdapter.CreateParameter("SupportedExtensions", (ds.SupportedExtensions == null) ? string.Empty : ds.SupportedExtensions),
     this.DataAccess.DbAdapter.CreateParameter("Directory", (ds.Directory == null) ? string.Empty : ds.Directory.GetPossiblyRelativePath()),
     this.DataAccess.DbAdapter.CreateParameter("SettingsFiles", (ds.SettingsFiles == null) ? string.Empty : ds.SettingsFiles),
     this.DataAccess.DbAdapter.CreateParameter("SourcePortID", ds.SourcePortID)
 };
示例#6
0
        public static bool Supported(ISourcePortDataSource sourcePort)
        {
            string str = sourcePort.Executable.ToLower();

            if (!str.Contains("prboom"))
            {
                return(str.Contains("glboom"));
            }
            return(true);
        }
示例#7
0
        private void ctrlFiles_CellFormatting(object sender, AdditionalFilesEventArgs e)
        {
            IGameFileDataSource   item          = e.Item as IGameFileDataSource;
            IGameFileDataSource   selectedIWad  = this.SelectedIWad;
            ISourcePortDataSource selectedValue = this.cmbSourcePorts.SelectedValue as ISourcePortDataSource;

            if (this.m_iwadAdditionalFiles.Contains(item))
            {
                e.DisplayText = $"{item.FileName} ({selectedIWad.FileName})";
            }
            if (this.m_sourcePortAdditionalFiles.Contains(item))
            {
                e.DisplayText = $"{item.FileName} ({selectedValue.Name})";
            }
        }
示例#8
0
        private void SetExtraAdditionalFilesFromSettings()
        {
            ISourcePortDataSource selectedItem = this.cmbSourcePorts.SelectedItem as ISourcePortDataSource;
            IGameFileDataSource   selectedIWad = this.SelectedIWad;

            if (selectedIWad != null)
            {
                List <IGameFileDataSource> files = this.GetAdditionalFiles();
                if (!selectedIWad.Equals(this.GameFile))
                {
                    this.m_iwadAdditionalFiles = this.GetAdditionalFiles(AddFilesType.IWAD, selectedIWad, selectedItem).FindAll(x => files.Contains(x));
                }
                this.m_sourcePortAdditionalFiles = this.GetAdditionalFiles(AddFilesType.SourcePort, selectedIWad, selectedItem).FindAll(x => files.Contains(x));
            }
        }
示例#9
0
 private void cmbSourcePorts_SelectedIndexChanged(object sender, EventArgs e)
 {
     if ((this.cmbSourcePorts.SelectedItem != null) && (this.GameFile != null))
     {
         ISourcePortDataSource sourcePort = this.cmbSourcePorts.SelectedItem as ISourcePortDataSource;
         if (this.GameFile.GameFileID.HasValue)
         {
             IEnumerable <IFileDataSource> source = from x in this.DataSourceAdapter.GetFiles(this.GameFile, FileType.Demo)
                                                    where x.SourcePortID == sourcePort.SourcePortID
                                                    select x;
             this.cmbDemo.DataSource = source.ToList <IFileDataSource>();
         }
         this.chkSaveStats.Enabled = this.SaveStatisticsSupported(sourcePort);
         this.AddExtraAdditionalFiles(AddFilesType.SourcePort);
     }
 }
示例#10
0
        private int?GetSourcePort(string port)
        {
            ISourcePortDataSource source = (from item in this.m_sourcePorts
                                            where item.Name == port
                                            select item).FirstOrDefault <ISourcePortDataSource>();

            if (source == null)
            {
                this.m_errors.Add($"Could not find Source Port - {port}");
            }
            if (source != null)
            {
                return(new int?(source.SourcePortID));
            }
            return(null);
        }
示例#11
0
 public void SetDataSource(ISourcePortDataSource ds)
 {
     this.m_directory = ds.Directory.GetPossiblyRelativePath();
     this.m_exec      = ds.Executable;
     if (!string.IsNullOrEmpty(ds.Name))
     {
         this.txtName.Text = ds.Name;
     }
     if ((ds.Directory != null) && (ds.Executable != null))
     {
         this.txtExec.Text = ds.Executable;
     }
     if (!string.IsNullOrEmpty(ds.SupportedExtensions))
     {
         this.txtExtensions.Text = ds.SupportedExtensions;
     }
 }
示例#12
0
 public void HandleUpdateSaveGames(ISourcePortDataSource sourcePort, IGameFileDataSource gameFile, IFileDataSource[] files)
 {
     foreach (IFileDataSource source in files)
     {
         FileInfo info = new FileInfo(Path.Combine(sourcePort.Directory.GetFullPath(), source.OriginalFileName));
         if (info.Exists)
         {
             try
             {
                 info.CopyTo(Path.Combine(this.SaveGameDirectory.GetFullPath(), source.FileName), true);
             }
             catch
             {
             }
         }
     }
 }
示例#13
0
        public IEnumerable <IFileDataSource> HandleNewDemo(ISourcePortDataSource sourcePort, IGameFileDataSource gameFile, string demoFile, string descriptionText)
        {
            FileInfo info = new FileInfo(demoFile);

            if (gameFile.GameFileID.HasValue && info.Exists)
            {
                info.CopyTo(Path.Combine(this.DemoDirectory.GetFullPath(), info.Name));
                FileDataSource ds = new FileDataSource {
                    FileName     = info.Name,
                    GameFileID   = gameFile.GameFileID.Value,
                    SourcePortID = sourcePort.SourcePortID,
                    FileTypeID   = 2,
                    Description  = descriptionText
                };
                this.DataAdapter.InsertFile(ds);
            }
            return(new List <IFileDataSource>());
        }
示例#14
0
 private void HandleEdit()
 {
     if (this.SelectedItem != null)
     {
         SourcePortEditForm form = new SourcePortEditForm();
         form.Initialize(this.DataAdapter, this.m_tabViews);
         ISourcePortDataSource selectedItem = this.SelectedItem;
         form.SetDataSource(selectedItem);
         form.StartPosition = FormStartPosition.CenterParent;
         form.Initialize(this.DataAdapter, this.m_tabViews);
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             form.UpdateDataSource(selectedItem);
             this.DataAdapter.UpdateSourcePort(selectedItem);
             this.SetDataSource(this.DataAdapter.GetSourcePorts());
         }
     }
 }
示例#15
0
        private void AddExtraAdditionalFiles(AddFilesType type)
        {
            ISourcePortDataSource selectedItem = this.cmbSourcePorts.SelectedItem as ISourcePortDataSource;
            IGameFileDataSource   selectedIWad = this.SelectedIWad;

            if (((selectedIWad != null) && this.ShouldAddExtraAdditionalFiles()) && this.AssertTypeObject(type, selectedIWad, selectedItem))
            {
                List <IGameFileDataSource> source          = this.ctrlFiles.GetFiles().Cast <IGameFileDataSource>().ToList <IGameFileDataSource>();
                List <IGameFileDataSource> second          = source.ToList <IGameFileDataSource>();
                List <IGameFileDataSource> newTypeFiles    = this.GetAdditionalFiles(type, selectedIWad, selectedItem);
                List <IGameFileDataSource> memberTypeFiles = this.FileListMemberForType(type);
                memberTypeFiles.RemoveAll(x => newTypeFiles.Contains(x));
                source.RemoveAll(x => memberTypeFiles.Contains(x));
                memberTypeFiles.Clear();
                memberTypeFiles.AddRange(newTypeFiles);
                source.AddRange(memberTypeFiles);
                this.ctrlFiles.SetDataSource(source.Distinct <IGameFileDataSource>().ToList <IGameFileDataSource>());
                this.ResetSpecificFilesSelections(source.Except <IGameFileDataSource>(second).ToArray <IGameFileDataSource>());
            }
        }
示例#16
0
 private bool HandleGameFile(IGameFileDataSource gameFile, StringBuilder sb, LauncherPath gameFileDirectory, LauncherPath tempDirectory, ISourcePortDataSource sourcePort, bool checkSpecific)
 {
     try
     {
         char[]        separator  = new char[] { ',' };
         string[]      extensions = sourcePort.SupportedExtensions.Split(separator, StringSplitOptions.RemoveEmptyEntries);
         List <string> parameters = new List <string>();
         using (ZipArchive archive = ZipFile.OpenRead(Path.Combine(gameFileDirectory.GetFullPath(), gameFile.FileName)))
         {
             foreach (ZipArchiveEntry entry in from item in archive.Entries
                      where (!string.IsNullOrEmpty(item.Name) && item.Name.Contains <char>('.')) && extensions.Any <string>(x => x.Equals(new FileInfo(item.Name).Extension, StringComparison.OrdinalIgnoreCase))
                      select item)
             {
                 bool flag = true;
                 if ((checkSpecific && (this.SpecificFiles != null)) && (this.SpecificFiles.Length != 0))
                 {
                     flag = this.SpecificFiles.Contains <string>(entry.Name);
                 }
                 if (flag)
                 {
                     string destinationFileName = Path.Combine(tempDirectory.GetFullPath(), entry.Name);
                     entry.ExtractToFile(destinationFileName, true);
                     parameters.Add(destinationFileName);
                 }
             }
         }
         parameters = this.SortParameters(parameters, extensions).ToList <string>();
         string[]      source = new string[] { ".deh", ".bex" };
         List <string> list2  = new List <string>();
         if (parameters.Count > 0)
         {
             sb.Append(" -file ");
             foreach (string str2 in parameters)
             {
                 FileInfo info = new FileInfo(str2);
                 if (!source.Contains <string>(info.Extension.ToLower()))
                 {
                     sb.Append($"" { str2 } " ");
                 }
                 else
                 {
                     list2.Add(str2);
                 }
             }
         }
         if (list2.Count > 0)
         {
             sb.Append(" -deh ");
             foreach (string str3 in list2)
             {
                 sb.Append($"" { str3 } " ");
             }
         }
     }
     catch (FileNotFoundException exception1)
     {
         string message = exception1.Message;
         this.LastError = $"The game file was not found: {gameFile.FileName}";
         return(false);
     }
     catch (InvalidDataException exception2)
     {
         string text2 = exception2.Message;
         this.LastError = $"The game file does not appear to be a valid zip file: {gameFile.FileName}";
         return(false);
     }
     return(true);
 }
示例#17
0
 public static bool Supported(ISourcePortDataSource sourcePort) =>
 sourcePort.Executable.ToLower().Contains("cndoom.exe");
示例#18
0
        public override bool Equals(object obj)
        {
            ISourcePortDataSource source = obj as ISourcePortDataSource;

            return((source != null) && (source.SourcePortID == this.SourcePortID));
        }
示例#19
0
        public void InsertSourcePort(ISourcePortDataSource ds)
        {
            string sql = "insert into SourcePorts (Name,Executable,SupportedExtensions,Directory,SettingsFiles) \r\n                values(@Name,@Executable,@SupportedExtensions,@Directory,@SettingsFiles)";

            this.DataAccess.ExecuteNonQuery(sql, this.GetSourcePortParams(ds));
        }
示例#20
0
 private bool SaveStatisticsSupported(ISourcePortDataSource sourcePort) =>
 (BoomStatsReader.Supported(sourcePort) || (ZDoomStatsReader.Supported(sourcePort) || CNDoomStatsReader.Supported(sourcePort)));
示例#21
0
 private List <IGameFileDataSource> GetAdditionalFiles(AddFilesType type, IGameFileDataSource gameIwad, ISourcePortDataSource sourcePort)
 {
     if (type != AddFilesType.SourcePort)
     {
         if (type == AddFilesType.IWAD)
         {
             return(DoomLauncher.Util.GetAdditionalFiles(this.DataSourceAdapter, gameIwad));
         }
         return(null);
     }
     return(DoomLauncher.Util.GetAdditionalFiles(this.DataSourceAdapter, sourcePort));
 }
示例#22
0
        public void UpdateSourcePort(ISourcePortDataSource ds)
        {
            string sql = "update SourcePorts set \r\n            Name = @Name, Executable = @Executable, SupportedExtensions = @SupportedExtensions,\r\n            Directory = @Directory, SettingsFiles = @SettingsFiles\r\n            where SourcePortID = @sourcePortID";

            this.DataAccess.ExecuteNonQuery(sql, this.GetSourcePortParams(ds));
        }
示例#23
0
 public void DeleteSourcePort(ISourcePortDataSource ds)
 {
     this.DataAccess.ExecuteNonQuery($"delete from SourcePorts where SourcePortID = {ds.SourcePortID}");
 }
示例#24
0
 public void UpdateDataSource(ISourcePortDataSource ds)
 {
     this.sourcePortEdit1.UpdateDataSource(ds);
     ds.SettingsFiles = this.ctrlFiles.GetAdditionalFilesString();
 }
示例#25
0
        public static bool Supported(ISourcePortDataSource sourcePort)
        {
            string str = sourcePort.Executable.ToLower();

            return(str.Contains("zdoom.exe") || str.Contains("zandronum.exe"));
        }
示例#26
0
        public bool Launch(LauncherPath gameFileDirectory, LauncherPath tempDirectory, IGameFileDataSource gameFile, ISourcePortDataSource sourcePort, bool isGameFileIwad)
        {
            if (!Directory.Exists(sourcePort.Directory.GetFullPath()))
            {
                this.LastError = "The source port directory does not exist:" + Environment.NewLine + Environment.NewLine + sourcePort.Directory.GetPossiblyRelativePath();
                return(false);
            }
            this.GameFile   = gameFile;
            this.SourcePort = sourcePort;
            string str = this.GetLaunchParameters(gameFileDirectory, tempDirectory, gameFile, sourcePort, isGameFileIwad);

            if (string.IsNullOrEmpty(str))
            {
                return(false);
            }
            Directory.SetCurrentDirectory(sourcePort.Directory.GetFullPath());
            try
            {
                Process process1 = Process.Start(sourcePort.GetFullExecutablePath(), str);
                process1.EnableRaisingEvents = true;
                process1.Exited += new EventHandler(this.proc_Exited);
            }
            catch
            {
                this.LastError = "Failed to execute the source port process.";
                return(false);
            }
            return(true);
        }
示例#27
0
        public string GetLaunchParameters(LauncherPath gameFileDirectory, LauncherPath tempDirectory, IGameFileDataSource gameFile, ISourcePortDataSource sourcePort, bool isGameFileIwad)
        {
            StringBuilder sb = new StringBuilder();
            List <IGameFileDataSource> list = this.AdditionalFiles.ToList <IGameFileDataSource>();

            if (isGameFileIwad)
            {
                list.Remove(gameFile);
            }
            if (this.AdditionalFiles != null)
            {
                foreach (IGameFileDataSource source in this.AdditionalFiles)
                {
                    if (!this.AssertFile(gameFileDirectory.GetFullPath(), source.FileName, "game file"))
                    {
                        return(null);
                    }
                    if (!this.HandleGameFile(source, sb, gameFileDirectory, tempDirectory, sourcePort, true))
                    {
                        return(null);
                    }
                }
            }
            if (this.IWad != null)
            {
                if (!this.AssertFile(gameFileDirectory.GetFullPath(), gameFile.FileName, "game file"))
                {
                    return(null);
                }
                if (!this.HandleGameFileIWad(this.IWad, sb, gameFileDirectory, tempDirectory))
                {
                    return(null);
                }
            }
            if (this.Map != null)
            {
                sb.Append($" -warp {BuildWarpParamter(this.Map)}");
                if (this.Skill != null)
                {
                    sb.Append($" -skill {this.Skill}");
                }
            }
            if (this.Record)
            {
                this.RecordedFileName = Path.Combine(tempDirectory.GetFullPath(), Guid.NewGuid().ToString());
                sb.Append($" -record " { this.RecordedFileName } "");
            }
            if (this.PlayDemo && (this.PlayDemoFile != null))
            {
                if (!this.AssertFile(this.PlayDemoFile, "", "demo file"))
                {
                    return(null);
                }
                sb.Append($" -playdemo " { this.PlayDemoFile } "");
            }
            if (this.ExtraParameters != null)
            {
                sb.Append(" " + this.ExtraParameters);
            }
            return(sb.ToString());
        }
示例#28
0
 internal <> f__AnonymousType2 <int, string, string, string, ISourcePortDataSource> < SetDataSource > b__11_0(ISourcePortDataSource item) =>
示例#29
0
 public void DeleteSourcePort(ISourcePortDataSource ds)
 {
     throw new NotImplementedException();
 }
示例#30
0
 public void SetDataSource(ISourcePortDataSource ds)
 {
     this.sourcePortEdit1.SetDataSource(ds);
     this.ctrlFiles.SetDataSource(DoomLauncher.Util.GetAdditionalFiles(this.m_adapter, ds));
 }