Пример #1
0
        private void PrepareForDrawingAndPlaySound(Entity entity, AlertDrawStyle drawStyle)
        {
            ItemIcon icon;

            if (Settings.UseDiamond)
            {
                icon = new ItemIcon(
                    entity,
                    new HudTexture("Icons.png")
                {
                    Color = Settings.LootIconBorderColor ? drawStyle.BackgroundColor : drawStyle.TextColor,
                    UV    = SpriteHelper.GetUV(MapIconsIndex.LootFilterLargeCyanStar)
                }, () => Settings.ShowItemOnMap, GameController, Settings);
            }
            else
            {
                icon = new ItemIcon(
                    entity,
                    new HudTexture("currency.png")
                {
                    Color = Settings.LootIconBorderColor ? drawStyle.BackgroundColor : drawStyle.TextColor
                },
                    () => Settings.ShowItemOnMap, GameController, Settings);
            }

            entity.SetHudComponent <BaseIcon>(icon);

            if (Settings.WithSound)
            {
                GameController.SoundController.PlaySound("alert");
            }
        }
Пример #2
0
        private Vector2 DrawItem(AlertDrawStyle drawStyle, Vector2 delta, Vector2 position, Vector2 padding, string text)
        {
            padding.X -= drawStyle.BorderWidth;
            padding.Y -= drawStyle.BorderWidth;
            double phi;
            var    distance      = delta.GetPolarCoordinates(out phi);
            float  compassOffset = Settings.TextSize + 8;
            var    textPos       = position.Translate(-padding.X - compassOffset, padding.Y);
            var    textSize      = Graphics.DrawText(text, textPos, drawStyle.TextColor, FontAlign.Right);
            var    iconSize      = drawStyle.IconIndex >= 0 ? textSize.Y : 0;
            var    fullHeight    = textSize.Y + 2 * padding.Y + 2 * drawStyle.BorderWidth;
            var    fullWidth     = textSize.X + 2 * padding.X + iconSize + 2 * drawStyle.BorderWidth + compassOffset;
            var    boxRect       = new RectangleF(position.X - fullWidth, position.Y, fullWidth - compassOffset, fullHeight);

            Graphics.DrawBox(boxRect, drawStyle.BackgroundColor);
            var rectUV     = MathHepler.GetDirectionsUV(phi, distance);
            var rectangleF = new RectangleF(position.X - padding.X - compassOffset + 6, position.Y + padding.Y, textSize.Y, textSize.Y);

            Graphics.DrawImage("directions.png", rectangleF, rectUV);

            if (iconSize > 0)
            {
                const float ICONS_IN_SPRITE = 4;
                var         iconX           = drawStyle.IconIndex / ICONS_IN_SPRITE;
                var         topLeft         = new System.Numerics.Vector2(textPos.X - iconSize - textSize.X, textPos.Y);
                var         topLeftUv       = new System.Numerics.Vector2(iconX, 0);

                Graphics.DrawImageGui("item_icons.png", topLeft, topLeft.Translate(iconSize, iconSize), topLeftUv,
                                      topLeftUv.Translate((drawStyle.IconIndex + 1) / ICONS_IN_SPRITE - iconX, 1));
            }

            if (drawStyle.BorderWidth > 0)
            {
                Graphics.DrawFrame(boxRect, drawStyle.BorderColor, drawStyle.BorderWidth);
            }

            return(new Vector2(fullWidth, fullHeight));
        }
Пример #3
0
        private Vector2 DrawText(Vector2 playerPos, Vector2 position, int BOTTOM_MARGIN, AlertDrawStyle kv, Entity entity)
        {
            var padding    = new Vector2(5, 2);
            var positioned = entity.GetComponent <Positioned>();

            if (positioned == null)
            {
                return(position);
            }
            var delta    = positioned.GridPos - playerPos;
            var itemSize = DrawItem(kv, delta, position, padding, kv.Text);

            if (itemSize != new Vector2())
            {
                position.Y += itemSize.Y + BOTTOM_MARGIN;
            }

            return(position);
        }
Пример #4
0
        public override void Render()
        {
            var playerPos = GameController.Player.GridPos;
            var position  = GameController.UnderPanel.StartDrawPoint;

            foreach (var entity in GameController.EntityListWrapper.ValidEntitiesByType[EntityType.WorldItem])
            {
                var alertDrawStyle = entity.GetHudComponent <AlertDrawStyle>();
                if (alertDrawStyle?.Text == null)
                {
                    continue;
                }

                if (!currentLabels.TryGetValue(entity.Address, out var entityLabel))
                {
                    shouldUpdate = true;
                    continue;
                }

                if (!Settings.ShowText)
                {
                    continue;
                }

                if (Settings.HideOthers)
                {
                    if (entityLabel.CanPickUp || entityLabel.MaxTimeForPickUp.TotalSeconds == 0)
                    {
                        position = DrawText(playerPos, position, BOTTOM_MARGIN, alertDrawStyle, entity);
                    }
                }
                else
                {
                    if (entityLabel.CanPickUp || entityLabel.MaxTimeForPickUp.TotalSeconds == 0)
                    {
                        position = DrawText(playerPos, position, BOTTOM_MARGIN, alertDrawStyle, entity);
                    }
                    else
                    {
                        // get current values
                        var TextColor       = alertDrawStyle.TextColor;
                        var BorderColor     = alertDrawStyle.BorderColor;
                        var BackgroundColor = alertDrawStyle.BackgroundColor;

                        if (Settings.DimOtherByPercentToggle)
                        {
                            // edit values to new ones
                            var ReduceByPercent = (double)Settings.DimOtherByPercent / 100;
                            TextColor       = ReduceNumbers(TextColor, ReduceByPercent);
                            BorderColor     = ReduceNumbers(BorderColor, ReduceByPercent);
                            BackgroundColor = ReduceNumbers(BackgroundColor, ReduceByPercent);

                            // backgrounds with low alpha start to look a little strange when dark so im adding an alpha threshold
                            if (BackgroundColor.A < 210)
                            {
                                BackgroundColor.A = 210;
                            }
                        }

                        // Complete new KeyValuePair with new stuff
                        var ModifiedDrawStyle = new AlertDrawStyle(alertDrawStyle.Text, TextColor, alertDrawStyle.BorderWidth, BorderColor,
                                                                   BackgroundColor, alertDrawStyle.IconIndex);

                        position = DrawText(playerPos, position, BOTTOM_MARGIN, ModifiedDrawStyle, entity);
                    }
                }
            }
        }