Example #1
0
        public virtual void DrawInfo(IDrawContext context)
        {
            Vector2 position = new Vector2(Bounds.Right + 2, Bounds.Top);

            context.DrawString(GlobalContent.Default.InfoFont, ClickState.ToString(), position, Color.Yellow);
            position += new Vector2(0, 20 + 4);
            context.DrawString(GlobalContent.Default.InfoFont, IsEnabled ? "Enabled": "Not enabled", position, Color.Yellow);
        }
Example #2
0
        //TODO Not finished, can still crashed if begin was not called
        public static void Draw()
        {
            //Draw the GUI

            //Write current click state to screen
            DrawingUtils.DrawFullRectangle(new Rectangle(0, 0, 210, 30), new Color(Color.Black, 150), true);
            DrawingUtils.DrawMessage("Current : " + _state.ToString(), Color.Orange);
            DrawSelectedUnitInfos();

            //Draw the mouse over tiles
            if (_tilesToDraw != null && _tilesToDraw.Count > 0)
            {
                foreach (KeyValuePair <Tile, Color> t in _tilesToDraw)
                {
                    DrawingUtils.DrawRectangle(new Rectangle(t.Key.Position.X * Engine.TileWidth, t.Key.Position.Y * Engine.TileHeight, Engine.TileWidth, Engine.TileHeight), t.Value, true);
                }
            }
        }
Example #3
0
        public override void Update(GameTime time)
        {
            // update saved screen.
            PreviousKeyboardState = CurrentKeyboardState;
            PreviousMouseState = CurrentMouseState;
            CurrentKeyboardState = Keyboard.GetState ();
            CurrentMouseState = Mouse.GetState ();

            if (time != null) {
                bool mouseMoved;
                if (CurrentMouseState != PreviousMouseState) {
                    // mouse movements
                    Vector2 mouseMove = CurrentMouseState.ToVector2 () - PreviousClickMouseState.ToVector2 ();
                    mouseMoved = mouseMove.Length () > 3;
                }
                else {
                    mouseMoved = false;
                }

                LeftButtonClickTimer += time.ElapsedGameTime.TotalMilliseconds;
                if (CurrentMouseState.LeftButton == ButtonState.Pressed && PreviousMouseState.LeftButton != ButtonState.Pressed) {
                    LeftMouseButton = LeftButtonClickTimer < 500 && !mouseMoved
                                      ? ClickState.DoubleClick : ClickState.SingleClick;
                    LeftButtonClickTimer = 0;
                    PreviousClickMouseState = PreviousMouseState;
                    Console.WriteLine ("LeftButton=" + LeftMouseButton.ToString ());
                }
                else {
                    LeftMouseButton = ClickState.None;
                }
                RightButtonClickTimer += time.ElapsedGameTime.TotalMilliseconds;
                if (CurrentMouseState.RightButton == ButtonState.Pressed && PreviousMouseState.RightButton != ButtonState.Pressed) {
                    RightMouseButton = RightButtonClickTimer < 500 && !mouseMoved
                                       ? ClickState.DoubleClick : ClickState.SingleClick;
                    RightButtonClickTimer = 0;
                    PreviousClickMouseState = PreviousMouseState;
                    Console.WriteLine ("RightButton=" + RightMouseButton.ToString ());
                }
                else {
                    RightMouseButton = ClickState.None;
                }
            }

            // fullscreen
            if (Keys.G.IsDown () || Keys.F11.IsDown ()) {
                screen.game.IsFullscreen = !screen.game.IsFullscreen;
                FullscreenToggled = true;
            }
        }