Пример #1
0
 public BrowserOptionButton(UDim2 position, UDim2 size, GUITheme theme, string text, TextAlign textAlign,
                            bool gotoParent, bool isFolder)
     : base(position, size, text, textAlign, theme)
 {
     ParentOption = gotoParent;
     IsFolder     = isFolder;
 }
Пример #2
0
 public GUIFrame(UDim2 position, UDim2 size, GUITheme theme)
     : base(theme)
 {
     Image    = theme.GetField <Image>(Image.Blank, "Frame.Image");
     Position = position;
     Size     = size;
 }
Пример #3
0
        public FileBrowserWindow(GUISystem system, GUITheme theme, UDim2 size, string title,
                                 FileBrowserMode mode, string[] exts, FileBrowserCompleted callback)
            : base(system, size, title, theme)
        {
            this.mode     = mode;
            this.callback = callback;
            this.exts     = exts;

            BMPFont smallFont = theme.GetField <BMPFont>(null, "SmallFont", "Font");

            dirField            = new GUITextField(new UDim2(0, 0, 0, 20), new UDim2(1, -40, 0, 20), Environment.CurrentDirectory, TextAlign.Left, theme);
            dirField.Label.Font = smallFont;

            GUIButton goToDirBtn = new GUIButton(new UDim2(1, -40, 0, 20), new UDim2(0, 40, 0, 20), "Go", theme);

            goToDirBtn.OnMouseClick += (btn, mbtn) =>
            {
                ScanDir();
            };

            GUILabel fileNameLabel = new GUILabel(new UDim2(0, 0, 1, -40), new UDim2(1, -200, 0, 20), "File Name:", TextAlign.Left, theme);

            selectedFileLabel            = new GUITextField(new UDim2(0, 0, 1, -20), new UDim2(1, -200, 0, 20), "", TextAlign.Left, theme);
            selectedFileLabel.Label.Font = smallFont;
            GUIButton doneBtn = new GUIButton(new UDim2(1, -100, 1, -40), new UDim2(0, 100, 0, 40),
                                              mode == FileBrowserMode.OpenFile ? "Open" : "Save", TextAlign.Center, theme);

            doneBtn.OnMouseClick += (btn, mbtn) => { callback(this); Visible = false; };
            GUIButton cancelBtn = new GUIButton(new UDim2(1, -200, 1, -40), new UDim2(0, 100, 0, 40), "Cancel", TextAlign.Center, theme);

            cancelBtn.OnMouseClick += (btn, mbtn) => { Visible = false; };

            AddTopLevel(dirField, goToDirBtn, fileNameLabel, selectedFileLabel, doneBtn, cancelBtn);
            ScanDir();
        }
Пример #4
0
 public GUICheckbox(UDim2 position, UDim2 size, string checkedText, GUITheme theme)
     : this(position, size, checkedText, theme,
            theme.GetField <Image>(Image.Blank, "Checkbox.NormalImage"),
            theme.GetField <Image>(Image.Blank, "Checkbox.HoverImage"),
            theme.GetField <Image>(Image.Blank, "Checkbox.ActiveImage"))
 {
 }
Пример #5
0
 public GUILabel(UDim2 position, UDim2 size, string text, TextAlign textAlign, Color textColor, GUITheme theme)
     : this(position, size, text, textAlign,
            theme.GetField <BMPFont>(null, "Label.Font", "Font"),
            textColor,
            theme.GetField <Color?>(null, "Label.TextShadowColor"))
 {
     Theme = theme;
 }
 public GUITextField(UDim2 position, UDim2 size, string text, GUITheme theme)
     : this(position, size, text, theme,
            theme.GetField <Image>(Image.Blank, "TextField.NormalImage"),
            theme.GetField <Image>(Image.Blank, "TextField.HoverImage"),
            theme.GetField <Image>(Image.Blank, "TextField.ActiveImage"),
            theme.GetField <Image>(Image.Blank, "TextField.ToggledImage"))
 {
 }
Пример #7
0
        public MessageWindow(GUISystem system, GUITheme theme, UDim2 size, string title)
            : base(system, size, title, theme)
        {
            msgLabel = new GUILabel(UDim2.Zero, new UDim2(1f, 0, 1f, -30), "", TextAlign.Center, theme);
            GUIButton okBtn = new GUIButton(new UDim2(0.5f, -75, 1f, -30), new UDim2(0, 150, 0, 30), "Okay", theme);

            okBtn.OnMouseClick += (btn, mbtn) => { Visible = false; };
            AddTopLevel(msgLabel, okBtn);
        }
