static MouseCursor() { Position = Vector2.Zero; IsVisible = true; state = MouseCursorState.None; didLoadResources = false; currentCursor = null; cursorResources = null; }
static MouseCursor() { Position = Vector2.Zero; IsVisible = true; state = MouseCursorState.None; didLoadResources = false; currentCursor = null; cursorResources = null; }
internal override void Update(Microsoft.Xna.Framework.GameTime gameTime) { if (GamePaused) { return; } Performance.Push("Game loop - base.Update"); base.Update(gameTime); Performance.Pop(); Performance.Push("Game loop - UpdateUI"); UpdateUI(); Performance.Pop(); bool leftClickNeeded = false; if (MapControl.InputHandler.InputMode == InputMode.Classic) { // TODO: Use me leftClickNeeded = true; } bool shouldScroll = false; MouseCursorState newState = MouseCursorState.None; if (currentPointerPos.X <= 3) { shouldScroll = true; scrollDelta.X -= scrollSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; newState = MouseCursorState.ScrollLeft; } if (currentPointerPos.Y <= 3) { shouldScroll = true; scrollDelta.Y -= scrollSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; if (newState == MouseCursorState.None) { newState = MouseCursorState.ScrollTop; } else { newState = MouseCursorState.ScrollTopleft; } } if (currentPointerPos.X >= Width - 3) { shouldScroll = true; scrollDelta.X += scrollSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; if (newState == MouseCursorState.ScrollTop) { newState = MouseCursorState.ScrollTopright; } else { newState = MouseCursorState.ScrollRight; } } if (currentPointerPos.Y >= Height - 3) { shouldScroll = true; scrollDelta.Y += scrollSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; if (newState == MouseCursorState.ScrollLeft) { newState = MouseCursorState.ScrollBottomleft; } else if (newState == MouseCursorState.ScrollRight) { newState = MouseCursorState.ScrollBottomright; } else { newState = MouseCursorState.ScrollBottom; } } if (shouldScroll) { MouseCursor.State = newState; Vector2 clampedScrollDelta = scrollDelta; clampedScrollDelta.X = (float)((int)scrollDelta.X / MapControl.TileWidth) * MapControl.TileWidth; clampedScrollDelta.Y = (float)((int)scrollDelta.Y / MapControl.TileHeight) * MapControl.TileHeight; MapControl.SetCameraOffset(MapControl.CameraTileX * MapControl.TileWidth + clampedScrollDelta.X, MapControl.CameraTileY * MapControl.TileHeight + clampedScrollDelta.Y); if (clampedScrollDelta.X != 0) { scrollDelta.X = 0; } if (clampedScrollDelta.Y != 0) { scrollDelta.Y = 0; } } else { scrollDelta.X = 0; scrollDelta.Y = 0; } }