Esempio n. 1
0
        private static Vec2 drawItem(RenderingContext rc, AlertDrawStyle drawStyle, 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

            Vec2 textPos   = new Vec2(x - vPadding.X, 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;

            rc.AddBox(new Rect(x - fullWidth, y, fullWidth, fullHeight), Color.FromArgb(180, 0, 0, 0));

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

                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, fullHeight);
                rc.AddFrame(frame, drawStyle.color, drawStyle.FrameWidth);
            }
            return(new Vec2(fullWidth, fullHeight));
        }
Esempio n. 2
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);
        }
Esempio n. 3
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;
            }
        }
Esempio n. 4
0
 public void DrawSprite(Texture texture, Rect rect, RectUV uvCoords, Color color)
 {
     ColoredTexturedVertex[] data =
     {
         new ColoredTexturedVertex(rect.X,          rect.Y,          uvCoords.U1, uvCoords.V1, color),
         new ColoredTexturedVertex(rect.X + rect.W, rect.Y,          uvCoords.U2, uvCoords.V1, color),
         new ColoredTexturedVertex(rect.X + rect.W, rect.Y + rect.H, uvCoords.U2, uvCoords.V2, color),
         new ColoredTexturedVertex(rect.X,          rect.Y + rect.H, uvCoords.U1, uvCoords.V2, color)
     };
     dx.SetTexture(0, texture);
     SendVerticesToDevice(data, 2, PrimitiveType.TriangleFan, ColoredTexturedVertex.VertexElements);
 }
Esempio n. 5
0
        public override void Render(RenderingContext rc, Dictionary <UiMountPoint, Vec2> mountPoints)
        {
            if (!Settings.ShowText)
            {
                return;
            }
            Rect rect          = model.Window.ClientRect();
            int  xScreenCenter = rect.W / 2 + rect.X;
            int  yPos          = rect.H / 5 + rect.Y;

            var  playerPos      = model.Player.GetComponent <Positioned>().GridPos;
            int  fontSize       = Settings.TextFontSize;
            bool first          = true;
            Rect rectBackground = new Rect();

            foreach (var alert in alertTexts)
            {
                if (!alert.Key.IsAlive)
                {
                    continue;
                }

                Vec2   delta = alert.Key.GetComponent <Positioned>().GridPos - playerPos;
                double phi;
                var    distance = delta.GetPolarCoordinates(out phi);
                RectUV uv       = GetDirectionsUv(phi, distance);

                Vec2 textSize = rc.AddTextWithHeight(new Vec2(xScreenCenter, yPos), alert.Value, Color.Red, fontSize, DrawTextFormat.Center);

                rectBackground    = new Rect(xScreenCenter - textSize.X / 2 - 6, yPos, textSize.X + 12, textSize.Y);
                rectBackground.X -= textSize.Y + 3;
                rectBackground.W += textSize.Y;

                Rect rectDirection = new Rect(rectBackground.X + 3, rectBackground.Y, rectBackground.H, rectBackground.H);

                if (first)                 // vertical padding above
                {
                    rectBackground.Y -= 5;
                    rectBackground.H += 5;
                    first             = false;
                }
                rc.AddBox(rectBackground, Color.FromArgb(Settings.TextBgAlpha, 1, 1, 1));
                rc.AddSprite("directions.png", rectDirection, uv, Color.Red);
                yPos += textSize.Y;
            }
            if (!first)              // vertical padding below
            {
                rectBackground.Y = rectBackground.Y + rectBackground.H;
                rectBackground.H = 5;
                rc.AddBox(rectBackground, Color.FromArgb(Settings.TextBgAlpha, 1, 1, 1));
            }
        }
Esempio n. 6
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);
        }
Esempio n. 7
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));
        }
