Ejemplo n.º 1
0
 public override void Draw()
 {
     for (var y = 0; y < RenderBounds.Height; y += rightBar.Bounds.Height)
     {
         WidgetUtils.DrawRGBA(rightBar, new float2(RenderBounds.X - Border, y));
     }
 }
Ejemplo n.º 2
0
        public override void DrawOuter()
        {
            if (!IsVisible())
            {
                return;
            }

            var rb = RenderBounds;

            var scrollbarHeight = rb.Height - 2 * ScrollbarWidth;

            var thumbHeight = ContentHeight == 0 ? 0 : Math.Max(MinimumThumbSize, (int)(scrollbarHeight * Math.Min(rb.Height * 1f / ContentHeight, 1f)));
            var thumbOrigin = rb.Y + ScrollbarWidth + (int)((scrollbarHeight - thumbHeight) * (-1f * currentListOffset / (ContentHeight - rb.Height)));

            if (thumbHeight == scrollbarHeight)
            {
                thumbHeight = 0;
            }

            backgroundRect = new Rectangle(rb.X, rb.Y, rb.Width - ScrollbarWidth + 1, rb.Height);
            upButtonRect   = new Rectangle(rb.Right - ScrollbarWidth, rb.Y, ScrollbarWidth, ScrollbarWidth);
            downButtonRect = new Rectangle(rb.Right - ScrollbarWidth, rb.Bottom - ScrollbarWidth, ScrollbarWidth, ScrollbarWidth);
            scrollbarRect  = new Rectangle(rb.Right - ScrollbarWidth, rb.Y + ScrollbarWidth - 1, ScrollbarWidth, scrollbarHeight + 2);
            thumbRect      = new Rectangle(rb.Right - ScrollbarWidth, thumbOrigin, ScrollbarWidth, thumbHeight);

            WidgetUtils.DrawPanel(Background, backgroundRect);
            WidgetUtils.DrawPanel(Background, scrollbarRect);
            ButtonWidget.DrawBackground(Button, upButtonRect, upDisabled, upPressed, false, false);
            ButtonWidget.DrawBackground(Button, downButtonRect, downDisabled, downPressed, false, false);

            if (thumbHeight > 0)
            {
                ButtonWidget.DrawBackground(Button, thumbRect, false, false, false);
            }

            var upOffset   = !upPressed || upDisabled ? 4 : 4 + ButtonDepth;
            var downOffset = !downPressed || downDisabled ? 4 : 4 + ButtonDepth;

            WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", upPressed || upDisabled ? "up_pressed" : "up_arrow"),
                                 new Vector2(upButtonRect.Left + upOffset, upButtonRect.Top + upOffset));
            WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", downPressed || downDisabled ? "down_pressed" : "down_arrow"),
                                 new Vector2(downButtonRect.Left + downOffset, downButtonRect.Top + downOffset));

            var drawBounds = backgroundRect.InflateBy(-BorderWidth, -BorderWidth, -BorderWidth, -BorderWidth);

            WarGame.Renderer.EnableScissor(drawBounds);

            drawBounds.Offset((-ChildOrigin).ToPoint());
            foreach (var child in Children)
            {
                if (child.Bounds.IntersectsWith(drawBounds))
                {
                    child.DrawOuter();
                }
            }

            WarGame.Renderer.DisableScissor();
        }
Ejemplo n.º 3
0
        public override void Draw()
        {
            if (actorActions.Actor == null)
            {
                return;
            }

            WidgetUtils.DrawRGBA(pressed ? backgroundDown : background, new float2(RenderBounds.X, RenderBounds.Y));
            actorActions.BamUi.Font.DrawTextWithShadow("Drop", new float2(RenderBounds.X + 10, RenderBounds.Y + 4), Color.YellowGreen, Color.DarkSlateGray, 1);
        }
