Ejemplo n.º 1
0
        public void Activate(OnEditDone doneCallback, string original, ValidateText validateTextCallback = null)
        {
            SetText(original);
            shared.blob.End();  // Start with cursor at end of existing string.

            if (state != States.Active)
            {
                shared.onEditDone           = doneCallback;
                shared.validateTextCallback = validateTextCallback;

                //------------------ Copied from other implementation --------------
                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Push(commandMap);

                HelpOverlay.Push(@"TextLineEditor");

                //------------------ Copied from other implementation END --------------

                state = States.Active;

                //shared.blob.s

                updateObj.Activate();
            }
        }
Ejemplo n.º 2
0
 public override void Activate()
 {
     parent.noCommunityMessage.Deactivate();
     // Do this here so that it happens after the previous object
     // has had a chance to deactivate.
     HelpOverlay.Push("MiniHub");
 }
            }   // end of TopLevelPaletteUpdateObj Update()

            private void SetHelpOverlay()
            {
                HelpOverlay.Pop();
                switch (curMode)
                {
                case UpdateMode.RunSim:
                    HelpOverlay.Push("TopLevelPaletteRunSim");
                    break;

                case UpdateMode.EditObject:
                    HelpOverlay.Push("TopLevelPaletteEditObject");
                    break;

                case UpdateMode.ToolBox:
                    HelpOverlay.Push("TopLevelPaletteToolBox");
                    break;

                case UpdateMode.EditWorldParameters:
                    HelpOverlay.Push("TopLevelPaletteEditWorldParameters");
                    break;

                case UpdateMode.EditObjectParameters:
                    HelpOverlay.Push("TopLevelPaletteEditObjectParameters");
                    break;
                }
            }   // end of TopLevelPalette SetHelpOverlay()
            }   // end of EditTextureUpdateObj Update()

            public override void Activate()
            {
                base.Activate();

                HelpOverlay.Push("TextureEdit");
                parent.cursor3D.Deactivate();
            } // end of EditTextureUpdateObj Activate()
Ejemplo n.º 5
0
        }   // end of OnCancel()

        public void Activate()
        {
            if (!active)
            {
                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Push(commandMap);
                HelpOverlay.Push(@"ToolMenu");
                active                  = true;
                grid.Active             = true;
                grid.RenderWhenInactive = false;

                // Never allow the Play button to be the default.
                if (grid.SelectionIndex.X == 0)
                {
                    // Default to object edit.
                    grid.SelectionIndex = new Point(2, 0);
                }

                // Reset all the tiles to the origin so they spring out nicely.
                for (int i = 0; i < grid.ActualDimensions.X; i++)
                {
                    UIGrid2DTextureElement e = (UIGrid2DTextureElement)grid.Get(i, 0);
                    e.Position = Vector3.Zero;
                }
                grid.Dirty = true;
                // Force the grid to update the positions before getting rendered.
                grid.Update(ref worldMatrix);

                lastChangedTime = Time.WallClockTotalSeconds;
                curIndex        = grid.SelectionIndex.X;

                InGame.inGame.StopAllSounds();
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="userRtCoords">Are we rendering on a rendertarget?</param>
        public void Activate(bool useRtCoords = false)
        {
            if (!active)
            {
                this.useRtCoords = useRtCoords;

                // We rely on this render target to get fully running. Refuse
                // to activate until it's available.
                if (UI2D.Shared.RenderTarget512_302 != null)
                {
                    // If we're still dirty, someone is trying to activate us before the system
                    // is loaded enough to support us. So refuse to activate until we have everything
                    // we need.
                    active = true;

                    RefreshTexture();

                    HelpOverlay.Push("ModularMessageDialog");

                    // Force a re-render of the texture.
                    dirty = true;
                    CommandStack.Push(commandMap);
                }
            }
        }   // and of Activate()
Ejemplo n.º 7
0
            public override void Activate()
            {
                if (!active)
                {
                    active = true;

                    CommandStack.Push(commandMap);
                    HelpOverlay.Push("RunSimulation");

                    // Wake everything up.
                    parent.ActivateAllGameThings();

                    // This is commented out since it was removing Creatables from the level
                    // when it shouldn't.  In particular if you restart Kodu, find a level in
                    // the LoadLevelMenu, and choose Edit, it would remove all the creatables.
                    // Running and then editing would restore them so it's not peristing the
                    // removal.
                    // Normally I'd just delete the line but if this change starts causing issues
                    // it might help to know this was here.  If it's now 2019 or later you can
                    // probably feel free to remove this.  :-)
                    //parent.RemoveCreatablesFromScene();

                    timerInstrument = Instrumentation.StartTimer(Instrumentation.TimerId.InGameRunSim);

#if !NETFX_CORE
                    // Refresh the list of attached microbits.
                    {
                        System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(MicrobitManager.RefreshWorker));
                        t.Start();
                    }
#endif

                    // Be sure all Auth UI is hidden.
                    AuthUI.HideAllDialogs();

                    base.Activate();
                }

                if (Program2.CmdLine.Exists("analytics"))
                {
#if !NETFX_CORE
                    Console.WriteLine("Begin Analytics");
#endif
                    ObjectAnalysis oa = new ObjectAnalysis();
                    oa.beginAnalysis(MainMenu.StartupWorldFilename.ToString());


                    //  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 RunSimUpdateObj Activate()
Ejemplo n.º 8
0
            }   // end of TexturePickerUpdateObj Update()

            public override void Activate()
            {
                base.Activate();

                HelpOverlay.Push("TexturePicker");
                parent.cursor3D.Deactivate();
                shared.texturePicker.Activate();
            }   // end of TexturePickerUpdateObj Activate()
Ejemplo n.º 9
0
 protected void SetOverlay(string overlay)
 {
     if (HelpOverlay.Peek() != overlay)
     {
         HelpOverlay.Pop();
         HelpOverlay.Push(overlay);
     }
 }
            }     // end of EditHeightMapUpdateObj Update()

            public override void Activate()
            {
                base.Activate();

                HelpOverlay.Push("HeightMapEdit");
                parent.cursor3D.Deactivate();

                starting = true;
            } // end of EditHeightMapUpdateObj Activate()
Ejemplo n.º 11
0
            }   // end of EditWorldParametersUpdateObj Update()

            public override void Activate()
            {
                if (!active)
                {
                    base.Activate();

                    HelpOverlay.Push("SelectNextLevel");
                    parent.cursor3D.Deactivate();
                }
            }   // end of EditWorldParametersUpdateObj Activate()
