示例#1
0
 public static void OnFakeInput()
 {
     Notif.AddNotification("Command is invalid!", 500, true);
 }
示例#2
0
 public static void OnFailedModel()
 {
     Notif.AddNotification("Invalid model specified!", 500, true);
 }
示例#3
0
 public static void OnModelChanged(string NewModel)
 {
     Notif.AddNotification("New Model: " + NewModel, 500, true);
 }
示例#4
0
 public static void OnSkinChanged(string NewSkin)
 {
     Notif.AddNotification("New Skin: " + NewSkin, 500, true);
 }
示例#5
0
 public static void OnModLoaded(string Name)
 {
     Notif.AddNotification("EU - " + Name + " loaded!", 1000, true);
 }
示例#6
0
        /// <summary>
        ///     Called per game tick for update
        /// </summary>
        public void OnUpdate()
        {
            if (!Update)
            {
                return;
            }

            switch (state)
            {
            case NotificationState.Idle:
            {
                #region Duration End Handler

                if (!flashing && duration > 0x0 && TextColor.A == 0x0 && BoxColor.A == 0x0 && BorderColor.A == 0x0)
                {
                    Update = Draw = false;
                    if (autoDispose)
                    {
                        Dispose();
                    }

                    Notifications.Free(handler);

                    return;
                }

                #endregion

                #region Decreasement Tick

                if (!flashing && duration > 0x0 && Utils.TickCount - decreasementTick > 0x0)
                {
                    if (TextColor.A > 0x0)
                    {
                        TextColor.A--;
                    }
                    if (BoxColor.A > 0x0)
                    {
                        BoxColor.A--;
                    }
                    if (BorderColor.A > 0x0)
                    {
                        BorderColor.A--;
                    }

                    decreasementTick = GetNextDecreasementTick();
                }

                #endregion

                #region Flashing

                if (flashing)
                {
                    if (Utils.TickCount - flashTick > 0x0)
                    {
                        if (TextColor.A > 0x0 && BoxColor.A > 0x0 && BorderColor.A > 0x0)
                        {
                            if (duration > 0x0)
                            {
                                if (TextColor.A == 0x0 && BoxColor.A == 0x0 && BorderColor.A == 0x0)
                                {
                                    Update = Draw = false;
                                    if (autoDispose)
                                    {
                                        Dispose();
                                    }

                                    Notifications.Free(handler);

                                    return;
                                }
                            }

                            flashingBytes[0x0] = --TextColor.A;
                            flashingBytes[0x1] = --BoxColor.A;
                            flashingBytes[0x2] = --BorderColor.A;

                            TextColor.A   = 0x0;
                            BoxColor.A    = 0x0;
                            BorderColor.A = 0x0;
                        }
                        else
                        {
                            TextColor.A   = flashingBytes[0x0];
                            BoxColor.A    = flashingBytes[0x1];
                            BorderColor.A = flashingBytes[0x2];

                            if (TextColor.A > 0x0)
                            {
                                TextColor.A--;
                            }
                            if (BoxColor.A > 0x0)
                            {
                                BoxColor.A--;
                            }
                            if (BorderColor.A > 0x0)
                            {
                                BorderColor.A--;
                            }

                            if (duration > 0x0)
                            {
                                if (TextColor.A == 0x0 && BoxColor.A == 0x0 && BorderColor.A == 0x0)
                                {
                                    Update = Draw = false;
                                    if (autoDispose)
                                    {
                                        Dispose();
                                    }

                                    Notifications.Free(handler);

                                    return;
                                }
                            }
                        }
                        flashTick = Utils.TickCount + flashInterval;
                    }
                }

                #endregion

                #region Mouse

                var mouseLocation = Drawing.WorldToScreen(Game.CursorPos);
                if (Utils.IsUnderRectangle(mouseLocation, position.X, position.Y, line.Width, 25f))
                {
                    TextColor.A   = 0xFF;
                    BoxColor.A    = 0xFF;
                    BorderColor.A = 0xFF;

                    var textDimension = Font.MeasureText(sprite, Text);
                    if (textDimension.Width + 0x10 > line.Width)
                    {
                        var extra = textDimension.Width - 0xB4;
                        if (updatePosition == Vector2.Zero)
                        {
                            textFix        = new Vector2(position.X, position.Y);
                            updatePosition = new Vector2(position.X - extra, position.Y);
                        }
                        if (updatePosition != Vector2.Zero && position.X > updatePosition.X)
                        {
                            position.X -= 1f;
                            line.Width += 1f;
                        }
                    }
                }
                else if (updatePosition != Vector2.Zero)
                {
                    if (position.X < textFix.X)
                    {
                        position.X += 1f;
                        line.Width -= 1f;
                    }
                    else
                    {
                        textFix        = Vector2.Zero;
                        updatePosition = Vector2.Zero;
                    }
                }

                #endregion

                #region Movement

                var location = Notifications.GetLocation();
                if (location != -0x1 && position.Y > location)
                {
                    if (Notifications.IsFirst((int)position.Y))
                    {
                        handler = Notifications.Reserve(GetId(), handler);
                        if (handler != null)
                        {
                            if (updatePosition != Vector2.Zero && textFix != Vector2.Zero)
                            {
                                position.X = textFix.X;
                                textFix    = Vector2.Zero;
                                line.Width = 190f;
                            }

                            updatePosition = new Vector2(position.X, Notifications.GetLocation(handler));
                            state          = NotificationState.AnimationMove;
                        }
                    }
                }

                #endregion

                break;
            }

            case NotificationState.AnimationMove:
            {
                #region Movement

                if (Math.Abs(position.Y - updatePosition.Y) > float.Epsilon)
                {
                    var value = (updatePosition.Distance(new Vector2(position.X, position.Y - 0x1)) <
                                 updatePosition.Distance(new Vector2(position.X, position.Y + 0x1)))
                            ? -0x1
                            : 0x1;
                    position.Y += value;
                }
                else
                {
                    updatePosition = Vector2.Zero;
                    state          = NotificationState.Idle;
                }

                #endregion

                break;
            }

            case NotificationState.AnimationShowShrink:
            {
                #region Shrink

                if (Math.Abs(line.Width - 0xB9) < float.Epsilon)
                {
                    handler = Notifications.Reserve(GetId(), handler);
                    if (handler != null)
                    {
                        state          = NotificationState.AnimationShowMove;
                        updatePosition = new Vector2(position.X, Notifications.GetLocation(handler));
                    }
                    return;
                }
                line.Width--;
                position.X++;

                #endregion

                break;
            }

            case NotificationState.AnimationShowMove:
            {
                #region Movement

                if (Math.Abs(Notifications.GetLocation() + 0x1E - updatePosition.Y) < float.Epsilon)
                {
                    updatePosition.Y = Notifications.GetLocation();
                }

                if (Math.Abs(position.Y - updatePosition.Y) > float.Epsilon)
                {
                    var value = (updatePosition.Distance(new Vector2(position.X, position.Y - 0.5f)) <
                                 updatePosition.Distance(new Vector2(position.X, position.Y + 0.5f)))
                            ? -0.5f
                            : 0.5f;
                    position.Y += value;
                }
                else
                {
                    updatePosition = Vector2.Zero;
                    state          = NotificationState.AnimationShowGrow;
                }

                #endregion

                break;
            }

            case NotificationState.AnimationShowGrow:
            {
                #region Growth

                if (Math.Abs(line.Width - 0xBE) < float.Epsilon)
                {
                    state = NotificationState.Idle;
                    return;
                }
                line.Width++;
                position.X--;

                #endregion

                break;
            }
            }
        }
