Exemple #1
0
        protected override void OnEntering(GameMode last)
        {
            OsuGameMode lastOsu = last as OsuGameMode;

            BackgroundMode bg = CreateBackground();

            if (lastOsu?.Background != null)
            {
                if (bg == null || lastOsu.Background.Equals(bg))
                {
                    //we can keep the previous mode's background.
                    Background = lastOsu.Background;
                }
                else
                {
                    lastOsu.Background.Push(Background = bg);
                }
            }
            else if (bg != null)
            {
                AddInternal(new ParallaxContainer
                {
                    Depth    = float.MaxValue,
                    Children = new[]
                    {
                        Background = bg
                    }
                });
            }

            base.OnEntering(last);
        }
Exemple #2
0
        public override bool Push(GameMode mode)
        {
            OsuGameMode nextOsu = mode as OsuGameMode;

            if (nextOsu != null)
            {
                nextOsu.beatmap = beatmap;
            }

            return(base.Push(mode));
        }
Exemple #3
0
        protected override bool OnExiting(GameMode next)
        {
            OsuGameMode nextOsu = next as OsuGameMode;

            if (Background != null && !Background.Equals(nextOsu?.Background))
            {
                if (nextOsu != null)
                {
                    //We need to use MakeCurrent in case we are jumping up multiple game modes.
                    nextOsu.Background?.MakeCurrent();
                }
                else
                {
                    Background.Exit();
                }
            }

            return(base.OnExiting(next));
        }
Exemple #4
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            Add(new Drawable[] {
                new VolumeControlReceptor
                {
                    RelativeSizeAxes = Axes.Both,
                    ActionRequested = delegate(InputState state) { volume.Adjust(state); }
                },
                mainContent = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                },
                volume = new VolumeControl(),
                overlayContent = new Container{ RelativeSizeAxes = Axes.Both },
                new GlobalHotkeys //exists because UserInputManager is at a level below us.
                {
                    Handler = globalHotkeyPressed
                }
            });

            (modeStack = new Intro()).Preload(this, d =>
            {
                mainContent.Add(d);

                modeStack.ModePushed += modeAdded;
                modeStack.Exited += modeRemoved;
                modeStack.DisplayAsRoot();
            });

            //overlay elements
            (chat = new ChatOverlay { Depth = 0 }).Preload(this, overlayContent.Add);
            (options = new OptionsOverlay { Depth = -1 }).Preload(this, overlayContent.Add);
            (musicController = new MusicController() { Depth = -3 }).Preload(this, overlayContent.Add);

            Dependencies.Cache(options);
            Dependencies.Cache(musicController);

            (Toolbar = new Toolbar
            {
                Depth = -2,
                OnHome = delegate { mainMenu?.MakeCurrent(); },
                OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
            }).Preload(this, t =>
            {
                PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
                PlayMode.TriggerChange();
                overlayContent.Add(Toolbar);
            });

            options.StateChanged += delegate
            {
                switch (options.State)
                {
                    case Visibility.Hidden:
                        intro.MoveToX(0, OptionsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint);
                        break;
                    case Visibility.Visible:
                        intro.MoveToX(OptionsOverlay.SIDEBAR_WIDTH / 2, OptionsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint);
                        break;
                }
            };

            Cursor.Alpha = 0;
        }