Ejemplo n.º 1
0
        bool HandleLeftClick(ProductionItem item, ProductionIcon icon, int handleCount)
        {
            if (PickUpCompletedBuildingIcon(icon, item))
            {
                Game.Sound.Play(SoundType.UI, TabClick);
                return(true);
            }

            if (item != null && item.Paused)
            {
                // Resume a paused item
                Game.Sound.Play(SoundType.UI, TabClick);
                World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, false));
                return(true);
            }

            if (CurrentQueue.BuildableItems().Any(a => a.Name == icon.Name))
            {
                // Queue a new item
                Game.Sound.Play(SoundType.UI, TabClick);
                Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, World.LocalPlayer.Faction.InternalName);
                World.IssueOrder(Order.StartProduction(CurrentQueue.Actor, icon.Name, handleCount));
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        bool HandleEvent(ProductionIcon icon, bool isLeftClick, bool handleMultiple)
        {
            var actor = World.Map.Rules.Actors[icon.Name];
            var first = icon.Queued.FirstOrDefault();

            if (isLeftClick)
            {
                // Pick up a completed building
                if (first != null && first.Done && actor.Traits.Contains <BuildingInfo>())
                {
                    Sound.Play(TabClick);
                    World.OrderGenerator = new PlaceBuildingOrderGenerator(CurrentQueue, icon.Name);
                }
                else if (first != null && first.Paused)
                {
                    // Resume a paused item
                    Sound.Play(TabClick);
                    World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, false));
                }
                else if (CurrentQueue.BuildableItems().Any(a => a.Name == icon.Name))
                {
                    // Queue a new item
                    Sound.Play(TabClick);
                    Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, World.LocalPlayer.Country.Race);
                    World.IssueOrder(Order.StartProduction(CurrentQueue.Actor, icon.Name,
                                                           handleMultiple ? 5 : 1));
                }
                else
                {
                    Sound.Play(DisabledTabClick);
                }
            }
            else
            {
                // Hold/Cancel an existing item
                if (first != null)
                {
                    Sound.Play(TabClick);

                    // instant cancel of things we havent started yet and things that are finished
                    if (first.Paused || first.Done || first.TotalCost == first.RemainingCost)
                    {
                        Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, World.LocalPlayer.Country.Race);
                        World.IssueOrder(Order.CancelProduction(CurrentQueue.Actor, icon.Name,
                                                                handleMultiple ? 5 : 1));
                    }
                    else
                    {
                        Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.OnHoldAudio, World.LocalPlayer.Country.Race);
                        World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, true));
                    }
                }
                else
                {
                    Sound.Play(DisabledTabClick);
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        bool HandleLeftClick(ProductionItem item, ProductionIcon icon, int handleCount)
        {
            if (PickUpCompletedBuildingIcon(icon, item))
            {
                Game.Sound.Play(SoundType.UI, TabClick);
                return(true);
            }

            if (item != null && item.Paused)
            {
                // Resume a paused item
                Game.Sound.Play(SoundType.UI, TabClick);
                World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, false));
                return(true);
            }

            var buildable = CurrentQueue.BuildableItems().FirstOrDefault(a => a.Name == icon.Name);

            if (buildable != null)
            {
                // Queue a new item
                Game.Sound.Play(SoundType.UI, TabClick);
                string notification;
                var    canQueue = CurrentQueue.CanQueue(buildable, out notification);
                Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", notification, World.LocalPlayer.Faction.InternalName);

                if (canQueue)
                {
                    World.IssueOrder(Order.StartProduction(CurrentQueue.Actor, icon.Name, handleCount));
                    return(true);
                }
            }

            return(false);
        }
        public override void Draw()
        {
            var iconOffset = 0.5f * IconSize.ToFloat2() + IconSpriteOffset;

            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);
                }

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

            // TODO: Selection overlay
        }