示例#7
0
        /// <summary>
        ///     Called per game tick for update
        /// </summary>
        public void OnUpdate()
        {
            if (!this.Update)
            {
                return;
            }

            switch (this.state)
            {
            case NotificationState.Idle:
            {
                #region Duration End Handler

                if (!this.flashing && this.duration > 0x0 && this.TextColor.A == 0x0 && this.BoxColor.A == 0x0 &&
                    this.BorderColor.A == 0x0)
                {
                    this.Update = this.Draw = false;
                    if (this.autoDispose)
                    {
                        this.Dispose();
                    }

                    Notifications.RemoveNotification(this);

                    return;
                }

                #endregion

                #region Decreasement Tick

                var t = Math.Max(0, this.startT + this.duration - Utils.GameTimeTickCount + 500);
                if (!this.flashing && this.duration > 0x0 && t < 500)
                {
                    var alpha = (byte)(255 * ((float)t / 500));
                    this.TextColor.A   = alpha;
                    this.BoxColor.A    = alpha;
                    this.BorderColor.A = alpha;
                }

                #endregion

                #region Flashing

                if (this.flashing)
                {
                    if (Utils.TickCount - this.flashTick > 0x0)
                    {
                        if (this.TextColor.A > 0x0 && this.BoxColor.A > 0x0 && this.BorderColor.A > 0x0)
                        {
                            if (this.duration > 0x0)
                            {
                                if (this.TextColor.A == 0x0 && this.BoxColor.A == 0x0 &&
                                    this.BorderColor.A == 0x0)
                                {
                                    this.Update = this.Draw = false;
                                    if (this.autoDispose)
                                    {
                                        this.Dispose();
                                    }

                                    Notifications.RemoveNotification(this);

                                    return;
                                }
                            }

                            this.flashingBytes[0x0] = --this.TextColor.A;
                            this.flashingBytes[0x1] = --this.BoxColor.A;
                            this.flashingBytes[0x2] = --this.BorderColor.A;

                            this.TextColor.A   = 0x0;
                            this.BoxColor.A    = 0x0;
                            this.BorderColor.A = 0x0;
                        }
                        else
                        {
                            this.TextColor.A   = this.flashingBytes[0x0];
                            this.BoxColor.A    = this.flashingBytes[0x1];
                            this.BorderColor.A = this.flashingBytes[0x2];

                            if (this.TextColor.A > 0x0)
                            {
                                this.TextColor.A--;
                            }
                            if (this.BoxColor.A > 0x0)
                            {
                                this.BoxColor.A--;
                            }
                            if (this.BorderColor.A > 0x0)
                            {
                                this.BorderColor.A--;
                            }

                            if (this.duration > 0x0)
                            {
                                if (this.TextColor.A == 0x0 && this.BoxColor.A == 0x0 &&
                                    this.BorderColor.A == 0x0)
                                {
                                    this.Update = this.Draw = false;
                                    if (this.autoDispose)
                                    {
                                        this.Dispose();
                                    }

                                    Notifications.RemoveNotification(this);

                                    return;
                                }
                            }
                        }
                        this.flashTick = Utils.TickCount + this.flashInterval;
                    }
                }

                #endregion

                #region Mouse

                var mouseLocation = Drawing.WorldToScreen(Game.CursorPos);
                if (Utils.IsUnderRectangle(
                        mouseLocation,
                        this.position.X,
                        this.position.Y,
                        this.line.Width,
                        25f))
                {
                    this.TextColor.A   = 0xFF;
                    this.BoxColor.A    = 0xFF;
                    this.BorderColor.A = 0xFF;

                    var textDimension = this.Font.MeasureText(this.sprite, this.Text);
                    if (textDimension.Width + 0x10 > this.line.Width)
                    {
                        var extra = textDimension.Width - 0xB4;
                        if (this.updatePosition == Vector2.Zero)
                        {
                            this.textFix        = new Vector2(this.position.X, this.position.Y);
                            this.updatePosition = new Vector2(this.position.X - extra, this.position.Y);
                        }
                        if (this.updatePosition != Vector2.Zero && this.position.X > this.updatePosition.X)
                        {
                            this.position.X -= 1f;
                            this.line.Width += 1f;
                        }
                    }
                }
                else if (this.updatePosition != Vector2.Zero)
                {
                    if (this.position.X < this.textFix.X)
                    {
                        this.position.X += 1f;
                        this.line.Width -= 1f;
                    }
                    else
                    {
                        this.textFix        = Vector2.Zero;
                        this.updatePosition = Vector2.Zero;
                    }
                }

                #endregion

                #region Movement

                var location = Notifications.GetLocation();
                if (location != -0x1 && this.position.Y > location)
                {
                    if (this.updatePosition != Vector2.Zero && this.textFix != Vector2.Zero)
                    {
                        this.position.X = this.textFix.X;
                        this.textFix    = Vector2.Zero;
                        this.line.Width = 190f;
                    }

                    this.updatePosition    = new Vector2(this.position.X, Notifications.GetLocation(this));
                    this.state             = NotificationState.AnimationMove;
                    this.moveStartT        = Utils.GameTimeTickCount;
                    this.moveStartPosition = this.position;
                }

                #endregion

                break;
            }

            case NotificationState.AnimationMove:
            {
                #region Movement

                if (Math.Abs(this.position.Y - this.updatePosition.Y) > float.Epsilon)
                {
                    var percentT = Math.Min(1, ((float)Utils.GameTimeTickCount - this.moveStartT) / 500);

                    this.position.Y = this.moveStartPosition.Y
                                      + (this.updatePosition.Y - this.moveStartPosition.Y) * percentT;
                }
                else
                {
                    this.updatePosition = Vector2.Zero;
                    this.state          = NotificationState.Idle;
                }

                #endregion

                break;
            }

            case NotificationState.AnimationShowShrink:
            {
                #region Shrink

                if (Math.Abs(this.line.Width - 0xB9) < float.Epsilon)
                {
                    this.state          = NotificationState.AnimationShowMove;
                    this.updatePosition = new Vector2(this.position.X, Notifications.GetLocation(this));
                    return;
                }
                this.line.Width--;
                this.position.X++;

                #endregion

                break;
            }

            case NotificationState.AnimationShowMove:
            {
                #region Movement

                if (Math.Abs(Notifications.GetLocation() + 0x1E - this.updatePosition.Y) < float.Epsilon)
                {
                    this.updatePosition.Y = Notifications.GetLocation();
                }

                if (Math.Abs(this.position.Y - this.updatePosition.Y) > float.Epsilon)
                {
                    var value =
                        (this.updatePosition.Distance(new Vector2(this.position.X, this.position.Y - 0.5f))
                         < this.updatePosition.Distance(new Vector2(this.position.X, this.position.Y + 0.5f)))
                                    ? -0.5f
                                    : 0.5f;
                    this.position.Y += value;
                }
                else
                {
                    this.updatePosition = Vector2.Zero;
                    this.state          = NotificationState.AnimationShowGrow;
                }

                #endregion

                break;
            }

            case NotificationState.AnimationShowGrow:
            {
                #region Growth

                if (Math.Abs(this.line.Width - 0xBE) < float.Epsilon)
                {
                    this.state = NotificationState.Idle;
                    return;
                }
                this.line.Width++;
                this.position.X--;

                #endregion

                break;
            }
            }
        }