Exemple #1
0
        private ITexture GetIconTexture(BuffPaintInfo info)
        {
            uint textureId = 0;

            if (info.Rule != null)
            {
                if (info.Rule.UseLegendaryItemTexture != null)
                {
                    return(Hud.Texture.GetItemTexture(info.Rule.UseLegendaryItemTexture));
                }

                textureId = info.SnoPower.NormalIconTextureId;
                if (!info.Rule.UsePowersTexture && info.Icons[0].Exists && (info.Icons[0].TextureId != 0))
                {
                    textureId = info.Icons[0].TextureId;
                }
            }
            else
            {
                textureId = info.Icons[0].TextureId;
            }

            if (textureId <= 0)
            {
                return(null);
            }

            return(Hud.Texture.GetTexture(textureId));
        }
Exemple #2
0
        protected void Paint(BuffPaintInfo info, RectangleF rect)
        {
            var firstIcon = info.Icons[0];
            var isDebuff  = firstIcon.Harmful;

            if (info.BackgroundTexture != null)
            {
                info.BackgroundTexture.Draw(rect.X, rect.Y, rect.Width, rect.Height, Opacity);
            }

            info.Texture.Draw(rect.X, rect.Y, rect.Width, rect.Height, Opacity);

            DrawTimeLeftClock(rect, info.Elapsed, info.TimeLeft);

            if (HasIconBorder)
            {
                (isDebuff ? Hud.Texture.DebuffFrameTexture : Hud.Texture.BuffFrameTexture).Draw(rect.X, rect.Y, rect.Width, rect.Height, Opacity);
            }

            if (Hud.Window.CursorInsideRect(rect.X, rect.Y, rect.Width, rect.Height) && ShowTooltips)
            {
                if (info.Rule == null)
                {
                    var name = info.SnoPower.NameLocalized;
                    if (name == null)
                    {
                        foreach (var icon in info.Icons)
                        {
                            name += (name == null ? "" : "\n") + icon.TitleLocalized;
                        }
                    }

                    string desc = null;
                    foreach (var icon in info.Icons)
                    {
                        desc += (desc == null ? "\n\n" : "\n") + icon.DescriptionLocalized;
                    }
                    Hud.Render.SetHint(name + desc);
                }
                else
                {
                    if (firstIcon.Exists)
                    {
                        var name = (!info.Rule.DisableName ? (info.Rule.UsePowersName ? info.SnoPower.NameLocalized : firstIcon.TitleLocalized) : null);
                        var desc = (info.Rule.UsePowersDesc ? info.SnoPower.DescriptionLocalized : (firstIcon.DescriptionLocalized != null ? firstIcon.DescriptionLocalized : ""));
                        Hud.Render.SetHint(name + (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(desc) ? "\n\n" : "") + desc);
                    }
                }
            }

            DrawTimeLeftNumbers(rect, info);

            if (info.Stacks > -1)
            {
                DrawStacks(rect, info.Stacks);
            }
        }
Exemple #3
0
        private void DrawTimeLeftNumbers(RectangleF rect, BuffPaintInfo info)
        {
            if (info.TimeLeft == 0)
            {
                return;
            }
            if (!ShowTimeLeftNumbers)
            {
                return;
            }
            if (info.TimeLeftNumbersOverride != null && !info.TimeLeftNumbersOverride.Value)
            {
                return;
            }

            string text;

            if (info.TimeLeft > 1.0f)
            {
                var mins = Convert.ToInt32(Math.Floor(info.TimeLeft / 60.0d));
                var secs = Math.Floor(info.TimeLeft - (mins * 60.0d));
                text = info.TimeLeft >= 60
                    ? mins.ToString("F0", CultureInfo.InvariantCulture) + ":" + (secs < 10 ? "0" : "") + secs.ToString("F0", CultureInfo.InvariantCulture)
                    : info.TimeLeft.ToString("F0", CultureInfo.InvariantCulture);
            }
            else
            {
                text = info.TimeLeft.ToString("F1", CultureInfo.InvariantCulture);
            }

            var layout = TimeLeftFont.GetTextLayout(text);

            if (UseAlternateStyleWhenBuffIsAlmostGone != null && info.TimeLeft <= (info.Elapsed + info.TimeLeft) * UseAlternateStyleWhenBuffIsAlmostGone.Value)
            {
                AlmostGoneBorderBrush?.DrawRectangle(rect);
                AlmostGoneTimeLeftFont.DrawText(layout, rect.X + ((rect.Width - (float)Math.Ceiling(layout.Metrics.Width)) / 2.0f), rect.Y + ((rect.Height - layout.Metrics.Height) / 2));
            }
            else
            {
                TimeLeftFont.DrawText(layout, rect.X + ((rect.Width - (float)Math.Ceiling(layout.Metrics.Width)) / 2.0f), rect.Y + ((rect.Height - layout.Metrics.Height) / 2));
            }
        }