Ejemplo n.º 5
0
        bool HandleLeftClick(ProductionItem item, ProductionIcon icon, bool handleMultiple)
        {
            if (PickUpCompletedBuildingIcon(icon, item))
            {
                Sound.Play(TabClick);
                return(true);
            }

            if (item != null && item.Paused)
            {
                // Resume a paused item
                Sound.Play(TabClick);
                World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, false));
                return(true);
            }

            if (CurrentQueue.BuildableItems().Any(a => a.Name == icon.Name))
            {
                // Queue a new item
                Sound.Play(TabClick);
                Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, World.LocalPlayer.Country.Race);
                World.IssueOrder(Order.StartProduction(CurrentQueue.Actor, icon.Name,
                                                       handleMultiple ? 5 : 1));
                return(true);
            }

            return(false);
        }
        bool HandleLeftClick(ProductionItem item, ProductionIcon icon, int handleCount, Modifiers modifiers)
        {
            if (PickUpCompletedBuildingIcon(icon, item))
            {
                Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Sounds", ClickSound, null);
                return(true);
            }

            if (item != null && item.Paused)
            {
                // Resume a paused item
                Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Sounds", ClickSound, null);
                Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, World.LocalPlayer.Faction.InternalName);
                World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, false));
                return(true);
            }

            var buildable = CurrentQueue.BuildableItems().FirstOrDefault(a => a.Name == icon.Name);

            if (buildable != null)
            {
                // Queue a new item
                Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Sounds", ClickSound, null);
                string notification;
                var    canQueue = CurrentQueue.CanQueue(buildable, out notification);

                if (!CurrentQueue.AllQueued().Any())
                {
                    Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", notification, World.LocalPlayer.Faction.InternalName);
                }

                if (canQueue)
                {
                    var queued = !modifiers.HasModifier(Modifiers.Ctrl);
                    World.IssueOrder(Order.StartProduction(CurrentQueue.Actor, icon.Name, handleCount, queued));
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 7
0
        public override void Draw()
        {
            var iconOffset = 0.5f * IconSize.ToVector2() + IconSpriteOffset;

            overlayFont  = WarGame.Renderer.Fonts["TinyBold"];
            timeOffset   = iconOffset - overlayFont.Measure(WidgetUtils.FormatTime(0, World.Timestep)) / 2;
            queuedOffset = new Vector2(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);

                //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);
                }
            }
        }
Ejemplo n.º 8
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);
                    }
                }
            }
        }
Ejemplo n.º 9
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);
                    }
                }
            }
        }
Ejemplo n.º 10
0
        public override bool HandleMouseInput(MouseInput mi)
        {
            var icon = icons.Where(i => i.Key.Contains(mi.Location))
                       .Select(i => i.Value).FirstOrDefault();

            if (mi.Event == MouseInputEvent.Move)
            {
                TooltipActor = icon != null ? icon.Name : null;
            }

            if (icon == null)
            {
                return(false);
            }

            // Eat mouse-up events
            if (mi.Event != MouseInputEvent.Down)
            {
                return(true);
            }

            var actor = Rules.Info[icon.Name];
            var first = icon.Queued.FirstOrDefault();

            if (mi.Button == MouseButton.Left)
            {
                // Pick up a completed building
                if (first != null && first.Done && actor.Traits.Contains <BuildingInfo>())
                {
                    Sound.Play(TabClick);
                    World.OrderGenerator = new PlaceBuildingOrderGenerator(CurrentQueue.self, icon.Name);
                }
                else if (first != null && first.Paused)
                {
                    // Resume a paused item
                    Sound.Play(TabClick);
                    World.IssueOrder(Order.PauseProduction(CurrentQueue.self, icon.Name, false));
                }
                else if (CurrentQueue.BuildableItems().Any(a => a.Name == icon.Name))
                {
                    // Queue a new item
                    Sound.Play(TabClick);
                    Sound.PlayNotification(World.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, World.LocalPlayer.Country.Race);
                    World.IssueOrder(Order.StartProduction(CurrentQueue.self, icon.Name,
                                                           Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1));
                }
                else
                {
                    Sound.Play(DisabledTabClick);
                }
            }
            else if (mi.Button == MouseButton.Right)
            {
                // Hold/Cancel an existing item
                if (first != null)
                {
                    Sound.Play(TabClick);

                    // instant cancel of things we havent started yet and things that are finished
                    if (first.Paused || first.Done || first.TotalCost == first.RemainingCost)
                    {
                        Sound.PlayNotification(World.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, World.LocalPlayer.Country.Race);
                        World.IssueOrder(Order.CancelProduction(CurrentQueue.self, icon.Name,
                                                                Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1));
                    }
                    else
                    {
                        Sound.PlayNotification(World.LocalPlayer, "Speech", CurrentQueue.Info.OnHoldAudio, World.LocalPlayer.Country.Race);
                        World.IssueOrder(Order.PauseProduction(CurrentQueue.self, icon.Name, true));
                    }
                }
                else
                {
                    Sound.Play(DisabledTabClick);
                }
            }

            return(true);
        }
