예제 #1
0
        public override void Draw()
        {
            var rb = RenderBounds;

            WidgetUtils.FillRectWithColor(rb, GetColor());
            D2WidgetUtils.DrawPanelBorder(rb, BarMargin);
        }
        protected override void DrawContents()
        {
            if (this.IsFocused?.Invoke() ?? false)
            {
                WidgetUtils.FillRectWithColor(this.RenderBounds, Color.FromArgb(25, 255, 255, 255));
            }

            if (this.image != null)
            {
                WidgetUtils.DrawSpriteCentered(this.image, this.Sidebar.IngameUi.Palette, this.Center + new int2(0, this.Active ? 1 : 0));
            }
            else
            {
                var previewWidget = this.actorPreviewWidget;

                if (previewWidget != null)
                {
                    previewWidget.Bounds = this.RenderBounds;

                    Game.Renderer.EnableScissor(
                        new(
                            this.RenderBounds.X + this.Sidebar.ButtonArea.X,
                            this.RenderBounds.Y + this.Sidebar.ButtonArea.Y,
                            this.Sidebar.ButtonArea.Width,
                            this.Sidebar.ButtonArea.Height
                            )
                        );

                    previewWidget.Draw();
                }

                Game.Renderer.DisableScissor();
            }
        }
예제 #3
0
        public override void Draw()
        {
            var tooltipTitleMeasure = TooltipTitle == null ? int2.Zero : tooltipTitleFont.Measure(TooltipTitle);
            var tooltipTextMeasure  = TooltipText == null ? int2.Zero : tooltipTextFont.Measure(TooltipText);

            WidgetUtils.FillRectWithColor(new Rectangle(
                                              RenderBounds.X - Math.Max(tooltipTitleMeasure.X, tooltipTextMeasure.X) - 12,
                                              RenderBounds.Y - (tooltipTitleMeasure.Y + tooltipTextMeasure.Y) / 2 - 6,
                                              Math.Max(tooltipTitleMeasure.X, tooltipTextMeasure.X) + 12,
                                              tooltipTitleMeasure.Y + tooltipTextMeasure.Y + 12), Color.FromArgb(255, 255, 255, 255));

            WidgetUtils.FillRectWithColor(new Rectangle(
                                              RenderBounds.X - Math.Max(tooltipTitleMeasure.X, tooltipTextMeasure.X) - 11,
                                              RenderBounds.Y - (tooltipTitleMeasure.Y + tooltipTextMeasure.Y) / 2 - 5,
                                              Math.Max(tooltipTitleMeasure.X, tooltipTextMeasure.X) + 10,
                                              tooltipTitleMeasure.Y + tooltipTextMeasure.Y + 10), Color.FromArgb(255, 0, 0, 0));

            if (TooltipTitle != null)
            {
                tooltipTitleFont.DrawText(TooltipTitle, new int2(
                                              RenderBounds.X - Math.Max(tooltipTitleMeasure.X, tooltipTextMeasure.X) - 6,
                                              RenderBounds.Y - (tooltipTitleMeasure.Y + tooltipTextMeasure.Y) / 2 - 5), Color.White);
            }

            if (TooltipText != null)
            {
                tooltipTextFont.DrawText(TooltipText, new int2(
                                             RenderBounds.X - Math.Max(tooltipTitleMeasure.X, tooltipTextMeasure.X) - 6,
                                             RenderBounds.Y - (tooltipTitleMeasure.Y + tooltipTextMeasure.Y) / 2 + tooltipTitleMeasure.Y), Color.White);
            }
        }
예제 #4
0
        protected override void DrawContents()
        {
            if (IsFocused())
            {
                WidgetUtils.FillRectWithColor(RenderBounds, Color.FromArgb(25, 255, 255, 255));
            }

            if (image != null)
            {
                WidgetUtils.DrawSHPCentered(image, center + new int2(0, Active ? 1 : 0), sidebar.IngameUi.Palette);
            }
            else
            {
                actorPreviewWidget.Bounds = RenderBounds;

                Game.Renderer.EnableScissor(new Rectangle(
                                                RenderBounds.X + sidebar.ButtonArea.X,
                                                RenderBounds.Y + sidebar.ButtonArea.Y,
                                                sidebar.ButtonArea.Width,
                                                sidebar.ButtonArea.Height));

                actorPreviewWidget.Draw();
                Game.Renderer.DisableScissor();
            }
        }
