Ejemplo n.º 1
0
        public void ShowMessage(string title, string message, NotificationStyle style = NotificationStyle.Blue, Sprite sprite = null, float time = 5.0f)
        {
            if (_title == title && _message == message)
            {
                // We are already showing this same notification, let's not annoy the user by re-animating (just extend the time if possible/needed)
                if (_currentStep == NotificationStep.Normal)
                {
                    _updateTimerTally = 0;
                    return;
                }
                else if (_currentStep == NotificationStep.Appearing)
                {
                    return;
                }
            }

            Plugin.Log?.Info($"Show floating notification: {title}, {message}");

            DismissMessage();

            _requestedStart = true;

            _title       = title;
            _message     = message;
            _style       = style;
            _time        = time;
            _currentStep = NotificationStep.Hidden;
            _sprite      = sprite ? sprite : Sprites.PortalUser;

            gameObject.SetActive(true);
        }
 /// <summary>
 /// Initialize a new instance of <see cref="GameNotificationChannel"/>, providing the notification style
 /// and optionally all other settings.
 /// </summary>
 public GameNotificationChannel(string id, string name, string description, NotificationStyle style, bool showsBadge = true, bool showLights = false, bool vibrates = true, bool highPriority = false, PrivacyMode privacy = PrivacyMode.Public, long[] vibrationPattern = null)
 {
     Id               = id;
     Name             = name;
     Description      = description;
     ShowsBadge       = showsBadge;
     ShowLights       = showLights;
     Vibrates         = vibrates;
     HighPriority     = highPriority;
     Style            = style;
     Privacy          = privacy;
     VibrationPattern = vibrationPattern;
 }
        /// <summary>
        /// Initialize a new instance of <see cref="GameNotificationChannel"/> with
        /// optional fields set to their default values.
        /// </summary>
        public GameNotificationChannel(string id, string name, string description) : this()
        {
            Id          = id;
            Name        = name;
            Description = description;

            ShowsBadge       = true;
            ShowLights       = false;
            Vibrates         = true;
            HighPriority     = false;
            Style            = NotificationStyle.Popup;
            Privacy          = PrivacyMode.Public;
            VibrationPattern = null;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PropertyStrategy"/> class.
        /// </summary>
        /// <param name="definition">The property definition.</param>
        /// <param name="mode">Explicit/implicit mode.</param>
        /// <param name="defaultStyle">The notification style that will be used if none is specified.</param>
        /// <param name="target">Notificaiton target method.</param>
        public PropertyStrategy(PropertyDefinition definition, NotificationMode mode,
                                NotificationStyle defaultStyle, MethodReference target)
        {
            this.Property     = definition;
            this.NotifyValues = GetNotifyPropertyNames(definition, mode).ToArray();
            this.IsIgnored    = !NotifyValues.Any() || Property.SetMethod == null;

            if (!this.IsIgnored)
            {
                this.NotifyTarget           = target;
                this.NotifyTargetDefinition = target.Resolve();
                this.NotificationStyle      = GetNotificationStyle(definition) ?? defaultStyle;
                this.ImplementationStyle    = this.NotificationStyle == NotificationStyle.OnChange || IsComplex(definition) ? ImplementationStyle.Wrapped : ImplementationStyle.Inline;
            }
        }
Ejemplo n.º 5
0
        public Notification(string title, string description, NotificationStyle style, BoolDelegate action = null)
        {
            Clocking = ClockTypes.Game;

            pSprite back = new pSprite(TextureManager.Load(OsuTexture.notification_background), FieldTypes.StandardSnapCentre, OriginTypes.Centre, ClockTypes.Game, Vector2.Zero, 0.98f, true, Color4.White)
            {
                DimImmune = true
            };

            pText titleText = new pText(title, 36, new Vector2(0, -130), new Vector2(500 * GameBase.SpriteToBaseRatio, 0), 1, true, Color4.White, true)
            {
                Field         = FieldTypes.StandardSnapCentre,
                Origin        = OriginTypes.Centre,
                TextAlignment = TextAlignment.Centre,
                Clocking      = ClockTypes.Game,
                DimImmune     = true
            };

            pText descText = new pText(description, 24, new Vector2(0, -90), new Vector2(500 * GameBase.SpriteToBaseRatio, 0), 1, true, Color4.White, false)
            {
                Field         = FieldTypes.StandardSnapCentre,
                Origin        = OriginTypes.TopCentre,
                TextAlignment = TextAlignment.Centre,
                Clocking      = ClockTypes.Game,
                DimImmune     = true
            };

            Alpha     = 0;
            DrawDepth = 1;

            Action = action;


            Style = style;

            AddControls(style);

            Add(back);
            Add(descText);
            Add(titleText);
        }
Ejemplo n.º 6
0
        public static void ShowMessage(Controller control, string title, string msg, NotificationStyle style)
        {
            control.TempData["notiTitle"] = title;
            control.TempData["notiMsg"]   = msg;
            switch (style)
            {
            case NotificationStyle.Default:
                control.TempData["notiStyle"] = "gray";
                break;

            case NotificationStyle.Success:
                control.TempData["notiStyle"] = "gray success";
                break;

            case NotificationStyle.Error:
                control.TempData["notiStyle"] = "gray error";
                break;

            default:
                control.TempData["notiStyle"] = "gray";
                break;
            }
        }
Ejemplo n.º 7
0
 private static bool Exists(this INotificationModel model, string?header, string message, NotificationStyle notificationType) => model.Notifications?.Any(x => (x.Header?.InvariantEquals(header) ?? false) && (x.Message?.InvariantEquals(message) ?? false) && x.NotificationType == notificationType) ?? false;
Ejemplo n.º 8
0
        public static void AddNotification(this INotificationModel model, string header, string msg, NotificationStyle type)
        {
            if (model.Exists(header, msg, type))
            {
                return;
            }

            model.Notifications?.Add(new BackOfficeNotification()
            {
                Header           = header,
                Message          = msg,
                NotificationType = type
            });
        }
 public static void AddNotification(this INotificationModel model, string header, string msg, NotificationStyle type)
 {
     model.Notifications.Add(new Notification()
     {
         Header           = header,
         Message          = msg,
         NotificationType = type
     });
 }
Ejemplo n.º 10
0
 public PropertyProcessor(MethodReference target, NotificationMode mode, NotificationStyle style)
 {
     this.notifyTarget = target;
     this.defaultMode  = mode;
     this.defaultStyle = style;
 }
Ejemplo n.º 11
0
 public NotifierAttribute(NotificationMode mode = NotificationMode.Explicit, NotificationStyle defaultStyle = NotificationStyle.OnSet)
 {
     this.NotificationMode = mode;
     this.DefaultStyle     = defaultStyle;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NotifyAttribute"/> class.
 /// </summary>
 /// <param name="sourceNames">Properties that will be passed to the cotification target method.</param>
 public NotifyAttribute(NotificationStyle style, params string[] sourceNames)
 {
     Style = style;
     NotificationSource = sourceNames;
 }
Ejemplo n.º 13
0
 private static bool Exists(this INotificationModel model, string header, string message, NotificationStyle notificationType) => model.Notifications.Any(x => x.Header.InvariantEquals(header) && x.Message.InvariantEquals(message) && x.NotificationType == notificationType);
Ejemplo n.º 14
0
        private void AddControls(NotificationStyle style)
        {
            const int button_height = 95;

            switch (style)
            {
            case NotificationStyle.Okay:
            {
                pDrawable additiveButton = null;

                okayButton = new pSprite(TextureManager.Load(OsuTexture.notification_button_ok), new Vector2(0, button_height))
                {
                    Field           = FieldTypes.StandardSnapCentre,
                    Origin          = OriginTypes.Centre,
                    Clocking        = ClockTypes.Game,
                    DimImmune       = true,
                    DrawDepth       = 0.99f,
                    HandleClickOnUp = true
                };
                okayButton.OnHover += delegate { additiveButton = okayButton.AdditiveFlash(10000, 0.4f); };

                okayButton.OnHoverLost += delegate
                {
                    if (additiveButton != null)
                    {
                        additiveButton.FadeOut(100);
                    }
                };

                okayButton.OnClick += delegate { dismiss(true); };

                Add(okayButton);

                pText okayText = new pText(LocalisationManager.GetString(OsuString.Okay), 24, new Vector2(0, button_height), Vector2.Zero, 1, true, Color4.White, true)
                {
                    Field     = FieldTypes.StandardSnapCentre,
                    Origin    = OriginTypes.Centre,
                    Clocking  = ClockTypes.Game,
                    DimImmune = true
                };

                Add(okayText);
            }
            break;

            case NotificationStyle.YesNo:
            {
                pDrawable additiveButton = null;

                okayButton = new pSprite(TextureManager.Load(OsuTexture.notification_button_yes), new Vector2(-140, button_height))
                {
                    Field           = FieldTypes.StandardSnapCentre,
                    Origin          = OriginTypes.Centre,
                    Clocking        = ClockTypes.Game,
                    DimImmune       = true,
                    DrawDepth       = 0.99f,
                    HandleClickOnUp = true
                };

                okayButton.OnHover += delegate { additiveButton = okayButton.AdditiveFlash(10000, 0.4f); };

                okayButton.OnHoverLost += delegate
                {
                    if (additiveButton != null)
                    {
                        additiveButton.FadeOut(100);
                    }
                };

                okayButton.OnClick += delegate { dismiss(true); };

                Add(okayButton);

                pText okayText = new pText(LocalisationManager.GetString(OsuString.Yes), 24, new Vector2(-140, button_height), Vector2.Zero, 1, true, Color4.White, true)
                {
                    Field     = FieldTypes.StandardSnapCentre,
                    Origin    = OriginTypes.Centre,
                    Clocking  = ClockTypes.Game,
                    DimImmune = true
                };

                Add(okayText);
            }
                {
                    pDrawable additiveButton = null;

                    cancelButton = new pSprite(TextureManager.Load(OsuTexture.notification_button_no), new Vector2(140, button_height))
                    {
                        Field           = FieldTypes.StandardSnapCentre,
                        Origin          = OriginTypes.Centre,
                        Clocking        = ClockTypes.Game,
                        DimImmune       = true,
                        DrawDepth       = 0.99f,
                        HandleClickOnUp = true
                    };
                    cancelButton.OnHover += delegate { additiveButton = cancelButton.AdditiveFlash(10000, 0.4f); };

                    cancelButton.OnHoverLost += delegate
                    {
                        if (additiveButton != null)
                        {
                            additiveButton.FadeOut(100);
                        }
                    };

                    cancelButton.OnClick += delegate { dismiss(false); };

                    Add(cancelButton);

                    pText cancelText = new pText(LocalisationManager.GetString(OsuString.No), 24, new Vector2(140, button_height), Vector2.Zero, 1, true, Color4.White, true)
                    {
                        Field     = FieldTypes.StandardSnapCentre,
                        Origin    = OriginTypes.Centre,
                        Clocking  = ClockTypes.Game,
                        DimImmune = true
                    };

                    Add(cancelText);
                }
                break;
            }
        }
 public static T Resolve <T>(this NotificationStyle @this, T snackbar, T notification)
 => @this switch
 {
 public BackOfficeNotification(string header, string message, NotificationStyle notificationType)
 {
     Header           = header;
     Message          = message;
     NotificationType = notificationType;
 }
Ejemplo n.º 17
0
        public async Task ShowMessageWithImageDownload(string title, string message, string imageUrl, NotificationStyle style = NotificationStyle.Blue, Sprite spriteFallback = null, float time = 5.0f)
        {
            _runningCoroutine = true;
            gameObject.SetActive(true);

            StartCoroutine(ShowMessageWithImageCoroutine(title, message, imageUrl, style, spriteFallback, time));
        }
Ejemplo n.º 18
0
        private IEnumerator ShowMessageWithImageCoroutine(string title, string message, string imageUrl, NotificationStyle style, Sprite sprite, float time)
        {
            var request = UnityWebRequestTexture.GetTexture(imageUrl);

            yield return(request.SendWebRequest());

            if (request.isNetworkError || request.isHttpError)
            {
                Plugin.Log?.Warn($"⚠ Notification image load failed: {imageUrl}");
            }
            else
            {
                var texture = ((DownloadHandlerTexture)request.downloadHandler).texture;
                sprite = Sprites.LoadSpriteFromTexture(texture);
            }

            ShowMessage(title, message, style, sprite, time);
            _runningCoroutine = false;
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Shows a notification.
        /// </summary>
        /// <param name="title">Title.</param>
        /// <param name="text">Text.</param>
        /// <param name="type">Type.</param>
        /// <param name="style">Style.</param>
        /// <param name="size">Size.</param>
        public void ShowNotification(string title, string text, NotificationType type, NotificationStyle style, Size2D size)
        {
            GuiNotificationDialog notification = new GuiNotificationDialog
            {
                Title    = title,
                Text     = text,
                Type     = type,
                Style    = style,
                Location = new Point2D((ScreenManager.Instance.Size.Width - size.Width) / 2,
                                       (ScreenManager.Instance.Size.Height - size.Height) / 2),
                Size = size
            };

            notification.LoadContent();

            GuiManager.Instance.GuiElements.Add(notification);
        }