Ejemplo n.º 1
0
        public OnClickVisitor(IInputAdapter inputAdapter)
        {
            this.inputAdapter = inputAdapter;

            previousMouseState = inputAdapter.GetMouseState();
            mouseState         = inputAdapter.GetMouseState();
        }
Ejemplo n.º 2
0
 public Game1()
 {
     inputAdapter          = new InputAdapter();
     graphics              = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     mouseState            = inputAdapter.GetMouseState();
     keyboardState         = inputAdapter.GetKeyboardState();
     windowFactory         = new WindowFactory();
 }
        public void Update(Button element, float deltaTime)
        {
            var mouseState    = inputAdapter.GetMouseState();
            var mouseIsInArea = element.Bounds.Contains(new Point2D <int>(mouseState.Position.X, mouseState.Position.Y));

            if (mouseIsInArea)
            {
                Mouse.SetCursor(MouseCursor.Hand); // Probably make an adapter for this
            }
        }
        public void Draw(Panel element)
        {
            var mouseState      = inputAdapter.GetMouseState();
            var mouseIsInArea   = element.Bounds.Contains(mouseState.Position);
            var leftMouseIsDown = mouseState.LeftButton == ButtonState.PRESSED;


            // Construct a rectangle, may be moved to a factory later?
            var rectangle = new Texture2D(graphicsDeviceManager.GraphicsDevice, element.Size.X, element.Size.Y);

            var data = new Color[element.Size.X * element.Size.Y];


            var workingBackgroundColor = element.BackgroundColor.Clone();

            // Color modifiers
            if (mouseIsInArea)
            {
                workingBackgroundColor.R -= 30;
                workingBackgroundColor.G -= 30;
                workingBackgroundColor.B -= 30;
            }
            if (leftMouseIsDown && mouseIsInArea)
            {
                workingBackgroundColor.R -= 20;
                workingBackgroundColor.G -= 20;
                workingBackgroundColor.B -= 20;
            }

            var backgroundColor = new Color(workingBackgroundColor.R, workingBackgroundColor.G, workingBackgroundColor.B, workingBackgroundColor.A);
            var borderColor     = new Color(element.BorderColor.R, element.BorderColor.G, element.BorderColor.B, element.BorderColor.A);

            for (int i = 0; i < data.Length; i++)
            {
                if (i % element.Size.X == 0 || i % element.Size.X == element.Size.X - 1 || i < element.Size.X || i > element.Size.X * (element.Size.Y - 1))
                {
                    data[i] = borderColor;
                }
                else
                {
                    data[i] = backgroundColor;
                }
            }

            rectangle.SetData(data);

            spriteBatch.Draw(rectangle, new Vector2(element.Position.X, element.Position.Y), Color.White);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // TODO: Add your update logic here
            previousState = mouseState;
            mouseState    = inputAdapter.GetMouseState();
            mousePosition = new Vector2(mouseState.Position.X, mouseState.Position.Y);

            keyboardState = inputAdapter.GetKeyboardState();

            switch (states)
            {
            case GameStates.MainWindow:
                while (mainWindowIterator.HasNext())
                {
                    mainWindowIterator.Next().Accept(updateVisitor);
                }
                break;

            case GameStates.LabelWindow:
                while (labelWindowIterator.HasNext())
                {
                    labelWindowIterator.Next().Accept(updateVisitor)
                    ;
                }
                break;

            case GameStates.InputFieldWindow:
                while (inputfieldIterator.HasNext())
                {
                    inputfieldIterator.Next().Accept(updateVisitor);
                }
                break;
            }

            base.Update(gameTime);
        }
Ejemplo n.º 6
0
 public void UpdateMouseState()
 {
     previousMouseState = mouseState;
     mouseState         = inputAdapter.GetMouseState();
 }