예제 #1
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));
 }
예제 #2
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;
                    }
                }
            }
        }
예제 #3
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);
            }
        }
예제 #4
0
 public static void InWorldUpdate()
 {
     Game1.PlayerWorldInstance.Update(MouseInput.MouseRealPosGame());
     Camera2DWorld.Update();
     Game1.mapLiveWorld.Update();
 }