Ejemplo n.º 4
0
        public override void Draw()
        {
            var name       = GetImageName();
            var collection = GetImageCollection();

            var sprite = ChromeProvider.GetImage(collection, name);

            if (sprite == null)
            {
                throw new ArgumentException("Sprite {0}/{1} was not found".F(collection, name));
            }

            WidgetUtils.DrawRGBA(sprite, RenderOrigin);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public override void Draw()
        {
            if (actorActions.Actor == null)
            {
                return;
            }

            transformAfterTime = actorActions.Actor.TraitOrDefault <TransformAfterTime>();

            //hide
            WidgetUtils.DrawRGBA(background2, new float2(RenderBounds.Left + 0, RenderBounds.Top + 298));
            WidgetUtils.DrawRGBA(background3, new float2(RenderBounds.Left + 90, RenderBounds.Top + 298));

            // draw empty
            WidgetUtils.DrawRGBA(emptyMoons, new float2(RenderBounds.Left + 4, RenderBounds.Top + 266));
            WidgetUtils.DrawRGBA(emptyMen, new float2(RenderBounds.Left + 124, RenderBounds.Top + 298));

            var progress = 8 * transformAfterTime.Ticker / transformAfterTime.Time;

            if (progress > 1)
            {
                WidgetUtils.DrawRGBA(moonPhase2, new float2(RenderBounds.Left + 38, RenderBounds.Top + 266 + 8));
            }
            if (progress > 2)
            {
                WidgetUtils.DrawRGBA(moonPhase3, new float2(RenderBounds.Left + 62, RenderBounds.Top + 266 + 8));
            }
            if (progress > 3)
            {
                WidgetUtils.DrawRGBA(moonPhase4, new float2(RenderBounds.Left + 88, RenderBounds.Top + 266 + 8));
            }
            if (progress > 5)
            {
                WidgetUtils.DrawRGBA(moonPhase5, new float2(RenderBounds.Left + 114, RenderBounds.Top + 266 + 8));
            }
            if (progress > 6)
            {
                WidgetUtils.DrawRGBA(moonPhase6, new float2(RenderBounds.Left + 142, RenderBounds.Top + 266 + 8));
            }
            if (progress > 7)
            {
                WidgetUtils.DrawRGBA(readyMen, new float2(RenderBounds.Left + 128, RenderBounds.Top + 298));
            }
        }
Ejemplo n.º 7
0
        public override void Draw()
        {
            var rb = RenderBounds;

            leftButtonRect  = new Rectangle(rb.X, rb.Y, ArrowWidth, rb.Height);
            rightButtonRect = new Rectangle(rb.Right - ArrowWidth, rb.Y, ArrowWidth, rb.Height);

            var leftDisabled  = ListOffset >= 0;
            var leftHover     = Ui.MouseOverWidget == this && leftButtonRect.Contains(Viewport.LastMousePos);
            var rightDisabled = ListOffset <= Bounds.Width - rightButtonRect.Width - leftButtonRect.Width - ContentWidth;
            var rightHover    = Ui.MouseOverWidget == this && rightButtonRect.Contains(Viewport.LastMousePos);

            WidgetUtils.DrawPanel("panel-black", rb);
            ButtonWidget.DrawBackground("button", leftButtonRect, leftDisabled, leftPressed, leftHover, false);
            ButtonWidget.DrawBackground("button", rightButtonRect, rightDisabled, rightPressed, rightHover, false);

            WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", leftPressed || leftDisabled ? "left_pressed" : "left_arrow"),
                                 new float2(leftButtonRect.Left + 2, leftButtonRect.Top + 2));
            WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", rightPressed || rightDisabled ? "right_pressed" : "right_arrow"),
                                 new float2(rightButtonRect.Left + 2, rightButtonRect.Top + 2));

            // Draw tab buttons
            Game.Renderer.EnableScissor(leftButtonRect.Right, rb.Y + 1, rightButtonRect.Left - leftButtonRect.Right - 1, rb.Height);
            var        origin = new int2(leftButtonRect.Right - 1 + (int)ListOffset, leftButtonRect.Y);
            SpriteFont font   = Game.Renderer.Fonts["TinyBold"];

            ContentWidth = 0;

            foreach (var tab in Groups[queueGroup].Tabs)
            {
                var rect     = new Rectangle(origin.X + ContentWidth, origin.Y, TabWidth, rb.Height);
                var hover    = !leftHover && !rightHover && Ui.MouseOverWidget == this && rect.Contains(Viewport.LastMousePos);
                var baseName = tab.Queue == CurrentQueue ? "button-toggled" : "button";
                ButtonWidget.DrawBackground(baseName, rect, false, false, hover, false);
                ContentWidth += TabWidth - 1;

                int2 textSize = font.Measure(tab.Name);
                int2 position = new int2(rect.X + (rect.Width - textSize.X) / 2, rect.Y + (rect.Height - textSize.Y) / 2);
                font.DrawTextWithContrast(tab.Name, position, tab.Queue.CurrentDone ? Color.Gold : Color.White, Color.Black, 1);
            }

            Game.Renderer.DisableScissor();
        }