Ejemplo n.º 12
0
        }   // end of GetHelpDescription()

        /// <summary>
        /// Activates the AddItem help card.
        /// </summary>
        /// <param name="parent">Parent pie selector.</param>
        /// <param name="typeName">This is the string that identifies the type of the object we're getting help for.  This is used to get the correct help data from the Help class.</param>
        /// <param name="objectName">This the displayed name of the object/actor.  This comes from the Strings class and may be localized.</param>
        public void Activate(PieSelector parent, string typeName, string objectName)
        {
            ToolTipManager.Clear();

            if (typeName == null || objectName == null)
            {
                return;
            }

            this.parent = parent;

            if (state != States.Active)
            {
                // Ensure we have valid help before activating.
                shared.actorHelp = Help.GetActorHelp(typeName);

                if (shared.actorHelp == null || shared.actorHelp.upid == null)
                {
                    return;
                }

                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Push(commandMap);

                state = States.Active;

                shared.curActorName = objectName;
                if (shared.actorHelp.description != null)
                {
                    shared.descBlob.RawText = shared.actorHelp.description.Trim();
                }

                shared.SetUpGrid();

                if (shared.examplesGrid != null)
                {
                    shared.examplesGrid.Active = true;
                }

                // Always start the description at the beginning.
                shared.topLine    = 0;
                shared.descOffset = 0;

                // Get the current scene thumbnail.
                shared.thumbnail = InGame.inGame.SmallThumbNail;

                // Tell InGame we're using the thumbnail so no need to do full render.
                InGame.inGame.RenderWorldAsThumbnail = true;

                HelpOverlay.Push(@"HelpCardAddItem");

                timerInstrument = Instrumentation.StartTimer(Instrumentation.TimerId.AddItemHelpCards);
            }
        }   // end of Activate
            }   // end of TopLevelPalette SetHelpOverlay()

            public override void Activate()
            {
                base.Activate();

                BokuGame.Audio.GetCue("programming move out").Play();
                shared.topLevelPalette.Open   = true;
                shared.topLevelPalette.Select = curMode;

                HelpOverlay.Push("TopLevelPalette");
                SetHelpOverlay();
            }   // end of TopLevelPaletteUpdateObj Activate()
Ejemplo n.º 14
0
        public void Activate(string gamepadText, string mouseText, string touchText, bool useBackgroundThumbnail, bool useOverscanForHitTesting)
        {
            this.gamepadText = gamepadText;
            this.mouseText   = mouseText;
            this.touchText   = touchText;

            if (gamepadText == null && mouseText == null && touchText == null)
            {
                Debug.Assert(false, "What are you trying to do?");
                return;
            }

            if (state != States.Active)
            {
                this.useBackgroundThumbnail = useBackgroundThumbnail;
                this.useRtCoords            = useOverscanForHitTesting;

                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Push(commandMap);

                state = States.Active;

                // Get the current scene thumbnail.  If we're using this from the main menu (options)
                // then use the title screen image instead.
                if (InGame.inGame.State == InGame.States.Inactive)
                {
                    thumbnail = BokuGame.bokuGame.mainMenu.BackgroundTexture;
                }
                else
                {
                    thumbnail = InGame.inGame.SmallThumbNail;
                }

                // Tell InGame we're using the thumbnail so no need to do full render.
                prevRenderWorldAsThumbnail = InGame.inGame.RenderWorldAsThumbnail;
                if (!prevRenderWorldAsThumbnail)
                {
                    InGame.inGame.RenderWorldAsThumbnail = true;
                }
                Time.Paused = true;

                HelpOverlay.Push(@"ScrollableTextDisplay");

                // Get text string.
                blob = new TextBlob(UI2D.Shared.GetGameFont20, mouseText, textWidth);
                blob.LineSpacingAdjustment = 6; // Taller lines to make programming tiles fit better.

                topLine    = 0;
                textOffset = 0;

                PreRender(); // Set up text rendering for first frame.
            }
        }                    // end of Activate
Ejemplo n.º 15
0
            public override void Activate()
            {
                base.Activate();

                if (parent.State != States.Paused)
                {
                    HelpOverlay.Push("ObjectTweak");
                }
                parent.cursor3D.Activate();
                RemoveAura();
                shared.editWayPoint.Clear();
            }   // end of TweakObjectUpdateObj Activate()
Ejemplo n.º 16
0
        }   // end of RoadTool Update()

        #endregion Public

        #region Internal
        protected override void SelectOverlay()
        {
            if (StretchGoing && rightTriggered)
            {
                HelpOverlay.Pop();
                HelpOverlay.Push(@"RoadToolRightTrig");
            }
            else
            {
                base.SelectOverlay();
            }
        }
        public void Activate(bool useRtCoords)
        {
            this.useRtCoords = useRtCoords;

            if (active != true)
            {
                active = true;

                HelpOverlay.Push("ModularCheckboxList");
                CommandStack.Push(commandMap);
                ApplyExclusiveFirstItemFiltering();
            }
        }   // end of Activate()
Ejemplo n.º 18
0
            public override void Activate()
            {
                if (!active)
                {
                    base.Activate();

                    HelpOverlay.Push("EditWorldParameters");
                    parent.cursor3D.Deactivate();
                    shared.editWorldParameters.Activate();

                    timerInstrument = Instrumentation.StartTimer(Instrumentation.TimerId.InGameEditWorldParameters);
                }
            }   // end of EditWorldParametersUpdateObj Activate()
Ejemplo n.º 19
0
        }   // end of DegviceReset()

        public void Activate(BaseHint curHint, bool useBackgroundThumbnail, bool useRtCoords)
        {
            this.curHint = curHint;

            if (curHint == null)
            {
                return;
            }

            if (state != States.Active)
            {
                this.useBackgroundThumbnail = useBackgroundThumbnail;
                this.useRtCoords            = useRtCoords;

                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Push(commandMap);

                state = States.Active;

                // Get the current scene thumbnail.  If we're using this from the main menu (options)
                // then use the title screen image instead.
                if (InGame.inGame.State == InGame.States.Inactive)
                {
                    thumbnail = BokuGame.bokuGame.mainMenu.BackgroundTexture;
                }
                else
                {
                    thumbnail = InGame.inGame.SmallThumbNail;
                }

                // Tell InGame we're using the thumbnail so no need to do full render.
                prevRenderWorldAsThumbnail = InGame.inGame.RenderWorldAsThumbnail;
                if (!prevRenderWorldAsThumbnail)
                {
                    InGame.inGame.RenderWorldAsThumbnail = true;
                }
                Time.Paused = true;

                HelpOverlay.Push(@"ScrollableModalHint");

                // Get text string.
                blob = new TextBlob(UI2D.Shared.GetGameFont20, curHint.ModalText, textWidth);

                topLine    = 0;
                textOffset = 0;

                PreRender(); // Set up text rendering for first frame.
            }
        }                    // end of Activate
Ejemplo n.º 20
0
        }   // end of ToolBox RestartCurrentTool()

        public void Activate()
        {
            if (!active)
            {
                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Push(commandMap);
                HelpOverlay.Push(@"ToolBox");
                active = true;
                if (activeTool != null)
                {
                    activeTool.Active = true;
                }
            }
        }
Ejemplo n.º 21
0
        override public void Activate()
        {
            if (state != States.Active)
            {
                pendingState             = States.Active;
                BokuGame.objectListDirty = true;

                // There should be no entry for "TextDialog" so this effectively
                // disables the help overlay while the dialog is active.
                HelpOverlay.Push("TextDialog");

                // Force the texture to be re-rendered.
                shared.dirty = true;
            }
        }
Ejemplo n.º 22
0
            }   // end of PreGameDesc Render()

            #endregion

            #region Internal

            protected override void Activate()
            {
                // Pause the game clock.
                // Instead of fully pausing the clock just let it run extremely slow.  This still
                // lets updates happen as expected and results in objects appearing when they
                // should and the camera moving to where it needs to be.
                //Time.Paused = true;
                Time.ClockRatio = 0.0001f;

                base.Activate();

                HelpOverlay.Push(@"PreGameDescription");

                UI2D.Shared.GetFont Font = BokuGame.bokuGame.GraphicsDevice.Viewport.Height < 720 ? UI2D.Shared.GetGameFont18Bold : UI2D.Shared.GetGameFont24Bold;
                blob = new TextBlob(Font, Terrain.Current.XmlWorldData.name + "\n\n" + Terrain.Current.XmlWorldData.description, (int)(BokuGame.bokuGame.GraphicsDevice.Viewport.Width / 2));
                blob.Justification = Terrain.Current.XmlWorldData.descJustification;
            }   // end of PreGameDesc Activate()