예제 #5
0
        public override void Draw()
        {
            base.Draw();

            if (Progress != null)
            {
                var progress = Progress();
                if (progress != -1)
                {
                    progress = progress * (Size - 10) / 100;
                    var o = Size - 10 - progress;
                    WidgetUtils.FillRectWithColor(new Rectangle(RenderBounds.X + 2, RenderBounds.Y + 4, 7, Size - 6), Color.Black);
                    WidgetUtils.FillRectWithColor(new Rectangle(RenderBounds.X + 3, RenderBounds.Y + 5, 5, Size - 8), sidebar.IngameUi.Palette.Palette.GetColor(10));
                    WidgetUtils.FillRectWithColor(new Rectangle(RenderBounds.X + 4, RenderBounds.Y + 6, 3, Size - 10), sidebar.IngameUi.Palette.Palette.GetColor(8));
                    WidgetUtils.FillRectWithColor(new Rectangle(RenderBounds.X + 4, RenderBounds.Y + 6 + o, 3, progress), sidebar.IngameUi.Palette.Palette.GetColor(12));

                    var amount = Amount();
                    if (amount == -1)
                    {
                        sidebar.Font.PlayFetchIndex("production", () => 10);
                        WidgetUtils.DrawSHPCentered(sidebar.Font.Image, new int2(RenderBounds.X + 14 + 4, RenderBounds.Y + 40), sidebar.IngameUi.Palette);
                    }
                    else if (amount > 1)
                    {
                        var numberString = amount.ToString();
                        for (var i = 0; i < numberString.Length; i++)
                        {
                            sidebar.Font.PlayFetchIndex("production", () => numberString[i] - 0x30);
                            WidgetUtils.DrawSHPCentered(sidebar.Font.Image, new int2(RenderBounds.X + 14 + i * 8, RenderBounds.Y + 40), sidebar.IngameUi.Palette);
                        }
                    }
                }
            }
        }
예제 #6
0
        public override void Draw()
        {
            WidgetUtils.FillRectWithColor(new Rectangle(RenderBounds.X, RenderBounds.Y, progress, 10), Color.Firebrick);
            var text = "HP: " + currentHP + " / " + maxHP;

            actorActions.BamUi.Font.DrawTextWithShadow(text, new float2(RenderBounds.X + RenderBounds.Width / 2 - actorActions.BamUi.Font.Measure(text).X / 2, RenderBounds.Y - 3),
                                                       Color.White, Color.Gray, 1);
        }
예제 #7
0
        public static void DrawColoredPanelBorder(Rectangle bounds, int size, Color highlightColor, Color shadowColor)
        {
            WidgetUtils.FillRectWithColor(new Rectangle(bounds.Left, bounds.Top, size, bounds.Height - size), highlightColor);
            WidgetUtils.FillRectWithColor(new Rectangle(bounds.Left, bounds.Top, bounds.Width - size, size), highlightColor);

            WidgetUtils.FillRectWithColor(new Rectangle(bounds.Left + size, bounds.Bottom - size, bounds.Width - size, size), shadowColor);
            WidgetUtils.FillRectWithColor(new Rectangle(bounds.Right - size, bounds.Top + size, size, bounds.Height - size), shadowColor);
        }
예제 #8
0
 protected override void DrawContents()
 {
     if (autoResearchEnabled)
     {
         WidgetUtils.FillRectWithColor(RenderBounds, Color.FromArgb(25, 255, 255, 255));
     }
     sidebar.Buttons.PlayFetchIndex("research", () => 0);
     WidgetUtils.DrawSHPCentered(sidebar.Buttons.Image, center + new int2(0, Active ? 1 : 0), sidebar.IngameUi.Palette);
 }
예제 #9
0
        public override void Draw()
        {
            WidgetUtils.FillRectWithColor(RenderBounds, Color.White);
            WidgetUtils.FillRectWithColor(new Rectangle(RenderBounds.X + 1, RenderBounds.Y, RenderBounds.Width - 2, RenderBounds.Height - 1), Color.Black);

            DrawTimer();
            DrawResources();
            DrawSuperweapons();
        }
예제 #10
0
        public static void DrawColoredTriangle(int2 a, int size, Color normalColor, Color highlightColor, Color shadowColor)
        {
            WidgetUtils.FillRectWithColor(new Rectangle(a.X - size, a.Y, size, size * 2), highlightColor);

            WidgetUtils.FillRectWithColor(new Rectangle(a.X - size * 2, a.Y + size, size, size), normalColor);
            WidgetUtils.FillRectWithColor(new Rectangle(a.X, a.Y + size, size, size), normalColor);

            WidgetUtils.FillRectWithColor(new Rectangle(a.X, a.Y, size, size), shadowColor);
            WidgetUtils.FillRectWithColor(new Rectangle(a.X + size, a.Y + size, size, size * 2), shadowColor);
            WidgetUtils.FillRectWithColor(new Rectangle(a.X - size * 2, a.Y + size * 2, size * 3, size), shadowColor);
        }