Ejemplo n.º 8
0
        public override void Draw()
        {
            var name        = GetImageName();
            var collection  = GetImageCollection();
            var paletteName = GetPaletteName();

            if (paletteName == null || paletteName.Length == 0)
            {
                paletteName = "player" + world.LocalPlayer.InternalName;
            }
            PaletteReference p = null;

            if (paletteName != null)
            {
                p = worldRenderer.Palette(paletteName);
            }

            var sprite = D2ChromeProvider.GetImage(collection, name, p);

            if (sprite == null)
            {
                throw new ArgumentException("Sprite {0}/{1} was not found.".F(collection, name));
            }

            if (FillBackground)
            {
                for (var y = 0; y < Bounds.Height; y += sprite.Bounds.Height)
                {
                    for (var x = 0; x < Bounds.Width; x += sprite.Bounds.Width)
                    {
                        WidgetUtils.DrawRGBA(sprite, RenderOrigin + new int2(x, y));
                    }
                }
            }
            else
            {
                WidgetUtils.DrawRGBA(sprite, RenderOrigin);
            }
        }
        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);
            ;
        }
Ejemplo n.º 10
0
        void DrawBuildTabs(World world)
        {
            const int tabWidth  = 24;
            const int tabHeight = 40;
            var       x         = paletteOrigin.X - tabWidth;
            var       y         = paletteOrigin.Y + 9;

            tabs.Clear();

            foreach (var queue in VisibleQueues)
            {
                string[] tabKeys   = { "normal", "ready", "selected" };
                var      producing = queue.CurrentItem();
                var      index     = queue == CurrentQueue ? 2 : (producing != null && producing.Done) ? 1 : 0;

                var race = world.LocalPlayer.Country.Race;
                WidgetUtils.DrawRGBA(ChromeProvider.GetImage("tabs-" + tabKeys[index], race + "-" + queue.Info.Type), new float2(x, y));

                var rect = new Rectangle((int)x, (int)y, tabWidth, tabHeight);
                tabs.Add(Pair.New(rect, HandleTabClick(queue, world)));

                if (rect.Contains(Viewport.LastMousePos))
                {
                    var text = queue.Info.Type;
                    var font = Game.Renderer.Fonts["Bold"];
                    var sz   = font.Measure(text);
                    WidgetUtils.DrawPanelPartial("dialog4",
                                                 Rectangle.FromLTRB(rect.Left - sz.X - 30, rect.Top, rect.Left - 5, rect.Bottom),
                                                 PanelSides.All);

                    font.DrawText(text, new float2(rect.Left - sz.X - 20, rect.Top + 12), Color.White);
                }

                y += tabHeight;
            }
        }
