Ejemplo n.º 1
0
        public void Update(ListPage page)
        {
            if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()) == true)
            {
                if (_state != ListItemStatesEnum.selected)
                {
                    _state = ListItemStatesEnum.hover;
                }
                if (MouseInput.MouseStateNew.LeftButton == ButtonState.Released && MouseInput.MouseStateOld.LeftButton == ButtonState.Pressed)
                {
                    page.CloseOthers(this);
                    _state = ListItemStatesEnum.selected;
                }
            }
            else
            {
                if (_state != ListItemStatesEnum.selected)
                {
                    _state = ListItemStatesEnum.none;
                }
            }

            if (_state == ListItemStatesEnum.selected)
            {
                foreach (Keys key in Enum.GetValues(typeof(Keys)))
                {
                    if (KeyboardInput.KeyboardStateNew.IsKeyDown(key))
                    {
                        Game1.STP.ControlKeys[_key] = key;
                        _state = ListItemStatesEnum.none;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public static void Draw(Vector2 gridStart)
 {
     if (Item != null)
     {
         Game1.SpriteBatchGlobal.Draw(Item.Texture, new Vector2((int)((MouseInput.MouseRealPosMenu().X - gridStart.X + 24) / 48) * 48 + gridStart.X, (int)((MouseInput.MouseRealPosMenu().Y - gridStart.Y + 24) / 48) * 48 + gridStart.Y), origin: new Vector2(192 / 2), rotation: Item.Rotation);
     }
 }
Ejemplo n.º 3
0
        public void Update()
        {
            if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()))
            {
                if (MouseInput.ScrolledDown())
                {
                    _offset -= 64f;
                }
                if (MouseInput.ScrolledUp())
                {
                    _offset += 64f;
                }
            }

            if (_offset < -((32 * _items.Count) - Boundary.Size.Y + 32))
            {
                _offset = -((32 * _items.Count) - Boundary.Size.Y + 32);
            }

            if (_offset > 0)
            {
                _offset = 0;
            }

            for (int i = 0; i < _items.Count; i++)
            {
                _items[i].Move(_offset);
                _items[i].Update(this);
            }
        }
Ejemplo n.º 4
0
        public void UpdateBase()
        {
            _doubleClickTime.Update();

            if (CompareF.RectangleVsVector2(_listBoundary, MouseInput.MouseRealPosMenu()) == true)
            {
                if (MouseInput.MouseStateNew.LeftButton == ButtonState.Released && MouseInput.MouseStateOld.LeftButton == ButtonState.Pressed)
                {
                    if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()) == true && CompareF.RectangleVsVector2(_listBoundary, MouseInput.MouseRealPosMenu()) == true)
                    {
                        _doubleClickTime.Reset();

                        if (_doubleClickTime.Ready == false)
                        {
                            _clicks++;
                        }
                        else
                        {
                            _clicks = 1;
                            _doubleClickTime.Reset();
                        }

                        Selected = true;
                    }

                    if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()) == false)
                    {
                        Selected = false;
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public override void Draw()
 {
     if (Selected == true)
     {
         Game1.SpriteBatchGlobal.Draw(Game1.Textures["TileBackSelected"], _boundary.Position, sourceRectangle: new Rectangle(0, 0, 256 + 16, 256 + 16));
     }
     else if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()) == true && CompareF.RectangleVsVector2(_listBoundary, MouseInput.MouseRealPosMenu()) == true)
     {
         Game1.SpriteBatchGlobal.Draw(Game1.Textures["TileBackHover"], _boundary.Position, sourceRectangle: new Rectangle(0, 0, 256 + 16, 256 + 16));
     }
     Game1.SpriteBatchGlobal.Draw(_tex, _boundary.Position + new Vector2(8));
 }
Ejemplo n.º 6
0
        public void Set()
        {
            if (_grabed == true)
            {
                _bar = new RectangleF(16, BarSize(), Start.X, MouseInput.MouseRealPosMenu().Y - _grabOffset);
                _scrollByBar?.Invoke();
            }

            _bar.Size = new Vector2(_bar.Size.X, BarSize());

            Limit();
        }
Ejemplo n.º 7
0
 public override void Draw()
 {
     if (Selected == true)
     {
         Game1.SpriteBatchGlobal.Draw(Game1.Textures["TileBackSelected"], _boundary.Position, Color.White);
     }
     else if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()) == true && CompareF.RectangleVsVector2(_listBoundary, MouseInput.MouseRealPosMenu()) == true)
     {
         Game1.SpriteBatchGlobal.Draw(Game1.Textures["TileBackHover"], _boundary.Position, Color.White);
     }
     Game1.SpriteBatchGlobal.Draw(Game1.Textures[_tile.TextureName], _boundary.Position + new Vector2(4), sourceRectangle: new Rectangle(new Point(_tile.IndexInPicture.X * 32, _tile.IndexInPicture.Y * 32), new Point(32)), scale: new Vector2(1));
 }
Ejemplo n.º 8
0
        public void Update()
        {
            MouseItem.Update();

            Inventory.Update();

            if (MouseInput.MouseClickedLeft())
            {
                if (MouseItem.Item != null && GridCraft.AddItem(MouseInput.MouseRealPosMenu(), _items, MouseItem.Item.Rotation) == true)
                {
                    if (Game1.PlayerInstance.Items.Any(i => i.Type == MouseItem.Item.Type) == true)
                    {
                        Game1.PlayerInstance.Items.Single(i => i.Type == MouseItem.Item.Type).Amount--;
                    }

                    if (Game1.PlayerInstance.Items.Single(i => i.Type == MouseItem.Item.Type).Amount <= 0)
                    {
                        Game1.PlayerInstance.Items.Remove(Game1.PlayerInstance.Items.Single(i => i.Type == MouseItem.Item.Type));
                    }

                    MouseItem.Item = null;

                    Inventory.ResetChoosed();
                    CalculateAll();
                }
            }

            if (MouseInput.MouseClickedRight())
            {
                GridItem item = GridCraft.RemoveItem(MouseInput.MouseRealPosMenu(), _items);

                if (item != null)
                {
                    if (Game1.PlayerInstance.Items.Any(i => i.Type == item.Type) == true)
                    {
                        Game1.PlayerInstance.Items.Single(i => i.Type == item.Type).Amount++;
                    }
                    else
                    {
                        Game1.PlayerInstance.Items.Add(new PlayersItem(item.Type, 1));
                    }
                }

                UIShop.Instance.Sync();

                CalculateAll();
            }
            UIShop.Instance.Sync();
            Inventory.Set();
        }
Ejemplo n.º 9
0
        public bool InClickable()
        {
            if (Droped == false)
            {
                Clickable = new RectangleF(_width, 32, __position.X, __position.Y);
            }
            else
            {
                Clickable = new RectangleF(_width, names.GetLength(0) * 32 + 32, __position.X, __position.Y);
            }

            if (CompareF.RectangleVsVector2(Clickable, MouseInput.MouseRealPosMenu()) == true)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 10
0
        public void Update()
        {
            if (MouseInput.MouseStateNew.LeftButton == ButtonState.Pressed && MouseInput.MouseStateOld.LeftButton == ButtonState.Released)
            {
                if (CompareF.RectangleVsVector2(_boudary, MouseInput.MouseRealPosMenu()) == true)
                {
                    _grabed = GraberState.grabed;
                }
            }
            else if (MouseInput.MouseStateNew.LeftButton == ButtonState.Released)
            {
                if (CompareF.RectangleVsVector2(_boudary, MouseInput.MouseRealPosMenu()) == true)
                {
                    _grabed = GraberState.hover;
                }
                else
                {
                    _grabed = GraberState.none;
                }
            }

            if (_grabed == GraberState.grabed)
            {
                _boudary.Position = new Vector2(MouseInput.MouseRealPosMenu().X, _boudary.Position.Y) - new Vector2(_boudary.Size.X / 2, 0);
            }
            if (_boudary.Position.X < _position.X - _boudary.Size.X / 2)
            {
                _boudary.Position = new Vector2(_position.X - _boudary.Size.X / 2, _boudary.Position.Y);
            }

            if (_boudary.Position.X > _position.X + 255 - _boudary.Size.X / 2)
            {
                _boudary.Position = new Vector2(_position.X + 255 - _boudary.Size.X / 2, _boudary.Position.Y);
            }

            if (_onChange != null)
            {
                if (_grabed == GraberState.grabed)
                {
                    _onChange(GetValue());
                }
            }
        }
Ejemplo n.º 11
0
        public override void Draw()
        {
            if (Selected == true)
            {
                Game1.SpriteBatchGlobal.DrawAtlas(Game1.Textures["SaveBackground"], _boundary.Position + new Vector2(0, 16), new Point(736, 256), new Point(0, 2));
            }
            else
            {
                if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()) == true && CompareF.RectangleVsVector2(_listBoundary, MouseInput.MouseRealPosMenu()) == true)
                {
                    Game1.SpriteBatchGlobal.DrawAtlas(Game1.Textures["SaveBackground"], _boundary.Position + new Vector2(0, 16), new Point(736, 256), new Point(0, 1));
                }
                else
                {
                    Game1.SpriteBatchGlobal.DrawAtlas(Game1.Textures["SaveBackground"], _boundary.Position + new Vector2(0, 16), new Point(736, 256), new Point(0, 0));
                }
            }

            Game1.SpriteBatchGlobal.Draw(_preview, _boundary.Position + new Vector2(16) + new Vector2(0, 16), scale: new Vector2((256f - 32f) / Globals.WinRenderSize.Y));

            DrawString.DrawText(_saveName, _boundary.Position + new Vector2(576, 16) + new Vector2(0, 16), Align.center, new Color(255, 255, 255), FontType.small);
        }