Ejemplo n.º 23
0
        }   // end of Render()

        public void Activate()
        {
            if (!Active)
            {
                CommandStack.Push(commandMap);
                HelpOverlay.Push("OptionsMenu");

                grid.Active = true;

                // Force the selected element to "reselect" itself so that
                // the help overlay gets updated properly.
                grid.SelectionElement.Selected = false;
                grid.SelectionElement.Selected = true;

                active = true;

                // Set initial state.
                showToolTips.Check         = XmlOptionsData.ShowToolTips;
                showHints.Check            = XmlOptionsData.ShowHints;
                restoreDisabledHints.Check = XmlOptionsData.DisabledHintIDs.Count == 0;
                showFramerate.Check        = XmlOptionsData.ShowFramerate;
                //helpLevel.CurIndex = XmlOptionsData.HelpLevel;
                modalToolMenu.Check = XmlOptionsData.ModalToolMenu;

                terrainSpeed.CurrentValue = XmlOptionsData.TerrainSpeed;

                uiVolume.CurrentValue    = XmlOptionsData.UIVolume * 100.0f;
                foleyVolume.CurrentValue = XmlOptionsData.FoleyVolume * 100.0f;
                musicVolume.CurrentValue = XmlOptionsData.MusicVolume * 100.0f;

                checkForUpdates.Check     = XmlOptionsData.CheckForUpdates;
                sendInstrumentation.Check = XmlOptionsData.SendInstrumentation;
                showIntroVideo.Check      = false;
                showTutorialDebug.Check   = XmlOptionsData.ShowTutorialDebug;

                language.SetValueByKey(XmlOptionsData.Language);
                prevLanguage = XmlOptionsData.Language;

                // Force an update to ensure everything is ready.
                Update();
            }
        }   // end of Activate()
Ejemplo n.º 24
0
        /// <summary>
        /// Override which overlay to be showing.
        /// </summary>
        protected override void SelectOverlay()
        {
            HelpOverlay.Pop();
            string helpStart = HelpOverlayStartID == null ? HelpOverlayID : HelpOverlayStartID;
            string helpGoing = HelpOverlayGoingID == null ? HelpOverlayID : HelpOverlayGoingID;

            if (rightTriggered)
            {
                HelpOverlay.Push(@"LevelToolRightTrig");
            }
            else
            if (StretchGoing)
            {
                HelpOverlay.Push(helpGoing);
            }
            else
            {
                HelpOverlay.Push(helpStart);
            }
        }
Ejemplo n.º 25
0
        }   // end of BaseTool Update()

        /// <summary>
        /// Override this to provide a place to initialize
        /// anything that needs to be done on a per-use basis.
        /// </summary>
        public virtual void OnActivate()
        {
            // Get references.  We can't do this in the
            // c'tor since not all of these exist yet.
            inGame         = Boku.InGame.inGame;
            shared         = inGame.shared;
            materialPicker = shared.ToolBox.MaterialPicker;
            waterPicker    = shared.ToolBox.WaterPicker;
            brushPicker    = shared.ToolBox.BrushPicker;
            starting       = true;
            StretchPhase   = Phase.Open;

            shared.editBrushIndex = prevBrushIndex;
            shared.editBrushStart = shared.editBrushPosition;

            HelpOverlay.Push(helpOverlayID);
            inGame.Cursor3D.Rep          = Cursor3D.Visual.Pointy;
            inGame.Cursor3D.Hidden       = false;
            inGame.Cursor3D.DiffuseColor = Vector4.One;

            terrainSpeed = Common.Xml.XmlOptionsData.TerrainSpeed; // just cache this.
        }
Ejemplo n.º 26
0
        protected void NavCard(int indexCard)
        {
            Debug.Assert(indexCard >= 0 && indexCard < listControls.Count);
            if (indexCard != this.indexActiveCard)
            {
                // Update help overlay.
                if (indexCard == 0)
                {
                    // Moving to the handle.
                    HelpOverlay.Pop();
                    // Decide which overlay to push...
                    if (ReflexPanel.CutPasteBuffer == null)
                    {
                        HelpOverlay.Push("RowHandleEmptyPasteBuffer");
                    }
                    else
                    {
                        HelpOverlay.Push("RowHandleFullPasteBuffer");
                    }
                }
                else if (indexActiveCard == 0 || indexActiveCard == -1)
                {
                    // Moving away from the handle OR moving to a newly created row.
                    HelpOverlay.Pop();
                    HelpOverlay.Push("Tile");
                }

                // update card state
                IControl card;
                if (this.indexActiveCard >= 0 && this.indexActiveCard < listControls.Count)
                {
                    card     = listControls[this.indexActiveCard] as IControl;
                    card.Hot = false;
                }
                this.indexActiveCard = indexCard;
                card     = listControls[this.indexActiveCard] as IControl;
                card.Hot = true;
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Activates scrollable text display.
        /// </summary>
        /// <param name="text">Text to display.</param>
        /// <param name="useBackgroundThumbnail">Should the game thumbnail be used as a backdrop when rendering?</param>
        /// <param name="useRtCoords">Should hit testing be adjusted for rendering to an RT?</param>
        /// <param name="scrubText">Should text be scrubbed through bad word filter?</param>
        public void Activate(GameActor thinker, string text, UIGridElement.Justification justification, bool useBackgroundThumbnail, bool useRtCoords, bool scrubText)
        {
            if (text == null)
            {
                return;
            }

            if (state != States.Active)
            {
                this.useBackgroundThumbnail = useBackgroundThumbnail;
                this.useRtCoords            = useRtCoords;

                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Push(commandMap);

                state = States.Active;

                // Get the current scene thumbnail.  If we're using this from the main menu (options)
                // then use the title screen image instead.
                if (InGame.inGame.State == InGame.States.Inactive)
                {
                    thumbnail = BokuGame.bokuGame.mainMenu.BackgroundTexture;
                }
                else
                {
                    thumbnail = InGame.inGame.SmallThumbNail;
                }

                // Tell InGame we're using the thumbnail so no need to do full render.
                prevRenderWorldAsThumbnail = InGame.inGame.RenderWorldAsThumbnail;
                if (!prevRenderWorldAsThumbnail)
                {
                    InGame.inGame.RenderWorldAsThumbnail = true;
                }
                Time.Paused = true;

                HelpOverlay.Push(@"ScrollableTextDisplay");

                // Get text string.
                if (thinker != null)
                {
                    text = TextHelper.ApplyStringSubstitutions(text, thinker as GameActor);
                }
                rawText            = text;
                text               = TextHelper.RemoveTags(text);
                blob               = new TextBlob(UI2D.Shared.GetGameFont20, text, textWidth);
                blob.Justification = justification;
                // By default TextBlob scrubs the text.  If the scrubText is false
                // then set the text again via a path that doesn't do any scrub.
                if (!scrubText)
                {
                    blob.RawTextNoScrub = text;
                }

                this.thinker = thinker;

                topLine    = 0;
                textOffset = 0;

                // If a second button is needed, the text for it should be set after activation.
                textB    = null;
                userHitA = true;

                PreRender(); // Set up text rendering for first frame.
            }
        }                    // end of Activate
Ejemplo n.º 28
0
 public override void Activate()
 {
     CommandStack.Push(commandMap);
     HelpOverlay.Push("RowMove");
 }
Ejemplo n.º 29
0
            }   // end of RunSimUpdateObj c'tor

            /// <summary>
            /// RunSimUpdateObj Update()
            /// </summary>
            /// <param name="camera"></param>
            public override void Update()
            {
                base.Update();

                parent.Camera.Update();

                float secs = Time.WallClockFrameSeconds;

                ThoughtBalloonManager.Update(shared.camera);
                SaidStringManager.Update();
#if !NETFX_CORE
                MicrobitManager.Update();
#endif

                // Start with visible cursor.
                parent.cursor3D.Activate();
                parent.cursor3D.Rep    = Cursor3D.Visual.RunSim;
                parent.cursor3D.Hidden = false;

                //
                // Determine the correct camera mode.
                //

                //
                //  The priorities used to determine the camera mode when the game is running are:
                //
                //  1)  First person.  This can be either via programming or because the user zoomed
                //      into a bot the camera was following.
                //  2)  Follow mode caused by bot(s) programmed with "follow" camera view.
                //  3)  World tweak screen fixed camera or fixed offset camera.
                //  4)  Follow mode caused by user controlled bot(s).
                //  5)  Free camera.
                //

                // Start with a fake loop to break out of.
                while (true)
                {
                    Terrain terrain = InGame.inGame.Terrain;    // Just a shortcut.

                    //
                    // Always use edit mode when the game is paused except during victory on level with one of the fixed cameras
                    // or when game is paused for a bot to speak (modal text display).
                    //
                    bool victoryActive = VictoryOverlay.ActiveGameOver || VictoryOverlay.ActiveWinner;
                    bool speaking      = InGame.inGame.shared.smallTextDisplay.Active || InGame.inGame.shared.scrollableTextDisplay.Active;
                    if (Time.Paused && !((terrain.FixedCamera || terrain.FixedOffsetCamera) && victoryActive) && !speaking)
                    {
                        CameraInfo.Mode = CameraInfo.Modes.Edit;
                        CameraInfo.CameraFocusGameActor = null;
                        break;
                    }

                    //
                    // 1) First person
                    //
                    if (CameraInfo.FirstPersonActive)
                    {
                        CameraInfo.Mode = CameraInfo.Modes.Actor;

                        // We're following a single actor so update the FollowActor camera values.
                        shared.camera.FollowCameraValid = false;

                        // Turn off 3d cursor since we don't need it.
                        parent.cursor3D.Deactivate();
                        if (parent.cursorClone != null)
                        {
                            parent.cursorClone.Deactivate();
                            parent.cursorClone = null;
                        }
                        break;
                    }

                    //
                    // 2)  Follow mode caused by bot(s) programmed with "follow" camera view.
                    //
                    if (CameraInfo.ProgrammedFollowList.Count > 0)
                    {
                        // Note that even though we looked at the count of bot programmed to
                        // have the camera follow them, for this mode we want to keep all
                        // deserving bots in camera.  So, the rest of this section will use
                        // the merged follow list instead of just the programmed follow list.

                        SetUpCameraFollowMode();

                        break;
                    }

                    //
                    // 3) World tweak fixed cameras.  Note for fixed offset we have to let
                    //    the later modes do their stuff and then override the camera.
                    //

                    if (terrain.FixedCamera)
                    {
                        CameraInfo.Mode = CameraInfo.Modes.FixedTarget;
                        CameraInfo.CameraFocusGameActor = null;

                        // Turn off 3d cursor since we don't need it.
                        parent.cursor3D.Deactivate();
                        if (parent.cursorClone != null)
                        {
                            parent.cursorClone.Deactivate();
                            parent.cursorClone = null;
                        }

                        break;
                    }

                    //
                    // 4) Follow mode caused by user controlled bot(s).
                    //
                    if (CameraInfo.MergedFollowList.Count > 0)
                    {
                        SetUpCameraFollowMode();

                        break;
                    }

                    //
                    // 5) Free!
                    //
                    // Not following an actor.
                    CameraInfo.Mode = CameraInfo.Modes.Edit;
                    CameraInfo.CameraFocusGameActor = null;

                    // Turn on 3d cursor in case we previously disabled it.
                    parent.cursor3D.Activate();
                    parent.CreateCursorClone();
                    parent.cursor3D.Hidden = false;

                    // We have no camera restrictions, so keep track of what the user is doing.
                    shared.camera.PlayValid      = true;
                    shared.camera.PlayCameraFrom = shared.camera.From;
                    shared.camera.PlayCameraAt   = shared.camera.At;

                    shared.camera.FollowCameraValid = false;


                    // Final break just to be sure the loop exits.
                    break;
                }

                //
                // Now that we're done, we need to check again to see if
                // we should be in FixedOffsetMode.
                //
                if (!Time.Paused && InGame.inGame.Terrain.FixedOffsetCamera && !CameraInfo.FirstPersonActive)
                {
                    CameraInfo.Mode = CameraInfo.Modes.FixedOffset;
                }

                // Zero out any offset while running.
                float t = Math.Min(Time.GameTimeFrameSeconds, 1.0f);
                shared.camera.HeightOffset = MyMath.Lerp(shared.camera.HeightOffset, 0.0f, t);

                //
                bool inputFocus = CommandStack.Peek() == commandMap;

                // Move the camera.
                switch (CameraInfo.Mode)
                {
                case CameraInfo.Modes.Edit:
                    MoveCameraEditMode(inputFocus, false);
                    break;

                case CameraInfo.Modes.Actor:
                    MoveCameraActorMode(true, false);
                    break;

                case CameraInfo.Modes.FixedTarget:
                    MoveCameraFixedTargetMode(inputFocus);
                    break;

                case CameraInfo.Modes.FixedOffset:
                    MoveCameraFixedOffsetMode(inputFocus);
                    break;

                case CameraInfo.Modes.MultiTarget:
                    MoveCameraMultiTargetMode(inputFocus, false);
                    break;
                }

                shared.camera.Update();

                // Update terrain.
                parent.terrain.Update(shared.camera);

                // Update the list of objects using our local camera.
                for (int i = 0; i < updateList.Count; i++)
                {
                    UpdateObject obj = (UpdateObject)updateList[i];
                    obj.Update();
                }
                parent.UpdateObjects();

                /// Pregame must update after parent.UpdateObjects, in case it
                /// decides to switchToMiniHub
                if (InGame.inGame.preGame != null)
                {
                    InGame.inGame.preGame.Update();
                }

                // Update the particle system.
                shared.particleSystemManager.Update();
                DistortionManager.Update();
                FirstPersonEffectMgr.Update();

                // This must be done after all brains are updated.
                Scoreboard.Update(shared.camera);

                // Update the TextDisplays.  Ignored if not active.
                shared.scrollableTextDisplay.Update(shared.camera);
                shared.smallTextDisplay.Update(shared.camera);

                VictoryOverlay.Update();

                // Do the input processing after object update because there will be order of operation issue if we don't
                //
                // Check if we have input focus.  Don't do any input
                // related update if we don't.
                if (inputFocus)
                {
                    // Grab the current state of the gamepad.
                    GamePadInput pad = GamePadInput.GetGamePad0();

                    // Switch to Mini-Hub?
                    if (Actions.MiniHub.WasPressed)
                    {
                        Actions.MiniHub.ClearAllWasPressedState();

                        //parent.ResetSim(CurrentLevelFilename());

                        // Needed to make sure that deactivated objects are actually removed from
                        // the list otherwise they may get saved along with the newly activated ones.
                        //parent.Refresh(BokuGame.gameListManager.updateList, BokuGame.gameListManager.renderList);

                        parent.SwitchToMiniHub();
                        return;
                    }

                    //handle swipe to return to edit for touch input
                    if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                    {
                        SwipeGestureRecognizer swipeGesture = TouchGestureManager.Get().SwipeGesture;
                        if (swipeGesture.WasRecognized &&
                            swipeGesture.SwipeDirection == Directions.North)
                        {
#if NETFX_CORE
                            float halfWidth = (float)BokuGame.bokuGame.Window.ClientBounds.Width * 0.5f;
                            float height    = (float)BokuGame.bokuGame.Window.ClientBounds.Height;
#else
                            float halfWidth = (float)XNAControl.Instance.ClientSize.Width * 0.5f;
                            float height    = (float)XNAControl.Instance.ClientSize.Height;
#endif

                            //center half of the screen width-wise
                            float minX = halfWidth - (halfWidth * k_TouchExitAreaWidthPercent);
                            float maxX = halfWidth + (halfWidth * k_TouchExitAreaWidthPercent);

                            //bottom 20% height-wise
                            float minY = height - (height * k_TouchExitAreaHeightPercent);


                            Vector2 pos = swipeGesture.InitialPosition;
                            if (pos.X >= minX && pos.X <= maxX && pos.Y >= minY)
                            {
                                // User did a swipe from the bottom of the screen, enter edit mode
                                InGame.inGame.CurrentUpdateMode = UpdateMode.EditObject;
                                InGame.inGame.CurrentUpdateMode = UpdateMode.TouchEdit;

                                Foley.PlayPressStart();
                                return;
                            }
                        }

                        // HACKHACK (****) Put in a tap recognizer since swipe seems to fail.
                        {
                            TapGestureRecognizer hackTapGesture = TouchGestureManager.Get().TapGesture;
                            if (hackTapGesture.WasTapped())
                            {
#if NETFX_CORE
                                float halfWidth = (float)BokuGame.bokuGame.Window.ClientBounds.Width * 0.5f;
                                float height    = (float)BokuGame.bokuGame.Window.ClientBounds.Height;
#else
                                float halfWidth = (float)XNAControl.Instance.ClientSize.Width * 0.5f;
                                float height    = (float)XNAControl.Instance.ClientSize.Height;
#endif

                                //center area of the screen width-wise
                                float minX = halfWidth - (halfWidth * 0.1f);
                                float maxX = halfWidth + (halfWidth * 0.1f);

                                //bottom 10% height-wise
                                float minY = height - (height * 0.1f);

                                Vector2 pos = hackTapGesture.Position;
                                if (pos.X >= minX && pos.X <= maxX && pos.Y >= minY)
                                {
                                    // User did a tap on the bottom of the screen, enter edit mode
                                    InGame.inGame.CurrentUpdateMode = UpdateMode.EditObject;
                                    InGame.inGame.CurrentUpdateMode = UpdateMode.TouchEdit;

                                    Foley.PlayPressStart();
                                    return;
                                }
                            }
                        }
                    }

                    bool gameOver = VictoryOverlay.GameOver;

                    if (Time.Paused && !gameOver)
                    {
                        // We must be in user induced pause mode.
                        if (Actions.Unpause.WasPressed)
                        {
                            Actions.Unpause.ClearAllWasPressedState();

                            Time.Paused = false;
                            HelpOverlay.Pop();
                        }
                    }
                    else
                    {
                        if (gameOver)
                        {
                            // Game over man!  Let the user restart if they want.
                            if (Actions.Restart.WasPressed)
                            {
                                Actions.Restart.ClearAllWasPressedState();

                                InGame.inGame.ResetSim(preserveScores: false, removeCreatablesFromScene: true, keepPersistentScores: false);
                                // Since we're going right back into RunSim mode we need to first inline.
                                ApplyInlining();
                            }
                        }

                        // Open ToolMenu.
                        if (Actions.ToolMenu.WasPressed)
                        {
                            Actions.ToolMenu.ClearAllWasPressedState();

                            parent.CurrentUpdateMode = UpdateMode.ToolMenu;
                            Foley.PlayPressStart();
                            return;
                        }

                        // Pause?
                        // We want to make pause hard to get into so it requires both triggers and both stickButtons to be pressed.
                        if ((pad.LeftStickButton.IsPressed && pad.RightStickButton.IsPressed && pad.LeftTriggerButton.IsPressed && pad.RightTriggerButton.IsPressed) || Actions.Pause.WasPressed)
                        {
                            Actions.Pause.ClearAllWasPressedState();

                            if (!Time.Paused)
                            {
                                Time.Paused = true;
                                HelpOverlay.Push("PauseGame");
                                GamePadInput.GetGamePad0().IgnoreLeftStickUntilZero();
                                GamePadInput.GetGamePad0().IgnoreRightStickUntilZero();
                            }
                        }
                    }
                }

                // Force the the HelpOverlay to be correct.
                if (!Time.Paused || VictoryOverlay.Active)
                {
                    if (InGame.inGame.PreGame != null && InGame.inGame.PreGame.Active)
                    {
                        if (HelpOverlay.Depth() != 1 || HelpOverlay.Peek() != "RunSimulationPreGame")
                        {
                            HelpOverlay.Clear();
                            HelpOverlay.Push("RunSimulationPreGame");
                        }
                    }
                    else
                    {
                        if (HelpOverlay.Depth() != 1 || HelpOverlay.Peek() != "RunSimulation")
                        {
                            HelpOverlay.Clear();
                            HelpOverlay.Push("RunSimulation");
                        }
                    }
                }
                else
                {
                    // We're paused.
                    if (HelpOverlay.Depth() != 2 || HelpOverlay.Peek(1) != "RunSimulation")
                    {
                        HelpOverlay.Clear();
                        HelpOverlay.Push("RunSimulation");
                        HelpOverlay.Push("PauseGame");
                    }
                }

                // When in run mode, allow the user to click on the "Press [esc] to edit" text as if it was a button.
                if (MouseInput.Left.WasPressed)
                {
                    Point mousePos = MouseInput.Position;
                    if (HelpOverlay.MouseHitBottomText(mousePos))
                    {
                        // Switch to edit mode.
                        InGame.inGame.CurrentUpdateMode = UpdateMode.EditObject;
                    }
                }
                TapGestureRecognizer tapGesture = TouchGestureManager.Get().TapGesture;
                if (tapGesture.WasTapped())
                {
                    // JW - Until we have proper Touch help overlays, we are still using the mouse/keyboard
                    // overlays. The mouse handling code for these depends on being able to 'absorb' pressed
                    // info to hide it from later callers. Our touch stuff doesn't (and really shouldn't)
                    // do this. So, we handle cases here based on what type of overlay is being displayed.
                    if (HelpOverlay.Peek() == "RunSimulationPreGame")
                    {
                        // Tap during instructions: just begin game.
                        InGame.inGame.PreGame.Active = false;
                    }

                    // Also test if running sim for tapping on "tap to edit" at bottom.
                    if (HelpOverlay.Peek() == "RunSimulation")
                    {
                        Point pos = new Point((int)tapGesture.Position.X, (int)tapGesture.Position.Y);
                        if (HelpOverlay.MouseHitBottomText(pos))
                        {
                            // Switch to edit mode.
                            InGame.inGame.CurrentUpdateMode = UpdateMode.EditObject;
                        }
                    }
                }
            }   // end of RunSimUpdateObj Update()
Ejemplo n.º 30
0
            public override void Update()
            {
                // Check for input focus.
                if (commandMap == CommandStack.Peek())
                {
                    GamePadInput pad = GamePadInput.GetGamePad0();

                    if (Actions.Select.WasPressed)
                    {
                        Actions.Select.ClearAllWasPressedState(3);

                        parent.MoveReflex(null, null);
                    }

                    /*
                     * // Replaced w/ auto blank line feature.
                     * if(pad.ButtonY.WasPressed)
                     * {
                     *  parent.InsertReflex(null, null);
                     *
                     *  GamePadInput.ClearAllWasPressedState(3);
                     * }
                     */

                    // Cut.
                    if (Actions.Cut.WasPressed)
                    {
                        Actions.Cut.ClearAllWasPressedState(3);

                        reflexBlock.Init(this.parent.LineNumber - 1);
                        reflexBlock.Cut();
                    }

                    // Copy
                    if (Actions.X.WasPressed)
                    {
                        Actions.X.ClearAllWasPressedState();

                        // Update the cut/paste buffer with the current ReflexData.
                        reflexBlock.Init(this.parent.LineNumber - 1);
                        reflexBlock.Copy();

                        HelpOverlay.Pop();
                        if (ReflexPanel.CutPasteBuffer == null)
                        {
                            HelpOverlay.Push("RowHandleEmptyPasteBuffer");
                        }
                        else
                        {
                            HelpOverlay.Push("RowHandleFullPasteBuffer");
                        }
                    }

                    // Paste
                    if (Actions.Paste.WasPressed)
                    {
                        Actions.Paste.ClearAllWasPressedState(3);

                        reflexBlock.Init(this.parent.LineNumber - 1);
                        reflexBlock.Paste();
                    }
                }   // end of if we have input focus.

                // Ensure the reflex has the correct indent.
                //ReflexPanel curPanel = (ReflexPanel)parent.parent;
                //curPanel.AnimatePanelIndent(false);
            }   // end of Update()