Example #1
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id != EventId.ScreenLoaded)
     {
         if (id == EventId.NativeAlertBoxDismissed)
         {
             Service.EventManager.UnregisterObserver(this, EventId.NativeAlertBoxDismissed);
             if ((bool)cookie)
             {
                 Application.Quit();
             }
         }
     }
     else
     {
         ClosableScreen closableScreen = cookie as ClosableScreen;
         if (closableScreen != null)
         {
             closableScreen.CloseButton.Visible = false;
             for (int i = 0; i < closableScreen.BackButtons.Count; i++)
             {
                 closableScreen.BackButtons[i].Visible = false;
             }
         }
     }
     return(EatResponse.NotEaten);
 }
Example #2
0
        private void HandleBackButton()
        {
            IState currentState = Service.GameStateMachine.CurrentState;

            if (currentState is IntroCameraState)
            {
                IntroCameraAnimation intro = Service.UXController.Intro;
                if (intro != null)
                {
                    intro.FinishUp(true);
                }
                return;
            }
            for (int i = this.backButtonHandlers.Count - 1; i >= 0; i--)
            {
                if (this.backButtonHandlers[i].HandleBackButtonPress())
                {
                    return;
                }
            }
            UICamera.selectedObject = null;
            UICamera.hoveredObject  = null;
            if (TouchScreenKeyboard.visible)
            {
                return;
            }
            ScreenController screenController = null;

            if (Service.ScreenController != null)
            {
                screenController = Service.ScreenController;
                AlertScreen highestLevelScreen = screenController.GetHighestLevelScreen <AlertScreen>();
                if (highestLevelScreen != null && highestLevelScreen.IsAlwaysOnTop)
                {
                    this.HandleScreenBack(highestLevelScreen);
                    return;
                }
            }
            if (Service.HoloController != null)
            {
                HoloController holoController = Service.HoloController;
                if (holoController.HasAnyCharacter())
                {
                    Service.EventManager.SendEvent(EventId.StoryNextButtonClicked, null);
                    return;
                }
            }
            if (screenController != null)
            {
                ScreenBase     highestLevelScreen2 = screenController.GetHighestLevelScreen <ScreenBase>();
                ClosableScreen highestLevelScreen3 = screenController.GetHighestLevelScreen <ClosableScreen>();
                if (Service.CurrentPlayer.CampaignProgress.FueInProgress || Service.UserInputInhibitor.IsDenying())
                {
                    if (highestLevelScreen2 != null && highestLevelScreen2.AllowFUEBackButton && this.HandleScreenBack(highestLevelScreen2))
                    {
                        return;
                    }
                    this.TryQuit();
                    return;
                }
                else
                {
                    if (highestLevelScreen2 != null && this.HandleScreenBack(highestLevelScreen2))
                    {
                        return;
                    }
                    if (highestLevelScreen3 != null && this.HandleScreenBack(highestLevelScreen3))
                    {
                        return;
                    }
                }
            }
            if (currentState is EditBaseState)
            {
                HomeState.GoToHomeState(null, false);
                return;
            }
            if (Service.BuildingController != null)
            {
                BuildingController buildingController = Service.BuildingController;
                if (buildingController.SelectedBuilding != null)
                {
                    buildingController.EnsureDeselectSelectedBuilding();
                    return;
                }
            }
            if (currentState is BaseLayoutToolState)
            {
                UXController uXController = Service.UXController;
                uXController.HUD.BaseLayoutToolView.CancelBaseLayoutTool();
                return;
            }
            if (Service.GalaxyViewController != null && currentState is GalaxyState)
            {
                GalaxyViewController galaxyViewController = Service.GalaxyViewController;
                galaxyViewController.GoToHome();
                return;
            }
            this.TryQuit();
        }