Esempio n. 1
0
        }   // end of Activate()

        public void Deactivate()
        {
            if (Active)
            {
                if (prevLanguage != XmlOptionsData.Language)
                {
                    changeLanguageMessage.Activate(useRtCoords: true);
                    grid.Active = true; // Keep grid active.
                    return;
                }

                grid.Active = false;
                HelpOverlay.Pop();      // Pop off the help overlay for the current options element.

                CommandStack.Pop(commandMap);
                HelpOverlay.Pop();      // Pop off the help for the options menu.

                // Prevent the button pressed from leaking into runtime.
                GamePadInput.IgnoreUntilReleased(Buttons.B);

                active = false;

                touched = (PlayerIndex)(-1);

                GamePadInput.ClearAllWasPressedState();

                MainMenu.Instance.LiveFeedDirty = true;
            }
        }   // end of Deactivate()
Esempio n. 2
0
        private void StartJumpingIn(string gamerTag, object param)
        {
            // Turn off background updates to friend profiles.
            LiveManager.FriendUpdatesEnabled = false;
            // Turn off background updates to friend joinable states.
            LiveManager.JoinableUpdatesEnabled = false;

            // TODO: Warn of potentially "destructive" action. Player may have invited people to join their session.
            // This action closes the local session, invalidating the invites.
            LiveManager.CloseSession();

            // Cancel pending friend profile and joinable state queries.
            LiveManager.ClearQueuedOperations(null);

            // Show the "initializing sharing room" notification dialog.
            openingSharingRoomMessage.Activate();

            // Start finding our friend's network session.
            SessionFinder finderOp = new SessionFinder(gamerTag, FindSessionComplete_Join, param, this);

            finderOp.Queue();
        }
Esempio n. 3
0
        }   // end of OnSaveLevelDialogButton()

        /// <summary>
        /// OnSelect method used by mini-hub grid.  If the level is dirty and needs to
        /// be saved the SaveChagesDialog will be activated.  Upon its deactivation
        /// the level should no longer be marked dirty and OnSelect() will get called
        /// again allowing the user's action to be executed.
        /// </summary>
        /// <param name="grid"></param>
        public void OnSelect(ModularMenu menu)
        {
            // Prevent the button pressed from leaking into runtime.
            GamePadInput.IgnoreUntilReleased(Buttons.A);

            // In every case, we need to reset the level to its starting state.
            InGame.inGame.ResetSim(preserveScores: false, removeCreatablesFromScene: false, keepPersistentScores: false);
            // Resetting the sim just started up all game audio, let's pause it down again.
            // It will be resumed when we go back into sim mode.
            BokuGame.Audio.PauseGameAudio();

            // Flag to let us know if the level needs saving.  If the save changes
            // dialog has already been activated then just set this to false.
            bool needToSaveLevel = (InGame.IsLevelDirty || InGame.AutoSaved) && !saveChangesActivated;

            // Does the current world belong to the user.  Required to share to community.
            // Test the genre flag and also special case look at empty world.
            bool isMyWorld = false;

            if (InGame.XmlWorldData != null)
            {
                bool genreTest    = ((int)InGame.XmlWorldData.genres & (int)Genres.MyWorlds) != 0;
                bool newWorldTest = InGame.XmlWorldData.Filename == emptyWorldFileName;
                if (genreTest && !newWorldTest)
                {
                    isMyWorld = true;
                }
            }

            // Normally there would be a switch here but if we compare strings
            // we proof ourselves against changes in the order of the elements.
            if (menu.CurString == Strings.Localize("miniHub.reset"))
            {
                // Reset.
                // We've already done a Reset, so force to RunSim mode if we already aren't.
                Deactivate();
                InGame.inGame.Activate();
                InGame.inGame.CurrentUpdateMode = InGame.UpdateMode.RunSim;
                InGame.inGame.RestorePlayModeCamera();

                // The ResetSim above doesn't ApplyInlining since it's generally
                // meant for resetting into the editor.  In this case we're going
                // into RunSim mode so be sure to apply inlining first.
                InGame.ApplyInlining();

                if (InGame.inGame.PreGame != null)
                {
                    InGame.inGame.PreGame.Active = true;
                }
            }
            else if (menu.CurString == Strings.Localize("miniHub.edit"))
            {
                // Edit level.
                Deactivate();
                InGame.inGame.Activate();
                InGame.inGame.CurrentUpdateMode = InGame.UpdateMode.ToolMenu;
            }
            else if (menu.CurString == Strings.Localize("miniHub.save"))
            {
                // Save
                saveLevelDialog.Activate();
            }
            else if (menu.CurString == Strings.Localize("miniHub.publish"))
            {
                // Offer to save first.  Need to save if world has changed or is world doesn't belong to user.
                if (needToSaveLevel || !isMyWorld)
                {
                    saveChangesActivated = true;
                    saveChangesMessage.Activate();
                }
                else
                {
                    var level = LevelMetadata.CreateFromXml(InGame.XmlWorldData);

                    shared.communityShareMenu.Activate(level);
                }
            }
            else if (menu.CurString == Strings.Localize("miniHub.load"))
            {
                // Load.

                // If we're back here and saveChangesActivated is true then the
                // user was given the option to save changes and chose Discard.
                // So don't offer to save again.
                if (!saveChangesActivated && needToSaveLevel)
                {
                    saveChangesActivated = true;
                    saveChangesWithDiscardMessage.Activate();
                }
                else
                {
                    saveChangesActivated = false;

                    // Deactivate mini-hub and bring up loading menu.
                    Deactivate();
                    //InGame.inGame.DiscardTerrain();
                    BokuGame.bokuGame.loadLevelMenu.LocalLevelMode = LoadLevelMenu.LocalLevelModes.General;
                    BokuGame.bokuGame.loadLevelMenu.ReturnToMenu   = LoadLevelMenu.ReturnTo.MiniHub;
                    BokuGame.bokuGame.loadLevelMenu.Activate();
                }
            }
            else if (menu.CurString == Strings.Localize("miniHub.emptyLevel"))
            {
                // Empty Level.
                // If saveChangesActivated is already true then user chose Discard and
                // we can ignore the needToSaveLevel flag.
                if (!saveChangesActivated && needToSaveLevel)
                {
                    saveChangesActivated = true;
                    saveChangesWithDiscardMessage.Activate();
                }
                else
                {
                    saveChangesActivated = false;

                    // Undo any previous warping.
                    ScreenWarp.FitRtToScreen(BokuGame.ScreenSize);

                    newWorldDialog.Active = true;
                }
            }
            else if (menu.CurString == Strings.Localize("miniHub.print"))
            {
                Print.PrintProgramming();

                // We don't want to exit the mini-hub so re-activate the menu.
                shared.menu.Active = true;
            }
            else if (menu.CurString == Strings.Localize("miniHub.quit"))
            {
                // Exit to main menu.
                // If we're back here and saveChangesActivated is true then the
                // user was given the option to save changes and chose Discard.
                // So don't offer to save again.
                if (!saveChangesActivated && needToSaveLevel)
                {
                    saveChangesActivated = true;
                    saveChangesWithDiscardMessage.Activate();
                }
                else
                {
                    saveChangesActivated = false;

                    // Wave bye, bye.  Go back to the main menu
                    Deactivate();
                    InGame.inGame.StopAllSounds();
                    BokuGame.bokuGame.mainMenu.Activate();
                }
            }
        }   // end of MiniHub OnSelect()
