예제 #1
0
        public void SetDataSource(IGameFileDataSource ds, IEnumerable <ITagDataSource> tags)
        {
            if (!string.IsNullOrEmpty(ds.Title))
            {
                this.txtTitle.Text = ds.Title;
            }
            else
            {
                this.txtTitle.Text = string.Empty;
            }
            if (!string.IsNullOrEmpty(ds.Author))
            {
                this.txtAuthor.Text = ds.Author;
            }
            else
            {
                this.txtAuthor.Text = string.Empty;
            }
            if (!string.IsNullOrEmpty(ds.Description))
            {
                this.txtDescription.Text = ds.Description.Replace("\n", "\r\n");
            }
            else
            {
                this.txtDescription.Text = string.Empty;
            }
            if (!string.IsNullOrEmpty(ds.Comments))
            {
                this.txtComments.Text = ds.Comments;
            }
            else
            {
                this.txtComments.Text = string.Empty;
            }
            if (ds.ReleaseDate.HasValue)
            {
                this.dtRelease.Value = ds.ReleaseDate.Value;
            }
            else
            {
                this.dtRelease.Value = DateTime.Now;
            }
            if (ds.Rating.HasValue)
            {
                this.ctrlStarRating.SelectedRating = Convert.ToInt32(ds.Rating.Value);
            }
            else
            {
                this.ctrlStarRating.SelectedRating = 0;
            }
            this.dtRelease.Checked = ds.ReleaseDate.HasValue;
            StringBuilder sb = new StringBuilder();

            if (tags.Count <ITagDataSource>() > 0)
            {
                Array.ForEach <ITagDataSource>(tags.ToArray <ITagDataSource>(), x => sb.Append(x.Name + ", "));
                sb.Remove(sb.Length - 2, 2);
            }
            this.lblTags.Text = sb.ToString();
        }
예제 #2
0
 private void ctrlFiles_NewItemNeeded(object sender, AdditionalFilesEventArgs e)
 {
     using (FileSelectForm form = new FileSelectForm())
     {
         form.Initialize(this.DataSourceAdapter, this.m_additionalFileViews);
         form.MultiSelect   = true;
         form.StartPosition = FormStartPosition.CenterParent;
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             IGameFileDataSource[] second = new IGameFileDataSource[] { this.GameFile };
             IGameFileDataSource[] source = form.SelectedFiles.Except <IGameFileDataSource>(second).ToArray <IGameFileDataSource>();
             if (source.Length != 0)
             {
                 e.NewItems = source.Cast <object>().ToList <object>();
                 try
                 {
                     IGameFileDataSource[] selectedFiles = new IGameFileDataSource[] { source.First <IGameFileDataSource>() };
                     this.ResetSpecificFilesSelections(selectedFiles);
                 }
                 catch (FileNotFoundException exception)
                 {
                     MessageBox.Show(this, $"The Game File {exception.FileName} is missing from the library.", "File Not Found");
                 }
                 catch (Exception exception2)
                 {
                     DoomLauncher.Util.DisplayUnexpectedException(this, exception2);
                 }
             }
         }
     }
 }
예제 #3
0
 public override void SetGameFiles(IEnumerable <GameFileSearchField> searchFields)
 {
     if (this.Options != null)
     {
         GameFileGetOptions options = new GameFileGetOptions {
             Limit        = 0x19,
             OrderBy      = 1,
             OrderField   = 7,
             SelectFields = base.m_selectFields
         };
         if ((searchFields != null) && (searchFields.Count <GameFileSearchField>() > 0))
         {
             IEnumerable <IGameFileDataSource> first = new IGameFileDataSource[0];
             foreach (GameFileSearchField field in searchFields)
             {
                 options.SearchField = field;
                 first = first.Union <IGameFileDataSource>(base.m_adapter.GetGameFiles(options));
             }
             base.SetDataSource(first);
         }
         else
         {
             base.SetDataSource(base.m_adapter.GetGameFiles(options));
         }
     }
     else
     {
         base.SetGameFiles(searchFields);
     }
 }
