} // end of HandleMouseInput() public override void Update(PerspectiveUICamera camera) { if (Active) { if (Hidden) { if (HelpOverlay.Peek() == (UseAltOverlay ? altHelpOverlay : helpOverlay)) { HelpOverlay.Pop(); } } else { if (Actions.MaterialFabric.WasPressed) { Actions.MaterialFabric.ClearAllWasPressedState(); FabricMode = true; RefreshPositions(); } if (Actions.MaterialCubic.WasPressed) { Actions.MaterialCubic.ClearAllWasPressedState(); FabricMode = false; RefreshPositions(); } HelpOverlay.ReplaceTop(UseAltOverlay ? altHelpOverlay : helpOverlay); } } base.Update(camera); }
protected void SetOverlay(string overlay) { if (HelpOverlay.Peek() != overlay) { HelpOverlay.Pop(); HelpOverlay.Push(overlay); } }
} // end of PreGameBase Activate() protected virtual void Deactivate() { CommandStack.Pop(commandMap); if (HelpOverlay.Peek() == "PreGame") { HelpOverlay.Pop(); } // If the pre-game has messed with the clock, restore it. Time.ClockRatio = 1.0f; } // end of PreGameBase Deactivate()
} // end of PreGameRacingWithDesc Activate() protected override void Deactivate() { // Restart the game clock. //Time.Paused = false; Time.ClockRatio = 1.0f; texture1 = null; texture2 = null; texture3 = null; // We need to be sure this really needs popping. It may be off already. if (HelpOverlay.Peek() == @"PreGameDescription") { HelpOverlay.Pop(); } base.Deactivate(); } // end of PreGameRacingWithDesc Deactivate()
} // 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()
} // end of PreRender() public static void Render() { if (!active || backdrop == null || rt == null) { return; } ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); Vector2 size = new Vector2(rt.Width, rt.Height); backdropBox.Set(Vector2.Zero, size); // Tutorial info needs to go at top of "real" screen. InGame.RestoreViewportToFull(); quad.Render(rt, Vector2.Zero, size, "TexturedNoAlpha"); if (modalDisplay.Active) { quad.Render(dropShadow, Vector2.Zero, BokuGame.ScreenSize, "TexturedRegularAlpha"); } modalDisplay.Render(); // Display debug spew if active. if (DebugMode && active) { Vector2 pos = new Vector2(20, 400); SpriteBatch batch = UI2D.Shared.SpriteBatch; Color color = Color.Yellow; TextBlob blob = new TextBlob(UI2D.Shared.GetGameFont20, "", 1000); string text = "Tutorial Manager\n"; try { text += " current game mode : " + curGameMode.ToString() + "\n"; text += " current help overlay : " + HelpOverlay.Peek() + "\n"; text += " current step\n"; text += " display mode : " + curStep.DisplayMode.ToString() + "\n"; text += " target mode : " + curStep.TargetMode.ToString() + "\n"; if (curStep.CompletionTest != null) { text += " completion test : " + curStep.CompletionTest.Name.ToString() + "\n"; text += " args : " + curStep.CompletionTest.Args.ToString() + "\n"; } text += " current input mode : " + GamePadInput.ActiveMode.ToString() + "\n"; if (curCrumb != null) { text += "current crumb id " + curCrumb.id + "\n"; } } catch { } blob.RawText = text; blob.RenderWithButtons(pos, Color.Black, outlineColor: Color.White, outlineWidth: 1.2f); } } // end of Render()
} // end of OnExitTutorial() public static void PreRender() { // Decide which font to use based on screen width. UI2D.Shared.GetFont prevFont = font; font = BokuGame.ScreenSize.X > 1280 ? UI2D.Shared.GetGameFont24Bold : UI2D.Shared.GetGameFont18Bold; // Did the font or window size change? If so, reallocate the rendertarget. if (font != prevFont || rt == null || BokuGame.ScreenSize.X > rt.Width) { InGame.RelRT("TutorialRT", rt); BokuGame.Release(ref rt); CreateRenderTarget(); } if (backdrop == null || rt == null) { return; } ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); InGame.SetRenderTarget(rt); // Clear and add highlight. quad.Render(backdrop, Vector2.Zero, new Vector2(rt.Width, rt.Height), "TexturedRegularAlpha"); if (Active) { int indent = 10; // Lazy allocation. if (titleBlob == null) { titleBlob = new TextBlob(font, "test", (int)(rt.Width - 2.0f * indent)); //titleBlob.ProgrammingTileBackdrop = true; } if (instructionBlob == null) { instructionBlob = new TextBlob(font, "test", (int)(rt.Width - 2.0f * indent)); //instructionBlob.ProgrammingTileBackdrop = true; } // Font may have changed, keep the blobs up to date. titleBlob.Font = font; instructionBlob.Font = font; // Raw strings to put into blobs. string titleStr = null; string instructionStr = null; // We only care about the non-modal text if there's no modal display. // TODO We could think about displaying this under the modal display but we'd have to // add a drop shadow first to avoid cluttering things up. if (!modalDisplay.Active) { // We should only display text when the tutorial mode is fully open. bool display = targetPositionY > 1 && BokuGame.ScreenPosition.Y > targetPositionY - 2.0f; if (display) { if (curCrumb != null || targetModeReached) { // First line should be the goal of this section of the tutorial. High level. titleStr = curStep.GoalText; // Second line is either from the crumb telling us where to go OR from the step telling us what to do now that we're here. if (curCrumb == null) { if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse) { instructionStr = curStep.MouseText; } else if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch) { instructionStr = curStep.TouchText; } else // gamepad { instructionStr = curStep.GamepadText; } } else { if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse) { instructionStr = curCrumb.MouseText; } else if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch) { instructionStr = curCrumb.TouchText; } else // gamepad { instructionStr = curCrumb.GamepadText; } } #if DEBUG // Add in some debug info. //instructionStr += "\nCurMode = " + curGameMode.ToString() + " curTargetMode = " + curStep.TargetMode.ToString(); #endif } else { if (DebugMode) { // We've got no crumb. Need to add one! instructionStr = "Missing Crumb!"; // Add in some debug info. instructionStr += "\nCurMode = " + curGameMode.ToString() + " HelpOverlay = " + HelpOverlay.Peek() + "\nUpdateMode = " + InGame.inGame.CurrentUpdateMode.ToString(); if (curStep != null) { instructionStr += "\nTargetMode = " + curStep.TargetMode; } } } // Render text blob. // TODO Center text vertically and if fewer lines, increase the spacing a bit. titleBlob.RawText = titleStr; instructionBlob.RawText = instructionStr; //Color titleColor = new Color(50, 255, 50); // Same green as the hover text color we user elsewhere. Color titleColor = new Color(20, 20, 20); // Not quite black. //Color titleColor = new Color(250, 190, 50); // Amber. Color shadowColor = new Color(0, 0, 0, 40); Color lightGrey = new Color(200, 200, 200); Color darkGrey = new Color(100, 100, 100); Color textColor = darkGrey; if (DebugMode && curGameMode == GameMode.Unknown) { textColor = Color.Red; } titleBlob.RenderWithButtons(new Vector2(indent, 0), titleColor, shadowColor, new Vector2(0, 2), maxLines: 4); // Vertically center the instruction text. int yOffset = 0; if (instructionBlob.NumLines == 1) { yOffset = instructionBlob.TotalSpacing; } else if (instructionBlob.NumLines == 2) { yOffset = (int)(instructionBlob.TotalSpacing / 2.0f); } instructionBlob.RenderWithButtons(new Vector2(indent, titleBlob.TotalSpacing + yOffset - 2), textColor, shadowColor, new Vector2(0, 2), maxLines: 4); } // end if display true } // end if not modal active } // end if tutorial mode active InGame.RestoreRenderTarget(); } // end of PreRender()
} // end of TweakObjectUpdateObj Update() /// <summary> /// Check if the cursor is close enough to anything to have that /// object be considered "in focus". If so, snap toward it. /// </summary> protected void CheckForEditFocusObject() { // Find the nearest GameThing. editFocusObject = null; Vector3 lookAt = parent.cursor3D.Position; float distance = float.MaxValue; for (int i = 0; i < parent.gameThingList.Count; i++) { GameThing thing = (GameThing)parent.gameThingList[i]; Vector3 thingPos = thing.Movement.Position; Vector3 delta = thingPos - lookAt; delta.Z = 0.0f; // Only consider horizontal distances. float dist = delta.Length(); if (dist < distance) { distance = dist; editFocusObject = thing; } } float secs = Time.WallClockFrameSeconds; // See if we need to snap. if (snapObject == null) { if (distance < snapCaptureRadius) { float z = lookAt.Z; GameThing thing = editFocusObject as GameThing; if (thing != null) { Vector3 thingPos = thing.Movement.Position; lookAt = Vector3.Lerp(lookAt, thingPos, snapLerp * secs * 30.0f); } lookAt.Z = z; parent.cursor3D.Position = lookAt; shared.CursorPosition = parent.cursor3D.Position; snapObject = editFocusObject; } } else { // See if we've moved far enough away from the // previous snap to reset. GameThing thing = snapObject as GameThing; Vector3 delta = new Vector3(); if (thing != null) { Vector3 thingPos = thing.Movement.Position; delta = thingPos - lookAt; } float dist = delta.Length(); if (dist > snapReleaseRadius) { snapObject = null; } else { float z = lookAt.Z; GameThing editThing = editFocusObject as GameThing; if (editThing != null) { Vector3 editThingPos = editThing.Movement.Position; lookAt = Vector3.Lerp(lookAt, editThingPos, snapLerp * secs * 30.0f); } lookAt.Z = z; parent.cursor3D.Position = lookAt; shared.CursorPosition = parent.cursor3D.Position; } } // We've now found the nearest object. If close enough, keep it // and turn the cursor blue to indicate it is in focus. If not // close enough set the cursor to white and null the focus object. const float nearThreshold = 0.5f; if (distance > nearThreshold) { editFocusObject = null; parent.cursor3D.DiffuseColor = Color.White.ToVector4(); HelpOverlay.Pop(); HelpOverlay.Push("ObjectTweak"); } else { parent.cursor3D.DiffuseColor = Color.Blue.ToVector4(); if (editFocusObject as GameActor != null) { if (String.Compare(HelpOverlay.Peek(), "ObjectTweakFocusProgrammable") != 0) { HelpOverlay.Pop(); HelpOverlay.Push("ObjectTweakFocusProgrammable"); } } else { if (String.Compare(HelpOverlay.Peek(), "ObjectTweakFocus") != 0) { HelpOverlay.Pop(); HelpOverlay.Push("ObjectTweakFocus"); } } } } // end of CheckForEditFocusObject()
/// <summary> /// Sets curGameMode to the current mode, if it can be figured out. /// If not, sets it to GameMode.Unknown. /// </summary> private static void SetGameMode() { // Note, this is going to be a little ad-hoc... // TODO What about dialogs on top of these modes? if (BokuGame.bokuGame.mainMenu.Active) { curGameMode = BokuGame.bokuGame.mainMenu.OptionsActive ? GameMode.OptionsMenu : GameMode.MainMenu; return; } if (BokuGame.bokuGame.helpScreens.Active) { curGameMode = GameMode.HelpScreens; return; } if (BokuGame.bokuGame.miniHub.Active) { curGameMode = GameMode.HomeMenu; return; } if (BokuGame.bokuGame.loadLevelMenu.Active) { curGameMode = GameMode.LoadLevelMenu; return; } if (BokuGame.bokuGame.community.Active) { curGameMode = GameMode.CommunityMenu; } if (BokuGame.bokuGame.sharingScreen.Active) { curGameMode = GameMode.SharingSession; return; } if (InGame.inGame.Editor.Active) { curGameMode = InGame.inGame.shared.programmingHelpCard.Active ? GameMode.ProgrammingHelp : GameMode.Programming; return; } if (BokuGame.bokuGame.inGame.State != InGame.States.Inactive) { // RunSim mode? if (BokuGame.bokuGame.inGame.CurrentUpdateMode == InGame.UpdateMode.RunSim) { curGameMode = GameMode.InGame; return; } if (BokuGame.bokuGame.inGame.CurrentUpdateMode == InGame.UpdateMode.EditObjectParameters) { curGameMode = GameMode.ObjectTweak; return; } // If the AddItemMenu is active. if (InGame.inGame.shared.UIShim.Active) { if (InGame.inGame.shared.addItemHelpCard.Active) { curGameMode = GameMode.AddItemHelp; return; } curGameMode = GameMode.AddItem; return; } // // Mouse Edit // if (BokuGame.bokuGame.inGame.CurrentUpdateMode == InGame.UpdateMode.MouseEdit) { // If we're just hovering, leave the curGameMode alone unless it's unknown. if (InGame.inGame.mouseEditUpdateObj.ToolBar.Hovering && curGameMode != GameMode.Unknown) { return; } // If any of the pickers are active: if (InGame.inGame.mouseEditUpdateObj.PickersActive) { if (InGame.inGame.mouseEditUpdateObj.ToolBox.BrushPicker.Active && !InGame.inGame.mouseEditUpdateObj.ToolBox.BrushPicker.Hidden) { curGameMode = GameMode.BrushPicker; return; } if (InGame.inGame.mouseEditUpdateObj.ToolBox.MaterialPicker.Active && !InGame.inGame.mouseEditUpdateObj.ToolBox.MaterialPicker.Hidden) { curGameMode = GameMode.MaterialPicker; return; } if (InGame.inGame.mouseEditUpdateObj.ToolBox.WaterPicker.Active && !InGame.inGame.mouseEditUpdateObj.ToolBox.WaterPicker.Hidden) { curGameMode = GameMode.WaterPicker; return; } } } if (BokuGame.bokuGame.inGame.CurrentUpdateMode == InGame.UpdateMode.TouchEdit) { // If we're just hovering, leave the curGameMode alone unless it's unknown. if (InGame.inGame.touchEditUpdateObj.ToolBar.Hovering && curGameMode != GameMode.Unknown) { return; } // If any of the pickers are active: if (InGame.inGame.touchEditUpdateObj.PickersActive) { if (InGame.inGame.touchEditUpdateObj.ToolBox.BrushPicker.Active && !InGame.inGame.touchEditUpdateObj.ToolBox.BrushPicker.Hidden) { curGameMode = GameMode.BrushPicker; return; } if (InGame.inGame.touchEditUpdateObj.ToolBox.MaterialPicker.Active && !InGame.inGame.touchEditUpdateObj.ToolBox.MaterialPicker.Hidden) { curGameMode = GameMode.MaterialPicker; return; } if (InGame.inGame.touchEditUpdateObj.ToolBox.WaterPicker.Active && !InGame.inGame.touchEditUpdateObj.ToolBox.WaterPicker.Hidden) { curGameMode = GameMode.WaterPicker; return; } } } if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse) { switch (HelpOverlay.Peek()) { case "MouseEditHome": curGameMode = GameMode.MouseHome; break; case "MouseEditPlay": curGameMode = GameMode.MousePlay; break; case "MouseEditCameraMove": curGameMode = GameMode.MouseCameraMove; break; case "MouseEditEditObject": curGameMode = GameMode.MouseEditObject; break; case "MouseEditEditObjectFocus": case "MouseEditEditObjectFocusTree": curGameMode = GameMode.MouseEditObjectFocus; break; case "MouseEditMenu": curGameMode = GameMode.MouseEditMenu; break; case "MouseEditPaths": case "MouseEditPathsFocusNode": case "MouseEditPathsFocusEdge": case "MouseEditPathsFocusPath": case "MouseEditPathsDeleteNode": case "MouseEditPathsDeletePath": curGameMode = GameMode.MousePaths; break; case "MouseEditTerrainPaint": case "MouseEditTerrainDelete": case "MouseEditTerrainPaintSmooth": case "MouseEditTerrainPaintCubic": curGameMode = GameMode.MouseTerrainPaint; break; case "MouseEditTerrainRaiseLower": case "MouseEditTerrainLowering": case "MouseEditTerrainRaising": curGameMode = GameMode.MouseTerrainUpDown; break; case "MouseEditTerrainSmoothLevel": case "MouseEditTerrainSmoothLevel_ToggleSmooth": case "MouseEditTerrainSmoothLevel_ToggleFlatten": curGameMode = GameMode.MouseTerrainSmoothLevel; break; case "MouseEditTerrainSpikeyHilly": case "MouseEditTerrainSpikeyHilly_ToggleHilly": case "MouseEditTerrainSpikeyHilly_ToggleSpikey": case "MouseEditTerrainSpikeyHilly_ToggleFlatten": curGameMode = GameMode.MouseTerrainSpikeyHilly; break; case "MouseEditWaterRaiseLower": case "MouseEditWaterRaiseLower_ToggleRaise": case "MouseEditWaterRaiseLower_ToggleLower": curGameMode = GameMode.MouseWater; break; case "MouseEditDeleteObjects": case "MouseEditDeleteObjects_Deleting": curGameMode = GameMode.MouseDeleteObjects; break; case "MouseEditWorldTweak": curGameMode = GameMode.MouseWorldSettings; break; case null: // don't change game mode. break; default: // Could be in WorldSettings... if (HelpOverlay.Peek(1) == "EditWorldParameters" || HelpOverlay.Peek(2) == "EditWorldParameters") { curGameMode = GameMode.MouseWorldSettings; } else { //Debug.Assert(false, "Must be missing a mode..."); curGameMode = GameMode.Unknown; } break; } return; } if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch) { switch (HelpOverlay.Peek()) { case "MouseEditHome": curGameMode = GameMode.TouchHome; break; case "MouseEditPlay": curGameMode = GameMode.TouchPlay; break; case "MouseEditCameraMove": curGameMode = GameMode.TouchCameraMove; break; case "MouseEditEditObject": curGameMode = GameMode.TouchEditObject; break; case "MouseEditEditObjectFocus": case "MouseEditEditObjectFocusTree": curGameMode = GameMode.TouchEditObjectFocus; break; case "MouseEditMenu": curGameMode = GameMode.TouchEditMenu; break; case "MouseEditPaths": case "MouseEditPathsFocusNode": case "MouseEditPathsFocusEdge": case "MouseEditPathsFocusPath": case "MouseEditPathsDeleteNode": case "MouseEditPathsDeletePath": curGameMode = GameMode.TouchPaths; break; case "MouseEditTerrainPaint": case "MouseEditTerrainDelete": case "MouseEditTerrainPaintSmooth": case "MouseEditTerrainPaintCubic": curGameMode = GameMode.TouchTerrainPaint; break; case "MouseEditTerrainRaiseLower": case "MouseEditTerrainLowering": case "MouseEditTerrainRaising": curGameMode = GameMode.TouchTerrainUpDown; break; case "MouseEditTerrainSmoothLevel": case "MouseEditTerrainSmoothLevel_ToggleSmooth": case "MouseEditTerrainSmoothLevel_ToggleFlatten": curGameMode = GameMode.TouchTerrainSmoothLevel; break; case "MouseEditTerrainSpikeyHilly": case "MouseEditTerrainSpikeyHilly_ToggleHilly": case "MouseEditTerrainSpikeyHilly_ToggleSpikey": case "MouseEditTerrainSpikeyHilly_ToggleFlatten": curGameMode = GameMode.TouchTerrainSpikeyHilly; break; case "MouseEditWaterRaiseLower": case "MouseEditWaterRaiseLower_ToggleRaise": case "MouseEditWaterRaiseLower_ToggleLower": curGameMode = GameMode.TouchWater; break; case "MouseEditDeleteObjects": case "MouseEditDeleteObjects_Deleting": curGameMode = GameMode.TouchDeleteObjects; break; case "MouseEditWorldTweak": curGameMode = GameMode.TouchWorldSettings; break; case null: // don't change game mode. break; default: // Could be in WorldSettings... if (HelpOverlay.Peek(1) == "EditWorldParameters" || HelpOverlay.Peek(2) == "EditWorldParameters") { curGameMode = GameMode.TouchWorldSettings; } else { //Debug.Assert(false, "Must be missing a mode..."); curGameMode = GameMode.Unknown; } break; } return; } // // Gamepad Edit // // In ToolMenu. if (InGame.inGame.CurrentUpdateMode == InGame.UpdateMode.ToolMenu) { switch (HelpOverlay.Peek()) { case "ToolMenuRunSim": curGameMode = GameMode.ToolMenuRunSim; break; case "ToolMenuHomeMenu": curGameMode = GameMode.ToolMenuHomeMenu; break; case "ToolMenuObjectEdit": curGameMode = GameMode.ToolMenuEditObject; break; case "ToolMenuTerrainSmoothLevel": curGameMode = GameMode.ToolMenuTerrainSmoothLevel; break; case "ToolMenuTerrainMaterial": curGameMode = GameMode.ToolMenuTerrainPaint; break; case "ToolMenuTerrainSpikeyHilly": curGameMode = GameMode.ToolMenuTerrainSpikeyHilly; break; case "ToolMenuTerrainUpDown": curGameMode = GameMode.ToolMenuTerrainUpDown; break; case "ToolMenuTerrainWater": curGameMode = GameMode.ToolMenuWater; break; case "ToolMenuDeleteObjects": curGameMode = GameMode.ToolMenuDeleteObjects; break; case "ToolMenuWorldSettings": curGameMode = GameMode.ToolMenuWorldSettings; break; case null: // don't change game mode. break; default: //Debug.Assert(false, "Must be missing a mode..."); curGameMode = GameMode.Unknown; break; } return; } // Not in the toolmenu so one of the tools must be active. switch (InGame.inGame.CurrentUpdateMode) { case InGame.UpdateMode.EditObject: curGameMode = InGame.inGame.ActiveActor == null ? GameMode.GamepadEditObject : GameMode.GamepadEditObjectFocus; return; case InGame.UpdateMode.TerrainFlatten: curGameMode = GameMode.GamepadTerrainSmoothLevel; if (!InGame.inGame.shared.ToolBox.BrushPicker.Hidden) { curGameMode = GameMode.BrushPicker; } return; case InGame.UpdateMode.TerrainMaterial: curGameMode = GameMode.GamepadTerrainPaint; if (!InGame.inGame.shared.ToolBox.BrushPicker.Hidden) { curGameMode = GameMode.BrushPicker; } if (!InGame.inGame.shared.ToolBox.MaterialPicker.Hidden) { curGameMode = GameMode.MaterialPicker; } return; case InGame.UpdateMode.TerrainRoughHill: curGameMode = GameMode.GamepadTerrainSpikeyHilly; if (!InGame.inGame.shared.ToolBox.BrushPicker.Hidden) { curGameMode = GameMode.BrushPicker; } return; case InGame.UpdateMode.TerrainUpDown: curGameMode = GameMode.GamepadTerrainUpDown; if (!InGame.inGame.shared.ToolBox.BrushPicker.Hidden) { curGameMode = GameMode.BrushPicker; } return; case InGame.UpdateMode.TerrainWater: curGameMode = GameMode.GamepadWater; if (!InGame.inGame.shared.ToolBox.WaterPicker.Hidden) { curGameMode = GameMode.WaterPicker; } return; case InGame.UpdateMode.DeleteObjects: curGameMode = GameMode.GamepadDeleteObjects; if (!InGame.inGame.shared.ToolBox.BrushPicker.Hidden) { curGameMode = GameMode.BrushPicker; } return; case InGame.UpdateMode.EditWorldParameters: // We need to check input mode in case user swapped input devices while active. curGameMode = GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad ? GameMode.GamepadWorldSettings : GameMode.MouseWorldSettings; return; } } // TODO Put an assert here to catch any we've missed. curGameMode = GameMode.Unknown; } // end of SetGameMode()