private void SetGraphicsDeviceWidthHeight(ResolutionProperty resolution) { GraphicsDeviceManager.PreferredBackBufferWidth = resolution.Width; GraphicsDeviceManager.PreferredBackBufferHeight = resolution.Height; GraphicsDeviceManager.SynchronizeWithVerticalRetrace = Settings.Engine.IsVSyncEnabled; GraphicsDeviceManager.ApplyChanges(); }
protected void SetGraphicsDeviceWidthHeight(ResolutionProperty resolution) { DeviceManager.PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8; DeviceManager.PreferredBackBufferWidth = resolution.Width; DeviceManager.PreferredBackBufferHeight = resolution.Height; DeviceManager.SynchronizeWithVerticalRetrace = Settings.Engine.IsVSyncEnabled; DeviceManager.ApplyChanges(); }
public static bool IsValidFullScreenResolution(ResolutionProperty resolution) { foreach (ResolutionProperty res in FullScreenResolutionsList) { if (resolution.Width == res.Width && resolution.Height == res.Height) { return(true); } } return(false); }
public UserInterfaceSettings() { FullScreenResolution = new ResolutionProperty(); WindowResolution = new ResolutionProperty(); PlayWindowGumpResolution = new ResolutionProperty(); m_PlayWindowPixelDoubling = false; IsMaximized = false; Mouse = new MouseProperty(); AlwaysRun = false; MenuBarDisabled = false; }
private void doMouseMovement(double frameMS) { Mobile player = (Mobile)WorldModel.Entities.GetPlayerEntity(); if (player == null) { return; } // if the move button is pressed, change facing and move based on mouse cursor direction. if (ContinuousMouseMovementCheck) { ResolutionProperty resolution = Settings.UserInterface.PlayWindowGumpResolution; Point centerScreen = new Point(resolution.Width / 2, resolution.Height / 2); Direction mouseDirection = DirectionHelper.DirectionFromPoints(centerScreen, MouseOverWorldPosition); m_TimeSinceMovementButtonPressed += frameMS; if (m_TimeSinceMovementButtonPressed >= c_PauseBeforeMouseMovementMS) { // Get the move direction. Direction moveDirection = mouseDirection; // add the running flag if the mouse cursor is far enough away from the center of the screen. float distanceFromCenterOfScreen = Utility.DistanceBetweenTwoPoints(centerScreen, MouseOverWorldPosition); if (distanceFromCenterOfScreen >= 150.0f || Settings.UserInterface.AlwaysRun) { moveDirection |= Direction.Running; } player.PlayerMobile_Move(moveDirection); } else { // Get the move direction. Direction facing = mouseDirection; if (player.Facing != facing) { // Tell the player entity to change facing to this direction. player.PlayerMobile_ChangeFacing(facing); // reset the time since the mouse cursor was pressed - allows multiple facing changes. m_TimeSinceMovementButtonPressed = 0d; } } } else { m_TimeSinceMovementButtonPressed = 0d; // Tell the player to stop moving. player.PlayerMobile_Move(Direction.Nothing); } }
public void SaveResolution() { if (IsMaximized) { Settings.UserInterface.IsMaximized = true; } else { ResolutionProperty res = new ResolutionProperty(DeviceManager.PreferredBackBufferWidth, DeviceManager.PreferredBackBufferHeight); Settings.UserInterface.WindowResolution = res; } }
protected override void OnDraw(double frameMS) { if (!IsMinimized) { if (Models.Current is WorldModel) { ResolutionProperty resolution = Settings.UserInterface.PlayWindowGumpResolution; CheckWindowSize(resolution.Width, resolution.Height); } else { CheckWindowSize(800, 600); } Models.Current.GetView().Draw(frameMS); m_UserInterface.Draw(frameMS); } }
private void CheckWindowSize(int minWidth, int minHeight) { GameWindow window = this.Window; // (sender as GameWindow); ResolutionProperty resolution = new ResolutionProperty(window.ClientBounds.Width, window.ClientBounds.Height); // this only occurs when the world is active. Make sure that we don't reduce the window size // smaller than the world gump size. if (resolution.Width < minWidth) { resolution.Width = minWidth; } if (resolution.Height < minHeight) { resolution.Height = minHeight; } if (resolution.Width != window.ClientBounds.Width || resolution.Height != window.ClientBounds.Height) { SetGraphicsDeviceWidthHeight(resolution); } }
public static void SetWindowSize(GameWindow window) { Rectangle game; System.Drawing.Rectangle screen; if (window != null) { game = window.ClientBounds; screen = Screen.GetWorkingArea(new System.Drawing.Rectangle(game.X, game.Y, game.Width, game.Height)); } else { screen = Screen.GetWorkingArea(new System.Drawing.Point(0, 0)); } foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes) { if (mode.Format != SurfaceFormat.Color) { continue; } ResolutionProperty res = new ResolutionProperty(mode.Width, mode.Height); if (res.Width <= MAX_BUFFER_SIZE && res.Height <= MAX_BUFFER_SIZE) { if (!FullScreenResolutionsList.Contains(res)) { FullScreenResolutionsList.Add(res); } } } foreach (ResolutionProperty res in FullScreenResolutionsList) { if (!PlayWindowResolutionsList.Contains(res) && res.Width <= screen.Width && res.Height <= screen.Height) { PlayWindowResolutionsList.Add(res); } } }
set => SetValue(ResolutionProperty, value);
protected override void BeforeDraw(SpriteBatchUI spriteBatch, Point position) { Mobile player = WorldModel.Entities.GetPlayerEntity(); // Hue the cursor if not in warmode and in trammel. if (WorldModel.IsInWorld && !player.Flags.IsWarMode && (m_World.MapIndex == 1)) { CursorHue = 2414; } else { CursorHue = 0; } if (IsHoldingItem) { ItemSpriteArtIndex = HeldItem.DisplayItemID; if (m_ItemSprite != null) { m_ItemSprite.Hue = HeldItem.Hue; m_ItemSprite.Offset = m_HeldItemOffset; if (HeldItem.Amount > 1 && HeldItem.ItemData.IsGeneric && HeldItem.DisplayItemID == HeldItem.ItemID) { int offset = HeldItem.ItemData.Unknown4; m_ItemSprite.Draw(spriteBatch, new Point(position.X - 5, position.Y - 5)); } m_ItemSprite.Draw(spriteBatch, position); } // set up to draw standard cursor sprite above item art. base.BeforeDraw(spriteBatch, position); } else if (IsTargeting) { int artworkIndex = 8310; if (WorldModel.IsInWorld && player.Flags.IsWarMode) { // Over the interface or not in world. Display a default cursor. artworkIndex -= 23; } CursorSpriteArtIndex = artworkIndex; CursorOffset = new Point(13, 13); // sourceRect = new Rectangle(1, 1, 46, 34); /*if (m_targetingMulti != -1) * { * // UNIMPLEMENTED !!! Draw a transparent multi * }*/ } else if ((m_World.Input.ContinuousMouseMovementCheck || m_World.Input.IsMouseOverWorld) && !m_UserInterface.IsModalControlOpen) { ResolutionProperty resolution = Settings.UserInterface.PlayWindowGumpResolution; Direction mouseDirection = DirectionHelper.DirectionFromPoints(new Point(resolution.Width / 2, resolution.Height / 2), m_World.Input.MouseOverWorldPosition); int artIndex = 0; switch (mouseDirection) { case Direction.North: CursorOffset = new Point(29, 1); artIndex = 8299; break; case Direction.Right: CursorOffset = new Point(41, 9); artIndex = 8300; break; case Direction.East: CursorOffset = new Point(36, 24); artIndex = 8301; break; case Direction.Down: CursorOffset = new Point(14, 33); artIndex = 8302; break; case Direction.South: CursorOffset = new Point(2, 26); artIndex = 8303; break; case Direction.Left: CursorOffset = new Point(2, 10); artIndex = 8304; break; case Direction.West: CursorOffset = new Point(1, 1); artIndex = 8305; break; case Direction.Up: CursorOffset = new Point(4, 2); artIndex = 8298; break; default: CursorOffset = new Point(2, 10); artIndex = 8309; break; } if (WorldModel.IsInWorld && player.Flags.IsWarMode) { // Over the interface or not in world. Display a default cursor. artIndex -= 23; } CursorSpriteArtIndex = artIndex; } else { // cursor is over UI or there is a modal message box open. Set up to draw standard cursor sprite. base.BeforeDraw(spriteBatch, position); } }