Exemple #1
0
        /****
        ** Methods
        ****/
        /// <summary>Skip the intro if the game is ready.</summary>
        /// <param name="menu">The title menu whose intro to skip.</param>
        /// <returns>Returns whether the intro was skipped successfully.</returns>
        private bool TrySkipIntro(TitleMenu menu)
        {
            // wait until the game is ready
            if (Game1.currentGameTime == null)
            {
                return(false);
            }

            // skip to title screen
            menu.receiveKeyPress(Keys.Escape);
            menu.update(Game1.currentGameTime);

            // skip to other screen
            switch (this.Config.SkipTo)
            {
            case Screen.Title:
                // skip button transition
                while (this.Helper.Reflection.GetField <int>(menu, "buttonsToShow").GetValue() < TitleMenu.numberOfButtons)
                {
                    menu.update(Game1.currentGameTime);
                }
                break;

            case Screen.Load:
                // skip to load screen
                menu.performButtonAction("Load");
                while (TitleMenu.subMenu == null)
                {
                    menu.update(Game1.currentGameTime);
                }
                break;

            case Screen.JoinCoop:
            case Screen.HostCoop:
                // skip to co-op screen
                menu.performButtonAction("Co-op");
                while (TitleMenu.subMenu == null)
                {
                    menu.update(Game1.currentGameTime);
                }

                // skip to host tab
                if (this.Config.SkipTo == Screen.HostCoop && TitleMenu.subMenu is CoopMenu submenu)
                {
                    ClickableComponent hostTab = submenu.hostTab;
                    submenu.receiveLeftClick(hostTab.bounds.X, hostTab.bounds.Y, playSound: false);
                }
                break;
            }

            return(true);
        }
Exemple #2
0
        /****
        ** Methods
        ****/
        /// <summary>Skip the intro if the game is ready.</summary>
        /// <param name="menu">The title menu whose intro to skip.</param>
        /// <returns>Returns whether the intro was skipped successfully.</returns>
        private bool TrySkipIntro(TitleMenu menu)
        {
            // wait until the game is ready
            if (Game1.currentGameTime == null)
            {
                return(false);
            }

            // skip to title screen
            menu.receiveKeyPress(Keys.Escape);
            menu.update(Game1.currentGameTime);

            // skip button transition
            if (!this.Config.SkipToLoadScreen)
            {
                while (this.Helper.Reflection.GetPrivateValue <int>(menu, "buttonsToShow") < TitleMenu.numberOfButtons)
                {
                    menu.update(Game1.currentGameTime);
                }
            }

            // skip to load screen
            if (this.Config.SkipToLoadScreen)
            {
                menu.performButtonAction("Load");
                while (TitleMenu.subMenu == null)
                {
                    menu.update(Game1.currentGameTime);
                }
            }

            return(true);
        }
Exemple #3
0
        /****
        ** Methods
        ****/
        /// <summary>Apply the next skip step.</summary>
        /// <param name="menu">The title menu to update.</param>
        /// <param name="step">The step to apply (starting at 0).</param>
        /// <returns>Returns whether there are more skip steps.</returns>
        /// <remarks>The skip logic is applied over several update ticks to let the game update itself smoothly. This prevents a few issues like a long pause before the game window opens, or the title menu not resizing itself for full-screen display.</remarks>
        private bool ApplySkip(TitleMenu menu, int step)
        {
            switch (step)
            {
            // skip to main menu
            case 1:
                menu.receiveKeyPress(Keys.Escape);
                return(true);

            // skip to loading screen
            case 2:
                if (this.Config.SkipToLoadScreen)
                {
                    menu.performButtonAction("Load");
                }
                return(true);

            default:
                return(false);
            }
        }
