예제 #1
0
 public RadioButton(Vector2 position, SpriteFont font, string text = "RadioButton")
 {
     labelText = text;
     label = new TextDrawer(font, labelText, position + new Vector2(radius + 5,  -radius * 2), Color.White);
     Position = position;
     base.UIC_Initialize();
 }
예제 #2
0
 public RadioButton(Vector2 position, SpriteFont font, string text = "RadioButton")
 {
     labelText = text;
     label     = new TextDrawer(font, labelText, position + new Vector2(radius + 5, -radius * 2), Color.White);
     Position  = position;
     base.UIC_Initialize();
 }
예제 #3
0
파일: SliderBar.cs 프로젝트: YogurtFP/YogUI
        public SliderBar(Vector2 position, float width, float height, int min, int max, SpriteFont font, float progress = 0.0f)
        {
            this.width = width;
            this.height = height;
            this.min = min;
            this.max = max;
            progressBar = new ProgressBar(position, width, height, progress);
            Vector2 center = new Vector2((int)(position.X + (width / 2)), (int)(position.Y + (height / 2)));
            progressText = new TextDrawer(font, "", center, Color.White, TextAlign.Center);

            InputManager.BindMouse(() => {
                Point mousePoint = InputManager.GetMousePos();
                Vector2 mouseVector = new Vector2(mousePoint.X, mousePoint.Y);
                if ((progressBar.BoundBox.Contains(mousePoint) || selected) && !selectedOutside)
                {
                    int dist = (int)(mousePoint.X - progressBar.BoundBox.Left);
                    float p = (dist / progressBar.width) * 100;
                    p = (p > 0) ? (p < 100) ? p : 100 : 0;
                    progressBar.setProgress(p);
                    selected = true;
                }
                else
                {
                    selectedOutside = true;
                }
            }, MouseButton.Left, true, true);
            InputManager.BindMouse(() =>
            {
                selected = false;
                selectedOutside = false;
            }, MouseButton.Left, false);
        }
예제 #4
0
파일: SliderBar.cs 프로젝트: YogurtFP/YogUI
        public SliderBar(Vector2 position, float width, float height, int min, int max, SpriteFont font, float progress = 0.0f)
        {
            this.width  = width;
            this.height = height;
            this.min    = min;
            this.max    = max;
            progressBar = new ProgressBar(position, width, height, progress);
            Vector2 center = new Vector2((int)(position.X + (width / 2)), (int)(position.Y + (height / 2)));

            progressText = new TextDrawer(font, "", center, Color.White, TextAlign.Center);

            InputManager.BindMouse(() => {
                Point mousePoint    = InputManager.GetMousePos();
                Vector2 mouseVector = new Vector2(mousePoint.X, mousePoint.Y);
                if ((progressBar.BoundBox.Contains(mousePoint) || selected) && !selectedOutside)
                {
                    int dist = (int)(mousePoint.X - progressBar.BoundBox.Left);
                    float p  = (dist / progressBar.width) * 100;
                    p        = (p > 0) ? (p < 100) ? p : 100 : 0;
                    progressBar.setProgress(p);
                    selected = true;
                }
                else
                {
                    selectedOutside = true;
                }
            }, MouseButton.Left, true, true);
            InputManager.BindMouse(() =>
            {
                selected        = false;
                selectedOutside = false;
            }, MouseButton.Left, false);
        }
예제 #5
0
파일: CheckBox.cs 프로젝트: YogurtFP/YogUI
 public CheckBox(Vector2 position, SpriteFont font)
 {
     Position = position;
     Vector2 textPosition = new Vector2(position.X + 10, position.Y - (height));
     labelDrawer = new TextDrawer(font, label, textPosition, labelColor);
     base.UIC_Initialize();
 }
예제 #6
0
 public TextClickable(Vector2 position, string text, SpriteFont font, Color c, Color cHover, Action onClick)
 {
     tdI = new TextDrawer(font, text, position, c, TextAlign.Left);
     this.color = c;
     this.cHover = cHover;
     this.onClick = onClick;
     base.UIC_Initialize();
 }
예제 #7
0
 public TextClickable(Vector2 position, string text, SpriteFont font, Color c, Color cHover, Action onClick)
 {
     tdI          = new TextDrawer(font, text, position, c, TextAlign.Left);
     this.color   = c;
     this.cHover  = cHover;
     this.onClick = onClick;
     base.UIC_Initialize();
 }
예제 #8
0
        public CheckBox(Vector2 position, SpriteFont font)
        {
            Position = position;
            Vector2 textPosition = new Vector2(position.X + 10, position.Y - (height));

            labelDrawer = new TextDrawer(font, label, textPosition, labelColor);
            base.UIC_Initialize();
        }