Ejemplo n.º 11
0
        public override void Draw()
        {
            buttons.Clear();

            if (world.LocalPlayer == null)
            {
                return;
            }

            var manager   = world.LocalPlayer.PlayerActor.Trait <SupportPowerManager>();
            var powers    = manager.Powers.Where(p => !p.Value.Disabled);
            var numPowers = powers.Count();

            if (numPowers == 0)
            {
                return;
            }

            var rectBounds = RenderBounds;

            WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-top"), new float2(rectBounds.X, rectBounds.Y));
            for (var i = 1; i < numPowers; i++)
            {
                WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-middle"), new float2(rectBounds.X, rectBounds.Y + i * 51));
            }
            WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-bottom"), new float2(rectBounds.X, rectBounds.Y + numPowers * 51));

            // Hack Hack Hack
            rectBounds.Width  = 69;
            rectBounds.Height = 10 + numPowers * 51 + 21;

            var y = rectBounds.Y + 10;

            foreach (var kv in powers)
            {
                var sp    = kv.Value;
                var image = spsprites[sp.Info.Image];

                var drawPos = new float2(rectBounds.X + 5, y);
                var rect    = new Rectangle(rectBounds.X + 5, y, 64, 48);

                if (rect.Contains(Viewport.LastMousePos))
                {
                    var pos = drawPos.ToInt2();
                    var tl  = new int2(pos.X - 3, pos.Y - 3);
                    var m   = new int2(pos.X + 64 + 3, pos.Y + 48 + 3);
                    var br  = tl + new int2(64 + 3 + 20, 40);

                    if (sp.TotalTime > 0)
                    {
                        br += new int2(0, 20);
                    }

                    if (sp.Info.LongDesc != null)
                    {
                        br += Game.Renderer.Fonts["Regular"].Measure(sp.Info.LongDesc.Replace("\\n", "\n"));
                    }
                    else
                    {
                        br += new int2(300, 0);
                    }

                    var border = WidgetUtils.GetBorderSizes("dialog4");

                    WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(tl.X, tl.Y, m.X + border[3], m.Y),
                                                 PanelSides.Left | PanelSides.Top | PanelSides.Bottom | PanelSides.Center);
                    WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(m.X - border[2], tl.Y, br.X, m.Y + border[1]),
                                                 PanelSides.Top | PanelSides.Right | PanelSides.Center);
                    WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(m.X, m.Y - border[1], br.X, br.Y),
                                                 PanelSides.Left | PanelSides.Right | PanelSides.Bottom | PanelSides.Center);

                    pos += new int2(77, 5);
                    Game.Renderer.Fonts["Bold"].DrawText(sp.Info.Description, pos, Color.White);

                    if (sp.TotalTime > 0)
                    {
                        pos += new int2(0, 20);
                        Game.Renderer.Fonts["Bold"].DrawText(WidgetUtils.FormatTime(sp.RemainingTime).ToString(), pos, Color.White);
                        Game.Renderer.Fonts["Bold"].DrawText("/ {0}".F(WidgetUtils.FormatTime(sp.TotalTime)), pos + new int2(45, 0), Color.White);
                    }

                    if (sp.Info.LongDesc != null)
                    {
                        pos += new int2(0, 20);
                        Game.Renderer.Fonts["Regular"].DrawText(sp.Info.LongDesc.Replace("\\n", "\n"), pos, Color.White);
                    }
                }

                WidgetUtils.DrawSHP(image, drawPos, worldRenderer);

                clock.PlayFetchIndex("idle",
                                     () => sp.TotalTime == 0 ? clock.CurrentSequence.Length - 1 : (sp.TotalTime - sp.RemainingTime)
                                     * (clock.CurrentSequence.Length - 1) / sp.TotalTime);
                clock.Tick();

                WidgetUtils.DrawSHP(clock.Image, drawPos, worldRenderer);

                var overlay = sp.Ready ? ReadyText : sp.Active ? null : HoldText;
                var font    = Game.Renderer.Fonts["TinyBold"];
                if (overlay != null)
                {
                    var size       = font.Measure(overlay);
                    var overlayPos = drawPos + new float2(32, 16);
                    font.DrawTextWithContrast(overlay, overlayPos - new float2(size.X / 2, 0), Color.White, Color.Black, 1);
                }

                buttons.Add(Pair.New(rect, HandleSupportPower(kv.Key, manager)));

                y += 51;
            }
        }