Exemple #4
0
        internal static void SkipIntroUpdateTicked()
        {
            // start intro skip on game launch
            if (Current == Step.Launching)
            {
                // wait until the game is ready
                if (Game1.activeClickableMenu is TitleMenu title && Game1.currentGameTime != null)
                {
                    int[] win = ModMain.Config.TitleWindow;
                    // set title screen resolution
                    if (win.Length >= 2 && win[0] > 1024 && win[1] > 768)
                    {
                        Game1.graphics.PreferredBackBufferWidth  = win[0];
                        Game1.graphics.PreferredBackBufferHeight = win[1];
                        Game1.graphics.ApplyChanges();
                        Game1.updateViewportForScreenSizeChange(false, win[0], win[1]);
                    }
                    // set title window position
                    if (win.Length >= 4 && win[2] > 0 && win[3] > 0)
                    {
                        var form = System.Windows.Forms.Control.FromHandle(Program.gamePtr.Window.Handle).FindForm();
                        form.Location = new System.Drawing.Point(win[2], win[3]);
                    }

                    // Don't pause on focus loss until game is fully loaded.
                    Game1.options.pauseWhenOutOfFocus = false;

                    title.skipToTitleButtons();  // skip intro
                    Current = Step.Skipping;
                }
                return;
            }
            else if (Current == Step.Skipping)
            {
                TitleMenu title = (TitleMenu)Game1.activeClickableMenu;

                // skip to other screen
                if (SkipTo == Screen.Title)
                {
                    // skip button transition
                    while (ModMain.Reflection.GetField <int>(title, "buttonsToShow").GetValue() < TitleMenu.numberOfButtons)
                    {
                        title.update(Game1.currentGameTime);
                    }
                }
                else if (SkipTo == Screen.Load)
                {
                    // skip to load screen
                    title.performButtonAction("Load");
                    while (TitleMenu.subMenu == null)
                    {
                        title.update(Game1.currentGameTime);
                    }
                }
                else if (SkipTo == Screen.Join || SkipTo == Screen.Host)
                {
                    // skip to co-op screen
                    title.performButtonAction("Co-op");
                    while (TitleMenu.subMenu == null)
                    {
                        title.update(Game1.currentGameTime);
                    }

                    if (SkipTo == Screen.Host)
                    {
                        Current = Step.Waiting;
                        return;
                    }
                }
                else if (SkipTo == Screen.AutoLoad || SkipTo == Screen.AutoHost)
                {
                    string lastLoaded = ModMain.Config.LastLoadedSave;      // recall last saved name

                    if (!String.IsNullOrEmpty(lastLoaded) && Directory.Exists(Path.Combine(Constants.SavesPath, lastLoaded)))
                    {
                        title.update(Game1.currentGameTime);

                        if (SkipTo == Screen.AutoHost)
                        {
                            Game1.multiplayerMode = 2;  // server mode
                        }
                        Game1.activeClickableMenu = new AutoLoader(lastLoaded);
                    }
                }
            }
            else if (Current == Step.Waiting)
            {
                // do nothing if a confirmation box is on-screen (e.g. multiplayer disconnect error)
                if (!(TitleMenu.subMenu is ConfirmationDialog) &&
                    (SkipTo == Screen.Host && TitleMenu.subMenu is CoopMenu submenu))
                {
                    if (submenu.hostTab == null) // select host tab
                    {
                        return;                  // not connected yet
                    }
                    submenu.receiveLeftClick(submenu.hostTab.bounds.X, submenu.hostTab.bounds.Y, playSound: false);
                }
            }

            Current = Step.Done;
        }
Exemple #5
0
        /// <summary>Skip the intro if the game is ready.</summary>
        /// <param name="menu">The title menu whose intro to skip.</param>
        /// <param name="currentStage">The current step in the mod logic.</param>
        /// <returns>Returns the next step in the skip logic.</returns>
        private Stage Skip(TitleMenu menu, Stage currentStage)
        {
            // wait until the game is ready
            if (Game1.currentGameTime == null)
            {
                return(currentStage);
            }

            // do nothing if a confirmation box is on-screen (e.g. multiplayer disconnect error)
            if (TitleMenu.subMenu is ConfirmationDialog)
            {
                return(Stage.None);
            }

            // main skip logic
            if (currentStage == Stage.SkipIntro)
            {
                if (Constants.TargetPlatform == GamePlatform.Android)
                {
                    // skip to title screen
                    menu.skipToTitleButtons();

                    // skip button transition
                    while (this.Helper.Reflection.GetField <bool>(menu, "isTransitioningButtons").GetValue())
                    {
                        menu.update(Game1.currentGameTime);
                    }
                }
                else
                {
                    // skip to title screen
                    menu.receiveKeyPress(Keys.Escape);
                    menu.update(Game1.currentGameTime);

                    // skip button transition
                    while (this.Helper.Reflection.GetField <int>(menu, "buttonsToShow").GetValue() < TitleMenu.numberOfButtons)
                    {
                        menu.update(Game1.currentGameTime);
                    }
                }

                // skip to next screen
                switch (this.Config.SkipTo)
                {
                case Screen.Title:
                    return(Stage.None);

                case Screen.Load:
                    // skip to load screen
                    menu.performButtonAction("Load");
                    while (TitleMenu.subMenu == null)
                    {
                        menu.update(Game1.currentGameTime);
                    }
                    return(Stage.None);

                case Screen.JoinCoop:
                case Screen.HostCoop:
                    // skip to co-op screen
                    menu.performButtonAction("Co-op");
                    while (TitleMenu.subMenu == null)
                    {
                        menu.update(Game1.currentGameTime);
                    }

                    return(this.Config.SkipTo == Screen.JoinCoop
                            ? Stage.None
                            : Stage.WaitingForConnection);
                }
            }

            // skip to host tab after connection is established
            if (currentStage == Stage.WaitingForConnection)
            {
                // not applicable
                if (this.Config.SkipTo != Screen.HostCoop || !(TitleMenu.subMenu is CoopMenu submenu))
                {
                    return(Stage.None);
                }

                // not connected yet
                if (submenu.hostTab == null)
                {
                    return(currentStage);
                }

                // select host tab
                submenu.receiveLeftClick(submenu.hostTab.bounds.X, submenu.hostTab.bounds.Y, playSound: false);
            }

            // ???
            return(Stage.None);
        }