コード例 #1
0
        private void load(IdleTracker idleTracker)
        {
            api.Register(this);

            if (idleTracker != null)
            {
                isIdle.BindTo(idleTracker.IsIdle);
            }
        }
コード例 #2
0
        private void load([CanBeNull] IdleTracker idleTracker)
        {
            if (idleTracker != null)
            {
                isIdle.BindTo(idleTracker.IsIdle);
            }

            AddInternal(selectionPollingComponent = new SelectionPollingComponent(Room));
        }
コード例 #3
0
ファイル: OnlinePlayScreen.cs プロジェクト: kj415j45/osu
        private void load(IdleTracker idleTracker)
        {
            apiState.BindTo(API.State);
            apiState.BindValueChanged(onlineStateChanged, true);

            if (idleTracker != null)
            {
                isIdle.BindTo(idleTracker.IsIdle);
            }
        }
コード例 #4
0
        private void load(IdleTracker idleTracker)
        {
            HighPollRate.BindValueChanged(updatePollRate);
            isIdle.BindValueChanged(updatePollRate, true);

            if (idleTracker != null)
            {
                isIdle.BindTo(idleTracker.IsIdle);
            }
        }
コード例 #5
0
ファイル: ButtonSystem.cs プロジェクト: nbayt/osu
        private void load(AudioManager audio, IdleTracker idleTracker)
        {
            isIdle.ValueChanged += updateIdleState;

            if (idleTracker != null)
            {
                isIdle.BindTo(idleTracker.IsIdle);
            }

            sampleBack = audio.Sample.Get(@"Menu/button-back-select");
        }
コード例 #6
0
ファイル: Multiplayer.cs プロジェクト: hornyyy/Osu-Toy
        private void load(IdleTracker idleTracker)
        {
            apiState.BindTo(api.State);
            apiState.BindValueChanged(onlineStateChanged, true);

            if (idleTracker != null)
            {
                isIdle.BindTo(idleTracker.IsIdle);
            }

            Notifications?.Post(new SimpleNotification
            {
                Text = $"Disclaimer: Please do not use this mod while accessing public game servers with unsuspecting players. \n" +
                       $"This is meant for single player and/or matched play with consenting participants. Thank you!"
            });
        }
コード例 #7
0
ファイル: SessionStaticsTest.cs プロジェクト: shadiwolf/e
        public void SetUp()
        {
            sessionStatics     = new SessionStatics();
            sessionIdleTracker = new GameIdleTracker(1000);

            sessionStatics.SetValue(Static.LoginOverlayDisplayed, true);
            sessionStatics.SetValue(Static.MutedAudioNotificationShownOnce, true);
            sessionStatics.SetValue(Static.LowBatteryNotificationShownOnce, true);
            sessionStatics.SetValue(Static.LastHoverSoundPlaybackTime, (double?)1d);

            sessionIdleTracker.IsIdle.BindValueChanged(e =>
            {
                if (e.NewValue)
                {
                    sessionStatics.ResetValues();
                }
            });
        }
コード例 #8
0
ファイル: PlayerLoader.cs プロジェクト: zi-jing/osu
        private void load(SessionStatics sessionStatics)
        {
            muteWarningShownOnce    = sessionStatics.GetBindable <bool>(Static.MutedAudioNotificationShownOnce);
            batteryWarningShownOnce = sessionStatics.GetBindable <bool>(Static.LowBatteryNotificationShownOnce);

            InternalChild = (content = new LogoTrackingContainer
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                RelativeSizeAxes = Axes.Both,
            }).WithChildren(new Drawable[]
            {
                MetadataInfo = new BeatmapMetadataDisplay(Beatmap.Value, Mods, content.LogoFacade)
                {
                    Alpha  = 0,
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre,
                },
                new FillFlowContainer <PlayerSettingsGroup>
                {
                    Anchor       = Anchor.TopRight,
                    Origin       = Anchor.TopRight,
                    AutoSizeAxes = Axes.Both,
                    Direction    = FillDirection.Vertical,
                    Spacing      = new Vector2(0, 20),
                    Margin       = new MarginPadding(25),
                    Children     = new PlayerSettingsGroup[]
                    {
                        VisualSettings = new VisualSettings(),
                        new InputSettings()
                    }
                },
                idleTracker = new IdleTracker(750)
            });

            if (Beatmap.Value.BeatmapInfo.EpilepsyWarning)
            {
                AddInternal(epilepsyWarning = new EpilepsyWarning
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre,
                });
            }
        }
