public override void HandleInput(GameTime gameTime, InputService input) { if (ScrollableGame.IsKeyPressed(Keys.Enter)) { OK_Selected(this, EventArgs.Empty); } if (ScrollableGame.IsKeyPressed(Keys.Escape)) { Cancel_Selected(this, EventArgs.Empty); } base.HandleInput(gameTime, input); }
protected bool MouseCollide() { Point point; if (UseScrolling) { point = new Point(ScrollableGame.MousePoint.X - (int)ScrollableGame.Scrolling.X, ScrollableGame.MousePoint.Y - (int)ScrollableGame.Scrolling.Y); } else { point = ScrollableGame.MousePoint; } return(Rec.Contains(point) && ScrollableGame.InScrollableRenderTarget(point) && (ScrollableGame.CheckValidTouchLocation() || ScrollableGame.CheckLeftReleased())); }
public override void Update(GameTime gameTime) { if (!Enabled || !Game.IsActive) { return; } _mouseDown = ScrollableGame.CheckLeftDown() || ScrollableGame.CheckLeftPressed(); bool newMouseOver = MouseCollide(); // Se antes não estava com o MouseOver e agora esta if (!IsMouseOver && newMouseOver) { if (MouseOver != null) { MouseOver(this, EventArgs.Empty); } } // Se antes estava com o MouseOver e agora não esta if (!newMouseOver && IsMouseOver) { if (MouseOut != null) { MouseOut(this, EventArgs.Empty); } } IsMouseOver = newMouseOver; Hits = Hits && _mouseDown && IsMouseOver; if (IsMouseOver && ScrollableGame.CheckLeftPressed()) { _pressedOver = true; Hits = true; } if (ScrollableGame.CheckLeftReleased()) { if (IsMouseOver && _pressedOver) { OnClick(); Hits = true; } _pressedOver = false; } base.Update(gameTime); }
public override void Update(GameTime gameTime) { if (!Enabled || !Game.IsActive) { return; } if (Rec.Contains(ScrollableGame.MousePoint)) { if (ScrollableGame.CheckLeftPressed()) { _clickXDif = ScrollableGame.MousePos.X; _clickYDif = ScrollableGame.MousePos.Y; } else if (ScrollableGame.CheckLeftDown()) { if (Horizontal) { XDif -= ScrollableGame.MousePos.X - _clickXDif; if (XDif > Width - _sourceRec.Width) { XDif = Width - _sourceRec.Width; } if (XDif < 0) { XDif = 0; } _sourceRec.X = (int)XDif; _clickXDif = ScrollableGame.MousePos.X; } if (Vertical) { YDif -= ScrollableGame.MousePos.Y - _clickYDif; if (YDif > Height - _sourceRec.Height) { YDif = Height - _sourceRec.Height; } if (YDif < 0) { YDif = 0; } _sourceRec.Y = (int)YDif; _clickYDif = ScrollableGame.MousePos.Y; } } } base.Update(gameTime); }
public override void Update(GameTime gameTime) { if (!Enabled || !Game.IsActive) { return; } bool mouseDown = ScrollableGame.CheckLeftDown() || ScrollableGame.CheckLeftPressed(); bool mouseOver = MouseCollide(); Hits = Hits && mouseDown && mouseOver; if (mouseOver && ScrollableGame.CheckLeftPressed()) { SetFocus(); Hits = true; } if (SelectedGuid == MyGuid) { _cursorFlickTime += gameTime.ElapsedGameTime; if (_cursorFlickTime.TotalMilliseconds >= 500) { ShowCursorFlick = !ShowCursorFlick; _cursorFlickTime = TimeSpan.Zero; } if (ValidadeKeyboard()) { if (SelectedEvent != null) { SelectedEvent(this, new EventArgs()); } } } else { ShowCursorFlick = false; } base.Update(gameTime); }
/// <summary> /// Responds to user input, changing the selected entry and accepting /// or cancelling the menu. /// </summary> public override void HandleInput(GameTime gameTime, InputService input) { var pressed = ScrollableGame.CheckLeftPressed(); if (pressed) { CheckMenuEntrySelection(ScrollableGame.MousePoint, input); } if ((ShowBackMenuEntry && backMenuEntry.Enabled && pressed && GetMenuEntryHitBounds(backMenuEntry).Contains(ScrollableGame.MousePoint)) #if GAMEPAD || (input.CurrentGamePadState.IsButtonDown(Buttons.Back) && input.LastGamePadState.IsButtonUp(Buttons.Back)) #endif ) { if (ButtonClicked != null) { ButtonClicked(backMenuEntry, EventArgs.Empty); } OnCancel(); } }
public override void Update(GameTime gameTime) { if (!Enabled || !Game.IsActive) { return; } // Select for Drag if (ScrollableGame.CheckLeftPressed(true)) { if (Rect.Contains(ScrollableGame.MousePoint)) { Draging = true; Hits = true; _draggedDif = ScrollableGame.MousePos; } } // Dragging if (Draging && ScrollableGame.CheckLeftDown()) { var pos = ScrollableGame.MousePos - _draggedDif; _draggedDif = ScrollableGame.MousePos; if (Horizontal) { PosX += (int)pos.X; var widthDif = Width - BarWidth; if (widthDif <= 0 || PosX < 0) { PosX = 0; } else if (widthDif > 0 && PosX > widthDif) { PosX = widthDif; } if (widthDif > 0) { PercentageX = PosX / widthDif; } else { UpdateRec(); } } if (Vertical) { PosY += (int)pos.Y; var heightDif = Height - BarHeight; if (heightDif <= 0 || PosY < 0) { PosY = 0; } else if (heightDif > 0 && PosY > heightDif) { PosY = heightDif; } if (heightDif > 0) { PercentageY = PosY / heightDif; } else { UpdateRec(); } } } // Drop if (ScrollableGame.CheckLeftReleased()) { Draging = false; Hits = false; } base.Update(gameTime); }
public override void Update(GameTime gameTime) { if (!Enabled || !Game.IsActive) { return; } UpdateRec(); // Select for Drag if (ScrollableGame.CheckLeftPressed(true)) { if (Rect.Contains(ScrollableGame.MousePoint)) { Draging = true; _draggedDif = ScrollableGame.MousePos; } if (_rec2.Contains(ScrollableGame.MousePoint)) { Hits = true; } } // Dragging if (Draging && ScrollableGame.CheckLeftDown()) { var pos = ScrollableGame.MousePos - _draggedDif; _draggedDif = ScrollableGame.MousePos; if (Vertical) { PosY += (int)pos.Y; var heightDif = Height - BarHeight; if (heightDif <= 0 || PosY < 0) { PosY = 0; } else if (heightDif > 0 && PosY > heightDif) { PosY = heightDif; } if (heightDif > 0) { PercentageY = PosY / heightDif; } UpdateRec(); ScrollContainer.Percentage = PercentageY; } } // Drop if (ScrollableGame.CheckLeftReleased()) { Draging = false; Hits = false; } _barraUp.Position = Position + new Vector2(0, PosY); _barraDown.Position = Position; base.Update(gameTime); }
/// <summary> /// Allows each screen to run logic. /// </summary> public override void Update(GameTime gameTime) { UpdateTouchPanelSize(); // Read the keyboard and gamepad. if (!SuppressInputUpdate) { _input.Update(gameTime); } SuppressInputUpdate = false; // Make a copy of the master screen list, to avoid confusion if // the process of updating one screen adds or removes others. _tempScreensList.Clear(); foreach (GameScreen screen in _screens) { _tempScreensList.Add(screen); } bool otherScreenHasFocus = !Game.IsActive; bool coveredByOtherScreen = false; // Loop as long as there are screens waiting to be updated. while (_tempScreensList.Count > 0) { // Pop the topmost screen off the waiting list. GameScreen screen = _tempScreensList[_tempScreensList.Count - 1]; _tempScreensList.RemoveAt(_tempScreensList.Count - 1); // Update the screen. screen.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); if (screen.ScreenState == ScreenState.TransitionOn || screen.ScreenState == ScreenState.Active) { // If this is the first active screen we came across, // give it a chance to handle input. if (!otherScreenHasFocus) { screen.HandleInput(gameTime, _input); otherScreenHasFocus = true; } // If this is an active non-popup, inform any subsequent // screens that they are covered by it. if (!screen.IsPopup) { coveredByOtherScreen = true; } } } ScrollableGame.End(); // Print debug trace? if (_traceEnabled) { TraceScreens(); } }
public override void Update(GameTime gameTime) { if (!Enabled) { return; } bool scrollDrag = false; if (_scroll != null) { _scroll.Update(gameTime); scrollDrag = _scroll.Draging || _scroll.Hits; } if (!scrollDrag) { // Select for Drag if (ScrollableGame.CheckLeftPressed(true)) { if (_rect.Contains(ScrollableGame.MousePoint)) { _draging = true; _draggedDifInicial = _draggedDif = ScrollableGame.MousePos; } } // Dragging if (_draging && ScrollableGame.CheckLeftDown()) { if (Horizontal) { var pos = ScrollableGame.MousePos.X - _draggedDif.X; _draggedDif = ScrollableGame.MousePos; PosDif -= (int)pos; if (Math.Abs(ScrollableGame.MousePos.X - _draggedDifInicial.X) > 5) { Button.CancelClick = true; } var widthDif = ContentSize - Width; if (widthDif <= 0 || PosDif < 0) { PosDif = 0; } else if (widthDif > 0 && PosDif > widthDif) { PosDif = widthDif; } if (widthDif > 0) { Percentage = PosDif / widthDif; } } else { var pos = ScrollableGame.MousePos.Y - _draggedDif.Y; _draggedDif = ScrollableGame.MousePos; PosDif -= (int)pos; if (Math.Abs(ScrollableGame.MousePos.Y - _draggedDifInicial.Y) > 5) { Button.CancelClick = true; } var heightDif = ContentSize - Height; if (heightDif <= 0 || PosDif < 0) { PosDif = 0; } else if (heightDif > 0 && PosDif > heightDif) { PosDif = heightDif; } if (heightDif > 0) { Percentage = PosDif / heightDif; } } } // Drop if (ScrollableGame.CheckLeftReleased() #if SILVERLIGHT || !_rect.Contains(ScrollableGame.MousePoint) #endif ) { _draging = false; #if SILVERLIGHT Microsoft.Xna.Framework.Input.Mouse.LeftButtonDown = false; #endif } ScrollableGame.Begin(this); if (_scrollable != null) { _scrollable.Update(gameTime); } ScrollableGame.End(this); } UpdateContentSize(); base.Update(gameTime); }