Beispiel #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);
        }
        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);
        }