예제 #1
0
        public override void Draw()
        {
            overlayFont  = Game.Renderer.Fonts["TinyBold"];
            timeOffset   = new float2(32, 24) - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2;
            queuedOffset = new float2(4, 2);
            holdOffset   = new float2(32, 24) - overlayFont.Measure(HoldText) / 2;
            readyOffset  = new float2(32, 24) - overlayFont.Measure(ReadyText) / 2;

            if (CurrentQueue == null)
            {
                return;
            }

            var buildableItems = CurrentQueue.BuildableItems().OrderBy(a => a.Traits.Get <BuildableInfo>().BuildPaletteOrder);

            // Background
            foreach (var rect in icons.Keys)
            {
                WidgetUtils.DrawPanel("panel-black", rect.InflateBy(1, 1, 1, 1));
            }

            // Icons
            foreach (var icon in icons.Values)
            {
                WidgetUtils.DrawSHP(icon.Sprite, icon.Pos, worldRenderer);

                // Build progress
                if (icon.Queued.Count > 0)
                {
                    var first = icon.Queued[0];
                    clock.PlayFetchIndex("idle",
                                         () => (first.TotalTime - first.RemainingTime)
                                         * (clock.CurrentSequence.Length - 1) / first.TotalTime);
                    clock.Tick();
                    WidgetUtils.DrawSHP(clock.Image, icon.Pos, worldRenderer);
                }
                else if (!buildableItems.Any(a => a.Name == icon.Name))
                {
                    WidgetUtils.DrawSHP(cantBuild.Image, icon.Pos, worldRenderer);
                }
            }

            // Overlays
            foreach (var icon in icons.Values)
            {
                var total = icon.Queued.Count;
                if (total > 0)
                {
                    var first   = icon.Queued[0];
                    var waiting = first != CurrentQueue.CurrentItem() && !first.Done;
                    if (first.Done)
                    {
                        overlayFont.DrawTextWithContrast(ReadyText,
                                                         icon.Pos + readyOffset,
                                                         Color.White, Color.Black, 1);
                    }
                    else if (first.Paused)
                    {
                        overlayFont.DrawTextWithContrast(HoldText,
                                                         icon.Pos + holdOffset,
                                                         Color.White, Color.Black, 1);
                    }
                    else if (!waiting)
                    {
                        overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(first.RemainingTimeActual),
                                                         icon.Pos + timeOffset,
                                                         Color.White, Color.Black, 1);
                    }

                    if (total > 1 || waiting)
                    {
                        overlayFont.DrawTextWithContrast(total.ToString(),
                                                         icon.Pos + queuedOffset,
                                                         Color.White, Color.Black, 1);
                    }
                }
            }
        }
예제 #2
0
        public override void Draw()
        {
            var iconOffset = 0.5f * IconSize.ToFloat2() + IconSpriteOffset;

            overlayFont  = Game.Renderer.Fonts["TinyBold"];
            timeOffset   = iconOffset - overlayFont.Measure(WidgetUtils.FormatTime(0, World.Timestep)) / 2;
            queuedOffset = new float2(4, 2);
            holdOffset   = iconOffset - overlayFont.Measure(HoldText) / 2;
            readyOffset  = iconOffset - overlayFont.Measure(ReadyText) / 2;

            if (CurrentQueue == null)
            {
                return;
            }

            var buildableItems = CurrentQueue.BuildableItems();

            var pios = currentQueue.Actor.Owner.PlayerActor.TraitsImplementing <IProductionIconOverlay>();

            // Icons
            foreach (var icon in icons.Values)
            {
                WidgetUtils.DrawSHPCentered(icon.Sprite, icon.Pos + iconOffset, icon.Palette);

                // Draw the ProductionIconOverlay's sprite
                var pio = pios.FirstOrDefault(p => p.IsOverlayActive(icon.Actor));
                if (pio != null)
                {
                    WidgetUtils.DrawSHPCentered(pio.Sprite, icon.Pos + iconOffset + pio.Offset(IconSize), worldRenderer.Palette(pio.Palette), 1f);
                }

                // Build progress
                if (icon.Queued.Count > 0)
                {
                    var first = icon.Queued[0];
                    clock.PlayFetchIndex(ClockSequence,
                                         () => (first.TotalTime - first.RemainingTime)
                                         * (clock.CurrentSequence.Length - 1) / first.TotalTime);
                    clock.Tick();

                    WidgetUtils.DrawSHPCentered(clock.Image, icon.Pos + iconOffset, icon.IconClockPalette);
                }
                else if (!buildableItems.Any(a => a.Name == icon.Name))
                {
                    WidgetUtils.DrawSHPCentered(cantBuild.Image, icon.Pos + iconOffset, icon.IconDarkenPalette);
                }
            }

            // Overlays
            foreach (var icon in icons.Values)
            {
                var total = icon.Queued.Count;
                if (total > 0)
                {
                    var first   = icon.Queued[0];
                    var waiting = first != CurrentQueue.CurrentItem() && !first.Done;
                    if (first.Done)
                    {
                        if (ReadyTextStyle == ReadyTextStyleOptions.Solid || orderManager.LocalFrameNumber * worldRenderer.World.Timestep / 360 % 2 == 0)
                        {
                            overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, Color.White, Color.Black, 1);
                        }
                        else if (ReadyTextStyle == ReadyTextStyleOptions.AlternatingColor)
                        {
                            overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, ReadyTextAltColor, Color.Black, 1);
                        }
                    }
                    else if (first.Paused)
                    {
                        overlayFont.DrawTextWithContrast(HoldText,
                                                         icon.Pos + holdOffset,
                                                         Color.White, Color.Black, 1);
                    }
                    else if (!waiting)
                    {
                        overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(first.RemainingTimeActual, World.Timestep),
                                                         icon.Pos + timeOffset,
                                                         Color.White, Color.Black, 1);
                    }

                    if (total > 1 || waiting)
                    {
                        overlayFont.DrawTextWithContrast(total.ToString(),
                                                         icon.Pos + queuedOffset,
                                                         Color.White, Color.Black, 1);
                    }
                }
            }
        }
