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();
        }
        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);
                }
            }
        }
        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 });
                }
            }
        }
        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();
        }
Exemple #5
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));
        }
 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 MainForm_Shown(object sender, EventArgs e)
        {
            if (m_launchFile != null)
            {
                string addFile = m_launchFile;

                IGameFile launchFile = DataSourceAdapter.GetGameFile(m_launchFile);
                m_launchFile = null;

                if (launchFile == null && File.Exists(addFile))
                {
                    HandleAddGameFiles(AddFileType.GameFile, new string[] { addFile });
                }
                else
                {
                    HandlePlay(new IGameFile[] { launchFile });
                }
            }
        }
Exemple #8
0
        void SyncLocalDatabaseComplete(SyncLibraryHandler handler)
        {
            SetIWadGameFiles();

            UpdateLocal();
            HandleTabSelectionChange();

            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 });
                }
            }
        }
 public bool New()
 {
     GameFile = DataSourceAdapter.GetGameFile(GameFile.FileName); //todo: refactor may have broke this, or no longer needed
     return(CreateFileAssociation(this, DataSourceAdapter, DataDirectory, FileType, GameFile, null).Count > 0);
 }