Ejemplo n.º 11
0
        public override void Draw()
        {
            timeOffset = iconOffset - overlayFont.Measure(WidgetUtils.FormatTime(0, World.Timestep)) / 2;

            if (CurrentQueue == null)
            {
                return;
            }

            var buildableItems = CurrentQueue.BuildableItems();

            // Icons
            Game.Renderer.EnableAntialiasingFilter();
            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);
                }
            }

            Game.Renderer.DisableAntialiasingFilter();

            // Overlays
            foreach (var icon in icons.Values)
            {
                var total = icon.Queued.Count;
                if (total > 0)
                {
                    var first   = icon.Queued[0];
                    var waiting = !CurrentQueue.IsProducing(first) && !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 && DrawTime)
                    {
                        overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(first.Queue.RemainingTimeActual(first), World.Timestep),
                                                         icon.Pos + timeOffset,
                                                         Color.White, Color.Black, 1);
                    }

                    if (first.Infinite && symbolFont != null)
                    {
                        symbolFont.DrawTextWithContrast(InfiniteSymbol,
                                                        icon.Pos + infiniteOffset,
                                                        Color.White, Color.Black, 1);
                    }
                    else if (total > 1 || waiting)
                    {
                        overlayFont.DrawTextWithContrast(total.ToString(),
                                                         icon.Pos + queuedOffset,
                                                         Color.White, Color.Black, 1);
                    }
                }
            }
        }
Ejemplo n.º 12
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);
                    }
                }
            }
        }
        public override void Draw()
        {
            var iconOffsetToCenter = 0.5f * IconSize.ToFloat2() + IconSpriteOffset;

            timeOffset   = iconOffsetToCenter - overlayFont.Measure(WidgetUtils.FormatTime(0, World.Timestep)) / 2;
            queuedOffset = new float2(4, 2);
            holdOffset   = iconOffsetToCenter - overlayFont.Measure(HoldText) / 2;
            readyOffset  = iconOffsetToCenter - overlayFont.Measure(ReadyText) / 2;

            if (ChromeMetrics.TryGet("InfiniteOffset", out infiniteOffset))
            {
                infiniteOffset += queuedOffset;
            }
            else
            {
                infiniteOffset = queuedOffset;
            }

            if (CurrentQueue == null)
            {
                return;
            }

            var buildableItems = CurrentQueue.BuildableItems();

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

            // Icons
            foreach (ProductionIcon icon in icons.Values)
            {
                WidgetUtils.DrawSHPCentered(icon.Sprite, icon.Pos + iconOffsetToCenter, icon.Palette, icon.RenderSize);                 //этот метод использует размер от icon.Sprite.Size для размера в FastQuad

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

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

                        WidgetUtils.DrawSHPCentered(clock.Image, icon.Pos + iconOffsetToCenter, icon.IconClockPalette, icon.RenderSize);
                    }
                    else
                    {
                        int    currentframe = (first.TotalTime - first.RemainingTime) * (59) / first.TotalTime;
                        float3 offs         = iconOffsetToCenter - 0.5f * icon.RenderSize.ToFloat2(); // из-за  icon.Pos + iconOffsetToCenter и DrawSHPCentered
                        Game.Renderer.Flush();                                                        // делаем, это  тут, так как рисуем вне очереди, то управляем очередью.
                        Game.Renderer.sproc.AddCommand(1, currentframe, 59, 0, 0, new int2(0, 0), icon.Pos + offs, icon.RenderSize, icon.Sprite, icon.Palette);
                        Game.Renderer.sproc.ExecCommandBuffer();
                    }
                }
                else if (!buildableItems.Any(a => a.Name == icon.Name))
                {
                    WidgetUtils.DrawSHPCentered(cantBuild.Image, icon.Pos + iconOffsetToCenter, icon.IconDarkenPalette, icon.RenderSize);
                }
            }

            // Overlays
            foreach (ProductionIcon icon in icons.Values)
            {
                var total = icon.Queued.Count;
                if (total > 0)
                {
                    var first   = icon.Queued[0];
                    var waiting = !CurrentQueue.IsProducing(first) && !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 && DrawTime)
                    {
                        overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(first.Queue.RemainingTimeActual(first), World.Timestep),
                                                         icon.Pos + timeOffset,
                                                         Color.White, Color.Black, 1);
                    }

                    if (first.Infinite)
                    {
                        symbolFont.DrawTextWithContrast(InfiniteSymbol,
                                                        icon.Pos + infiniteOffset,
                                                        Color.White, Color.Black, 1);
                    }
                    else if (total > 1 || waiting)
                    {
                        overlayFont.DrawTextWithContrast(total.ToString(),
                                                         icon.Pos + queuedOffset,
                                                         Color.White, Color.Black, 1);
                    }
                }
            }
        }