示例#1
0
        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");
                    }
                }
            }
        }
示例#2
0
        public bool Edit()
        {
            List <IFileData> selectedFiles = GetSelectedFiles();

            if (selectedFiles.Count > 0)
            {
                IFileData           file = selectedFiles.First();
                FileDetailsEditForm form = new FileDetailsEditForm();
                form.Initialize(DataSourceAdapter, file);
                form.StartPosition = FormStartPosition.CenterParent;

                if (form.ShowDialog(this) == DialogResult.OK && form.SourcePort != null && !file.IsUrl)
                {
                    file.SourcePortID = form.SourcePort.SourcePortID;
                    file.Description  = form.Description;
                    DataSourceAdapter.UpdateFile(file);
                    return(true);
                }
                else if (form.SourcePort == null)
                {
                    MessageBox.Show(this, "A source port must be selected.", "Error", MessageBoxButtons.OK);
                }
            }

            return(false);
        }
示例#3
0
        private void RebuildTagToolStrip()
        {
            GameFileViewControl currentControl = GetCurrentViewControl();

            if (currentControl != null)
            {
                List <ITagData> addTags    = new List <ITagData>();
                List <ITagData> removeTags = new List <ITagData>();

                Tags = DataSourceAdapter.GetTags().OrderBy(x => x.Name).ToArray();

                foreach (var gameFile in SelectedItems(currentControl))
                {
                    if (gameFile.GameFileID.HasValue)
                    {
                        var gameFileTags      = TagMapLookup.GetTags(gameFile);
                        var currentRemoveTags = Tags.Where(x => gameFileTags.Any(y => y.TagID == x.TagID));
                        var currentAddTags    = Tags.Except(currentRemoveTags);

                        addTags    = addTags.Union(currentAddTags).ToList();
                        removeTags = removeTags.Union(currentRemoveTags).ToList();
                    }
                }

                ToolStripMenuItem tagToolStrip       = mnuLocal.Items.Cast <ToolStripItem>().FirstOrDefault(x => x.Text == "Tag") as ToolStripMenuItem;
                ToolStripMenuItem removeTagToolStrip = mnuLocal.Items.Cast <ToolStripItem>().FirstOrDefault(x => x.Text == "Remove Tag") as ToolStripMenuItem;

                if (tagToolStrip != null)
                {
                    BuildTagToolStrip(tagToolStrip, addTags, tagToolStripItem_Click);
                    BuildTagToolStrip(removeTagToolStrip, removeTags, removeTagToolStripItem_Click);
                }
            }
        }
示例#4
0
        private void SyncIWads(FileAddResults fileAddResults)
        {
            foreach (string file in fileAddResults.GetAllFiles())
            {
                IGameFile gameFile = DataSourceAdapter.GetGameFile(file);

                if (gameFile != null && !gameFile.IWadID.HasValue)
                {
                    DataSourceAdapter.InsertIWad(new IWadData()
                    {
                        GameFileID = gameFile.GameFileID.Value, FileName = file, Name = file
                    });
                    var iwad = DataSourceAdapter.GetIWads().OrderBy(x => x.IWadID).LastOrDefault();

                    IWadInfo wadInfo = IWadInfo.GetIWadInfo(gameFile.FileName);
                    gameFile.Title = wadInfo == null?Path.GetFileNameWithoutExtension(gameFile.FileName).ToUpper() : wadInfo.Title;

                    DataSourceAdapter.UpdateGameFile(gameFile, new GameFileFieldType[] { GameFileFieldType.Title });

                    if (iwad != null)
                    {
                        gameFile.IWadID = iwad.IWadID;
                        DataSourceAdapter.UpdateGameFile(gameFile, new[] { GameFileFieldType.IWadID });
                    }
                }
            }

            UpdateLocal();
            HandleTabSelectionChange();
        }
示例#5
0
        private void HandleCopySaveGames(IGameFile gameFile, ISourcePortData sourcePort)
        {
            m_saveGames = DataSourceAdapter.GetFiles(gameFile, FileType.SaveGame).Where(x => x.SourcePortID == sourcePort.SourcePortID).ToArray();
            SaveGameHandler saveGameHandler = new SaveGameHandler(DataSourceAdapter, AppConfiguration.SaveGameDirectory);

            saveGameHandler.CopySaveGamesToSourcePort(sourcePort, m_saveGames);
        }
