Ejemplo n.º 1
0
        public override void Load(BaseGame game)
        {
            if (!Host.IsPrimaryInstance)
            {
                Logger.Log(@"osu! does not support multiple running instances.", LoggingTarget.Runtime, LogLevel.Error);
                Environment.Exit(0);
            }

            base.Load(game);

            if (args?.Length > 0)
            {
                Schedule(delegate { Beatmaps.Import(args); });
            }

            //attach our bindables to the audio subsystem.
            Audio.Volume.Weld(Config.GetBindable <double>(OsuConfig.VolumeGlobal));
            Audio.VolumeSample.Weld(Config.GetBindable <double>(OsuConfig.VolumeEffect));
            Audio.VolumeTrack.Weld(Config.GetBindable <double>(OsuConfig.VolumeMusic));

            Add(new Drawable[] {
                new VolumeControlReceptor
                {
                    RelativeSizeAxes  = Axes.Both,
                    ActivateRequested = delegate { volume.Show(); }
                },
                intro   = new Intro(),
                Toolbar = new Toolbar
                {
                    OnHome           = delegate { MainMenu?.MakeCurrent(); },
                    OnSettings       = Options.ToggleVisibility,
                    OnPlayModeChange = delegate(PlayMode m) { PlayMode.Value = m; },
                },
                Chat   = new ChatConsole(API),
                volume = new VolumeControl
                {
                    VolumeGlobal = Audio.Volume,
                    VolumeSample = Audio.VolumeSample,
                    VolumeTrack  = Audio.VolumeTrack
                },
                new GlobalHotkeys //exists because UserInputManager is at a level below us.
                {
                    Handler = globalHotkeyPressed
                }
            });

            intro.ModePushed += modeAdded;
            intro.Exited     += modeRemoved;

            PlayMode = Config.GetBindable <PlayMode>(OsuConfig.PlayMode);
            PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
            PlayMode.TriggerChange();

            Cursor.Alpha = 0;
        }
Ejemplo n.º 2
0
        protected override void Load(BaseGame game)
        {
            if (!Host.IsPrimaryInstance)
            {
                Logger.Log(@"osu! does not support multiple running instances.", LoggingTarget.Runtime, LogLevel.Error);
                Environment.Exit(0);
            }

            base.Load(game);

            if (args?.Length > 0)
            {
                Schedule(delegate { Beatmaps.Import(args); });
            }

            //attach our bindables to the audio subsystem.
            Audio.Volume.Weld(Config.GetBindable <double>(OsuConfig.VolumeUniversal));
            Audio.VolumeSample.Weld(Config.GetBindable <double>(OsuConfig.VolumeEffect));
            Audio.VolumeTrack.Weld(Config.GetBindable <double>(OsuConfig.VolumeMusic));

            PlayMode = Config.GetBindable <PlayMode>(OsuConfig.PlayMode);

            Add(new Drawable[] {
                new VolumeControlReceptor
                {
                    RelativeSizeAxes  = Axes.Both,
                    ActivateRequested = delegate { volume.Show(); }
                },
                mainContent = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                },
                volume = new VolumeControl
                {
                    VolumeGlobal = Audio.Volume,
                    VolumeSample = Audio.VolumeSample,
                    VolumeTrack  = Audio.VolumeTrack
                },
                overlayContent = new Container {
                    RelativeSizeAxes = Axes.Both
                },
                new GlobalHotkeys //exists because UserInputManager is at a level below us.
                {
                    Handler = globalHotkeyPressed
                }
            });

            (modeStack = new Intro
            {
                Beatmap = Beatmap
            }).Preload(game, d =>
            {
                mainContent.Add(d);

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

            //overlay elements
            (chat = new ChatConsole(API)
            {
                Depth = 0
            }).Preload(game, overlayContent.Add);
            (musicController = new MusicController()).Preload(game, overlayContent.Add);
            (Options = new OptionsOverlay {
                Depth = 1
            }).Preload(game, overlayContent.Add);
            (Toolbar = new Toolbar
            {
                Depth = 2,
                OnHome = delegate { mainMenu?.MakeCurrent(); },
                OnSettings = Options.ToggleVisibility,
                OnPlayModeChange = delegate(PlayMode m) { PlayMode.Value = m; },
                OnMusicController = musicController.ToggleVisibility
            }).Preload(game, t =>
            {
                PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
                PlayMode.TriggerChange();
                overlayContent.Add(Toolbar);
            });

            Cursor.Alpha = 0;
        }