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;
            }
        }
Example #2
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();
        }
Example #3
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");
                    }
                }
            }
        }
Example #4
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 async Task CheckFirstInit()
        {
            if (!DataSourceAdapter.GetSourcePorts().Any()) //If no source ports setup then it's the first time setup, display welcome/setup info
            {
                DisplayWelcome();
                HandleEditSourcePorts(true);
            }

            if (!DataSourceAdapter.GetIWads().Any()) //If no iwads then prompt to add iwads
            {
                await HandleAddIWads();

                this.Invoke((MethodInvoker) delegate { tabControl.SelectTab(s_iwadKey); }); //the user has only added iwads on setup, so set the tab to iwads on first launch so there is something to see
                DisplayInitSettings();                                                      //give user the change set default port, iwad, skill
            }
        }
Example #6
0
        private void SyncIWads(string[] files)
        {
            IEnumerable <string> iwads      = DataSourceAdapter.GetIWads().Select(x => x.Name);
            IEnumerable <string> iwadsToAdd = files.Except(iwads);

            foreach (string file in iwadsToAdd)
            {
                try
                {
                    DataSourceAdapter.InsertIWad(new IWadData()
                    {
                        FileName = file, Name = file
                    });
                }
                catch (Exception ex)
                {
                    Util.DisplayUnexpectedException(this, ex);
                }
            }
        }
Example #7
0
        private async Task CheckFirstInit()
        {
            if (!DataSourceAdapter.GetSourcePorts().Any()) //If no source ports setup then it's the first time setup, display welcome/setup info
            {
                InvokeHideSplashScreen();
                DisplayWelcome();
                HandleEditSourcePorts(true);
            }

            if (!DataSourceAdapter.GetIWads().Any()) //If no iwads then prompt to add iwads
            {
                InvokeHideSplashScreen();
                await HandleAddIWads();

                Invoke((MethodInvoker) delegate { tabControl.SelectedIndex = 3; }); //the user has only added iwads on setup, so set the tab to iwads on first launch so there is something to see
                DisplayInitSettings();                                              //give user the change set default port, iwad, skill
            }
            else
            {
                Invoke((MethodInvoker) delegate { tabControl.SelectedIndex = AppConfiguration.LastSelectedTabIndex; });
            }
        }