示例#6
0
        public bool SetFileOrderFirst()
        {
            List <IFileData> selectedFiles = GetSelectedFiles();

            if (selectedFiles.Count > 0)
            {
                IFileData file = selectedFiles.First();
                if (!file.IsUrl)
                {
                    List <IFileData> files = Files.ToList();
                    files.Remove(file);
                    files.Insert(0, file);
                    SetFilePriorities(files);

                    foreach (IFileData fileUpdate in files)
                    {
                        DataSourceAdapter.UpdateFile(fileUpdate);
                    }

                    return(true);
                }
            }

            return(false);
        }
示例#7
0
        public bool Delete()
        {
            List <IFileData> selectedFiles = GetSelectedFiles();

            if (selectedFiles.Count > 0 &&
                MessageBox.Show(this, "Delete selected file(s)?", "Confirm", MessageBoxButtons.OKCancel,
                                MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.OK)
            {
                foreach (IFileData file in selectedFiles)
                {
                    if (file.IsUrl)
                    {
                        //can't delete a remote file...
                    }
                    else
                    {
                        FileInfo fi = new FileInfo(Path.Combine(DataDirectory.GetFullPath(), file.FileName));
                        DataSourceAdapter.DeleteFile(file);
                        try
                        {
                            fi.Delete();
                        }
                        catch { }
                    }
                }

                return(true);
            }

            return(false);
        }
        public IEnumerable <IFileData> HandleNewScreenshots(ISourcePort sourcePort, IGameFile gameFile, string[] files)
        {
            List <IFileData> ret = new List <IFileData>();

            if (gameFile != null && gameFile.GameFileID.HasValue)
            {
                foreach (string file in files)
                {
                    try
                    {
                        FileInfo fi       = new FileInfo(file);
                        string   fileName = Guid.NewGuid().ToString() + fi.Extension;
                        fi.CopyTo(Path.Combine(ScreenshotDirectory.GetFullPath(), fileName));
                        FileData fileData = new FileData();
                        fileData.FileName     = fileName;
                        fileData.GameFileID   = gameFile.GameFileID.Value;
                        fileData.SourcePortID = sourcePort.SourcePortID;
                        fileData.FileTypeID   = FileType.Screenshot;

                        DataSourceAdapter.InsertFile(fileData);
                        ret.Add(fileData);
                    }
                    catch
                    {
                        //failed, nothing to do
                    }
                }
            }

            return(ret);
        }
示例#9
0
        private void Refresh(bool throwErrors)
        {
            try
            {
                IEnumerable <IConfigurationData> config = DataSourceAdapter.GetConfiguration();

                IdGamesUrl = GetValue(config, "IdGamesUrl");
                ApiPage    = GetValue(config, "ApiPage");
                MirrorUrl  = GetValue(config, "MirrorUrl");
                CleanTemp  = Convert.ToBoolean(GetValue(config, "CleanTemp"));

                SetChildDirectories(config);
                SplitTopBottom        = Convert.ToInt32(GetValue(config, "SplitTopBottom"));
                SplitLeftRight        = Convert.ToInt32(GetValue(config, "SplitLeftRight"));
                AppWidth              = Convert.ToInt32(GetValue(config, "AppWidth"));
                AppHeight             = Convert.ToInt32(GetValue(config, "AppHeight"));
                AppX                  = Convert.ToInt32(GetValue(config, "AppX"));
                AppY                  = Convert.ToInt32(GetValue(config, "AppY"));
                WindowState           = (FormWindowState)Enum.Parse(typeof(FormWindowState), GetValue(config, "WindowState"));
                ColumnConfig          = GetValue(config, "ColumnConfig");
                ScreenshotPreviewSize = Convert.ToInt32(GetValue(config, "ScreenshotPreviewSize"));

                DateParseFormats             = Util.SplitString(GetValue(config, "DateParseFormats"));
                ScreenshotCaptureDirectories = Util.SplitString(GetValue(config, "ScreenshotCaptureDirectories"));
            }
            catch (Exception)
            {
                if (throwErrors)
                {
                    throw;
                }
            }
            VerifyPaths(throwErrors);
        }
示例#10
0
        void SyncLocalDatabaseComplete(SyncLibraryHandler handler, bool updateViews)
        {
            if (updateViews)
            {
                UpdateLocal();
                HandleTabSelectionChange();

                foreach (IGameFile updateGameFile in handler.UpdatedGameFiles)
                {
                    UpdateDataSourceViews(updateGameFile);
                }
            }

            if (handler != null &&
                (handler.InvalidFiles.Length > 0 || m_zdlInvalidFiles.Count > 0))
            {
                DisplayInvalidFilesError(handler.InvalidFiles.Union(m_zdlInvalidFiles));
            }
            else if (m_launchFile != null)
            {
                IGameFile launchFile = DataSourceAdapter.GetGameFile(Path.GetFileName(m_launchFile));
                m_launchFile = null;
                if (launchFile != null)
                {
                    HandlePlay(new IGameFile[] { launchFile });
                }
            }
        }
示例#11
0
        private void SyncPendingZdlFiles()
        {
            foreach (IGameFile gameFile in m_pendingZdlFiles)
            {
                IGameFile libraryGameFile = DataSourceAdapter.GetGameFile(gameFile.FileName);

                if (libraryGameFile != null)
                {
                    libraryGameFile.SettingsSkill       = gameFile.SettingsSkill;
                    libraryGameFile.SettingsMap         = gameFile.SettingsMap;
                    libraryGameFile.SettingsExtraParams = gameFile.SettingsExtraParams;
                    libraryGameFile.SourcePortID        = gameFile.SourcePortID;
                    libraryGameFile.IWadID        = gameFile.IWadID;
                    libraryGameFile.SettingsSkill = gameFile.SettingsSkill;
                    libraryGameFile.SettingsFiles = gameFile.SettingsFiles;

                    if (string.IsNullOrEmpty(libraryGameFile.Comments))
                    {
                        libraryGameFile.Comments = gameFile.Comments;
                    }

                    DataSourceAdapter.UpdateGameFile(libraryGameFile);
                }
            }
        }
示例#12
0
        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;
            }
        }