Пример #8
0
        public GUICheckbox(UDim2 position, UDim2 size, string checkedText, GUITheme theme,
                           Image normalImg, Image hoverImg, Image activeImg)
            : base(theme)
        {
            Position = position;
            Size     = size;

            CapturesMouseClicks = true;
            Label = new GUILabel(UDim2.Zero, new UDim2(1f, 0, 1f, 0), checkedText,
                                 theme.GetField <Color>(Color.White, "Checkbox.TextColor", "Label.TextColor", "TextColor"),
                                 theme)
            {
                Parent = this, Visible = false
            };

            NormalImage = normalImg;
            HoverImage  = hoverImg;
            ActiveImage = activeImg;
        }
Пример #9
0
        public GUIDropDownButton(UDim2 position, UDim2 size, GUITheme theme,
                                 string text, GUIButtonClick onClick, GUIDropDown dropdown, object value,
                                 GUIDropDown sub, GUIDropDownButtonClick callback, int index)
            : base(position, size, text + (sub != null ? " >" : ""), theme)
        {
            Sub           = sub;
            this.dropdown = dropdown;
            Parent        = dropdown;
            Value         = value;
            Callback      = callback;
            Index         = index;

            if (sub != null)
            {
                ActiveImage = HoverImage;
            }

            Visible       = false;
            Label.Visible = false;
        }
Пример #10
0
 public GUICheckbox(UDim2 position, UDim2 size, GUITheme theme,
                    Image normalImg, Image hoverImg, Image activeImg)
     : this(position, size, "X", theme, normalImg, hoverImg, activeImg)
 {
 }
Пример #11
0
 public GUITextField(UDim2 position, UDim2 size, GUITheme theme)
     : this(position, size, "", theme)
 {
 }
Пример #12
0
 public GUIDropDown(UDim2 position, UDim2 size, GUITheme theme, bool applyTextOnClick)
     : base(position, size, "", theme)
 {
     this.applyTextOnClick = applyTextOnClick;
     Items = new List <GUIDropDownButton>();
 }
Пример #13
0
        public GUIButton(UDim2 position, UDim2 size, string text, TextAlign textAlign, GUITheme theme,
                         Image normalImg, Image hoverImg, Image activeImg, Image toggledImage)
            : base(theme)
        {
            Position = position;
            Size     = size;

            CapturesMouseClicks = true;
            Label = new GUILabel(UDim2.Zero, new UDim2(1f, 0, 1f, 0), text, textAlign,
                                 theme.GetField <Color>(Color.White, "Button.TextColor", "Label.TextColor", "TextColor"),
                                 theme)
            {
                Parent = this
            };

            NormalImage  = normalImg;
            HoverImage   = hoverImg;
            ActiveImage  = activeImg;
            ToggledImage = toggledImage;
        }
Пример #14
0
 public GUITextField(UDim2 position, UDim2 size, string text, TextAlign textAlign, GUITheme theme,
                     Image normalImg, Image hoverImg, Image activeImg, Image toggledImg)
     : base(position, size, text, textAlign, theme, normalImg, hoverImg, activeImg, toggledImg)
 {
 }
Пример #15
0
 public GUIButton(UDim2 position, UDim2 size, string text, GUITheme theme)
     : this(position, size, text, TextAlign.Center, theme)
 {
 }
Пример #16
0
 public GUIButton(UDim2 position, UDim2 size, string text, TextAlign textAlign, GUITheme theme)
     : this(position, size, text, textAlign, theme,
            theme.GetField <Image>(Image.Blank, "Button.NormalImage"),
            theme.GetField <Image>(Image.Blank, "Button.HoverImage"),
            theme.GetField <Image>(Image.Blank, "Button.ActiveImage"),
            theme.GetField <Image>(Image.Blank, "Button.ToggledImage"))
 {
 }
Пример #17
0
 public GUIButton(UDim2 position, UDim2 size, GUITheme theme)
     : this(position, size, "", theme)
 {
 }
Пример #18
0
 public GUIElement(GUITheme theme)
     : this()
 {
     Theme = theme;
 }
