示例#1
0
        public void RefreshIcons()
        {
            icons = new Dictionary <Rectangle, ProductionIcon>();
            if (CurrentQueue == null)
            {
                return;
            }

            var allBuildables = CurrentQueue.AllItems().OrderBy(a => a.Traits.Get <BuildableInfo>().BuildPaletteOrder);
            var i             = 0;
            var rb            = RenderBounds;

            foreach (var item in allBuildables)
            {
                var x    = i % Columns;
                var y    = i / Columns;
                var rect = new Rectangle(rb.X + x * 64 + 1, rb.Y + y * 48 + 1, 64, 48);
                var icon = new Animation(RenderSimple.GetImage(item));
                icon.Play(item.Traits.Get <TooltipInfo>().Icon);
                var pi = new ProductionIcon()
                {
                    Name   = item.Name,
                    Sprite = icon.Image,
                    Pos    = new float2(rect.Location),
                    Queued = CurrentQueue.AllQueued().Where(a => a.Item == item.Name).ToList(),
                };
                icons.Add(rect, pi);
                i++;
            }

            eventBounds = icons.Keys.Aggregate(Rectangle.Union);
        }
示例#2
0
        public void RefreshIcons()
        {
            icons = new Dictionary <Rectangle, ProductionIcon>();
            if (CurrentQueue == null)
            {
                if (IconCount != 0)
                {
                    OnIconCountChanged(IconCount, 0);
                    IconCount = 0;
                }

                return;
            }

            var allBuildables = CurrentQueue.AllItems().OrderBy(a => a.Traits.Get <BuildableInfo>().BuildPaletteOrder);

            var oldIconCount = IconCount;

            IconCount = 0;

            var ks = Game.Settings.Keys;
            var rb = RenderBounds;

            foreach (var item in allBuildables)
            {
                var x    = IconCount % Columns;
                var y    = IconCount / Columns;
                var rect = new Rectangle(rb.X + x * (IconSize.X + IconMargin.X), rb.Y + y * (IconSize.Y + IconMargin.Y), IconSize.X, IconSize.Y);
                var icon = new Animation(World, RenderSimple.GetImage(item));
                icon.Play(item.Traits.Get <TooltipInfo>().Icon);

                var pi = new ProductionIcon()
                {
                    Actor  = item,
                    Name   = item.Name,
                    Hotkey = ks.GetProductionHotkey(IconCount),
                    Sprite = icon.Image,
                    Pos    = new float2(rect.Location),
                    Queued = CurrentQueue.AllQueued().Where(a => a.Item == item.Name).ToList(),
                };

                icons.Add(rect, pi);
                IconCount++;
            }

            eventBounds = icons.Any() ? icons.Keys.Aggregate(Rectangle.Union) : Rectangle.Empty;

            if (oldIconCount != IconCount)
            {
                OnIconCountChanged(oldIconCount, IconCount);
            }
        }