示例#13
0
        private void HandleFormClosing()
        {
            if (DataSourceAdapter != null)
            {
                IEnumerable <IConfigurationData> config = DataSourceAdapter.GetConfiguration();

                if (WindowState != FormWindowState.Minimized) //too many problems when the form is minimized, not supported
                {
                    UpdateConfig(config, AppConfiguration.SplitTopBottomName, splitTopBottom.SplitterDistance.ToString());
                    UpdateConfig(config, AppConfiguration.SplitLeftRightName, splitLeftRight.SplitterDistance.ToString());
                    UpdateConfig(config, AppConfiguration.SplitTagSelectName, splitTagSelect.SplitterDistance.ToString());

                    UpdateConfig(config, AppConfiguration.AppWidthName, Size.Width.ToString());
                    UpdateConfig(config, AppConfiguration.AppHeightName, Size.Height.ToString());
                    UpdateConfig(config, AppConfiguration.AppXName, Location.X.ToString());
                    UpdateConfig(config, AppConfiguration.AppYName, Location.Y.ToString());
                    UpdateConfig(config, AppConfiguration.WindowStateName, WindowState.ToString());
                }

                UpdateConfig(config, AppConfiguration.ColumnConfigName, BuildColumnConfig());
                UpdateConfig(config, ConfigType.AutoSearch.ToString("g"), chkAutoSearch.Checked.ToString());
                UpdateConfig(config, AppConfiguration.ItemsPerPageName, AppConfiguration.ItemsPerPage.ToString());
                UpdateConfig(config, AppConfiguration.LastSelectedTabIndexName, tabControl.SelectedIndex.ToString());
                UpdateConfig(config, AppConfiguration.TagSelectPinnedName, m_tagSelectControl.Pinned.ToString());
            }
        }