Ejemplo n.º 12
0
        public void Update(float contentSize)
        {
            ContentSize = contentSize;

            if (ContentSize > ContentContainerSize)
            {
                if (CompareF.RectangleVsVector2(_bar, MouseInput.MouseRealPosMenu()) == true && MouseInput.MouseStateNew.LeftButton == ButtonState.Pressed && MouseInput.MouseStateOld.LeftButton == ButtonState.Released)
                {
                    _grabed     = true;
                    _grabOffset = MouseInput.MouseRealPosMenu().Y - _bar.Position.Y;
                }
                if (MouseInput.MouseStateNew.LeftButton == ButtonState.Released)
                {
                    _grabed     = false;
                    _grabOffset = 0;
                }

                _up.Update();
                _down.Update();

                Set();
            }
        }
Ejemplo n.º 13
0
        public void Update()
        {
            _oldSelectedIndex = SelectedIndex;

            _scrollBar.Update(GetLenghtOfContent());

            if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()))
            {
                if (MouseInput.ScrolledDown())
                {
                    _scrollBar.ScroolDown();
                }
                if (MouseInput.ScrolledUp())
                {
                    _scrollBar.ScroolUp();
                }
            }

            Set();

            SelectedIndex = null;

            foreach (IHolderItem tile in Items)
            {
                tile.Update();

                if (tile.Selected == true)
                {
                    SelectedIndex = tile.Index;
                }
            }

            if (ChangedSelection() == true)
            {
                _method?.Invoke();
            }
        }
Ejemplo n.º 14
0
        public bool Update()
        {
            bool returnClicked = false;

            _border.Position = Position;

            if (_locked == false)
            {
                if (_clickedIn == false)
                {
                    if (CompareF.RectangleVsVector2(_border, MouseInput.MouseRealPosMenu()) == true)
                    {
                        StateOfButton = ButtonStates.hover;
                    }
                    else
                    {
                        StateOfButton = ButtonStates.none;
                    }
                }

                if (_clickedIn == true)
                {
                    if (CompareF.RectangleVsVector2(_border, MouseInput.MouseRealPosMenu()) == true && MouseInput.MouseStateNew.LeftButton == ButtonState.Released)
                    {
                        _method?.Invoke();
                        _methodWindow?.Invoke(_changeWin);
                        _methodIndex?.Invoke(_index);
                        Game1.soundSelect.Play();
                        returnClicked = true;
                    }

                    if (CompareF.RectangleVsVector2(_border, MouseInput.MouseRealPosMenu()) == false && MouseInput.MouseStateNew.LeftButton == ButtonState.Pressed)
                    {
                        StateOfButton = ButtonStates.none;
                    }
                    if (CompareF.RectangleVsVector2(_border, MouseInput.MouseRealPosMenu()) == true && MouseInput.MouseStateNew.LeftButton == ButtonState.Pressed)
                    {
                        StateOfButton = ButtonStates.pressed;
                    }
                }

                if (_clickedIn == false && _clickedOut == false)
                {
                    if (CompareF.RectangleVsVector2(_border, MouseInput.MouseRealPosMenu()) == false && MouseInput.MouseStateNew.LeftButton == ButtonState.Pressed)
                    {
                        _clickedOut = true;
                    }

                    if (CompareF.RectangleVsVector2(_border, MouseInput.MouseRealPosMenu()) == true && MouseInput.MouseStateNew.LeftButton == ButtonState.Pressed && MouseInput.MouseStateOld.LeftButton == ButtonState.Released)
                    {
                        _clickedIn    = true;
                        StateOfButton = ButtonStates.pressed;
                    }
                }

                if (MouseInput.MouseStateNew.LeftButton == ButtonState.Released)
                {
                    _clickedIn  = false;
                    _clickedOut = false;

                    if (CompareF.RectangleVsVector2(_border, MouseInput.MouseRealPosMenu()) == true)
                    {
                        StateOfButton = ButtonStates.hover;
                    }
                    else
                    {
                        StateOfButton = ButtonStates.none;
                    }
                }
            }
            else
            {
                StateOfButton = ButtonStates.locked;
            }

            return(returnClicked);
        }
