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();
            }
        }
Пример #2
0
        public override void Draw()
        {
            for (var y = 0; y < this.Bounds.Height; y += SidebarButtonWidget.Size)
            {
                this.Buttons.PlayFetchIndex("button", () => 0);

                WidgetUtils.DrawSpriteCentered(
                    this.Buttons.Image,
                    this.IngameUi.Palette,
                    new(this.RenderBounds.X + SidebarButtonWidget.Size / 2, y + SidebarButtonWidget.Size / 2)
                    );
            }
        }
        public override void Draw()
        {
            // TODO this whole block can be removed when arrows are widgets!
            if (this.visibleIcons >= this.buildableItems.Length)
            {
                return;
            }

            var position = new int2(
                this.RenderBounds.X + SidebarButtonWidget.Size / 4,
                this.RenderBounds.Y + SidebarButtonWidget.Size / 4 + this.visibleIcons * SidebarButtonWidget.Size
                );

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

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

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

            if (this.scrollOffset + this.visibleIcons == this.buildableItems.Length)
            {
                WidgetUtils.FillRectWithColor(
                    new(
                        this.RenderBounds.X + SidebarButtonWidget.Size / 2,
                        this.RenderBounds.Y + this.visibleIcons * SidebarButtonWidget.Size,
                        SidebarButtonWidget.Size / 2,
                        SidebarButtonWidget.Size / 2
                        ),
                    Color.FromArgb(128, 0, 0, 0)
                    );
            }
        }
Пример #4
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));
            }
        }
Пример #5
0
 protected override void DrawContents()
 {
     this.Sidebar.Buttons.PlayFetchIndex("sell", () => 0);
     WidgetUtils.DrawSpriteCentered(this.Sidebar.Buttons.Image, this.Sidebar.IngameUi.Palette, this.Center + new int2(0, this.Active ? 1 : 0));
 }
        public override void Draw()
        {
            base.Draw();

            if (this.Progress == null)
            {
                return;
            }

            var progress = this.Progress();

            if (progress == -1)
            {
                return;
            }

            progress = progress * (SidebarButtonWidget.Size - 10) / 100;
            var o = SidebarButtonWidget.Size - 10 - progress;

            WidgetUtils.FillRectWithColor(new(this.RenderBounds.X + 2, this.RenderBounds.Y + 4, 7, SidebarButtonWidget.Size - 6), Color.Black);

            WidgetUtils.FillRectWithColor(
                new(this.RenderBounds.X + 3, this.RenderBounds.Y + 5, 5, SidebarButtonWidget.Size - 8),
                this.Sidebar.IngameUi.Palette.Palette.GetColor(10)
                );

            WidgetUtils.FillRectWithColor(
                new(this.RenderBounds.X + 4, this.RenderBounds.Y + 6, 3, SidebarButtonWidget.Size - 10),
                this.Sidebar.IngameUi.Palette.Palette.GetColor(8)
                );

            WidgetUtils.FillRectWithColor(
                new(this.RenderBounds.X + 4, this.RenderBounds.Y + 6 + o, 3, progress),
                this.Sidebar.IngameUi.Palette.Palette.GetColor(12)
                );

            var amount = this.Amount?.Invoke() ?? 0;

            switch (amount)
            {
            case -1:
                this.Sidebar.Font.PlayFetchIndex("production", () => 10);

                WidgetUtils.DrawSpriteCentered(
                    this.Sidebar.Font.Image,
                    this.Sidebar.IngameUi.Palette,
                    new int2(this.RenderBounds.X + 14 + 4, this.RenderBounds.Y + 40)
                    );

                break;

            case > 1:
            {
                var numberString = amount.ToString();

                for (var i = 0; i < numberString.Length; i++)
                {
                    var j = i;
                    this.Sidebar.Font.PlayFetchIndex("production", () => numberString[j] - 0x30);

                    WidgetUtils.DrawSpriteCentered(
                        this.Sidebar.Font.Image,
                        this.Sidebar.IngameUi.Palette,
                        new int2(this.RenderBounds.X + 14 + i * 8, this.RenderBounds.Y + 40)
                        );
                }

                break;
            }
            }
        }