コード例 #9
0
ファイル: ButtonSystem.cs プロジェクト: Wieku/osu
        private void load(AudioManager audio, IdleTracker idleTracker, GameHost host)
        {
            buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Solo, @"button-solo-select", FontAwesome.Solid.User, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P));
            buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Multi, @"button-generic-select", FontAwesome.Solid.Users, new Color4(94, 63, 186, 255), onMultiplayer, 0, Key.M));
            buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Playlists, @"button-generic-select", OsuIcon.Charts, new Color4(94, 63, 186, 255), onPlaylists, 0, Key.L));
            buttonsPlay.ForEach(b => b.VisibleState = ButtonSystemState.Play);

            buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Play, @"button-play-select", OsuIcon.Logo, new Color4(102, 68, 204, 255), () => State = ButtonSystemState.Play, WEDGE_WIDTH,
                                                   Key.P));
            buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Edit, @"button-edit-select", OsuIcon.EditCircle, new Color4(238, 170, 0, 255), () => OnEdit?.Invoke(), 0, Key.E));
            buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Browse, @"button-direct-select", OsuIcon.ChevronDownCircle, new Color4(165, 204, 0, 255), () => OnBeatmapListing?.Invoke(), 0,
                                                   Key.D));

            if (host.CanExit)
            {
                buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Exit, string.Empty, OsuIcon.CrossCircle, new Color4(238, 51, 153, 255), () => OnExit?.Invoke(), 0, Key.Q));
            }

            buttonArea.AddRange(buttonsPlay);
            buttonArea.AddRange(buttonsTopLevel);

            buttonArea.ForEach(b =>
            {
                if (b is MainMenuButton)
                {
                    b.Origin = Anchor.CentreLeft;
                    b.Anchor = Anchor.CentreLeft;
                }
            });

            isIdle.ValueChanged += idle => updateIdleState(idle.NewValue);

            if (idleTracker != null)
            {
                isIdle.BindTo(idleTracker.IsIdle);
            }

            sampleBack = audio.Samples.Get(@"Menu/button-back-select");
        }
コード例 #10
0
        private void load(AudioManager audio, IdleTracker idleTracker, GameHost host)
        {
            buttonsPlay.Add(new Button(@"pee", @"button-solo-select", FontAwesome.Solid.User, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P));
            buttonsPlay.Add(new Button(@"poop", @"button-generic-select", FontAwesome.Solid.Users, new Color4(94, 63, 186, 255), onMulti, 0, Key.M));
            buttonsPlay.Add(new Button(@"chart", @"button-generic-select", OsuIcon.Charts, new Color4(80, 53, 160, 255), () => OnChart?.Invoke()));
            buttonsPlay.ForEach(b => b.VisibleState = ButtonSystemState.Play);

            buttonsTopLevel.Add(new Button(@"min jae thing", @"button-play-select", OsuIcon.Logo, new Color4(102, 68, 204, 255), () => State = ButtonSystemState.Play, WEDGE_WIDTH, Key.P));
            buttonsTopLevel.Add(new Button(@"national emblem", @"button-generic-select", OsuIcon.EditCircle, new Color4(238, 170, 0, 255), () => OnEdit?.Invoke(), 0, Key.E));
            buttonsTopLevel.Add(new Button(@"osu!march", @"button-direct-select", OsuIcon.ChevronDownCircle, new Color4(165, 204, 0, 255), () => OnDirect?.Invoke(), 0, Key.D));

            if (host.CanExit)
            {
                buttonsTopLevel.Add(new Button(@"all josh's fault", string.Empty, OsuIcon.CrossCircle, new Color4(238, 51, 153, 255), () => OnExit?.Invoke(), 0, Key.Q));
            }

            buttonArea.AddRange(buttonsPlay);
            buttonArea.AddRange(buttonsTopLevel);

            buttonArea.ForEach(b =>
            {
                if (b is Button)
                {
                    b.Origin = Anchor.CentreLeft;
                    b.Anchor = Anchor.CentreLeft;
                }
            });

            isIdle.ValueChanged += idle => updateIdleState(idle.NewValue);

            if (idleTracker != null)
            {
                isIdle.BindTo(idleTracker.IsIdle);
            }

            sampleBack = audio.Samples.Get(@"Menu/button-back-select");
        }
