Exemplo n.º 1
0
        void SwitchToScreen(MenuScreen newScreen)
        {
            try {
                if (CurrentScreen != null)
                {
                    CurrentScreen.Hide();

                    if (CurrentScreen != LoadingScreen)
                    {
                        PreviousScreens.Push(CurrentScreen);
                    }
                }

                CurrentScreen = newScreen;
                newScreen.Show();
                try {
                    ScreenChanged?.Invoke();
                }
                catch (Exception e) {
                    Urho.IO.Log.Write(LogLevel.Warning,
                                      $"Invocation of {nameof(ScreenChanged)} threw an exception: {e.Message}");
                }
            }
            catch (Exception e) {
                string message =
                    $"There was an error while switching menu screens: {e.Message}";

                Urho.IO.Log.Write(LogLevel.Error, message);
                Game.ErrorExit(message);
            }
        }
Exemplo n.º 2
0
        public void SwitchBack()
        {
            CurrentScreen.Hide();

            if (PreviousScreens.Count != 0)
            {
                CurrentScreen = PreviousScreens.Pop();
                CurrentScreen.Show();
            }
        }