当前位置: 首页>>代码示例>>C#>>正文


C# RenderingContext.AddSprite方法代码示例

本文整理汇总了C#中RenderingContext.AddSprite方法的典型用法代码示例。如果您正苦于以下问题:C# RenderingContext.AddSprite方法的具体用法?C# RenderingContext.AddSprite怎么用?C# RenderingContext.AddSprite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RenderingContext的用法示例。


在下文中一共展示了RenderingContext.AddSprite方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Render

        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;
            }
        }
开发者ID:sbradno,项目名称:PoeHud,代码行数:49,代码来源:ItemAlerter.cs

示例2: Render

        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));
            }
        }
开发者ID:benjy3gg,项目名称:PoeHud,代码行数:63,代码来源:MonsterTracker.cs

示例3: drawItem

        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);
        }
开发者ID:benjy3gg,项目名称:PoeHud,代码行数:41,代码来源:ItemAlerter.cs


注:本文中的RenderingContext.AddSprite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。