コード例 #11
0
        private void load(SessionStatics sessionStatics, AudioManager audio)
        {
            muteWarningShownOnce    = sessionStatics.GetBindable <bool>(Static.MutedAudioNotificationShownOnce);
            batteryWarningShownOnce = sessionStatics.GetBindable <bool>(Static.LowBatteryNotificationShownOnce);

            const float padding = 25;

            InternalChildren = new Drawable[]
            {
                (content = new LogoTrackingContainer
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre,
                    RelativeSizeAxes = Axes.Both,
                }).WithChildren(new Drawable[]
                {
                    MetadataInfo = new BeatmapMetadataDisplay(Beatmap.Value, Mods, content.LogoFacade)
                    {
                        Alpha  = 0,
                        Anchor = Anchor.Centre,
                        Origin = Anchor.Centre,
                    },
                    new OsuScrollContainer
                    {
                        Anchor           = Anchor.TopRight,
                        Origin           = Anchor.TopRight,
                        RelativeSizeAxes = Axes.Y,
                        Width            = SettingsToolboxGroup.CONTAINER_WIDTH + padding * 2,
                        Padding          = new MarginPadding {
                            Vertical = padding
                        },
                        Masking = false,
                        Child   = PlayerSettings = new FillFlowContainer <PlayerSettingsGroup>
                        {
                            AutoSizeAxes = Axes.Both,
                            Direction    = FillDirection.Vertical,
                            Spacing      = new Vector2(0, 20),
                            Padding      = new MarginPadding {
                                Horizontal = padding
                            },
                            Children = new PlayerSettingsGroup[]
                            {
                                VisualSettings = new VisualSettings(),
                                AudioSettings  = new AudioSettings(),
                                new InputSettings()
                            }
                        },
                    },
                    idleTracker = new IdleTracker(750),
                }),
                lowPassFilter  = new AudioFilter(audio.TrackMixer),
                highPassFilter = new AudioFilter(audio.TrackMixer, BQFType.HighPass)
            };

            if (Beatmap.Value.BeatmapInfo.EpilepsyWarning)
            {
                AddInternal(epilepsyWarning = new EpilepsyWarning
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre,
                });
            }
        }
