Selecting stairs based on WorldRect in editor, disable input if window not active, disable traveling if no locations are selected

This commit is contained in:
Regalis
2016-01-27 22:27:51 +02:00
parent 8cc12b6988
commit 7637bc441f
21 changed files with 95 additions and 77 deletions

View File

@@ -253,7 +253,7 @@ namespace Barotrauma
return;
}
if (PlayerInput.GetKeyboardState.IsKeyDown(Keys.Delete))
if (PlayerInput.KeyDown(Keys.Delete))
{
foreach (MapEntity e in selectedList) e.Remove();
selectedList.Clear();
@@ -283,7 +283,7 @@ namespace Barotrauma
//started moving selected entities
if (startMovingPos != Vector2.Zero)
{
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Released)
if (PlayerInput.LeftButtonReleased())
{
//mouse released -> move the entities to the new position of the mouse
@@ -320,10 +320,10 @@ namespace Barotrauma
e.isHighlighted = true;
}
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Released)
if (PlayerInput.LeftButtonReleased())
{
if (PlayerInput.GetKeyboardState.IsKeyDown(Keys.LeftControl) ||
PlayerInput.GetKeyboardState.IsKeyDown(Keys.RightControl))
if (PlayerInput.KeyDown(Keys.LeftControl) ||
PlayerInput.KeyDown(Keys.RightControl))
{
foreach (MapEntity e in newSelection)
{
@@ -353,8 +353,8 @@ namespace Barotrauma
else
{
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Pressed &&
PlayerInput.GetKeyboardState.IsKeyUp(Keys.Space))
if (PlayerInput.LeftButtonDown() &&
PlayerInput.KeyUp(Keys.Space))
{
//if clicking a selected entity, start moving it
foreach (MapEntity e in selectedList)
@@ -377,7 +377,7 @@ namespace Barotrauma
{
if (GUIComponent.MouseOn != null) return;
Vector2 position = new Vector2(PlayerInput.GetMouseState.X, PlayerInput.GetMouseState.Y);
Vector2 position = PlayerInput.MousePosition;
position = cam.ScreenToWorld(position);
if (startMovingPos != Vector2.Zero)

View File

@@ -134,7 +134,7 @@ namespace Barotrauma
GUI.DrawLine(spriteBatch, new Vector2(position.X, -(position.Y - GameMain.GraphicsHeight)), new Vector2(position.X, -(position.Y + GameMain.GraphicsHeight)), Color.White);
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Pressed) placePosition = position;
if (PlayerInput.LeftButtonDown()) placePosition = position;
}
else
{
@@ -152,7 +152,7 @@ namespace Barotrauma
newRect.Location -= Submarine.Loaded.Position.ToPoint();
}
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Released)
if (PlayerInput.LeftButtonReleased())
{
object[] lobject = new object[] { this, newRect };
constructor.Invoke(lobject);
@@ -164,7 +164,7 @@ namespace Barotrauma
GUI.DrawRectangle(spriteBatch, newRect, Color.DarkBlue);
}
if (PlayerInput.GetMouseState.RightButton == ButtonState.Pressed)
if (PlayerInput.RightButtonDown())
{
placePosition = Vector2.Zero;
selected = null;

View File

@@ -283,11 +283,11 @@ namespace Barotrauma
if (StairDirection == Direction.Left)
{
return MathUtils.LineToPointDistance(new Vector2(rect.X, rect.Y), new Vector2(rect.Right, rect.Y - rect.Height), position)< 40.0f;
return MathUtils.LineToPointDistance(new Vector2(WorldRect.X, WorldRect.Y), new Vector2(WorldRect.Right, WorldRect.Y - WorldRect.Height), position) < 40.0f;
}
else
{
return MathUtils.LineToPointDistance(new Vector2(rect.X,rect.Y-rect.Height), new Vector2(rect.Right, rect.Y), position) <40.0f;
{
return MathUtils.LineToPointDistance(new Vector2(WorldRect.X, WorldRect.Y - rect.Height), new Vector2(WorldRect.Right, WorldRect.Y), position) < 40.0f;
}
}
}

View File

@@ -124,7 +124,7 @@ namespace Barotrauma
if (placePosition == Vector2.Zero)
{
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Pressed)
if (PlayerInput.LeftButtonDown())
placePosition = Submarine.MouseToWorldGrid(cam);
newRect.X = (int)position.X;
@@ -140,7 +140,7 @@ namespace Barotrauma
newRect = Submarine.AbsRect(placePosition, placeSize);
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Released)
if (PlayerInput.LeftButtonReleased())
{
if (Submarine.Loaded != null)
{
@@ -161,7 +161,7 @@ namespace Barotrauma
GUI.DrawRectangle(spriteBatch, new Rectangle(newRect.X - GameMain.GraphicsWidth, -newRect.Y, newRect.Width + GameMain.GraphicsWidth*2, newRect.Height), Color.White);
GUI.DrawRectangle(spriteBatch, new Rectangle(newRect.X, -newRect.Y - GameMain.GraphicsHeight, newRect.Width, newRect.Height + GameMain.GraphicsHeight*2), Color.White);
if (PlayerInput.GetMouseState.RightButton == ButtonState.Pressed) selected = null;
if (PlayerInput.RightButtonDown()) selected = null;
}
}
}

View File

@@ -258,7 +258,7 @@ namespace Barotrauma
public static Vector2 MouseToWorldGrid(Camera cam)
{
Vector2 position = new Vector2(PlayerInput.GetMouseState.X, PlayerInput.GetMouseState.Y);
Vector2 position = PlayerInput.MousePosition;
position = cam.ScreenToWorld(position);
return VectorToWorldGrid(position);