Ejemplo n.º 12
0
        int DrawPalette(ProductionQueue queue)
        {
            buttons.Clear();

            var paletteCollection = "palette-" + world.LocalPlayer.Country.Race;
            var origin            = new float2(paletteOrigin.X + 9, paletteOrigin.Y + 9);
            var iconOffset        = 0.5f * new float2(IconWidth, IconHeight);
            var x = 0;
            var y = 0;

            if (queue != null)
            {
                var buildableItems = queue.BuildableItems().ToArray();
                var allBuildables  = queue.AllItems().OrderBy(a => a.Traits.Get <BuildableInfo>().BuildPaletteOrder).ToArray();

                var overlayBits = new List <Pair <Sprite, float2> >();
                var textBits    = new List <Pair <float2, string> >();
                numActualRows = Math.Max((allBuildables.Count() + Columns - 1) / Columns, Rows);

                // Palette Background
                WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "top"), new float2(origin.X - 9, origin.Y - 9));
                for (var w = 0; w < numActualRows; w++)
                {
                    WidgetUtils.DrawRGBA(
                        ChromeProvider.GetImage(paletteCollection, "bg-" + (w % 4)),
                        new float2(origin.X - 9, origin.Y + IconHeight * w));
                }
                WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "bottom"),
                                     new float2(origin.X - 9, origin.Y - 1 + IconHeight * numActualRows));


                // Icons
                string tooltipItem   = null;
                var    tooltipHotkey = Hotkey.Invalid;
                var    i             = 0;
                foreach (var item in allBuildables)
                {
                    var rect    = new RectangleF(origin.X + x * IconWidth, origin.Y + IconHeight * y, IconWidth, IconHeight);
                    var drawPos = new float2(rect.Location);
                    var icon    = new Animation(world, RenderSimple.GetImage(item));
                    icon.Play(item.Traits.Get <TooltipInfo>().Icon);
                    WidgetUtils.DrawSHPCentered(icon.Image, drawPos + iconOffset, worldRenderer);

                    var firstOfThis = queue.AllQueued().FirstOrDefault(a => a.Item == item.Name);

                    if (rect.Contains(Viewport.LastMousePos))
                    {
                        tooltipItem   = item.Name;
                        tooltipHotkey = Game.Settings.Keys.GetProductionHotkey(i);
                    }

                    var overlayPos = drawPos + new float2(32, 16);

                    if (firstOfThis != null)
                    {
                        clock.PlayFetchIndex("idle",
                                             () => (firstOfThis.TotalTime - firstOfThis.RemainingTime)
                                             * (clock.CurrentSequence.Length - 1) / firstOfThis.TotalTime);
                        clock.Tick();
                        WidgetUtils.DrawSHPCentered(clock.Image, drawPos + iconOffset, worldRenderer);

                        if (queue.CurrentItem() == firstOfThis)
                        {
                            textBits.Add(Pair.New(overlayPos, GetOverlayForItem(firstOfThis)));
                        }

                        var repeats = queue.AllQueued().Count(a => a.Item == item.Name);
                        if (repeats > 1 || queue.CurrentItem() != firstOfThis)
                        {
                            textBits.Add(Pair.New(overlayPos + new float2(-24, -14), repeats.ToString()));
                        }
                    }
                    else
                    if (buildableItems.All(a => a.Name != item.Name))
                    {
                        overlayBits.Add(Pair.New(cantBuild.Image, drawPos));
                    }

                    var closureName = buildableItems.Any(a => a.Name == item.Name) ? item.Name : null;
                    buttons.Add(Pair.New(new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height), HandleClick(closureName, world)));

                    if (++x == Columns)
                    {
                        x = 0; y++;
                    }
                    i++;
                }
                if (x != 0)
                {
                    y++;
                }

                foreach (var ob in overlayBits)
                {
                    WidgetUtils.DrawSHPCentered(ob.First, ob.Second + iconOffset, worldRenderer);
                }

                var font = Game.Renderer.Fonts["TinyBold"];
                foreach (var tb in textBits)
                {
                    var size = font.Measure(tb.Second);
                    if (ReadyTextStyle == ReadyTextStyleOptions.Solid || orderManager.LocalFrameNumber / 9 % 2 == 0 || tb.Second != ReadyText)
                    {
                        font.DrawTextWithContrast(tb.Second, tb.First - new float2(size.X / 2, 0),
                                                  Color.White, Color.Black, 1);
                    }
                    else if (ReadyTextStyle == ReadyTextStyleOptions.AlternatingColor)
                    {
                        font.DrawTextWithContrast(tb.Second, tb.First - new float2(size.X / 2, 0),
                                                  ReadyTextAltColor, Color.Black, 1);
                    }
                }

                // Tooltip
                if (tooltipItem != null && !paletteAnimating && paletteOpen)
                {
                    DrawProductionTooltip(world, tooltipItem, tooltipHotkey,
                                          new float2(Game.Renderer.Resolution.Width, origin.Y + numActualRows * IconHeight + 9).ToInt2());
                }
            }

            // Palette Dock
            WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-top"),
                                 new float2(Game.Renderer.Resolution.Width - 14, origin.Y - 23));

            for (var i = 0; i < numActualRows; i++)
            {
                WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-" + (i % 4)),
                                     new float2(Game.Renderer.Resolution.Width - 14, origin.Y + IconHeight * i));
            }

            WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-bottom"),
                                 new float2(Game.Renderer.Resolution.Width - 14, origin.Y - 1 + IconHeight * numActualRows));

            return(IconHeight * y + 9);
        }