コード例 #12
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            // The next time this is updated is in UpdateAfterChildren, which occurs too late and results
            // in the cursor being shown for a few frames during the intro.
            // This prevents the cursor from showing until we have a screen with CursorVisible = true
            MenuCursorContainer.CanShowCursor = currentScreen?.CursorVisible ?? false;

            // todo: all archive managers should be able to be looped here.
            SkinManager.PostNotification = n => notifications?.Post(n);
            SkinManager.GetStableStorage = GetStorageForStableInstall;

            BeatmapManager.PostNotification = n => notifications?.Post(n);
            BeatmapManager.GetStableStorage = GetStorageForStableInstall;

            BeatmapManager.PresentBeatmap = PresentBeatmap;

            AddRange(new Drawable[]
            {
                new VolumeControlReceptor
                {
                    RelativeSizeAxes      = Axes.Both,
                    ActionRequested       = action => volume.Adjust(action),
                    ScrollActionRequested = (action, amount, isPrecise) => volume.Adjust(action, amount, isPrecise),
                },
                screenContainer = new ScalingContainer(ScalingMode.ExcludeOverlays)
                {
                    RelativeSizeAxes = Axes.Both,
                },
                mainContent = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                },
                overlayContent = new Container {
                    RelativeSizeAxes = Axes.Both, Depth = float.MinValue
                },
                idleTracker = new IdleTracker(6000)
            });

            loadComponentSingleFile(screenStack = new Loader(), d =>
            {
                screenStack.ModePushed += screenAdded;
                screenStack.Exited     += screenRemoved;
                screenContainer.Add(screenStack);
            });

            loadComponentSingleFile(Toolbar = new Toolbar
            {
                Depth  = -5,
                OnHome = delegate
                {
                    CloseAllOverlays(false);
                    intro?.ChildScreen?.MakeCurrent();
                },
            }, overlayContent.Add);

            loadComponentSingleFile(volume          = new VolumeOverlay(), overlayContent.Add);
            loadComponentSingleFile(onscreenDisplay = new OnScreenDisplay(), Add);

            loadComponentSingleFile(screenshotManager, Add);

            //overlay elements
            loadComponentSingleFile(direct = new DirectOverlay {
                Depth = -1
            }, mainContent.Add);
            loadComponentSingleFile(social = new SocialOverlay {
                Depth = -1
            }, mainContent.Add);
            loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal);
            loadComponentSingleFile(chatOverlay    = new ChatOverlay {
                Depth = -1
            }, mainContent.Add);
            loadComponentSingleFile(settings = new MainSettings
            {
                GetToolbarHeight = () => ToolbarOffset,
                Depth            = -1
            }, overlayContent.Add);
            loadComponentSingleFile(userProfile = new UserProfileOverlay {
                Depth = -2
            }, mainContent.Add);
            loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay {
                Depth = -3
            }, mainContent.Add);
            loadComponentSingleFile(musicController = new MusicController
            {
                Depth    = -5,
                Position = new Vector2(0, Toolbar.HEIGHT),
                Anchor   = Anchor.TopRight,
                Origin   = Anchor.TopRight,
            }, overlayContent.Add);

            loadComponentSingleFile(notifications = new NotificationOverlay
            {
                GetToolbarHeight = () => ToolbarOffset,
                Depth            = -4,
                Anchor           = Anchor.TopRight,
                Origin           = Anchor.TopRight,
            }, overlayContent.Add);

            loadComponentSingleFile(accountCreation = new AccountCreationOverlay
            {
                Depth = -6,
            }, overlayContent.Add);

            loadComponentSingleFile(dialogOverlay = new DialogOverlay
            {
                Depth = -7,
            }, overlayContent.Add);

            loadComponentSingleFile(externalLinkOpener = new ExternalLinkOpener
            {
                Depth = -8,
            }, overlayContent.Add);

            dependencies.Cache(idleTracker);
            dependencies.Cache(settings);
            dependencies.Cache(onscreenDisplay);
            dependencies.Cache(social);
            dependencies.Cache(direct);
            dependencies.Cache(chatOverlay);
            dependencies.Cache(channelManager);
            dependencies.Cache(userProfile);
            dependencies.Cache(musicController);
            dependencies.Cache(beatmapSetOverlay);
            dependencies.Cache(notifications);
            dependencies.Cache(dialogOverlay);
            dependencies.Cache(accountCreation);

            chatOverlay.StateChanged += state => channelManager.HighPollRate.Value = state == Visibility.Visible;

            Add(externalLinkOpener = new ExternalLinkOpener());

            var singleDisplaySideOverlays = new OverlayContainer[] { settings, notifications };

            overlays.AddRange(singleDisplaySideOverlays);

            foreach (var overlay in singleDisplaySideOverlays)
            {
                overlay.StateChanged += state =>
                {
                    if (state == Visibility.Hidden)
                    {
                        return;
                    }
                    singleDisplaySideOverlays.Where(o => o != overlay).ForEach(o => o.Hide());
                };
            }

            // eventually informational overlays should be displayed in a stack, but for now let's only allow one to stay open at a time.
            var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile };

            overlays.AddRange(informationalOverlays);

            foreach (var overlay in informationalOverlays)
            {
                overlay.StateChanged += state =>
                {
                    if (state == Visibility.Hidden)
                    {
                        return;
                    }
                    informationalOverlays.Where(o => o != overlay).ForEach(o => o.Hide());
                };
            }

            // ensure only one of these overlays are open at once.
            var singleDisplayOverlays = new OverlayContainer[] { chatOverlay, social, direct };

            overlays.AddRange(singleDisplayOverlays);

            foreach (var overlay in singleDisplayOverlays)
            {
                overlay.StateChanged += state =>
                {
                    // informational overlays should be dismissed on a show or hide of a full overlay.
                    informationalOverlays.ForEach(o => o.Hide());

                    if (state == Visibility.Hidden)
                    {
                        return;
                    }

                    singleDisplayOverlays.Where(o => o != overlay).ForEach(o => o.Hide());
                };
            }

            OverlayActivationMode.ValueChanged += v =>
            {
                if (v != OverlayActivation.All)
                {
                    CloseAllOverlays();
                }
            };

            void updateScreenOffset()
            {
                float offset = 0;

                if (settings.State == Visibility.Visible)
                {
                    offset += ToolbarButton.WIDTH / 2;
                }
                if (notifications.State == Visibility.Visible)
                {
                    offset -= ToolbarButton.WIDTH / 2;
                }

                screenContainer.MoveToX(offset, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint);
            }

            settings.StateChanged      += _ => updateScreenOffset();
            notifications.StateChanged += _ => updateScreenOffset();
        }