Пример #19
0
 public GUICheckbox(UDim2 position, float size, GUITheme theme)
     : this(position, new UDim2(0, size, 0, size), "X", theme)
 {
 }
        public GUIColorPicker(UDim2 position, UDim2 size, GUITheme theme)
            : base(theme)
        {
            // Generate static textures if necessary
            GenerateHuePalette();
            GenerateAlphaTextures();

            // Generate dynamic palette
            hsvPalette = new Texture();
            hsvPalette.Bind();

            hsvPalette.SetMinMag(TextureMinFilter.Linear, TextureMagFilter.Linear);
            hsvPalette.SetWrapMode(TextureWrapMode.ClampToEdge, TextureWrapMode.ClampToEdge);

            // Pre-allocate some room
            hsvPalette.SetData(25, 100, PixelType.UnsignedByte, PixelFormat.Rgba, IntPtr.Zero);

            hsvPalette.Unbind();

            // Set properties
            Position = position;
            Size     = size;

            // Build layout
            // Left layout
            GUIFrame pickerFrame = new GUIFrame(UDim2.Zero, new UDim2(1f, -90, 1f, 0),
                                                Image.CreateBlank(Color.Transparent))
            {
                Parent = this
            };

            hsvPicker = new GUIHSVPalette(this,
                                          UDim2.Zero, new UDim2(1f, -70, 1f, 0),
                                          new Image(hsvPalette))
            {
                Parent = pickerFrame
            };

            alphaSlider = new GUIAlphaSlider(this,
                                             new UDim2(1f, -60, 0, 0), new UDim2(0, 25, 1f, 0),
                                             new Image(checkersTex), new Image(alphaSliderTex))
            {
                Parent = pickerFrame
            };

            hueSlider = new GUIHueSlider(this,
                                         new UDim2(1f, -25, 0, 0), new UDim2(0, 25, 1f, 0),
                                         new Image(huePalette))
            {
                Parent = pickerFrame
            };

            // Right layout
            GUIFrame editFrame = new GUIFrame(new UDim2(1f, -80, 0, 0), new UDim2(0, 80, 1f, 0),
                                              Image.CreateBlank(Color.Transparent))
            {
                Parent = this
            };

            colorPreview = new GUIFrame(new UDim2(1f, -60, 0, 0), new UDim2(0, 60, 0, 60), Image.Blank)
            {
                Parent = editFrame
            };

            GUIFrame textFieldFrame = new GUIFrame(new UDim2(0, 0, 0, 70), new UDim2(1f, 0, 1f, -70),
                                                   Image.CreateBlank(Color.Transparent))
            {
                Parent = editFrame
            };

            BMPFont smallFont = theme.GetField <BMPFont>(null, "SmallFont");

            hueTextField        = AddEditField(textFieldFrame, smallFont, "H", 0);
            saturationTextField = AddEditField(textFieldFrame, smallFont, "S", 1);
            valueTextField      = AddEditField(textFieldFrame, smallFont, "V", 2);
            redTextField        = AddEditField(textFieldFrame, smallFont, "R", 3);
            greenTextField      = AddEditField(textFieldFrame, smallFont, "G", 4);
            blueTextField       = AddEditField(textFieldFrame, smallFont, "B", 5);
            alphaTextField      = AddEditField(textFieldFrame, smallFont, "A", 6);

            alphaLabel = (GUILabel)textFieldFrame.Children[textFieldFrame.Children.Count - 2];

            #region OnTextChanged Event Handlers
            hueTextField.OnTextChanged += (field, text) =>
            {
                float hue;
                if (float.TryParse(text, out hue))
                {
                    hueSlider.SetHue(hue);
                }

                UpdateColor();
            };

            saturationTextField.OnTextChanged += (field, text) =>
            {
                float sat;
                if (float.TryParse(text, out sat))
                {
                    hsvPicker.SetSV(sat, hsvPicker.Value * 100);
                }

                UpdateColor();
            };

            valueTextField.OnTextChanged += (field, text) =>
            {
                float val;
                if (float.TryParse(text, out val))
                {
                    hsvPicker.SetSV(hsvPicker.Saturation * 100, val);
                }

                UpdateColor();
            };

            redTextField.OnTextChanged += (field, text) =>
            {
                float r;
                if (float.TryParse(text, out r))
                {
                    float h, s, v;
                    Maths.RGBToHSV((byte)MathHelper.Clamp(r, 0, 255), Color.G, Color.B, out h, out s, out v);
                    hueSlider.SetHue(h);
                    hsvPicker.SetSV(s * 100, v * 100);
                }

                SetHue(hueSlider.Hue);
                UpdateColor();
            };

            greenTextField.OnTextChanged += (field, text) =>
            {
                float g;
                if (float.TryParse(text, out g))
                {
                    float h, s, v;
                    Maths.RGBToHSV(Color.R, (byte)MathHelper.Clamp(g, 0, 255), Color.B, out h, out s, out v);
                    hueSlider.SetHue(h);
                    hsvPicker.SetSV(s * 100, v * 100);
                }

                SetHue(hueSlider.Hue);
                UpdateColor();
            };

            blueTextField.OnTextChanged += (field, text) =>
            {
                float b;
                if (float.TryParse(text, out b))
                {
                    float h, s, v;
                    Maths.RGBToHSV(Color.R, Color.G, (byte)MathHelper.Clamp(b, 0, 255), out h, out s, out v);
                    hueSlider.SetHue(h);
                    hsvPicker.SetSV(s * 100, v * 100);
                }

                SetHue(hueSlider.Hue);
                UpdateColor();
            };

            alphaTextField.OnTextChanged += (field, text) =>
            {
                float alpha;
                if (float.TryParse(text, out alpha))
                {
                    alphaSlider.SetAlpha((int)alpha);
                }

                UpdateColor();
            };
            #endregion

            // Setup defaults
            SetHue(0);
            UpdateColor();
        }
Пример #21
0
 public GUICheckbox(UDim2 position, UDim2 size, GUITheme theme)
     : this(position, size, "X", theme)
 {
 }