Ejemplo n.º 13
0
        int DrawPalette(ProductionQueue queue)
        {
            buttons.Clear();

            string paletteCollection = "palette-" + world.LocalPlayer.Country.Race;
            float2 origin            = new float2(paletteOrigin.X + 9, paletteOrigin.Y + 9);
            var    x = 0;
            var    y = 0;

            if (queue != null)
            {
                var buildableItems = queue.BuildableItems().ToArray();
                var allBuildables  = queue.AllItems().OrderBy(a => a.Traits.Get <BuildableInfo>().BuildPaletteOrder).ToArray();

                var overlayBits = new List <Pair <Sprite, float2> >();
                var textBits    = new List <Pair <float2, string> >();
                numActualRows = Math.Max((allBuildables.Count() + Columns - 1) / Columns, Rows);

                // Palette Background
                WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "top"), new float2(origin.X - 9, origin.Y - 9));
                for (var w = 0; w < numActualRows; w++)
                {
                    WidgetUtils.DrawRGBA(
                        ChromeProvider.GetImage(paletteCollection, "bg-" + (w % 4).ToString()),
                        new float2(origin.X - 9, origin.Y + 48 * w));
                }
                WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "bottom"),
                                     new float2(origin.X - 9, origin.Y - 1 + 48 * numActualRows));


                // Icons
                string tooltipItem = null;
                foreach (var item in allBuildables)
                {
                    var rect    = new RectangleF(origin.X + x * 64, origin.Y + 48 * y, 64, 48);
                    var drawPos = new float2(rect.Location);
                    WidgetUtils.DrawSHP(iconSprites[item.Name], drawPos, worldRenderer);

                    var firstOfThis = queue.AllQueued().FirstOrDefault(a => a.Item == item.Name);

                    if (rect.Contains(Viewport.LastMousePos))
                    {
                        tooltipItem = item.Name;
                    }

                    var overlayPos = drawPos + new float2(32, 16);

                    if (firstOfThis != null)
                    {
                        clock.PlayFetchIndex("idle",
                                             () => (firstOfThis.TotalTime - firstOfThis.RemainingTime)
                                             * (clock.CurrentSequence.Length - 1) / firstOfThis.TotalTime);
                        clock.Tick();
                        WidgetUtils.DrawSHP(clock.Image, drawPos, worldRenderer);

                        if (queue.CurrentItem() == firstOfThis)
                        {
                            textBits.Add(Pair.New(overlayPos, GetOverlayForItem(firstOfThis)));
                        }

                        var repeats = queue.AllQueued().Count(a => a.Item == item.Name);
                        if (repeats > 1 || queue.CurrentItem() != firstOfThis)
                        {
                            textBits.Add(Pair.New(overlayPos + new float2(-24, -14), repeats.ToString()));
                        }
                    }
                    else
                    if (!buildableItems.Any(a => a.Name == item.Name))
                    {
                        overlayBits.Add(Pair.New(cantBuild.Image, drawPos));
                    }

                    var closureName = buildableItems.Any(a => a.Name == item.Name) ? item.Name : null;
                    buttons.Add(Pair.New(new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height), HandleClick(closureName, world)));

                    if (++x == Columns)
                    {
                        x = 0; y++;
                    }
                }
                if (x != 0)
                {
                    y++;
                }

                foreach (var ob in overlayBits)
                {
                    WidgetUtils.DrawSHP(ob.First, ob.Second, worldRenderer);
                }

                var font = Game.Renderer.Fonts["TinyBold"];
                foreach (var tb in textBits)
                {
                    var size = font.Measure(tb.Second);
                    font.DrawTextWithContrast(tb.Second, tb.First - new float2(size.X / 2, 0),
                                              Color.White, Color.Black, 1);
                }

                // Tooltip
                if (tooltipItem != null && !paletteAnimating && paletteOpen)
                {
                    DrawProductionTooltip(world, tooltipItem,
                                          new float2(Game.viewport.Width, origin.Y + numActualRows * 48 + 9).ToInt2());
                }
            }

            // Palette Dock
            WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-top"),
                                 new float2(Game.viewport.Width - 14, origin.Y - 23));

            for (int i = 0; i < numActualRows; i++)
            {
                WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-" + (i % 4).ToString()),
                                     new float2(Game.viewport.Width - 14, origin.Y + 48 * i));
            }

            WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-bottom"),
                                 new float2(Game.viewport.Width - 14, origin.Y - 1 + 48 * numActualRows));

            return(48 * y + 9);
        }