예제 #4
0
        private void UpdateBase(IGameFileDataSourceAdapter adapter, GameFileViewControl ctrl, GameFileGetOptions options, IEnumerable <GameFileSearchField> searchFields)
        {
            IEnumerable <IGameFileDataSource> first = new IGameFileDataSource[0];

            GameFileFieldType[] defaultGameFileSelectFields = this.DefaultGameFileSelectFields;
            if (options == null)
            {
                foreach (GameFileSearchField field in searchFields)
                {
                    first = first.Union <IGameFileDataSource>(adapter.GetGameFiles(new GameFileGetOptions(defaultGameFileSelectFields, field)));
                }
            }
            else
            {
                foreach (GameFileSearchField field2 in searchFields)
                {
                    options.SearchField = field2;
                    first = first.Union <IGameFileDataSource>(adapter.GetGameFiles(options));
                }
                if (options.SearchField != null)
                {
                    first = first.Union <IGameFileDataSource>(adapter.GetGameFiles(new GameFileGetOptions(defaultGameFileSelectFields, options.SearchField)));
                }
            }
            this.SetDataSource(ctrl, first.ToList <IGameFileDataSource>());
        }
예제 #5
0
 public void DeleteGameFile(IGameFileDataSource ds)
 {
     if (ds.GameFileID.HasValue)
     {
         this.DataAccess.ExecuteNonQuery($"delete from GameFiles where GameFileID = {ds.GameFileID}");
     }
 }
예제 #6
0
 private void Pre_2_4_0()
 {
     if (this.DataAccess.ExecuteSelect("pragma table_info(IWads);").Tables[0].Select("name = 'GameFileID'").Count <DataRow>() == 0)
     {
         this.DataAccess.ExecuteNonQuery("alter table IWads add column 'GameFileID' int;");
         IEnumerable <IGameFileDataSource> gameFiles = this.m_adapter.GetGameFiles();
         using (IEnumerator <IIWadDataSource> enumerator = this.m_adapter.GetIWads().GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 IIWadDataSource     iwad   = enumerator.Current;
                 IGameFileDataSource source = (from x in gameFiles
                                               where x.FileName.ToLower() == iwad.FileName.ToLower().Replace(".wad", ".zip")
                                               select x).FirstOrDefault <IGameFileDataSource>();
                 if (source != null)
                 {
                     iwad.GameFileID = source.GameFileID;
                     this.m_adapter.UpdateIWad(iwad);
                 }
             }
         }
     }
     if (this.DataAccess.ExecuteSelect("pragma table_info(SourcePorts);").Tables[0].Select("name = 'SettingsFiles'").Count <DataRow>() == 0)
     {
         this.DataAccess.ExecuteNonQuery("alter table SourcePorts add column 'SettingsFiles' TEXT;");
     }
     this.DataAccess.ExecuteNonQuery("update GameFiles set MapCount = null where Map is null or length(Map) = 0");
 }
예제 #7
0
 public ZDoomStatsReader(IGameFileDataSource gameFile, string directory, IEnumerable <IStatsDataSource> existingStats)
 {
     this.m_dir = directory;
     string[] extensions = new string[] { ".zds" };
     this.m_detector   = new NewFileDetector(extensions, directory, true);
     this.m_statistics = existingStats.ToList <IStatsDataSource>();
     this.m_gameFile   = gameFile;
 }
예제 #8
0
 public void SetData(IGameFileDataSource gameFile)
 {
     this.m_gameFile = gameFile;
     this.SetViewData(this.ctrlScreenshotView, gameFile);
     this.SetViewData(this.ctrlDemoView, gameFile);
     this.SetViewData(this.ctrlSaveGameView, gameFile);
     this.SetViewData(this.ctrlViewStats, gameFile);
 }
예제 #9
0
 private bool AssertTypeObject(AddFilesType type, IGameFileDataSource iwad, ISourcePortDataSource sourcePort)
 {
     if (type != AddFilesType.SourcePort)
     {
         return((type == AddFilesType.IWAD) && (iwad > null));
     }
     return(sourcePort > null);
 }