示例#14
0
        public void HandleUpdateSaveGames(ISourcePortData sourcePort, IGameFile gameFile, IFileData[] files)
        {
            foreach (IFileData file in files)
            {
                FileInfo fi = new FileInfo(Path.Combine(sourcePort.GetSavePath().GetFullPath(), file.OriginalFileName));

                if (fi.Exists)
                {
                    if (file.DateCreated == fi.LastWriteTime)
                    {
                        continue;
                    }

                    try
                    {
                        fi.CopyTo(Path.Combine(SaveGameDirectory.GetFullPath(), file.FileName), true);
                    }
                    catch
                    {
                        //failed, nothing to do
                    }

                    //check to see if the save name changed
                    string saveName = GetSaveGameName(sourcePort, fi);
                    if (saveName != file.Description)
                    {
                        file.Description = saveName;
                    }

                    file.DateCreated = fi.LastWriteTime;
                    DataSourceAdapter.UpdateFile(file);
                }
            }
        }
        private void HandleFormClosing()
        {
            if (DataSourceAdapter != null)
            {
                IEnumerable <IConfigurationData> config = DataSourceAdapter.GetConfiguration();

                if (WindowState != FormWindowState.Minimized) //too many problems when the form is minimized, not supported
                {
                    UpdateConfig(config, AppConfiguration.SplitTopBottomName, splitTopBottom.SplitterDistance.ToString());
                    UpdateConfig(config, AppConfiguration.SplitLeftRightName, splitLeftRight.SplitterDistance.ToString());

                    UpdateConfig(config, AppConfiguration.AppWidthName, Size.Width.ToString());
                    UpdateConfig(config, AppConfiguration.AppHeightName, Size.Height.ToString());
                    UpdateConfig(config, AppConfiguration.AppXName, Location.X.ToString());
                    UpdateConfig(config, AppConfiguration.AppYName, Location.Y.ToString());
                    UpdateConfig(config, AppConfiguration.WindowStateName, WindowState.ToString());
                }

                if (GameFileViewFactory.IsUsingColumnView)
                {
                    UpdateConfig(config, AppConfiguration.ColumnConfigName, BuildColumnConfig());
                }
                else
                {
                    UpdateConfig(config, AppConfiguration.ColumnConfigName, BuildTileColumnConfig());
                }

                UpdateConfig(config, ConfigType.AutoSearch.ToString("g"), chkAutoSearch.Checked.ToString());
                UpdateConfig(config, AppConfiguration.ItemsPerPageName, AppConfiguration.ItemsPerPage.ToString());
            }
        }
示例#16
0
 void DataFill(DataSourceAdapter source)
 {
     Image1.ImageUrl            = adapter.ImageURL;
     LabelNameValue.Text        = adapter.Name;
     LabelPriceValue.Text       = adapter.Price;
     CheckBoxIsDiscount.Checked = adapter.IsDiscount;
     LabelDiscountValue.Text    = adapter.Discount;
 }
示例#17
0
        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;

            List <ITabView> views = GetAdditionalTabViews();

            if (gameFile != null)
            {
                gameFile = DataSourceAdapter.GetGameFile(gameFile.FileName); //this file came from the grid, which does not have all info populated to save perfomance
            }
            m_currentPlayForm.Initialize(views, gameFile);

            SetDefaultSelections();

            if (gameFile != null)
            {
                IIWadData iwad = DataSourceAdapter.GetIWad(gameFile.GameFileID.Value);

                if (iwad != null)
                {
                    m_currentPlayForm.SelectedIWad = gameFile;
                }

                if (gameFile.SourcePortID.HasValue)
                {
                    m_currentPlayForm.SelectedSourcePort = DataSourceAdapter.GetSourcePort(gameFile.SourcePortID.Value);
                }

                if (gameFile.IWadID.HasValue)
                {
                    m_currentPlayForm.SelectedIWad = gameFile;
                    m_currentPlayForm.SelectedIWad = DataSourceAdapter.GetGameFileIWads().FirstOrDefault(x => x.IWadID == gameFile.IWadID);
                }

                if (!string.IsNullOrEmpty(gameFile.SettingsMap))
                {
                    m_currentPlayForm.SelectedMap = gameFile.SettingsMap;
                }
                if (!string.IsNullOrEmpty(gameFile.SettingsSkill))
                {
                    m_currentPlayForm.SelectedSkill = gameFile.SettingsSkill;
                }
                if (!string.IsNullOrEmpty(gameFile.SettingsExtraParams))
                {
                    m_currentPlayForm.ExtraParameters = gameFile.SettingsExtraParams;
                }
                if (!string.IsNullOrEmpty(gameFile.SettingsSpecificFiles))
                {
                    m_currentPlayForm.SpecificFiles = gameFile.SettingsSpecificFiles.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                }
            }

            m_currentPlayForm.InitializeComplete();
        }