コード例 #13
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            // The next time this is updated is in UpdateAfterChildren, which occurs too late and results
            // in the cursor being shown for a few frames during the intro.
            // This prevents the cursor from showing until we have a screen with CursorVisible = true
            MenuCursorContainer.CanShowCursor = menuScreen?.CursorVisible ?? false;

            // todo: all archive managers should be able to be looped here.
            SkinManager.PostNotification = n => notifications?.Post(n);
            SkinManager.GetStableStorage = GetStorageForStableInstall;

            BeatmapManager.PostNotification = n => notifications?.Post(n);
            BeatmapManager.GetStableStorage = GetStorageForStableInstall;
            BeatmapManager.PresentImport    = items => PresentBeatmap(items.First());

            ScoreManager.PostNotification = n => notifications?.Post(n);
            ScoreManager.GetStableStorage = GetStorageForStableInstall;
            ScoreManager.PresentImport    = items => PresentScore(items.First());

            Container logoContainer;

            BackButton.Receptor receptor;

            dependencies.CacheAs(idleTracker = new GameIdleTracker(6000));

            AddRange(new Drawable[]
            {
                new VolumeControlReceptor
                {
                    RelativeSizeAxes      = Axes.Both,
                    ActionRequested       = action => volume.Adjust(action),
                    ScrollActionRequested = (action, amount, isPrecise) => volume.Adjust(action, amount, isPrecise),
                },
                screenContainer = new ScalingContainer(ScalingMode.ExcludeOverlays)
                {
                    RelativeSizeAxes = Axes.Both,
                    Children         = new Drawable[]
                    {
                        receptor    = new BackButton.Receptor(),
                        ScreenStack = new OsuScreenStack {
                            RelativeSizeAxes = Axes.Both
                        },
                        BackButton = new BackButton(receptor)
                        {
                            Anchor = Anchor.BottomLeft,
                            Origin = Anchor.BottomLeft,
                            Action = () =>
                            {
                                if ((ScreenStack.CurrentScreen as IOsuScreen)?.AllowBackButton == true)
                                {
                                    ScreenStack.Exit();
                                }
                            }
                        },
                        logoContainer = new Container {
                            RelativeSizeAxes = Axes.Both
                        },
                    }
                },
                overlayContent = new Container {
                    RelativeSizeAxes = Axes.Both
                },
                rightFloatingOverlayContent = new Container {
                    RelativeSizeAxes = Axes.Both
                },
                leftFloatingOverlayContent = new Container {
                    RelativeSizeAxes = Axes.Both
                },
                topMostOverlayContent = new Container {
                    RelativeSizeAxes = Axes.Both
                },
                idleTracker
            });

            ScreenStack.ScreenPushed += screenPushed;
            ScreenStack.ScreenExited += screenExited;

            loadComponentSingleFile(osuLogo, logo =>
            {
                logoContainer.Add(logo);

                // Loader has to be created after the logo has finished loading as Loader performs logo transformations on entering.
                ScreenStack.Push(CreateLoader().With(l => l.RelativeSizeAxes = Axes.Both));
            });

            loadComponentSingleFile(Toolbar = new Toolbar
            {
                OnHome = delegate
                {
                    CloseAllOverlays(false);
                    menuScreen?.MakeCurrent();
                },
            }, d =>
            {
                topMostOverlayContent.Add(d);
                toolbarElements.Add(d);
            });

            loadComponentSingleFile(volume = new VolumeOverlay(), leftFloatingOverlayContent.Add, true);

            loadComponentSingleFile(new OnScreenDisplay(), Add, true);

            loadComponentSingleFile(musicController = new MusicController(), Add, true);

            loadComponentSingleFile(notifications = new NotificationOverlay
            {
                GetToolbarHeight = () => ToolbarOffset,
                Anchor           = Anchor.TopRight,
                Origin           = Anchor.TopRight,
            }, rightFloatingOverlayContent.Add, true);

            loadComponentSingleFile(screenshotManager, Add);

            //overlay elements
            loadComponentSingleFile(direct         = new DirectOverlay(), overlayContent.Add, true);
            loadComponentSingleFile(social         = new SocialOverlay(), overlayContent.Add, true);
            loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal, true);
            loadComponentSingleFile(chatOverlay    = new ChatOverlay(), overlayContent.Add, true);
            loadComponentSingleFile(Settings       = new SettingsOverlay {
                GetToolbarHeight = () => ToolbarOffset
            }, leftFloatingOverlayContent.Add, true);
            var changelogOverlay = loadComponentSingleFile(new ChangelogOverlay(), overlayContent.Add, true);

            loadComponentSingleFile(userProfile       = new UserProfileOverlay(), overlayContent.Add, true);
            loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true);

            loadComponentSingleFile(new LoginOverlay
            {
                GetToolbarHeight = () => ToolbarOffset,
                Anchor           = Anchor.TopRight,
                Origin           = Anchor.TopRight,
            }, rightFloatingOverlayContent.Add, true);

            loadComponentSingleFile(new NowPlayingOverlay
            {
                GetToolbarHeight = () => ToolbarOffset,
                Anchor           = Anchor.TopRight,
                Origin           = Anchor.TopRight,
            }, d =>
            {
                rightFloatingOverlayContent.Add(d);
                toolbarElements.Add(d);
            }, true);

            loadComponentSingleFile(new AccountCreationOverlay(), topMostOverlayContent.Add, true);
            loadComponentSingleFile(new DialogOverlay(), topMostOverlayContent.Add, true);
            loadComponentSingleFile(externalLinkOpener = new ExternalLinkOpener(), topMostOverlayContent.Add);

            chatOverlay.State.ValueChanged += state => channelManager.HighPollRate.Value = state.NewValue == Visibility.Visible;

            Add(externalLinkOpener = new ExternalLinkOpener());

            var singleDisplaySideOverlays = new OverlayContainer[] { Settings, notifications };

            overlays.AddRange(singleDisplaySideOverlays);

            foreach (var overlay in singleDisplaySideOverlays)
            {
                overlay.State.ValueChanged += state =>
                {
                    if (state.NewValue == Visibility.Hidden)
                    {
                        return;
                    }

                    singleDisplaySideOverlays.Where(o => o != overlay).ForEach(o => o.Hide());
                };
            }

            // eventually informational overlays should be displayed in a stack, but for now let's only allow one to stay open at a time.
            var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile };

            overlays.AddRange(informationalOverlays);

            foreach (var overlay in informationalOverlays)
            {
                overlay.State.ValueChanged += state =>
                {
                    if (state.NewValue == Visibility.Hidden)
                    {
                        return;
                    }

                    informationalOverlays.Where(o => o != overlay).ForEach(o => o.Hide());
                };
            }

            // ensure only one of these overlays are open at once.
            var singleDisplayOverlays = new OverlayContainer[] { chatOverlay, social, direct, changelogOverlay };

            overlays.AddRange(singleDisplayOverlays);

            foreach (var overlay in singleDisplayOverlays)
            {
                overlay.State.ValueChanged += state =>
                {
                    // informational overlays should be dismissed on a show or hide of a full overlay.
                    informationalOverlays.ForEach(o => o.Hide());

                    if (state.NewValue == Visibility.Hidden)
                    {
                        return;
                    }

                    singleDisplayOverlays.Where(o => o != overlay).ForEach(o => o.Hide());
                };
            }

            OverlayActivationMode.ValueChanged += mode =>
            {
                if (mode.NewValue != OverlayActivation.All)
                {
                    CloseAllOverlays();
                }
            };

            void updateScreenOffset()
            {
                float offset = 0;

                if (Settings.State.Value == Visibility.Visible)
                {
                    offset += ToolbarButton.WIDTH / 2;
                }
                if (notifications.State.Value == Visibility.Visible)
                {
                    offset -= ToolbarButton.WIDTH / 2;
                }

                screenContainer.MoveToX(offset, SettingsPanel.TRANSITION_LENGTH, Easing.OutQuint);
            }

            Settings.State.ValueChanged      += _ => updateScreenOffset();
            notifications.State.ValueChanged += _ => updateScreenOffset();
        }
