Change how mouse is handled in client

This makes it playable on Wayland, which I've been using a lot lately.
This commit is contained in:
Drew DeVault 2015-11-20 17:32:58 -05:00
parent c374b38b3f
commit 7e2d657393
4 changed files with 53 additions and 3 deletions

View File

@ -28,7 +28,7 @@ namespace TrueCraft.Client.Input
: base(x, y)
{
DeltaX = deltaX;
DeltaY = DeltaY;
DeltaY = deltaY;
}
}
}

View File

@ -215,9 +215,13 @@ namespace TrueCraft.Client.Modules
return false;
var centerX = Game.GraphicsDevice.Viewport.Width / 2;
var centerY = Game.GraphicsDevice.Viewport.Height / 2;
Mouse.SetPosition(centerX, centerY);
if (e.X < 10 || e.X > Game.GraphicsDevice.Viewport.Width - 10 ||
e.Y < 10 || e.Y > Game.GraphicsDevice.Viewport.Height - 10)
{
Mouse.SetPosition(centerX, centerY);
}
var look = new Vector2((centerX - e.X), (centerY - e.Y))
var look = new Vector2((-e.DeltaX), (-e.DeltaY))
* (float)(gameTime.ElapsedGameTime.TotalSeconds * 30);
Game.Client.Yaw -= look.X;

View File

@ -425,4 +425,45 @@ namespace TrueCraft.Commands
client.SendMessage("/reinv: Resends your inventory.");
}
}
public class RelightCommand : Command
{
public override string Name
{
get { return "relight"; }
}
public override string Description
{
get { return "Relights the chunk you're standing in."; }
}
public override string[] Aliases
{
get { return new string[0]; }
}
public override void Handle(IRemoteClient client, string alias, string[] arguments)
{
if (arguments.Length != 0)
{
Help(client, alias, arguments);
return;
}
var server = client.Server as MultiplayerServer;
var chunk = client.World.FindChunk((Coordinates3D)client.Entity.Position);
var lighter = server.WorldLighters.SingleOrDefault(l => l.World == client.World);
if (lighter != null)
{
lighter.InitialLighting(chunk, true);
(client as RemoteClient).UnloadChunk(chunk.Coordinates);
(client as RemoteClient).LoadChunk(chunk.Coordinates);
}
}
public override void Help(IRemoteClient client, string alias, string[] arguments)
{
client.SendMessage("/reinv: Resends your inventory.");
}
}
}

View File

@ -170,6 +170,11 @@ namespace TrueCraft
void HandleChunkLoaded(object sender, ChunkLoadedEventArgs e)
{
ChunksToSchedule.Add(new Tuple<IWorld, IChunk>(sender as IWorld, e.Chunk));
if (Program.ServerConfiguration.EnableLighting)
{
var lighter = WorldLighters.SingleOrDefault(l => l.World == sender);
lighter.InitialLighting(e.Chunk, false);
}
}
void HandleBlockChanged(object sender, BlockChangeEventArgs e)