Ejemplo n.º 14
0
        public override void Draw()
        {
            if (Viewport.TicksSinceLastMove < TooltipDelay || world == null)
            {
                return;
            }

            var cell = Game.viewport.ViewToWorld(Viewport.LastMousePos);

            if (!world.Map.IsInMap(cell))
            {
                return;
            }

            if (world.ShroudObscures(cell))
            {
                var utext = "Unexplored Terrain";
                var usz   = Game.Renderer.Fonts["Bold"].Measure(utext) + new int2(20, 24);

                WidgetUtils.DrawPanel("dialog4", Rectangle.FromLTRB(
                                          Viewport.LastMousePos.X + 20, Viewport.LastMousePos.Y + 20,
                                          Viewport.LastMousePos.X + usz.X + 20, Viewport.LastMousePos.Y + usz.Y + 20));

                Game.Renderer.Fonts["Bold"].DrawText(utext,
                                                     new float2(Viewport.LastMousePos.X + 30, Viewport.LastMousePos.Y + 30), Color.White);

                return;
            }

            var actor = world.FindUnitsAtMouse(Viewport.LastMousePos).FirstOrDefault();

            if (actor == null)
            {
                return;
            }

            var itt = actor.TraitsImplementing <IToolTip>().FirstOrDefault();

            if (itt == null)
            {
                return;
            }

            var owner      = itt.Owner();
            var nameText   = itt.Name();
            var ownerText  = !owner.NonCombatant ? owner.PlayerName : "";
            var stanceText = (world.LocalPlayer != null && owner != actor.World.LocalPlayer &&
                              !owner.NonCombatant) ? " ({0})".F(itt.Stance()) : "";

            var nameSize   = Game.Renderer.Fonts["Bold"].Measure(nameText);
            var ownerSize  = Game.Renderer.Fonts["Regular"].Measure(ownerText);
            var stanceSize = Game.Renderer.Fonts["Regular"].Measure(stanceText);
            var panelSize  = new int2(Math.Max(nameSize.X, ownerSize.X + stanceSize.X + 35) + 20, nameSize.Y + 24);

            if (ownerText != "")
            {
                panelSize.Y += ownerSize.Y + 2;
            }

            WidgetUtils.DrawPanel("dialog4", Rectangle.FromLTRB(
                                      Viewport.LastMousePos.X + 20, Viewport.LastMousePos.Y + 20,
                                      Viewport.LastMousePos.X + panelSize.X + 20, Viewport.LastMousePos.Y + panelSize.Y + 20));

            Game.Renderer.Fonts["Bold"].DrawText(nameText,
                                                 new float2(Viewport.LastMousePos.X + 30, Viewport.LastMousePos.Y + 30), Color.White);

            if (ownerText != "")
            {
                Game.Renderer.Fonts["Regular"].DrawText(ownerText,
                                                        new float2(Viewport.LastMousePos.X + 65, Viewport.LastMousePos.Y + 50), actor.Owner.Color.RGB);

                Game.Renderer.Fonts["Regular"].DrawText(stanceText,
                                                        new float2(Viewport.LastMousePos.X + 65 + ownerSize.X, Viewport.LastMousePos.Y + 50), Color.White);

                WidgetUtils.DrawRGBA(
                    ChromeProvider.GetImage("flags", actor.Owner.Country.Race),
                    new float2(Viewport.LastMousePos.X + 30, Viewport.LastMousePos.Y + 50));
            }
        }