예제 #9
0
파일: TextInput.cs 프로젝트: YogurtFP/YogUI
 public TextInput(Vector2 position, SpriteFont font, Color color, Action lambdaTextEnter, string input = "", Action lambdaTextChanged = null)
 {
     this.input = input;
     this.lambdaTextEnter = lambdaTextEnter;
     this.lambdaTextChanged = lambdaTextChanged;
     tdI = new TextDrawer(font, input, position, color, TextAlign.Left);
     this.bindKeys();
     base.UIC_Initialize();
 }
예제 #10
0
 public TextInput(Vector2 position, SpriteFont font, Color color, Action lambdaTextEnter, string input = "", Action lambdaTextChanged = null)
 {
     this.input             = input;
     this.lambdaTextEnter   = lambdaTextEnter;
     this.lambdaTextChanged = lambdaTextChanged;
     tdI = new TextDrawer(font, input, position, color, TextAlign.Left);
     this.bindKeys();
     base.UIC_Initialize();
 }
예제 #11
0
 public Button(Vector2 Position, string text, SpriteFont font, Action lambdaOnClick = null)
 {
     this.Position = Position;
     base.UIC_Initialize();
     this.lambdaOnClick = lambdaOnClick;
     td          = new TextDrawer(font, text, Position, textColor, TextAlign.Center);
     patchNormal = YogUI.btn_normal;
     patchHover  = YogUI.btn_hover;
     patchClick  = YogUI.btn_hover;
 }
예제 #12
0
파일: Button.cs 프로젝트: YogurtFP/YogUI
 public Button(Vector2 Position, string text, SpriteFont font, Action lambdaOnClick = null)
 {
     this.Position = Position;
     base.UIC_Initialize();
     this.lambdaOnClick = lambdaOnClick;
     td = new TextDrawer(font, text, Position, textColor, TextAlign.Center);
     patchNormal = YogUI.btn_normal;
     patchHover = YogUI.btn_hover;
     patchClick = YogUI.btn_hover;
 }
예제 #13
0
 public void BoundBoxTest()
 {
     SpriteFont font = null; // TODO: Initialize to an appropriate value
     string text = string.Empty; // TODO: Initialize to an appropriate value
     Vector2 position = new Vector2(); // TODO: Initialize to an appropriate value
     Color color = new Color(); // TODO: Initialize to an appropriate value
     TextAlign align = new TextAlign(); // TODO: Initialize to an appropriate value
     TextDrawer target = new TextDrawer(font, text, position, color, align); // TODO: Initialize to an appropriate value
     Rectangle actual;
     actual = target.BoundBox;
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
예제 #14
0
 public void DrawTest()
 {
     SpriteFont font = null; // TODO: Initialize to an appropriate value
     string text = string.Empty; // TODO: Initialize to an appropriate value
     Vector2 position = new Vector2(); // TODO: Initialize to an appropriate value
     Color color = new Color(); // TODO: Initialize to an appropriate value
     TextAlign align = new TextAlign(); // TODO: Initialize to an appropriate value
     TextDrawer target = new TextDrawer(font, text, position, color, align); // TODO: Initialize to an appropriate value
     SpriteBatch sb = null; // TODO: Initialize to an appropriate value
     target.Draw(sb);
     Assert.Inconclusive("A method that does not return a value cannot be verified.");
 }
예제 #15
0
파일: ComboBox.cs 프로젝트: YogurtFP/YogUI
        public ComboBox(Vector2 position, SpriteFont font, params string[] items)
        {
            Position = position;
            drop = new DropDownList(position + new Vector2((-width - 15), height / 2), font);
            label = new TextDrawer(font, "", position, Color.White, TextAlign.Center);
            drop.Hide();
            foreach (string item in items)
            {
                drop.AddItem(new Structs.DropDownItem(item, () => { updateSelected(); }));
            }
            if (items.Length > 0)
                selectedIndex = -1;

            base.UIC_Initialize();
        }
예제 #16
0
        public ComboBox(Vector2 position, SpriteFont font, params string[] items)
        {
            Position = position;
            drop     = new DropDownList(position + new Vector2((-width - 15), height / 2), font);
            label    = new TextDrawer(font, "", position, Color.White, TextAlign.Center);
            drop.Hide();
            foreach (string item in items)
            {
                drop.AddItem(new Structs.DropDownItem(item, () => { updateSelected(); }));
            }
            if (items.Length > 0)
            {
                selectedIndex = -1;
            }

            base.UIC_Initialize();
        }
예제 #17
0
 public void TextDrawerConstructorTest()
 {
     SpriteFont font = null; // TODO: Initialize to an appropriate value
     string text = string.Empty; // TODO: Initialize to an appropriate value
     Vector2 position = new Vector2(); // TODO: Initialize to an appropriate value
     Color color = new Color(); // TODO: Initialize to an appropriate value
     TextAlign align = new TextAlign(); // TODO: Initialize to an appropriate value
     TextDrawer target = new TextDrawer(font, text, position, color, align);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }