Пример #1
0
        void SetupProductionGroupButton(ProductionTypeButtonWidget button)
        {
            if (button == null)
            {
                return;
            }

            Action <bool> selectTab = reverse =>
            {
                if (tabs.QueueGroup == button.ProductionGroup)
                {
                    tabs.SelectNextTab(reverse);
                }
                else
                {
                    tabs.QueueGroup = button.ProductionGroup;
                }

                tabs.PickUpCompletedBuilding();
            };

            button.IsDisabled    = () => !tabs.Groups[button.ProductionGroup].Tabs.Any(t => t.Queue.BuildableItems().Any());
            button.OnMouseUp     = mi => selectTab(mi.Modifiers.HasModifier(Modifiers.Shift));
            button.OnKeyPress    = e => selectTab(e.Modifiers.HasModifier(Modifiers.Shift));
            button.IsHighlighted = () => tabs.QueueGroup == button.ProductionGroup;

            var chromeName = button.ProductionGroup.ToLowerInvariant();
            var icon       = button.Get <ImageWidget>("ICON");

            icon.GetImageName = () => button.IsDisabled() ? chromeName + "-disabled" :
                                tabs.Groups[button.ProductionGroup].Alert ? chromeName + "-alert" : chromeName;
        }
Пример #2
0
        void SetupProductionGroupButton(ProductionTypeButtonWidget button)
        {
            if (button == null)
            {
                return;
            }

            Action <bool> selectTab = reverse =>
            {
                if (tabs.QueueGroup == button.ProductionGroup)
                {
                    tabs.SelectNextTab(reverse);
                }
                else
                {
                    tabs.QueueGroup = button.ProductionGroup;
                }

                tabs.PickUpCompletedBuilding();
            };

            Func <ButtonWidget, Hotkey> getKey = _ => Hotkey.Invalid;

            if (!string.IsNullOrEmpty(button.HotkeyName))
            {
                var ks    = Game.Settings.Keys;
                var field = ks.GetType().GetField(button.HotkeyName);
                if (field != null)
                {
                    getKey = _ => (Hotkey)field.GetValue(ks);
                }
            }

            button.IsDisabled    = () => tabs.Groups[button.ProductionGroup].Tabs.Count == 0;
            button.OnMouseUp     = mi => selectTab(mi.Modifiers.HasModifier(Modifiers.Shift));
            button.OnKeyPress    = e => selectTab(e.Modifiers.HasModifier(Modifiers.Shift));
            button.IsHighlighted = () => tabs.QueueGroup == button.ProductionGroup;
            button.GetKey        = getKey;

            var chromeName = button.ProductionGroup.ToLowerInvariant();
            var icon       = button.Get <ImageWidget>("ICON");

            icon.GetImageName = () => button.IsDisabled() ? chromeName + "-disabled" :
                                tabs.Groups[button.ProductionGroup].Alert ? chromeName + "-alert" : chromeName;
        }
Пример #3
0
        void SetupProductionGroupButton(ToggleButtonWidget button, string group)
        {
            Action<bool> selectTab = reverse =>
            {
                if (queueTabs.QueueGroup == group)
                    queueTabs.SelectNextTab(reverse);
                else
                    queueTabs.QueueGroup = group;
            };

            button.IsDisabled = () => queueTabs.Groups[group].Tabs.Count == 0;
            button.OnMouseUp = mi => selectTab(mi.Modifiers.HasModifier(Modifiers.Shift));
            button.OnKeyPress = e => selectTab(e.Modifiers.HasModifier(Modifiers.Shift));
            button.IsToggled = () => queueTabs.QueueGroup == group;
            var chromeName = group.ToLowerInvariant();
            var icon = button.Get<ImageWidget>("ICON");
            icon.GetImageName = () => button.IsDisabled() ? chromeName+"-disabled" :
                queueTabs.Groups[group].Alert ? chromeName+"-alert" : chromeName;
        }