예제 #10
0
        public void InsertGameFile(IGameFileDataSource ds)
        {
            List <DbParameter> list;

            string[] exclude = new string[] { "GameFileID", "FileSizeBytes" };
            string   sql     = this.InsertStatement("GameFiles", ds, exclude, out list);

            this.DataAccess.ExecuteNonQuery(sql, list);
        }
예제 #11
0
        public override void SetGameFiles(IEnumerable <GameFileSearchField> searchFields)
        {
            IEnumerable <IGameFileDataSource> first = new IGameFileDataSource[0];

            foreach (GameFileSearchField field in searchFields)
            {
                first = first.Union <IGameFileDataSource>(this.m_tagAdapter.GetGameFiles(new GameFileGetOptions(base.m_selectFields, field), this.TagDataSource));
            }
            base.SetDataSource(first);
        }
예제 #12
0
 public ITagDataSource[] GetTags(IGameFileDataSource gameFile)
 {
     if (((gameFile != null) && gameFile.GameFileID.HasValue) && this.m_fileTagMapping.ContainsKey(gameFile.GameFileID.Value))
     {
         return((from k in this.m_fileTagMapping[gameFile.GameFileID.Value]
                 where this.m_tags.ContainsKey(k.TagID)
                 select this.m_tags[k.TagID]).ToArray <ITagDataSource>());
     }
     return(new ITagDataSource[0]);
 }
예제 #13
0
        public virtual void SetGameFiles(IEnumerable <GameFileSearchField> searchFields)
        {
            IEnumerable <IGameFileDataSource> first = new IGameFileDataSource[0];

            foreach (GameFileSearchField field in searchFields)
            {
                first = first.Union <IGameFileDataSource>(this.m_adapter.GetGameFiles(new GameFileGetOptions(this.m_selectFields, field)));
            }
            this.SetDataSource(first);
        }
예제 #14
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));
 }
예제 #15
0
 public void SetData(IGameFileDataSource gameFile)
 {
     if ((gameFile != null) && gameFile.GameFileID.HasValue)
     {
         IEnumerable <IStatsDataSource> stats = this.DataSourceAdapter.GetStats(gameFile.GameFileID.Value);
         this.dgvMain.DataSource       = new BindingListView <StatsBind>(this.GetStatsBind(stats));
         this.dgvMain.ContextMenuStrip = this.m_menu;
     }
     else
     {
         this.dgvMain.DataSource = null;
     }
 }
예제 #16
0
        public void InitializeComplete()
        {
            IGameFileDataSource selectedIWad = this.SelectedIWad;

            if ((selectedIWad != null) && selectedIWad.Equals(this.GameFile))
            {
                this.cmbIwad.Enabled = false;
            }
            this.AddExtraAdditionalFiles(AddFilesType.SourcePort);
            this.AddExtraAdditionalFiles(AddFilesType.IWAD);
            this.SetExtraAdditionalFilesFromSettings();
            this.m_init = false;
        }
예제 #17
0
        public void SetAdditionalFiles(IEnumerable <IGameFileDataSource> gameFiles)
        {
            IGameFileDataSource selectedIWad = this.SelectedIWad;

            if ((!gameFiles.Contains <IGameFileDataSource>(this.GameFile) && (selectedIWad != null)) && !selectedIWad.Equals(this.GameFile))
            {
                List <IGameFileDataSource> list1 = new List <IGameFileDataSource>();
                list1.AddRange(gameFiles);
                list1.Add(this.GameFile);
                gameFiles = list1;
            }
            this.ctrlFiles.SetDataSource(gameFiles.ToArray <IGameFileDataSource>());
        }
예제 #18
0
 public override void SetData(IGameFileDataSource gameFile)
 {
     if (this.m_pictureBoxes.Count == 0)
     {
         this.InitPictureBoxes();
     }
     this.flpScreenshots.SuspendLayout();
     this.flpScreenshots.Controls.Clear();
     this.flpScreenshots.ResumeLayout();
     this.m_lookup.Clear();
     if (((gameFile != null) && gameFile.GameFileID.HasValue) && (this.RequestScreenshots != null))
     {
         this.RequestScreenshots(this, new RequestScreenshotsEventArgs(gameFile));
     }
 }