Exemple #4
0
        private void DrawTimeLeftNumbers(RectangleF rect, BuffPaintInfo info)
        {
            if (info.TimeLeft == 0)
            {
                return;
            }

            if (!ShowTimeLeftNumbers)
            {
                return;
            }
            if (info.TimeLeftNumbersOverride != null && info.TimeLeftNumbersOverride.Value == false)
            {
                return;
            }

            var text = "";

            if (info.TimeLeft > 1.0f)
            {
                var mins = Convert.ToInt32(Math.Floor(info.TimeLeft / 60.0d));
                var secs = Math.Floor(info.TimeLeft - mins * 60.0d);
                if (info.TimeLeft >= 60)
                {
                    text = mins.ToString("F0", CultureInfo.InvariantCulture) + ":" + (secs < 10 ? "0" : "") + secs.ToString("F0", CultureInfo.InvariantCulture);
                }
                else
                {
                    text = info.TimeLeft.ToString("F0", CultureInfo.InvariantCulture);
                }
            }
            else
            {
                text = info.TimeLeft.ToString("F1", CultureInfo.InvariantCulture);
            }

            var layout = TimeLeftFont.GetTextLayout(text);

            TimeLeftFont.DrawText(layout, rect.X + (rect.Width - (float)Math.Ceiling(layout.Metrics.Width)) / 2.0f, rect.Y + (rect.Height - layout.Metrics.Height) / 2);
        }
Exemple #5
0
        private void GetPaintInfo(IPlayer player, List <BuffPaintInfo> container, BuffRule rule, float iconSize)
        {
            var buff = player.Powers.GetBuff(rule.PowerSno);

            if (buff == null || !buff.Active)
            {
                return;
            }

            for (int iconIndex = 0; iconIndex < buff.TimeLeftSeconds.Length; iconIndex++)
            {
                var timeLeft = buff.TimeLeftSeconds[iconIndex];
                if (timeLeft < 0)
                {
                    timeLeft = 0;
                }

                if ((rule.IconIndex != null) && (iconIndex != rule.IconIndex.Value))
                {
                    continue;
                }
                if ((rule.NoIconIndex != null) && (iconIndex == rule.IconIndex.Value))
                {
                    continue;
                }
                if (buff.IconCounts[iconIndex] < rule.MinimumIconCount)
                {
                    continue;
                }

                var stacks = rule.ShowStacks ? buff.IconCounts[iconIndex] : -1;
                if (!rule.ShowTimeLeft)
                {
                    timeLeft = 0;
                }

                var icon = buff.SnoPower.Icons[iconIndex];

                if (!icon.MergesTooltip || !rule.AllowInGameMergeRules)
                {
                    var id = (buff.SnoPower.Sno << 32) + (uint)iconIndex;
                    if (container.Any(x => x.Id == id))
                    {
                        return;
                    }

                    var info = new BuffPaintInfo()
                    {
                        Id       = id,
                        SnoPower = buff.SnoPower,
                        Icons    = new List <SnoPowerIcon>()
                        {
                            icon
                        },
                        TimeLeft = timeLeft,
                        Elapsed  = buff.TimeElapsedSeconds[iconIndex],
                        Stacks   = stacks,
                        Rule     = rule,
                    };
                    if (info.Rule != null && info.Rule.UseLegendaryItemTexture != null)
                    {
                        if (info.Rule.UseLegendaryItemTexture.ItemHeight == 1)
                        {
                            info.BackgroundTexture = info.Rule.UseLegendaryItemTexture.SetItemBonusesSno == uint.MaxValue ? Hud.Texture.InventoryLegendaryBackgroundSmall : Hud.Texture.InventorySetBackgroundSmall;
                        }
                        else
                        {
                            info.BackgroundTexture = info.Rule.UseLegendaryItemTexture.SetItemBonusesSno == uint.MaxValue ? Hud.Texture.InventoryLegendaryBackgroundLarge : Hud.Texture.InventorySetBackgroundLarge;
                        }
                    }

                    info.Texture = GetIconTexture(info);
                    info.Size    = iconSize * rule.IconSizeMultiplier;
                    if (info.Texture != null)
                    {
                        container.Add(info);
                    }
                }
                else
                {
                    var id   = (buff.SnoPower.Sno << 32) + icon.MergesTooltipIndex;
                    var info = container.FirstOrDefault(x => x.Id == id);
                    if (info != null)
                    {
                        info.Icons.Add(icon);
                    }
                }
            }
        }