示例#18
0
        private LaunchData GetLaunchFiles(IEnumerable <IGameFile> gameFiles)
        {
            IGameFile gameFile = null;

            if (gameFiles != null)
            {
                if (gameFiles.Count() > 1)
                {
                    gameFile = PromptUserMainFile(gameFiles, out bool accepted);  //ask user which file to tie all stats to
                    if (!accepted)
                    {
                        return(new LaunchData(string.Empty, string.Empty));
                    }
                }
                else
                {
                    gameFile = gameFiles.FirstOrDefault();
                }
            }

            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)
                {
                    gameFile = DataSourceAdapter.GetGameFile(gameFile.FileName);                     //this file came from the grid, which does not have all info populated to save performance
                }
                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>()
                    {
                        gameFile
                    };
                    Array.ForEach(gameFiles.Skip(1).ToArray(), x => gameFilesList.Add(x));
                    gameFiles = gameFilesList;
                }
            }

            return(new LaunchData(gameFile, (GameFile)gameFile, gameFiles));
        }
示例#19
0
        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 });
            }
        }
示例#20
0
        public void EnableCopySaveFiles()
        {
            CopySaveFiles = true;
            IConfigurationData config = DataSourceAdapter.GetConfiguration().FirstOrDefault(x => x.Name == CopySaveFilesName);

            if (config != null)
            {
                config.Value = "true";
                DataSourceAdapter.UpdateConfiguration(config);
            }
        }
示例#21
0
        public void RemoveGameFileTag(IEnumerable <IGameFile> gameFiles, ITagData tag)
        {
            TagMapping tagMapping = new TagMapping();

            foreach (IGameFile gameFile in gameFiles)
            {
                tagMapping.TagID  = tag.TagID;
                tagMapping.FileID = gameFile.GameFileID.Value;
                DataSourceAdapter.DeleteTagMapping(tagMapping);
            }
        }
示例#22
0
 private void DeleteLibraryGameFiles(IEnumerable <string> files)
 {
     foreach (string file in files)
     {
         IGameFile gameFile = DataSourceAdapter.GetGameFile(file);
         if (gameFile != null && gameFile.GameFileID.HasValue)
         {
             DeleteGameFileAndAssociations(gameFile);
         }
     }
 }
示例#23
0
        public string GetConfigValue(ConfigType ct)
        {
            IConfigurationData config = DataSourceAdapter.GetConfiguration().FirstOrDefault(x => x.Name == ct.ToString("g"));

            if (config != null)
            {
                return(config.Value);
            }

            return(null);
        }
示例#24
0
        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));
        }
示例#25
0
        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);
        }
示例#26
0
 public void HandleDeleteSaveGames(string[] deletedFiles, IFileData[] previousFiles)
 {
     foreach (var file in deletedFiles)
     {
         FileInfo  fi       = new FileInfo(file);
         IFileData saveFile = previousFiles.FirstOrDefault(x => x.OriginalFileName == fi.Name);
         if (saveFile != null)
         {
             DataSourceAdapter.DeleteFile(saveFile);
         }
     }
 }
示例#27
0
        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);
            }
        }
示例#28
0
        public void UpdateTags()
        {
            if (Tags != null)
            {
                PreviousTags = Tags.ToArray();
            }

            Tags = DataSourceAdapter.GetTags().OrderBy(x => x.Name).ToArray();
            if (PreviousTags == null)
            {
                PreviousTags = Tags;
            }
        }
示例#29
0
 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;
     }
 }
示例#30
0
        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);
        }