Handle closing windows a bit better

Sends the window close packet if appropriate and also moves the mouse to
the center of the screen so your view doesn't jerk around when you
resume gameplay.
This commit is contained in:
Drew DeVault 2015-10-08 08:44:30 -04:00
parent be8649447a
commit 90f39b5696

View File

@ -5,6 +5,7 @@ using TrueCraft.Core.Logic.Items;
using TrueCraft.API.Logic;
using TrueCraft.Client.Input;
using Microsoft.Xna.Framework.Input;
using TrueCraft.Core.Networking.Packets;
namespace TrueCraft.Client.Modules
{
@ -60,7 +61,10 @@ namespace TrueCraft.Client.Modules
{
if (e.Key == Keys.Escape)
{
if (Game.Client.CurrentWindow.Type != -1)
Game.Client.QueuePacket(new CloseWindowPacket(Game.Client.CurrentWindow.ID));
Game.Client.CurrentWindow = null;
Mouse.SetPosition(Game.GraphicsDevice.Viewport.Width / 2, Game.GraphicsDevice.Viewport.Height / 2);
}
return true;
}