예제 #19
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})";
            }
        }
예제 #20
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));
            }
        }
예제 #21
0
 public virtual void UpdateDataSourceFile(IGameFileDataSource ds)
 {
     if (this.ctrlView.DataSource != null)
     {
         foreach (ObjectView <GameFileDataSource> view in (BindingListView <GameFileDataSource>) this.ctrlView.DataSource)
         {
             if (view.Object.Equals(ds))
             {
                 IGameFileDataSource dsSet = view.Object;
                 Array.ForEach <PropertyInfo>(dsSet.GetType().GetProperties(), x => x.SetValue(dsSet, x.GetValue(ds)));
                 this.ctrlView.Invalidate(true);
                 break;
             }
         }
     }
 }
예제 #22
0
        public IGameFileDataSource[] Parse(string file)
        {
            this.m_errors.Clear();
            List <IGameFileDataSource> list = new List <IGameFileDataSource>();
            string text = File.ReadAllText(file).Replace("\r\n", "\n");

            if (!text.StartsWith("[zdl.save]"))
            {
                this.m_errors.Add("Not a valid zdl file");
                return(new IGameFileDataSource[0]);
            }
            string str2 = null;
            int    num  = 0;

            do
            {
                str2 = this.FindValue(text, $"file{num}", s_regexFull, true).Trim();
                num++;
                if (!string.IsNullOrEmpty(str2))
                {
                    GameFileDataSource item = new GameFileDataSource {
                        FileName = str2
                    };
                    list.Add(item);
                }
            }while (!string.IsNullOrEmpty(str2));
            if (list.Count > 0)
            {
                string str3 = this.FindValue(text, "skill", s_regexFull, true);
                string port = this.FindValue(text, "port", s_regexFull, true);
                string str5 = this.FindValue(text, "warp", s_regexFull, true);
                string str6 = this.FindValue(text, "iwad", s_regexFull, true);
                string str7 = this.FindValue(text, "extra", s_regexFull, true);
                IGameFileDataSource local1 = list[0];
                local1.SettingsSkill       = str3;
                local1.SettingsMap         = str5;
                local1.Map                 = str5;
                local1.SettingsExtraParams = str7;
                local1.SourcePortID        = this.GetSourcePort(port);
                local1.IWadID              = this.GetIWad(str6 + ".wad");
            }
            else
            {
                this.m_errors.Add("Did not contain any files (e.g. file=0)");
            }
            return(list.ToArray());
        }
예제 #23
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
             {
             }
         }
     }
 }
