Exemplo n.º 1
0
        private Vector2 DrawMod(ModValue item, Vector2 position)
        {
            const float EPSILON = 0.001f;
            const int   MARGIN_BOTTOM = 4, MARGIN_LEFT = 50;

            Vector2          oldPosition = position;
            ItemModsSettings settings    = Settings.ItemMods;

            string prefix = item.AffixType == ModsDat.ModType.Prefix
                ? "[P]"
                : item.AffixType == ModsDat.ModType.Suffix ? "[S]" : "[?]";

            if (item.AffixType != ModsDat.ModType.Hidden)
            {
                if (item.CouldHaveTiers())
                {
                    prefix += string.Format(" T{0} ", item.Tier);
                }

                Graphics.DrawText(prefix, settings.ModTextSize, position.Translate(5 - MARGIN_LEFT, 0));
                Size2 textSize = Graphics.DrawText(item.AffixText, settings.ModTextSize, position, item.Color);
                if (textSize != new Size2())
                {
                    position.Y += textSize.Height;
                }
            }

            for (int i = 0; i < 4; i++)
            {
                IntRange range = item.Record.StatRange[i];
                if (range.Min == 0 && range.Max == 0)
                {
                    continue;
                }

                StatsDat.StatRecord stat = item.Record.StatNames[i];
                int value = item.StatValue[i];
                if (value <= -1000 || stat == null)
                {
                    continue;
                }
                float  percents = range.GetPercentage(value);
                bool   noSpread = !range.HasSpread();
                double hue      = percents > 1 ? 180 : 120 * percents;
                if (noSpread)
                {
                    hue = 300;
                }

                string line2 = string.Format(noSpread ? "{0}" : "{0} [{1}]", stat, range);
                Graphics.DrawText(line2, settings.ModTextSize, position, Color.White);

                string  statText     = stat.ValueToString(value);
                Vector2 statPosition = position.Translate(-5, 0);
                Color   statColor    = ColorUtils.ColorFromHsv(hue, 1, 1);
                Size2   txSize       = Graphics.DrawText(statText, settings.ModTextSize, statPosition, statColor, FontDrawFlags.Right);
                position.Y += txSize.Height;
            }
            return(Math.Abs(position.Y - oldPosition.Y) > EPSILON?position.Translate(0, MARGIN_BOTTOM) : oldPosition);
        }
Exemplo n.º 2
0
        private static int drawStatLine(RenderingContext rc, RollValue item, Rect clientRect, int yPos)
        {
            const int leftRuler = 50;

            bool   isUniqAffix = item.AffixType == ModsDat.ModType.Hidden;
            string prefix      = item.AffixType == ModsDat.ModType.Prefix
            ? "[P]"
            : item.AffixType == ModsDat.ModType.Suffix ? "[S]" : "[?]";

            if (!isUniqAffix)
            {
                if (item.CouldHaveTiers())
                {
                    prefix += " T" + item.Tier + " ";
                }
                rc.AddTextWithHeight(new Vec2(clientRect.X + 5, yPos), prefix, item.TextColor, 8, DrawTextFormat.Left);
                var textSize = rc.AddTextWithHeight(new Vec2(clientRect.X + leftRuler, yPos), item.AffixText, item.TextColor, 8,
                                                    DrawTextFormat.Left);
                yPos += textSize.Y;
            }

            for (int iStat = 0; iStat < 4; iStat++)
            {
                IntRange range = item.TheMod.StatRange[iStat];
                if (range.Min == 0 && range.Max == 0)
                {
                    continue;
                }

                var theStat = item.TheMod.StatNames[iStat];
                if (theStat != null)
                {
                    int   val      = item.StatValue[iStat];
                    float percents = range.GetPercentage(val);
                    bool  noSpread = !range.HasSpread();

                    double hue = 120 * percents;
                    if (noSpread)
                    {
                        hue = 300;
                    }
                    if (percents > 1)
                    {
                        hue = 180;
                    }

                    Color col = ColorUtils.ColorFromHsv(hue, 1, 1);

                    string line2 = string.Format(noSpread ? "{0}" : "{0} [{1}]", theStat, range);

                    rc.AddTextWithHeight(new Vec2(clientRect.X + leftRuler, yPos), line2, Color.White, 8, DrawTextFormat.Left);

                    string sValue = theStat.ValueToString(val);
                    var    txSize = rc.AddTextWithHeight(new Vec2(clientRect.X + leftRuler - 5, yPos), sValue,
                                                         col, 8,
                                                         DrawTextFormat.Right);
                    yPos += txSize.Y;
                }
            }
            return(yPos);
        }
Exemplo n.º 3
0
        private Vector2 DrawMod(ModValue item, Vector2 position)
        {
            const float EPSILON = 0.001f;
            const int   MARGIN_BOTTOM = 4, MARGIN_LEFT = 50;

            Vector2          oldPosition = position;
            ItemModsSettings settings    = Settings.ItemMods;

            string affix = item.AffixType == ModsDat.ModType.Prefix ? "[P]"
                : item.AffixType == ModsDat.ModType.Suffix ? "[S]" : "[?]";

            Dictionary <int, Color> TColors = new Dictionary <int, Color>
            {
                { 1, settings.T1Color },
                { 2, settings.T2Color },
                { 3, settings.T3Color }
            };

            if (item.AffixType != ModsDat.ModType.Hidden)
            {
                if (item.CouldHaveTiers())
                {
                    affix += $" T{item.Tier} ";
                }

                if (item.AffixType == ModsDat.ModType.Prefix)
                {
                    Graphics.DrawText(affix, settings.ModTextSize, position.Translate(5 - MARGIN_LEFT, 0), settings.PrefixColor);
                    if (!TColors.TryGetValue(item.Tier, out TColor))
                    {
                        TColor = settings.PrefixColor;
                    }
                }

                if (item.AffixType == ModsDat.ModType.Suffix)
                {
                    Graphics.DrawText(affix, settings.ModTextSize, position.Translate(5 - MARGIN_LEFT, 0), settings.SuffixColor);
                    if (!TColors.TryGetValue(item.Tier, out TColor))
                    {
                        TColor = settings.SuffixColor;
                    }
                }
                Size2 textSize = Graphics.DrawText(item.AffixText, settings.ModTextSize, position, TColor);
                if (textSize != new Size2())
                {
                    position.Y += textSize.Height;
                }
            }

            for (int i = 0; i < 4; i++)
            {
                IntRange range = item.Record.StatRange[i];
                if (range.Min == 0 && range.Max == 0)
                {
                    continue;
                }
                StatsDat.StatRecord stat = item.Record.StatNames[i];
                int value = item.StatValue[i];
                if (value <= -1000 || stat == null)
                {
                    continue;
                }
                bool   noSpread = !range.HasSpread();
                string line2    = string.Format(noSpread ? "{0}" : "{0} [{1}]", stat, range);
                Graphics.DrawText(line2, settings.ModTextSize, position, Color.Gainsboro);
                string  statText     = stat.ValueToString(value);
                Vector2 statPosition = position.Translate(-5, 0);
                Size2   txSize       = Graphics.DrawText(statText, settings.ModTextSize, statPosition, Color.Gainsboro, FontDrawFlags.Right);
                position.Y += txSize.Height;
            }
            return(Math.Abs(position.Y - oldPosition.Y) > EPSILON?position.Translate(0, MARGIN_BOTTOM) : oldPosition);
        }