예제 #11
0
        public override void Draw()
        {
            WidgetUtils.DrawRGBA(background, new float2(RenderBounds.X, RenderBounds.Y));


            var value = 144 * (playerResources.Resources + playerResources.Cash) / 400;

            WidgetUtils.FillRectWithColor(new Rectangle(RenderBounds.X + 8, RenderBounds.Y + 3, value, 10), Color.CornflowerBlue);

            var text = "Mana: " + (playerResources.Resources + playerResources.Cash);

            bamUi.Font.DrawTextWithContrast(text,
                                            new float2(RenderBounds.X + RenderBounds.Width / 2 - bamUi.Font.Measure(text).X / 2, RenderBounds.Y + RenderBounds.Height / 2 - bamUi.Font.Measure(text).Y / 2),
                                            Color.White,
                                            Color.DarkBlue, 1);
        }
예제 #12
0
        public override void Draw()
        {
            center = new int2(RenderBounds.X + Size / 2, RenderBounds.Y + Size / 2);

            WidgetUtils.FillRectWithColor(new Rectangle(RenderBounds.X, RenderBounds.Y, Size, Size), Color.FromArgb(255, 0, 0, 0));

            sidebar.Buttons.PlayFetchIndex(Active && IsUsable() ? type + "-down" : type, () => 0);
            WidgetUtils.DrawSHPCentered(sidebar.Buttons.Image, center, sidebar.IngameUi.Palette);

            if (IsUsable())
            {
                DrawContents();
            }

            if (Active && IsUsable())
            {
                WidgetUtils.FillRectWithColor(RenderBounds, Color.FromArgb(128, 0, 0, 0));
            }
        }
예제 #13
0
        public override void Draw()
        {
            if (GetPercentage == null)
            {
                return;
            }

            var rb = RenderBounds;
            var r  = new Rectangle(rb.Left, rb.Top, rb.Width, rb.Height - 3 * BarMargin);

            var percentage = GetPercentage();

            var backgroundColor = Color.FromArgb(186, 190, 150);

            WidgetUtils.FillRectWithColor(rb, backgroundColor);
            D2WidgetUtils.DrawPanelBorder(r, BarMargin);

            D2WidgetUtils.DrawRedTriangle(new int2(r.Left + BarMargin * 2, r.Bottom), BarMargin);
            D2WidgetUtils.DrawYellowTriangle(new int2((r.Left + r.Right) / 2, r.Bottom), BarMargin);
            D2WidgetUtils.DrawGreenTriangle(new int2(r.Right - 2 * BarMargin, r.Bottom), BarMargin);

            var minBarWidth = 1;
            var maxBarWidth = r.Width - BarMargin * 2;
            var barWidth    = percentage * maxBarWidth / 100;

            barWidth = Math.Max(barWidth, minBarWidth);

            var barRect  = new Rectangle(r.X + BarMargin, r.Y + BarMargin, barWidth, r.Height - 2 * BarMargin);
            var barColor = Color.FromArgb(85, 254, 81);

            if (percentage < 25)
            {
                barColor = Color.FromArgb(168, 0, 0);
            }
            else if (percentage < 50)
            {
                barColor = Color.FromArgb(254, 251, 84);
            }

            WidgetUtils.FillRectWithColor(barRect, barColor);
        }
예제 #14
0
        public override void Draw()
        {
            if (Monitor.TryEnter(front))
            {
                try
                {
                    mixerSprite.sheet.Texture.SetData(front, 256, 256);
                }
                finally
                {
                    Monitor.Exit(front);
                }
            }

            Game.Renderer.RgbaSpriteRenderer.DrawSprite(mixerSprite, RenderOrigin, new float2(RenderBounds.Size));

            var sprite = ChromeProvider.GetImage("lobby-bits", "colorpicker");
            var pos    = RenderOrigin + PxFromValue() - new int2(sprite.bounds.Width / 2, sprite.bounds.Height / 2);

            WidgetUtils.FillRectWithColor(new Rectangle(pos.X + 3, pos.Y + 3, 10, 10), Color.RGB);
            Game.Renderer.RgbaSpriteRenderer.DrawSprite(sprite, pos);
        }