コード例 #14
0
ファイル: LoungeSubScreen.cs プロジェクト: nekodex/osu
        private void load([CanBeNull] IdleTracker idleTracker)
        {
            const float controls_area_height = 25f;

            if (idleTracker != null)
            {
                isIdle.BindTo(idleTracker.IsIdle);
            }

            OsuScrollContainer scrollContainer;

            InternalChildren = new Drawable[]
            {
                ListingPollingComponent = CreatePollingComponent().With(c => c.Filter.BindTarget = filter),
                popoverContainer        = new PopoverContainer
                {
                    Name             = @"Rooms area",
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding
                    {
                        Horizontal = WaveOverlayContainer.WIDTH_PADDING,
                        Top        = Header.HEIGHT + controls_area_height + 20,
                    },
                    Child = scrollContainer = new OsuScrollContainer
                    {
                        RelativeSizeAxes         = Axes.Both,
                        ScrollbarOverlapsContent = false,
                        Child = roomsContainer = new RoomsContainer
                        {
                            Filter       = { BindTarget = filter },
                            SelectedRoom = { BindTarget = SelectedRoom }
                        }
                    },
                },
                loadingLayer = new LoadingLayer(true),
                new FillFlowContainer
                {
                    Name             = @"Header area flow",
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Padding          = new MarginPadding {
                        Horizontal = WaveOverlayContainer.WIDTH_PADDING
                    },
                    Direction = FillDirection.Vertical,
                    Children  = new Drawable[]
                    {
                        new Container
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = Header.HEIGHT,
                            Child            = searchTextBox = new SearchTextBox
                            {
                                Anchor           = Anchor.CentreRight,
                                Origin           = Anchor.CentreRight,
                                RelativeSizeAxes = Axes.X,
                                Width            = 0.6f,
                            },
                        },
                        new Container
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = controls_area_height,
                            Children         = new Drawable[]
                            {
                                Buttons.WithChild(CreateNewRoomButton().With(d =>
                                {
                                    d.Anchor = Anchor.BottomLeft;
                                    d.Origin = Anchor.BottomLeft;
                                    d.Size   = new Vector2(150, 37.5f);
                                    d.Action = () => Open();
                                })),
                                new FillFlowContainer
                                {
                                    Anchor             = Anchor.TopRight,
                                    Origin             = Anchor.TopRight,
                                    AutoSizeAxes       = Axes.Both,
                                    Direction          = FillDirection.Horizontal,
                                    Spacing            = new Vector2(10),
                                    ChildrenEnumerable = CreateFilterControls().Select(f => f.With(d =>
                                    {
                                        d.Anchor = Anchor.TopRight;
                                        d.Origin = Anchor.TopRight;
                                    }))
                                }
                            }
                        }
                    },
                },
            };

            // scroll selected room into view on selection.
            SelectedRoom.BindValueChanged(val =>
            {
                var drawable = roomsContainer.Rooms.FirstOrDefault(r => r.Room == val.NewValue);
                if (drawable != null)
                {
                    scrollContainer.ScrollIntoView(drawable);
                }
            });
        }
コード例 #15
0
ファイル: ButtonSystem.cs プロジェクト: Natsuhou/osu
 private void load(AudioManager audio, OsuGame game, IdleTracker idleTracker)
 {
     this.game        = game;
     this.idleTracker = idleTracker;
     sampleBack       = audio.Sample.Get(@"Menu/button-back-select");
 }