예제 #1
0
            public List <GuiElement> addPanel(string name, Rectangle rectangle, GuiElement parent, Layer layer, GuiColor panelColor = null, float FadeIn = 0, float FadeOut = 0, GuiText text = null, string imgName = null, Blur blur = Blur.none)
            {
                if (string.IsNullOrEmpty(name))
                {
                    name = "panel";
                }
                purgeDuplicates(name);

                List <GuiElement> panel = GuiPanel.GetNewGuiPanel(plugin, name, rectangle, parent, layer, panelColor, FadeIn, FadeOut, text, imgName, blur);

                AddRange(panel);
                return(panel);
            }
예제 #2
0
            public static List <GuiElement> GetNewGuiInputField(
                Plugin plugin,
                GuiContainer container,
                string name,
                Rectangle rectangle,
                Action <BasePlayer,
                        string[]> callback,
                GuiElement parent,
                Layer layer,
                string close        = null,
                GuiColor panelColor = null,
                int charLimit       = 100,
                GuiText text        = null,
                float FadeIn        = 0,
                float FadeOut       = 0,
                bool isPassword     = false,
                bool CursorEnabled  = true,
                string imgName      = null,
                Blur blur           = Blur.none)
            {
                List <GuiElement> elements = new List <GuiElement>();

                Layer higherLayer = layer;

                if (parent != null)
                {
                    higherLayer = (Layer)Math.Min((int)layer, (int)parent.Layer);
                }

                StringBuilder closeString = new StringBuilder("");

                if (close != null)
                {
                    closeString.Append(" --close ");
                    closeString.Append(close);
                }

                if (text != null)
                {
                    text.FadeIn = FadeIn;
                }

                if (imgName != null || panelColor != null)
                {
                    elements.AddRange(
                        GuiPanel.GetNewGuiPanel(
                            plugin,
                            name + "_label",
                            rectangle,
                            parent,
                            layer,
                            panelColor,
                            FadeIn,
                            FadeOut,
                            null,
                            imgName,
                            blur
                            ));
                }

                elements.Add(new GuiElement
                {
                    Name          = name,
                    Rectangle     = rectangle.WithParent(parent?.Rectangle),
                    Layer         = higherLayer,
                    Parent        = layers[(int)higherLayer],
                    FadeOut       = FadeOut,
                    ParentElement = parent,
                    Components    =
                    {
                        new CuiInputFieldComponent
                        {
                            Align      = text.Align,
                            FontSize   = text.FontSize,
                            Color      = text.Color,
                            Command    = $"gui.input {plugin.Name} {container.name} {removeWhiteSpaces(name)}{closeString} --input",
                            CharsLimit = charLimit,
                            IsPassword = isPassword
                        },
                        rectangle.WithParent(parent?.Rectangle)
                    }
                });

                if (CursorEnabled)
                {
                    elements.Add(new GuiElement()
                    {
                        Name       = name + "_cursor",
                        Parent     = name,
                        Components =
                        {
                            new CuiNeedsCursorComponent()
                        }
                    });
                }

                return(elements);
            }