Esempio n. 4
0
        public void OnSelect(UIGrid grid)
        {
            // User selected a friend.

            grid.Active = true;

            int index = shared.grid.SelectionIndex.Y;

            UIGridShareFriendElement friendElement = shared.grid.Get(0, index) as UIGridShareFriendElement;

            UIGridSharingServerElement serverElement = shared.grid.Get(0, index) as UIGridSharingServerElement;

            if (friendElement != null)
            {
                if (friendElement.Friend.IsOnline)
                {
                    if (friendElement.Friend.InvitedUs || friendElement.Friend.IsJoinable)
                    {
                        // Friend has a joinable session, directly join it ("jump in").
                        StartJumpingIn(friendElement.Friend.GamerTag, friendElement);

                        // Don't allow the user to interact with the share hub while the SessionFinder is running.
                        grid.Active = false;
                    }
                    else if (friendElement.Friend.IsJoined && LiveManager.IsConnected)
                    {
                        // Selected friend has joined our session, just go to the sharing room.

                        ActivateSharingScreen();

                        grid.Active = false;
                    }
                    else if (!friendElement.Friend.InvitedThem)
                    {
                        // Start sending an invitation to this friend.

                        friendElement.Friend.InvitingThem = true;

                        if (!LiveManager.IsConnected)
                        {
                            openingInviteGuideMessage.Activate();

                            LiveManager.ClearQueuedOperations(null);

                            // We must have a session open before we can send an invite.
                            // Start creating the network session.
                            SessionCreator createOp = new SessionCreator(SessionCreatorComplete_StartInvitingFriend, friendElement, this);
                            createOp.Queue();
                        }
                        else
                        {
                            // Session is already open, no need to create it before sending the invite.
                            StartInvitingFriend(friendElement);
                        }
                    }
                }
            }
            else if (serverElement != null)
            {
                if (serverElement.IsOnline)
                {
                    StartJumpingIn(serverElement.GamerTag, serverElement);

                    // Don't allow the user to interact with the share hub while the SessionFinder is running.
                    grid.Active = false;
                }
            }
        }