예제 #24
0
        public void UpdateGameFile(IGameFileDataSource ds, GameFileFieldType[] updateFields)
        {
            StringBuilder builder = new StringBuilder("update GameFiles set ");

            if ((updateFields != null) && (updateFields.Length != 0))
            {
                foreach (GameFileFieldType type in updateFields)
                {
                    builder.Append(type.ToString());
                    builder.Append(" = @");
                    builder.Append(type.ToString());
                    builder.Append(",");
                }
                builder.Remove(builder.Length - 1, 1);
                builder.Append(" where GameFileID = @gameFileID");
            }
            else
            {
                builder = new StringBuilder("update GameFiles set Title = @Title, Author = @Author, ReleaseDate = @ReleaseDate,\r\n                    Description = @Description, Map = @Map, SourcePortID = @SourcePortID,\r\n                    Thumbnail = @Thumbnail, Comments = @Comments, Rating = @Rating,\r\n                    IWadID = @IWadID, LastPlayed = @LastPlayed, Downloaded = @Downloaded, \r\n                    SettingsMap = @SettingsMap, SettingsSkill = @SettingsSkill, SettingsExtraParams = @SettingsExtraParams, SettingsFiles = @SettingsFiles,\r\n                    SettingsSpecificFiles = @SettingsSpecificFiles, FileName = @FileName\r\n                    where GameFileID = @gameFileID");
            }
            List <DbParameter> parameters = new List <DbParameter> {
                this.DataAccess.DbAdapter.CreateParameter("Title", (ds.Title == null) ? ((object)DBNull.Value) : ((object)ds.Title)),
                this.DataAccess.DbAdapter.CreateParameter("Author", (ds.Author == null) ? ((object)DBNull.Value) : ((object)ds.Author)),
                this.DataAccess.DbAdapter.CreateParameter("ReleaseDate", !ds.ReleaseDate.HasValue ? ((object)DBNull.Value) : ((object)ds.ReleaseDate.Value)),
                this.DataAccess.DbAdapter.CreateParameter("Description", (ds.Description == null) ? ((object)DBNull.Value) : ((object)ds.Description)),
                this.DataAccess.DbAdapter.CreateParameter("Map", (ds.Map == null) ? ((object)DBNull.Value) : ((object)ds.Map)),
                this.DataAccess.DbAdapter.CreateParameter("SourcePortID", !ds.SourcePortID.HasValue ? ((object)DBNull.Value) : ((object)ds.SourcePortID.Value)),
                this.DataAccess.DbAdapter.CreateParameter("Thumbnail", (ds.Thumbnail == null) ? ((object)DBNull.Value) : ((object)ds.Thumbnail)),
                this.DataAccess.DbAdapter.CreateParameter("Comments", (ds.Comments == null) ? ((object)DBNull.Value) : ((object)ds.Comments)),
                this.DataAccess.DbAdapter.CreateParameter("Rating", !ds.Rating.HasValue ? ((object)DBNull.Value) : ((object)ds.Rating)),
                this.DataAccess.DbAdapter.CreateParameter("IWadID", !ds.IWadID.HasValue ? ((object)DBNull.Value) : ((object)ds.IWadID)),
                this.DataAccess.DbAdapter.CreateParameter("GameFileID", ds.GameFileID.Value),
                this.DataAccess.DbAdapter.CreateParameter("LastPlayed", !ds.LastPlayed.HasValue ? ((object)DBNull.Value) : ((object)ds.LastPlayed)),
                this.DataAccess.DbAdapter.CreateParameter("Downloaded", !ds.Downloaded.HasValue ? ((object)DBNull.Value) : ((object)ds.Downloaded)),
                this.DataAccess.DbAdapter.CreateParameter("SettingsMap", (ds.SettingsMap == null) ? ((object)DBNull.Value) : ((object)ds.SettingsMap)),
                this.DataAccess.DbAdapter.CreateParameter("SettingsSkill", (ds.SettingsSkill == null) ? ((object)DBNull.Value) : ((object)ds.SettingsSkill)),
                this.DataAccess.DbAdapter.CreateParameter("SettingsExtraParams", (ds.SettingsExtraParams == null) ? ((object)DBNull.Value) : ((object)ds.SettingsExtraParams)),
                this.DataAccess.DbAdapter.CreateParameter("SettingsFiles", (ds.SettingsFiles == null) ? ((object)DBNull.Value) : ((object)ds.SettingsFiles)),
                this.DataAccess.DbAdapter.CreateParameter("SettingsSpecificFiles", (ds.SettingsSpecificFiles == null) ? ((object)DBNull.Value) : ((object)ds.SettingsSpecificFiles)),
                this.DataAccess.DbAdapter.CreateParameter("MapCount", !ds.MapCount.HasValue ? ((object)DBNull.Value) : ((object)ds.MapCount)),
                this.DataAccess.DbAdapter.CreateParameter("MinutesPlayed", ds.MinutesPlayed),
                this.DataAccess.DbAdapter.CreateParameter("FileName", ds.FileName)
            };

            this.DataAccess.ExecuteNonQuery(builder.ToString(), parameters);
        }
예제 #25
0
 private bool HandleGameFileIWad(IGameFileDataSource gameFile, StringBuilder sb, LauncherPath gameFileDirectory, LauncherPath tempDirectory)
 {
     try
     {
         using (ZipArchive archive = ZipFile.OpenRead(Path.Combine(gameFileDirectory.GetFullPath(), gameFile.FileName)))
         {
             ZipArchiveEntry source = archive.Entries.First <ZipArchiveEntry>();
             string          destinationFileName = Path.Combine(tempDirectory.GetFullPath(), source.Name);
             source.ExtractToFile(destinationFileName, true);
             sb.Append($" -iwad " { destinationFileName } " ");
         }
     }
     catch
     {
         this.LastError = $"There was an issue with the IWad: {gameFile.FileName}";
         return(false);
     }
     return(true);
 }