Esempio n. 8
0
        public override void Render(RenderingContext rc, Dictionary <UiMountPoint, Vec2> mountPoints)
        {
            if (!Settings.ShowText || !alertsText.Any())
            {
                return;
            }

            Rect rect          = model.Window.ClientRect();
            int  xScreenCenter = rect.W / 2 + rect.X;
            int  yPos          = rect.H * Settings.YPosition / 100 + rect.Y;

            var  playerPos      = model.Player.GetComponent <Positioned>().GridPos;
            int  fontSize       = Settings.TextFontSize;
            bool first          = true;
            Rect rectBackground = new Rect();

            foreach (var alert in alertsText)
            {
                int cntAlive = alert.Value.Count(c => c.IsAlive);
                if (cntAlive == 0)
                {
                    continue;
                }

                Vec2 textSize = rc.MeasureString(alert.Key, fontSize, DrawTextFormat.Center);

                int iconSize = 3 + textSize.Y;

                int xPos = xScreenCenter - textSize.X / 2 - 6;
                rc.AddTextWithHeight(new Vec2(xPos + 6, yPos), alert.Key, Color.Red, fontSize, DrawTextFormat.Left);


                int cntArrows = 1;
                rectBackground = new Rect(xPos - cntAlive * iconSize, yPos, textSize.X + 12 + cntAlive * iconSize, textSize.Y);
                if (first)                 // vertical padding above
                {
                    if (!Settings.StackUp)
                    {
                        rectBackground.Y -= 5;
                    }
                    rectBackground.H += 5;
                    first             = false;
                }
                rc.AddBox(rectBackground, Color.FromArgb(Settings.TextBgAlpha, 1, 1, 1));

                foreach (EntityWrapper mob in alert.Value)
                {
                    if (!mob.IsAlive)
                    {
                        continue;
                    }
                    Vec2   delta = mob.GetComponent <Positioned>().GridPos - playerPos;
                    double phi;
                    double distance = delta.GetPolarCoordinates(out phi);
                    RectUV uv       = GetDirectionsUv(phi, distance);

                    Rect rectDirection = new Rect(xPos - cntArrows * iconSize, yPos, rectBackground.H, rectBackground.H);
                    cntArrows++;
                    rc.AddSprite("directions.png", rectDirection, uv, Color.Red);
                }



                yPos += Settings.StackUp ? -textSize.Y : textSize.Y;
            }

            if (!first)              // vertical padding below
            {
                rectBackground.Y = rectBackground.Y + (Settings.StackUp ? -rectBackground.H - 5: rectBackground.H);
                rectBackground.H = 5;
                rc.AddBox(rectBackground, Color.FromArgb(Settings.TextBgAlpha, 1, 1, 1));
            }
        }
Esempio n. 9
0
 public bool Equals(RectUV other)
 {
     return U1.Equals(other.U1) && V1.Equals(other.V1) && U2.Equals(other.U2) && V2.Equals(other.V2);
 }
Esempio n. 10
0
 public RectUV(float w, float h)
 {
     this = new RectUV(0, 0, w, h);
 }
Esempio n. 11
0
 public void AddSprite(string file, Rect rect, RectUV uv, Color color)
 {
     this.texrenderer.DrawSprite(file, rect, uv, color);
 }
Esempio n. 12
0
 public void DrawSprite(Texture texture, Rect rect, RectUV uvCoords)
 {
     DrawSprite(texture, rect, uvCoords, Color.White);
 }
Esempio n. 13
0
 public void DrawSprite(string fileName, Rect rect, RectUV uvCoords, Color color)
 {
     DrawSprite(GetTextureFrom(fileName), rect, uvCoords, color);
 }
Esempio n. 14
0
 public bool Equals(RectUV other)
 {
     return(U1.Equals(other.U1) && V1.Equals(other.V1) && U2.Equals(other.U2) && V2.Equals(other.V2));
 }
Esempio n. 15
0
 public RectUV(float w, float h)
 {
     this = new RectUV(0, 0, w, h);
 }