Exemplo n.º 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 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);
        }
Exemplo n.º 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 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);
        }
        /// <summary>Perform any logic needed on update while the animation is active.</summary>
        /// <param name="playerAnimationID">The player's current animation ID.</param>
        public override void Update(int playerAnimationID)
        {
            TitleMenu titleMenu    = (TitleMenu)Game1.activeClickableMenu;
            var       isTransition = this.GetIsTransitionField(titleMenu);

            for (int i = 1; i < this.Multiplier && isTransition.GetValue(); i++)
            {
                titleMenu.update(Game1.currentGameTime);
            }
        }
Exemplo n.º 4
0
        /// <summary>Perform any logic needed on update while the animation is active.</summary>
        /// <param name="playerAnimationID">The player's current animation ID.</param>
        public override void Update(int playerAnimationID)
        {
            TitleMenu titleMenu    = (TitleMenu)Game1.activeClickableMenu;
            var       isTransition = this.GetIsTransitionField(titleMenu);

            this.ApplySkips(
                run: () => titleMenu.update(Game1.currentGameTime),
                until: () => !isTransition.GetValue()
                );
        }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
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);
        }