예제 #26
0
        private void GameFileViewControl_CustomRowPaint(object sender, CancelEventArgs e)
        {
            e.Cancel = false;
            IGameFileDataSource gameFile = base.FromDataBoundItem(base.GameFileViewControl.CustomRowPaintDataBoundItem);

            if (gameFile != null)
            {
                ITagDataSource source2 = (from item in this.m_tagLookup.GetTags(gameFile)
                                          where item.HasColor && item.Color.HasValue
                                          select item).FirstOrDefault <ITagDataSource>();
                if (source2 != null)
                {
                    base.GameFileViewControl.CustomRowPaintForeColor = Color.FromArgb(source2.Color.Value);
                }
                else
                {
                    base.GameFileViewControl.CustomRowPaintForeColor = Control.DefaultForeColor;
                }
            }
        }
예제 #27
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>());
            }
        }
예제 #28
0
        public string GetToolTipText(Font font, IGameFileDataSource item)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("Title: ");
            if (item.Title != null)
            {
                builder.Append(item.Title);
            }
            builder.Append(Environment.NewLine);
            builder.Append(Environment.NewLine);
            builder.Append("Author: ");
            if (item.Author != null)
            {
                builder.Append(item.Author);
            }
            builder.Append(Environment.NewLine);
            builder.Append(Environment.NewLine);
            builder.Append("Release Date: ");
            if (item.ReleaseDate.HasValue)
            {
                builder.Append(item.ReleaseDate.Value.ToShortDateString());
            }
            else
            {
                builder.Append("N/A");
            }
            builder.Append(Environment.NewLine);
            builder.Append(Environment.NewLine);
            builder.Append("Description: ");
            try
            {
                builder.Append(this.FormatDescritionToWidth(font, item.Description.Replace("\r\n", "\n"), 640, 20));
            }
            catch
            {
                builder.Append(item.Description.Replace("\r\n", "\n"));
            }
            return(builder.ToString());
        }
예제 #29
0
        public IEnumerable <IFileDataSource> GetFiles(IGameFileDataSource gameFile, FileType fileTypeID)
        {
            WadArchiveGameFileDataSource source = gameFile as WadArchiveGameFileDataSource;

            if (source == null)
            {
                throw new ArgumentException("Parameter gameFile must be of type WadArchiveGameFileDataSource");
            }
            List <WadArchiveFileDataSource> list = new List <WadArchiveFileDataSource>();

            if (source.screenshots != null)
            {
                foreach (KeyValuePair <string, string> pair in source.screenshots)
                {
                    WadArchiveFileDataSource item = new WadArchiveFileDataSource {
                        FileName = pair.Value
                    };
                    list.Add(item);
                }
            }
            return((IEnumerable <IFileDataSource>)list);
        }
예제 #30
0
        public static string[] GetSupportedFiles(string gameFileDirectory, IGameFileDataSource gameFile, string[] supportedExtensions)
        {
            List <string> list = new List <string>();

            using (ZipArchive archive = ZipFile.OpenRead(Path.Combine(gameFileDirectory, gameFile.FileName)))
            {
                from item in archive.Entries
                where (!string.IsNullOrEmpty(item.Name) && item.Name.Contains <char>('.')) && supportedExtensions.Any <string>(x => x.Equals(new FileInfo(item.Name).Extension, StringComparison.OrdinalIgnoreCase))
                select item;
                using (IEnumerator <ZipArchiveEntry> enumerator = archive.Entries.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ZipArchiveEntry zae = enumerator.Current;
                        if (!string.IsNullOrEmpty(zae.Name) && supportedExtensions.Any <string>(x => x.Equals(new FileInfo(zae.Name).Extension, StringComparison.OrdinalIgnoreCase)))
                        {
                            list.Add(zae.Name);
                        }
                    }
                }
            }
            return(list.ToArray());
        }