Beispiel #1
0
 public override void DrawAt(RenderingContext rc, Vec2 point, Rect rect)
 {
     float xD = ((float)(SpriteSize.X)) / SpriteSize.X;
     float yD = ((float)(SpriteSize.Y)) / SpriteSize.Y;
     RectUV uvRect = new RectUV(xD * ChosenImage.X, yD * ChosenImage.Y, xD * (ChosenImage.X + 1), yD * (ChosenImage.Y + 1));
     rc.AddSprite(this.TextureFile, rect, uvRect, TintColor);
 }
Beispiel #2
0
        public override void Render(RenderingContext rc)
        {
            if (!Settings.GetBool("ItemAlert") || !Settings.GetBool("ItemAlert.ShowText"))
            {
                return;
            }
            Rect clientRect = this.poe.Internal.game.IngameState.IngameUi.Minimap.SmallMinimap.GetClientRect();
            Vec2 rightTopAnchor = new Vec2(clientRect.X + clientRect.W, clientRect.Y + clientRect.H + 5);

            int y = rightTopAnchor.Y;
            int fontSize = Settings.GetInt("ItemAlert.ShowText.FontSize");

            foreach (KeyValuePair<ExileBot.Entity, AlertDrawStyle> kv in this.currentAlerts)
            {
                if (!kv.Key.IsValid) continue;

                string text = GetItemName(kv);
                if( null == text ) continue;

                AlertDrawStyle drawStyle = kv.Value;
                int frameWidth = drawStyle.FrameWidth;
                Vec2 vPadding = new Vec2(frameWidth + 5, frameWidth);
                int frameMargin = frameWidth + 2;

                Vec2 textPos = new Vec2(rightTopAnchor.X - vPadding.X, y + vPadding.Y);

                var vTextFrame = rc.AddTextWithHeight(textPos, text, drawStyle.color, fontSize, DrawTextFormat.Right);
                int iconSize = vTextFrame.Y;
                bool hasIcon = drawStyle.IconIndex >= 0;

                int maxHeight = vTextFrame.Y + 2*vPadding.Y + frameMargin;
                int maxWidth = vTextFrame.X + 2 * vPadding.X + (hasIcon ? iconSize : 0);
                rc.AddBox(new Rect(rightTopAnchor.X - maxWidth, y, maxWidth, maxHeight), Color.FromArgb(180, 0, 0, 0));

                if (hasIcon)
                {
                    const float iconsInSprite = 4;

                    Rect iconPos = new Rect(textPos.X - iconSize - vTextFrame.X, textPos.Y, iconSize, iconSize);
                    RectUV uv = new RectUV(drawStyle.IconIndex / iconsInSprite, 0, (drawStyle.IconIndex + 1) / iconsInSprite, 1);
                    rc.AddSprite("item_icons.png", iconPos, uv);
                }
                if( frameWidth > 0) {
                    Rect frame = new Rect(rightTopAnchor.X - vTextFrame.X - 2*vPadding.X, y, vTextFrame.X + 2*vPadding.X, vTextFrame.Y + 2*vPadding.Y);
                    rc.AddFrame(frame, kv.Value.color, frameWidth);
                }
                y += vTextFrame.Y + 2 * vPadding.Y + frameMargin;
            }
        }
Beispiel #3
0
 public void AddSprite(string file, Rect rect, RectUV uv, Color color)
 {
     this.texrenderer.DrawSprite(file, rect, uv, color);
 }
Beispiel #4
0
        private static Vec2 drawItem(RenderingContext rc, AlertDrawStyle drawStyle, Vec2 delta, int x, int y, Vec2 vPadding, string text,
			int fontSize)
        {
            // collapse padding when there's a frame
            vPadding.X -= drawStyle.FrameWidth;
            vPadding.Y -= drawStyle.FrameWidth;
            // item will appear to have equal size

            double phi;
            var distance = delta.GetPolarCoordinates(out phi);

            //text = text + " @ " + (int)distance + " : " + (int)(phi / Math.PI * 180)  + " : " + xSprite;

            int compassOffset = fontSize + 8;
            Vec2 textPos = new Vec2(x - vPadding.X - compassOffset, y + vPadding.Y);
            Vec2 vTextSize = rc.AddTextWithHeight(textPos, text, drawStyle.color, fontSize, DrawTextFormat.Right);

            int iconSize =  drawStyle.IconIndex >= 0 ? vTextSize.Y : 0;

            int fullHeight = vTextSize.Y + 2 * vPadding.Y + 2 * drawStyle.FrameWidth;
            int fullWidth = vTextSize.X + 2 * vPadding.X + iconSize + 2 * drawStyle.FrameWidth + compassOffset;
            rc.AddBox(new Rect(x - fullWidth, y, fullWidth - compassOffset, fullHeight), Color.FromArgb(180, 0, 0, 0));

            var rectUV = GetDirectionsUv(phi, distance);
            rc.AddSprite("directions.png", new Rect(x - vPadding.X - compassOffset + 6, y + vPadding.Y, vTextSize.Y, vTextSize.Y), rectUV);

            if (iconSize > 0)
            {
                const float iconsInSprite = 6;

                Rect iconPos = new Rect(textPos.X - iconSize - vTextSize.X, textPos.Y, iconSize, iconSize);
                RectUV uv = new RectUV(drawStyle.IconIndex/iconsInSprite, 0, (drawStyle.IconIndex + 1)/iconsInSprite, 1);
                rc.AddSprite("item_icons.png", iconPos, uv);
            }
            if (drawStyle.FrameWidth > 0)
            {
                Rect frame = new Rect(x - fullWidth, y, fullWidth - compassOffset , fullHeight);
                rc.AddFrame(frame, drawStyle.color, drawStyle.FrameWidth);
            }
            return new Vec2(fullWidth, fullHeight);
        }
Beispiel #5
0
 // could not fing a better place yet
 protected static RectUV GetDirectionsUv(double phi, double distance)
 {
     phi += Math.PI * 0.25; // fix roration due to projection
     if (phi > 2 * Math.PI)
         phi -= 2 * Math.PI;
     float xSprite = (float)Math.Round(phi / Math.PI * 4);
     if (xSprite >= 8) xSprite = 0;
     float ySprite = distance > 60 ? distance > 120 ? 2 : 1 : 0;
     var rectUV = new RectUV(xSprite / 8, ySprite / 3, (xSprite + 1) / 8, (ySprite + 1) / 3);
     return rectUV;
 }