Ejemplo n.º 1
0
        public VerbCategoryPopup(VerbSystem system, IEnumerable <Verb> verbs, VerbType type, EntityUid target, bool drawOnlyIcons)
            : base()
        {
            // Do any verbs have icons? If not, don't bother leaving space for icons in the pop-up.
            var drawVerbIcons = false;

            foreach (var verb in verbs)
            {
                if (verb.Icon != null)
                {
                    drawVerbIcons = true;
                    break;
                }
            }

            // If no verbs have icons. we cannot draw only icons
            if (drawVerbIcons == false)
            {
                drawOnlyIcons = false;
            }

            // If we are drawing only icons, show them side by side
            if (drawOnlyIcons)
            {
                List.Orientation = LayoutOrientation.Horizontal;
            }

            foreach (var verb in verbs)
            {
                AddToMenu(new VerbButton(system, verb, type, target, drawVerbIcons));
            }
        }
Ejemplo n.º 2
0
        public VerbButton(VerbSystem system, Verb verb, VerbType type, EntityUid target, bool drawIcons = true, bool categoryPrefix = false) : base()
        {
            Disabled     = verb.Disabled;
            ToolTip      = verb.Tooltip;
            TooltipDelay = 0.5f;

            var buttonContents = new BoxContainer {
                Orientation = LayoutOrientation.Horizontal
            };

            // maybe draw verb icons
            if (drawIcons)
            {
                TextureRect icon = new()
                {
                    MinSize      = (ContextMenuPopup.ButtonHeight, ContextMenuPopup.ButtonHeight),
                    Stretch      = TextureRect.StretchMode.KeepCentered,
                    TextureScale = (0.5f, 0.5f)
                };

                // Even though we are drawing icons, the icon for this specific verb may be null.
                if (verb.Icon != null)
                {
                    icon.Texture = verb.Icon.Frame0();
                }
                else if (categoryPrefix && verb.Category?.Icon != null)
                {
                    // we will use the category icon instead
                    icon.Texture = verb.Category.Icon.Frame0();
                }

                buttonContents.AddChild(icon);
            }

            // maybe add a label
            if (verb.Text != string.Empty || categoryPrefix)
            {
                // First add a small bit of padding
                buttonContents.AddChild(new Control {
                    MinSize = (4, ContextMenuPopup.ButtonHeight)
                });