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;
            }
        }
Beispiel #2
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
            }
        }
Beispiel #4
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; });
            }
        }