예제 #3
0
        public override void Draw()
        {
            var iconOffset = 0.5f * IconSize.ToFloat2() + IconSpriteOffset;

            overlayFont  = Game.Renderer.Fonts["TinyBold"];
            timeOffset   = iconOffset - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2;
            queuedOffset = new float2(4, 2);
            holdOffset   = iconOffset - overlayFont.Measure(HoldText) / 2;
            readyOffset  = iconOffset - overlayFont.Measure(ReadyText) / 2;

            if (CurrentQueue == null)
            {
                return;
            }

            var buildableItems = CurrentQueue.BuildableItems();

            // Icons
            foreach (var icon in icons.Values)
            {
                WidgetUtils.DrawSHPCentered(icon.Sprite, icon.Pos + iconOffset, worldRenderer);

                // Build progress
                if (icon.Queued.Count > 0)
                {
                    var first = icon.Queued[0];
                    clock.PlayFetchIndex("idle",
                                         () => (first.TotalTime - first.RemainingTime)
                                         * (clock.CurrentSequence.Length - 1) / first.TotalTime);
                    clock.Tick();

                    WidgetUtils.DrawSHPCentered(clock.Image, icon.Pos + iconOffset, worldRenderer);
                }
                else if (!buildableItems.Any(a => a.Name == icon.Name))
                {
                    WidgetUtils.DrawSHPCentered(cantBuild.Image, icon.Pos + iconOffset, worldRenderer);
                }
            }

            // Overlays
            foreach (var icon in icons.Values)
            {
                var total = icon.Queued.Count;
                if (total > 0)
                {
                    var first   = icon.Queued[0];
                    var waiting = first != CurrentQueue.CurrentItem() && !first.Done;
                    if (first.Done)
                    {
                        if (ReadyTextStyle == ReadyTextStyleOptions.Solid || orderManager.LocalFrameNumber / 9 % 2 == 0)
                        {
                            overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, Color.White, Color.Black, 1);
                        }
                        else if (ReadyTextStyle == ReadyTextStyleOptions.AlternatingColor)
                        {
                            overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, ReadyTextAltColor, Color.Black, 1);
                        }
                    }
                    else if (first.Paused)
                    {
                        overlayFont.DrawTextWithContrast(HoldText,
                                                         icon.Pos + holdOffset,
                                                         Color.White, Color.Black, 1);
                    }
                    else if (!waiting)
                    {
                        overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(first.RemainingTimeActual),
                                                         icon.Pos + timeOffset,
                                                         Color.White, Color.Black, 1);
                    }

                    if (total > 1 || waiting)
                    {
                        overlayFont.DrawTextWithContrast(total.ToString(),
                                                         icon.Pos + queuedOffset,
                                                         Color.White, Color.Black, 1);
                    }
                }
            }
        }