Ejemplo n.º 15
0
 public override void Draw()
 {
     WidgetUtils.DrawRGBA(isHovered || isActive ? active : inactive, new float2(RenderBounds.X, RenderBounds.Y));
 }
Ejemplo n.º 16
0
        public override void Draw()
        {
            if (!Initialised)
            {
                Init();
            }

            if (!IsVisible())
            {
                return;
            }

            var rb     = RenderBounds;
            var offset = int2.Zero;

            var svc = world.Players.Select(p => p.PlayerActor.TraitOrDefault <StrategicVictoryConditions>()).FirstOrDefault();

            var totalWidth = svc.Total * 32;
            var curX       = -totalWidth / 2;

            foreach (var a in svc.AllPoints)
            {
                WidgetUtils.DrawRGBA(ChromeProvider.GetImage("strategic", "critical_unowned"), offset + new float2(rb.Left + curX, rb.Top));

                if (WorldUtils.AreMutualAllies(a.Actor.Owner, world.LocalPlayer))
                {
                    WidgetUtils.DrawRGBA(ChromeProvider.GetImage("strategic", "player_owned"), offset + new float2(rb.Left + curX, rb.Top));
                }
                else if (!a.Actor.Owner.NonCombatant)
                {
                    WidgetUtils.DrawRGBA(ChromeProvider.GetImage("strategic", "enemy_owned"), offset + new float2(rb.Left + curX, rb.Top));
                }

                curX += 32;
            }

            offset += new int2(0, 32);

            if (world.LocalPlayer == null)
            {
                return;
            }
            var pendingWinner = FindFirstWinningPlayer(world);

            if (pendingWinner == null)
            {
                return;
            }
            var winnerSvc = pendingWinner.PlayerActor.Trait <StrategicVictoryConditions>();

            var isVictory = pendingWinner == world.LocalPlayer || !WorldUtils.AreMutualAllies(pendingWinner, world.LocalPlayer);
            var tc        = "Strategic {0} in {1}".F(
                isVictory ? "victory" : "defeat",
                WidgetUtils.FormatTime(winnerSvc.TicksLeft));

            var font = Game.Renderer.Fonts["Bold"];

            var size = font.Measure(tc);

            font.DrawTextWithContrast(tc, offset + new float2(rb.Left - size.X / 2 + 1, rb.Top + 1), Color.White, Color.Black, 1);
            offset += new int2(0, size.Y + 1);
        }
Ejemplo n.º 17
0
 public override void Draw()
 {
     WidgetUtils.DrawRGBA(background, new float2(RenderBounds.X, RenderBounds.Y));
 }