Ejemplo n.º 15
0
        public bool Update()
        {
            _textOld = Text;

            if (MouseInput.MouseClickedLeft() == true)
            {
                if (CompareF.RectangleVsVector2(_boundary, MouseInput.MouseRealPosMenu()) == true)
                {
                    IsActive = true;
                    _cursor  = (int)Math.Round(MouseInput.MouseRealPosMenu().X - _boundary.Position.X) / 16;
                    if (_cursor > Text.Length)
                    {
                        _cursor = Text.Length;
                    }
                    if (_cursor < 0)
                    {
                        _cursor = 0;
                    }
                    MakeVisible();
                }
                else
                {
                    IsActive = false;
                    MakeVisible();
                }
            }

            if (IsActive == true)
            {
                keys = KeyboardInput.GetPressedKeys();
                _backSpace.Update();
                _left.Update();
                _right.Update();

                _blink.Update();
                if (_blink.Ready == true)
                {
                    _cursorVisible = !_cursorVisible;
                    _blink.Reset();
                }

                foreach (Keys key in keys)
                {
                    int number = (int)key;

                    if (_type == textBoxType.text || _type == textBoxType.fileName)
                    {
                        if (number >= 65 && number <= 90)
                        {
                            if (_cursor <= Text.Length)
                            {
                                Text = Text.Insert(_cursor + _offset, key.ToString());
                                CursorAdd();
                                MakeVisible();
                            }
                        }
                        if (key == Keys.Space)
                        {
                            if (_cursor <= Text.Length)
                            {
                                Text = Text.Insert(_cursor + _offset, " ");
                                CursorAdd();
                                MakeVisible();
                            }
                        }
                    }
                    if (number >= 96 && number <= 105)
                    {
                        if (_cursor <= Text.Length)
                        {
                            Text = Text.Insert(_cursor + _offset, (number - 96).ToString());
                            CursorAdd();
                            MakeVisible();
                        }
                    }
                    if (number >= 48 && number <= 57)
                    {
                        if (_cursor <= Text.Length)
                        {
                            Text = Text.Insert(_cursor + _offset, (number - 48).ToString());
                            CursorAdd();
                            MakeVisible();
                        }
                    }
                    if (key == Keys.OemMinus || key == Keys.Subtract)
                    {
                        if (_cursor <= Text.Length)
                        {
                            Text = Text.Insert(_cursor + _offset, "-");
                            CursorAdd();
                            MakeVisible();
                        }
                    }
                }

                if (KeyboardInput.KeyboardStateNew.IsKeyDown(Keys.Back) == true && KeyboardInput.KeyboardStateOld.IsKeyDown(Keys.Back) == true)
                {
                    if (_backSpace.Ready == true)
                    {
                        if (_cursor > 0 || _offset > 0)
                        {
                            Text = Text.Remove(_cursor - 1 + _offset, 1);
                            MakeVisible();
                            _backSpace.Reset();
                        }

                        if (_offset > 0)
                        {
                            _offset--;
                        }
                        else if (_cursor > 0)
                        {
                            _cursor--;
                        }
                    }
                }

                if (KeyboardInput.KeyboardStateNew.IsKeyDown(Keys.Left) == true && KeyboardInput.KeyboardStateOld.IsKeyDown(Keys.Left) == true)
                {
                    if (_left.Ready == true)
                    {
                        if (_cursor > 0)
                        {
                            _cursor--;
                        }
                        else if (_offset > 0)
                        {
                            _offset--;
                        }
                        MakeVisible();
                        _left.Reset();
                    }
                }
                if (KeyboardInput.KeyboardStateNew.IsKeyDown(Keys.Right) == true && KeyboardInput.KeyboardStateOld.IsKeyDown(Keys.Right) == true)
                {
                    if (_right.Ready == true)
                    {
                        if (_cursor < Text.Length)
                        {
                            if (_cursor < (int)((_boundary.Size.X - 16) / 16))
                            {
                                _cursor++;
                            }
                            else if (_offset < Text.Length - (int)((_boundary.Size.X - 16) / 16))
                            {
                                _offset++;
                            }
                        }

                        MakeVisible();
                        _right.Reset();
                    }
                }
            }

            int i = 0;

            Parsed = int.TryParse(Text, out i);

            Valid = true;
            if ((Text.IndexOfAny(Path.GetInvalidFileNameChars()) != -1 && _type == textBoxType.fileName) || Text == "")
            {
                Valid = false;
            }
            if (_type == textBoxType.number && Parsed == true && (i < _min || i > _max))
            {
                Valid = false;
            }
            if (Parsed == false && _type == textBoxType.number)
            {
                Valid = false;
            }

            if (_changeMehod != null)
            {
                _changeMehod?.Invoke();
                return(true);
            }
            else
            {
                return(false);
            }
        }