// c'tor public Shared(MiniHub parent) { // Create text elements. // Start with a blob of common parameters. UIGridElement.ParamBlob blob = new UIGridElement.ParamBlob(); blob.width = 5.0f; blob.height = 0.75f; blob.edgeSize = 0.06f; blob.Font = UI2D.Shared.GetGameFont30Bold; blob.textColor = Color.White; blob.dropShadowColor = Color.Black; blob.useDropShadow = true; blob.invertDropShadow = false; blob.unselectedColor = new Color(new Vector3(4, 100, 90) / 255.0f); blob.selectedColor = new Color(new Vector3(5, 180, 160) / 255.0f); blob.normalMapName = @"Slant0Smoothed5NormalMap"; blob.justify = UIGrid2DTextElement.Justification.Center; menu = new ModularMenu(blob, Strings.Localize("miniHub.minihub")); menu.OnChange = parent.OnChange; menu.OnCancel = parent.OnCancel; menu.OnSelect = parent.OnSelect; menu.WorldMatrix = Matrix.CreateScale(1.4f); //menu.AcceptStartForCancel = true; menu.UseRtCoords = false; menu.HelpOverlay = "MiniHub"; BuildMenu(); }
public void OnCancel(ModularMenu menu) { // Prevent the button pressed from leaking into runtime. GamePadInput.IgnoreUntilReleased(Buttons.B); // Never mind. Just deactivate the mini hub and reactivate InGame. Deactivate(); InGame.inGame.Activate(); }
public void OnCancel(ModularMenu menu) { // Nothing to see here, move along. Just be sure the menu remains active. menu.Active = true; // Make "Quit" the selected menu item. int quitIdx = menu.Index(Strings.Localize("mainMenu.exit")); if (quitIdx >= 0) { menu.CurIndex = quitIdx; } } // end of MainMenu OnCancel()
} // end of MiniHub OnSelect() public void OnChange(ModularMenu menu) { // Nothing to do here... }
} // 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()
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
} // end of MainMenu c'tor #if NETFX_CORE public async void OnSelect(ModularMenu menu)
// c'tor public Shared(MainMenu parent) { // Set up the options menu. optionsMenu = new OptionsMenu(); liveFeed = new LiveFeedDisplay(); if (BokuGame.bMarsMode) { boku = ActorManager.GetActor("RoverGreeter").CreateNewInstance() as BokuGreeter; } else { boku = ActorManager.GetActor("BokuGreeter").CreateNewInstance() as BokuGreeter; } boku.SetColor(Classification.Colors.White); bokuCamera.NearClip = 0.1f; bokuCamera.FarClip = 20.0f; // These are the values for the model when its translation off the ground has been thrown away (and added back via constant) bokuCamera.From = 1.3f * new Vector3(1.5f, 0.3f, 0.5f); bokuCamera.At = new Vector3(0.0f, -0.5f, 0.0f); // These are the values for a "correct" model - that is raised off the ground in Max and whose translation is intact // bokuCamera.From = new Vector3(1.5f, 0.3f, 1.4f); // bokuCamera.At = new Vector3(0.0f, -0.5f, 0.7f); // Move camera to look at menu from an angle. //camera.From = 0.9f * camera.From; camera.At = new Vector3(-0.6f, 0, 0); Matrix foo = Matrix.CreateRotationY(-0.3f) * Matrix.CreateTranslation(new Vector3(1.0f, 0.0f, -2.0f)); camera.At = Vector3.Transform(camera.At, foo); camera.From = Vector3.Transform(camera.From, foo); // We'll be using a 1280x720 rendertarget for all rendering. camera.Resolution = new Point(1280, 720); bokuCamera.Resolution = new Point(1280, 720); timer = new Boku.Base.GameTimer(Boku.Base.GameTimer.ClockType.WallClock, 3.1415927); timer.TimerElapsed += ChangeExpression; // Create text elements. // Start with a blob of common parameters. UIGridElement.ParamBlob blob = new UIGridElement.ParamBlob(); blob.width = 3.4f; blob.height = 0.5f; blob.edgeSize = 0.06f; blob.Font = UI2D.Shared.GetGameFont24Bold; blob.textColor = Color.White; blob.dropShadowColor = Color.Black; blob.useDropShadow = true; blob.invertDropShadow = true; blob.unselectedColor = new Color(new Vector3(4, 100, 90) / 255.0f); blob.selectedColor = new Color(new Vector3(5, 180, 160) / 255.0f); blob.normalMapName = @"Slant0Smoothed5NormalMap"; blob.justify = UIGrid2DTextElement.Justification.Left; menu = new ModularMenu(blob, null /*Strings.Localize("mainMenu.mainMenu")*/); menu.OnSelect = parent.OnSelect; menu.OnCancel = parent.OnCancel; menu.UseRtCoords = true; menu.AddText(Strings.Localize("mainMenu.new")); menu.AddText(Strings.Localize("mainMenu.play")); #if NETFX_CORE menu.AddText(Strings.Localize("mainMenu.import")); #else if (WinStoreHelpers.RunningAsUWP) { menu.AddText(Strings.Localize("mainMenu.import")); } #endif menu.AddText(Strings.Localize("mainMenu.community")); menu.AddText(Strings.Localize("mainMenu.options")); menu.AddText(Strings.Localize("mainMenu.help")); #if !NETFX_CORE // Once you run an app in Win8, you are never allowed to kill it. // Only the system can kill it. menu.AddText(Strings.Localize("mainMenu.exit")); #endif // And then remove what we don't want. if (!Program2.SiteOptions.CommunityEnabled) { menu.DeleteText(Strings.Localize("mainMenu.community")); } menu.WorldMatrix = Matrix.CreateScale(0.9f, 1.0f, 1.0f); string signOutStr = Strings.Localize("textDialog.signOut"); signOutButton = new Button(signOutStr, Color.White, null, UI2D.Shared.GetGameFont20); //Because this button has no texture and we can't set the width of the texture passed in explicitly. Just use the fixed size based on text size. UI2D.Shared.GetFont Font = UI2D.Shared.GetGameFont20; Vector2 size = (null != Font) ? Font().MeasureString(signOutStr) : new Vector2(60.0f, 20.0f); signOutButton.FixedSize = size; signOutButton.UseFixedSize = true; textBlob = new TextBlob(UI2D.Shared.GetGameFont24, "", 340); } // end of Shared c'tor