예제 #15
0
        public override void Draw()
        {
            this.Center = new(this.RenderBounds.X + SidebarButtonWidget.Size / 2, this.RenderBounds.Y + SidebarButtonWidget.Size / 2);

            WidgetUtils.FillRectWithColor(
                new(this.RenderBounds.X, this.RenderBounds.Y, SidebarButtonWidget.Size, SidebarButtonWidget.Size),
                Color.FromArgb(255, 0, 0, 0)
                );

            this.Sidebar.Buttons.PlayFetchIndex(this.Active && this.IsUsable() ? $"{this.Type}-down" : this.Type, () => 0);
            WidgetUtils.DrawSpriteCentered(this.Sidebar.Buttons.Image, this.Sidebar.IngameUi.Palette, this.Center);

            if (this.IsUsable())
            {
                this.DrawContents();
            }

            if (this.Active && this.IsUsable())
            {
                WidgetUtils.FillRectWithColor(this.RenderBounds, Color.FromArgb(128, 0, 0, 0));
            }
        }
예제 #16
0
        public override void Draw()
        {
            lock (syncWorker)
            {
                if (updateFront)
                {
                    var swap = swapBitmap;
                    swapBitmap  = frontBitmap;
                    frontBitmap = swap;

                    mixerSprite.sheet.Texture.SetData(frontBitmap);
                    updateFront = false;
                }
            }

            Game.Renderer.RgbaSpriteRenderer.DrawSprite(mixerSprite, RenderOrigin, new float2(RenderBounds.Size));

            var sprite = ChromeProvider.GetImage("lobby-bits", "colorpicker");
            var pos    = RenderOrigin + PxFromValue() - new int2(sprite.bounds.Width / 2, sprite.bounds.Height / 2);

            WidgetUtils.FillRectWithColor(new Rectangle(pos.X + 3, pos.Y + 3, 10, 10), Color.RGB);
            Game.Renderer.RgbaSpriteRenderer.DrawSprite(sprite, pos);
        }
        public override void Draw()
        {
            var currentMana = actorActions.Actor.Trait <ManaShooter>().CurrentStorage;
            var maxMana     = actorActions.Actor.Info.TraitInfo <ManaShooterInfo>().MaxStorage;
            var progress    = 128 * currentMana / maxMana;

            WidgetUtils.DrawRGBA(pressed ? backgroundDown : background, new float2(RenderBounds.X, RenderBounds.Y));
            WidgetUtils.FillRectWithColor(new Rectangle(RenderBounds.X + 26, RenderBounds.Y + 18, progress, 10), Color.RoyalBlue);


            var text = "Transferer";

            actorActions.BamUi.Font.DrawTextWithContrast(text,
                                                         new float2(RenderBounds.X + RenderBounds.Width / 4 - actorActions.BamUi.Font.Measure(text).X / 2, RenderBounds.Y + 2), Color.White, Color.Black, 1);

            var text2 = "Mana: " + currentMana;

            actorActions.BamUi.Font.DrawTextWithContrast(text2,
                                                         new float2(RenderBounds.X + RenderBounds.Width / 2 - actorActions.BamUi.Font.Measure(text2).X / 2,
                                                                    RenderBounds.Y + 5 + RenderBounds.Height / 2 - actorActions.BamUi.Font.Measure(text2).Y / 2), Color.White,
                                                         Color.DarkBlue, 1);
            ;
        }
예제 #18
0
        public override void Draw()
        {
            // TODO this whole block can be removed when arrows are widgets!
            if (visibleIcons < buildableItems.Length)
            {
                var position = new int2(RenderBounds.X + ButtonWidget.Size / 4, RenderBounds.Y + ButtonWidget.Size / 4 + visibleIcons * ButtonWidget.Size);

                sidebar.Buttons.PlayFetchIndex("button-small", () => 0);
                WidgetUtils.DrawSHPCentered(sidebar.Buttons.Image, position, sidebar.IngameUi.Palette);
                sidebar.Buttons.PlayFetchIndex("button-small-down", () => 0);
                WidgetUtils.DrawSHPCentered(sidebar.Buttons.Image, position, sidebar.IngameUi.Palette);

                if (scrollOffset + visibleIcons == buildableItems.Length)
                {
                    WidgetUtils.FillRectWithColor(new Rectangle(
                                                      RenderBounds.X,
                                                      RenderBounds.Y + visibleIcons * ButtonWidget.Size,
                                                      ButtonWidget.Size / 2,
                                                      ButtonWidget.Size / 2), Color.FromArgb(128, 0, 0, 0));
                }

                sidebar.Buttons.PlayFetchIndex("button-small", () => 0);
                WidgetUtils.DrawSHPCentered(sidebar.Buttons.Image, position + new int2(ButtonWidget.Size / 2, 0), sidebar.IngameUi.Palette);
                sidebar.Buttons.PlayFetchIndex("button-small-up", () => 0);
                WidgetUtils.DrawSHPCentered(sidebar.Buttons.Image, position + new int2(ButtonWidget.Size / 2, 0), sidebar.IngameUi.Palette);

                if (scrollOffset == 0)
                {
                    WidgetUtils.FillRectWithColor(new Rectangle(
                                                      RenderBounds.X + ButtonWidget.Size / 2,
                                                      RenderBounds.Y + visibleIcons * ButtonWidget.Size,
                                                      ButtonWidget.Size / 2,
                                                      ButtonWidget.Size / 2), Color.FromArgb(128, 0, 0, 0));
                }
            }
        }
