private void AssignClickEventsAndStatusToButtons() { var nextLevel = PlayerDataManager.LastLevelNumberCompleted + 1; var results = PlayerDataManager.LevelResults; foreach (var element in MapScreenGumInstance.ContainedElements) { if (element is LevelButtonRuntime levelButton) { if (results.Any(lr => lr.LevelName + "Level" == levelButton.LevelName)) { //TODO: Show level as completed levelButton.Visible = true; levelButton.Disable(); } else if (levelButton.LevelAsNumber == nextLevel) { levelButton.Click += LoadLevel; levelButton.Visible = true; } else { levelButton.Visible = false; levelButton.Disable(); } } if (element is ButtonFrameRuntime optionsButton) { optionsButton.Click += ShowMenu; } if (element is MenuWindowRuntime menuWindow) { menuWindow.AssignEventToCloseButton(window => MapScreenGumInstance.HideMenuAnimation.Play(this)); menuWindow.AssignEventToButton1(window => { ConfirmationWindowInstance.Confirm("Exit and return to desktop?", () => { LocalLogManager.AddLine("Main Menu - Exiting game"); PlayerDataManager.SaveData(); FlatRedBallServices.Game.Exit(); }); }); //menuWindow.ButtonType3State = ButtonFrameRuntime.ButtonType.Disabled; menuWindow.AssignEventToButton3(window => { LocalLogManager.AddLine("Main Menu - Show chat history"); ChatHistoryInstance.PopulateWithAllChatHistory(); ChatHistoryInstance.Visible = true; }); menuWindow.AssignEventToButton4(window => OkMessageInstance.ShowMessage(Messages["Intro"].MessageText)); } } ChatHistoryInstance.CloseButtonClick += (sender, args) => { ChatHistoryInstance.Children.Clear(); ChatHistoryInstance.Visible = false; }; }
private void ShowIntroMessageIfNecessary() { if (!PlayerDataManager.PlayerHasSeenIntro) { LocalLogManager.AddLine("Main Menu - Show Intro Message"); OkMessageInstance.ShowMessage(Messages["Intro"].MessageText); PlayerDataManager.MarkSeenIntro(); PlayerDataManager.SaveData(); } else if (PlayerDataManager.PlayerHasBeatGame && PlayerDataManager.LevelResults.Count == 0) { LocalLogManager.AddLine("Main Menu - Show Welcome Back Message"); OkMessageInstance.ShowMessage(Messages["WelcomeBack"].MessageText); } }