Esempio n. 5
0
        public void OnSelect(ModularMenu menu)
#endif
        {
            menu.Active = false;
            string cur = menu.CurString;

            // RESUME
            if (cur == Strings.Localize("mainMenu.resume"))
            {
                if (InGame.CurrentWorldId == Guid.Empty)
                {
                    if (InGame.UnDoStack.Resume())
                    {
                        Deactivate();

                        // Force resume to go into Edit mode.
                        InGame.inGame.CurrentUpdateMode = InGame.UpdateMode.MouseEdit;
                    }
                    else
                    {
                        //Debug.Assert(false, "Resume should not be enabled unless there is something to resume from");

                        // We had some error in trying to resume.  So, remove the resume
                        // option from the menu and soldier on.
                        shared.menu.DeleteText(Strings.Localize("mainMenu.resume"));
                        shared.menu.Active          = true;
                        XmlOptionsData.LastAutoSave = -1;
                    }
                }
                else
                {
                    Deactivate();
                    // Just reactivate the existing game.
                    BokuGame.bokuGame.inGame.Activate();
                }
            }

            // NEW WORLD
            if (cur == Strings.Localize("mainMenu.new") || cur == "CREATE")
            {
                newWorldDialog.Active = true;
            }

            // PLAY
            if (cur == Strings.Localize("mainMenu.play"))
            {
                Deactivate();
                BokuGame.bokuGame.loadLevelMenu.LocalLevelMode = LoadLevelMenu.LocalLevelModes.General;
                BokuGame.bokuGame.loadLevelMenu.ReturnToMenu   = LoadLevelMenu.ReturnTo.MainMenu;
                BokuGame.bokuGame.loadLevelMenu.Activate();
            }

#if NETFX_CORE
            // IMPORT
            if (cur == Strings.Localize("mainMenu.import"))
            {
                // Note this also switches to the LoadLevelMenu if any worlds are imported.
                bool levelImported = await PickImportFilesAsync();

                if (levelImported)
                {
                    Deactivate();
                    // Switch to LoadLevelMenu which should also trigger a loading of the files in the Imports dir.
                    BokuGame.bokuGame.loadLevelMenu.LocalLevelMode = LoadLevelMenu.LocalLevelModes.General;
                    BokuGame.bokuGame.loadLevelMenu.ReturnToMenu   = LoadLevelMenu.ReturnTo.MainMenu;
                    BokuGame.bokuGame.loadLevelMenu.Activate();
                }
                else
                {
                    menu.Active = true;
                }
            }
#endif
            if (WinStoreHelpers.RunningAsUWP)
            {
                // IMPORT
                if (cur == Strings.Localize("mainMenu.import"))
                {
                    // Note this also switches to the LoadLevelMenu if any worlds are imported.
                    bool levelImported = PickImportFiles();
                    if (levelImported)
                    {
                        Deactivate();
                        // Switch to LoadLevelMenu which should also trigger a loading of the files in the Imports dir.
                        BokuGame.bokuGame.loadLevelMenu.LocalLevelMode = LoadLevelMenu.LocalLevelModes.General;
                        BokuGame.bokuGame.loadLevelMenu.ReturnToMenu   = LoadLevelMenu.ReturnTo.MainMenu;
                        BokuGame.bokuGame.loadLevelMenu.Activate();
                    }
                    else
                    {
                        menu.Active = true;
                    }
                }
            }

            // COMMUNITY
            if (cur == Strings.Localize("mainMenu.community") || cur == "GALLERY")
            {
                // Check to see if the community server is reachable before switching screens.
                if (!Web.Community.Async_Ping(Callback_Ping, null))
                {
                    noCommunityMessage.Activate();
                    menu.Active = true;
                }
            }

            // OPTIONS
            if (cur == Strings.Localize("mainMenu.options"))
            {
                // Reactivate the menu since we want it alive when the options menu comes back.
                // Need to do this before activating the options menu in order to keep the stacks correct.
                menu.Active = true;
                shared.optionsMenu.Activate();
            }

            // HELP
            if (cur == Strings.Localize("mainMenu.help"))
            {
                Deactivate();
                BokuGame.bokuGame.helpScreens.Activate();
            }

            // QUIT
            if (cur == Strings.Localize("mainMenu.exit"))
            {
                //GamePadInput.stopActiveInputTimer();

                //deactivate the menu on exit to stop the timer
                Deactivate();

                // Wave bye, bye.
#if NETFX_CORE
                Windows.UI.Xaml.Application.Current.Exit();
#else
                BokuGame.bokuGame.Exit();
#endif
            }
        }   // end of OnSelect