예제 #19
0
 public static void D2DrawBackground(Color color, int margin, Rectangle rect, bool disabled, bool pressed, bool hover, bool highlighted)
 {
     WidgetUtils.FillRectWithColor(rect, color);
     D2WidgetUtils.DrawPanelBorder(rect, margin, pressed || highlighted);
 }
예제 #20
0
 public override void Draw()
 {
     WidgetUtils.FillRectWithColor(RenderBounds, GetColor());
 }
예제 #21
0
        public override void Draw()
        {
            UpdateShroud();

            WidgetUtils.FillRectWithColor(new Rectangle(RenderBounds.X - size, RenderBounds.Y - size, RenderBounds.Width + size * 2, RenderBounds.Height + size * 2), Color.White);

            radarSheet.CommitBufferedData();
            Game.Renderer.RgbaSpriteRenderer.DrawSprite(terrainSprite, new int2(RenderBounds.X, RenderBounds.Y), new int2(RenderBounds.Width, RenderBounds.Height));
            Game.Renderer.RgbaSpriteRenderer.DrawSprite(shroudSprite, new int2(RenderBounds.X, RenderBounds.Y), new int2(RenderBounds.Width, RenderBounds.Height));

            var cells = new List <(CPos, Color)>();

            foreach (var e in ingameUi.World.ActorsWithTrait <IRadarSignature>())
            {
                if (!e.Actor.IsInWorld || e.Actor.IsDead || ingameUi.World.ShroudObscures(e.Actor.CenterPosition) || ingameUi.World.FogObscures(e.Actor) || e.Actor.Owner == null)
                {
                    continue;
                }

                if (!ShowStances.HasRelationship(PlayerRelationship.Ally) && e.Actor.Owner.RelationshipWith(ingameUi.World.LocalPlayer).HasRelationship(PlayerRelationship.Ally))
                {
                    continue;
                }

                if (!ShowStances.HasRelationship(PlayerRelationship.Enemy) && e.Actor.Owner.RelationshipWith(ingameUi.World.LocalPlayer).HasRelationship(PlayerRelationship.Enemy))
                {
                    continue;
                }

                cells.Clear();
                e.Trait.PopulateRadarSignatureCells(e.Actor, cells);

                foreach (var cell in cells)
                {
                    if (!ingameUi.World.Map.Contains(cell.Item1))
                    {
                        continue;
                    }

                    var pos   = cell.Item1.ToMPos(ingameUi.World.Map.Grid.Type);
                    var color = useStanceColor ? Color.FromArgb(e.Actor.Owner.PlayerRelationshipColor(e.Actor).ToArgb()) : e.Actor.Owner.Color;

                    WidgetUtils.FillRectWithColor(new Rectangle(RenderBounds.X + pos.U * size, RenderBounds.Y + pos.V * size, size, size), color);
                }
            }

            Game.Renderer.EnableScissor(RenderBounds);

            Game.Renderer.RgbaColorRenderer.DrawRect(
                new int2(RenderBounds.X, RenderBounds.Y) + ingameUi.WorldRenderer.Viewport.TopLeft / 32 * size,
                new int2(RenderBounds.X, RenderBounds.Y) + ingameUi.WorldRenderer.Viewport.BottomRight / 32 * size, size,
                Color.White);

            foreach (var ping in ingameUi.RadarPings.Pings)
            {
                if (!ping.IsVisible())
                {
                    continue;
                }

                var center = ingameUi.World.Map.CellContaining(ping.Position).ToMPos(ingameUi.World.Map.Grid.Type);
                var points = ping.Points(new int2(RenderBounds.X + center.U * size, RenderBounds.Y + center.V * size)).ToArray();
                Game.Renderer.RgbaColorRenderer.DrawPolygon(points, 2, ping.Color);
            }

            Game.Renderer.DisableScissor();
        }