Beispiel #1
0
        private void load(IAPIProvider api, INotificationOverlay notifications)
        {
            SpriteIcon icon;

            AddRange(new Drawable[]
            {
                icon = new SpriteIcon
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre,
                    Icon   = FontAwesome.Regular.Heart,
                    Size   = new Vector2(18),
                    Shadow = false,
                },
                loading = new LoadingLayer(true, false),
            });

            Action = () =>
            {
                // guaranteed by disabled state above.
                Debug.Assert(BeatmapSet.Value.OnlineID > 0);

                loading.Show();

                request?.Cancel();

                request = new PostBeatmapFavouriteRequest(BeatmapSet.Value.OnlineID, favourited.Value ? BeatmapFavouriteAction.UnFavourite : BeatmapFavouriteAction.Favourite);

                request.Success += () =>
                {
                    favourited.Toggle();
                    loading.Hide();
                };

                request.Failure += e =>
                {
                    notifications?.Post(new SimpleNotification
                    {
                        Text = e.Message,
                        Icon = FontAwesome.Solid.Times,
                    });

                    loading.Hide();
                };

                api.Queue(request);
            };

            favourited.ValueChanged += favourited => icon.Icon = favourited.NewValue ? FontAwesome.Solid.Heart : FontAwesome.Regular.Heart;

            localUser.BindTo(api.LocalUser);
            localUser.BindValueChanged(_ => updateEnabled());

            // must be run after setting the Action to ensure correct enabled state (setting an Action forces a button to be enabled).
            BeatmapSet.BindValueChanged(setInfo =>
            {
                updateEnabled();
                favourited.Value = setInfo.NewValue?.HasFavourited ?? false;
            }, true);
        }
Beispiel #2
0
            private void load(OsuColour colours, INotificationOverlay notificationOverlay)
            {
                Icon = FontAwesome.Solid.BatteryQuarter;
                IconBackground.Colour = colours.RedDark;

                Activated = delegate
                {
                    notificationOverlay.Hide();
                    return(true);
                };
            }
Beispiel #3
0
            private void load(OsuColour colours, ChatOverlay chatOverlay, INotificationOverlay notificationOverlay)
            {
                IconBackground.Colour = colours.PurpleDark;

                Activated = delegate
                {
                    notificationOverlay.Hide();
                    chatOverlay.HighlightMessage(message, channel);
                    return(true);
                };
            }
Beispiel #4
0
            private void load(OsuColour colours, ChangelogOverlay changelog, INotificationOverlay notificationOverlay)
            {
                Icon = FontAwesome.Solid.CheckSquare;
                IconBackground.Colour = colours.BlueDark;

                Activated = delegate
                {
                    notificationOverlay.Hide();
                    changelog.ShowBuild(OsuGameBase.CLIENT_STREAM_NAME, version);
                    return(true);
                };
            }
Beispiel #5
0
        private void load(INotificationOverlay notificationOverlay)
        {
            StateContainer = notificationOverlay as NotificationOverlay;

            if (notificationOverlay != null)
            {
                NotificationCount.BindTo(notificationOverlay.UnreadCount);
            }

            NotificationCount.ValueChanged += count =>
            {
                if (count.NewValue == 0)
                {
                    countDisplay.FadeOut(200, Easing.OutQuint);
                }
                else
                {
                    countDisplay.Count = count.NewValue;
                    countDisplay.FadeIn(200, Easing.OutQuint);
                }
            };
        }
Beispiel #6
0
        private void load(OsuConfigManager config, INotificationOverlay notificationOverlay)
        {
            if (drawableRuleset != null)
            {
                BindDrawableRuleset(drawableRuleset);
            }

            ModDisplay.Current.Value = mods;

            configVisibilityMode = config.GetBindable <HUDVisibilityMode>(OsuSetting.HUDVisibilityMode);

            if (configVisibilityMode.Value == HUDVisibilityMode.Never && !hasShownNotificationOnce)
            {
                hasShownNotificationOnce = true;

                notificationOverlay?.Post(new SimpleNotification
                {
                    Text = $"The score overlay is currently disabled. You can toggle this by pressing {config.LookupKeyBindings(GlobalAction.ToggleInGameInterface)}."
                });
            }

            // start all elements hidden
            hideTargets.ForEach(d => d.Hide());
        }
Beispiel #7
0
            private void load(OsuColour colours, AudioManager audioManager, INotificationOverlay notificationOverlay, VolumeOverlay volumeOverlay)
            {
                Icon = FontAwesome.Solid.VolumeMute;
                IconBackground.Colour = colours.RedDark;

                Activated = delegate
                {
                    notificationOverlay.Hide();

                    volumeOverlay.IsMuted.Value = false;

                    // Check values before resetting, as the user may have only had mute enabled, in which case we might not need to adjust volumes.
                    if (audioManager.Volume.Value <= volume_requirement)
                    {
                        audioManager.Volume.SetDefault();
                    }
                    if (audioManager.VolumeTrack.Value <= volume_requirement)
                    {
                        audioManager.VolumeTrack.SetDefault();
                    }

                    return(true);
                };
            }
Beispiel #8
0
        private void load(INotificationOverlay notifications)
        {
            notificationOverlay = notifications;

            SquirrelLocator.CurrentMutable.Register(() => squirrelLogger, typeof(ILogger));
        }