Fixes and minor enhancements for sub editor
- Zoom now works relative to the mouse's position rather than the center of the screen, much like Valve's Hammer Editor (or pulsegun's map editor shameless plug ;) ) - Rectangles now have line widths dependent on the camera zoom, not perfect but it's better than having lines disappear - Fixed background resizing - Fixed editor being completely broken because of no vsync, might still have a few bugs here and there - Fixed selection rectangle not rendering at all when dragging from bottom right to top left - Newline change in Item.cs
This commit is contained in:
@@ -129,18 +129,14 @@ namespace Barotrauma
|
||||
Category = MapEntityCategory.Structure;
|
||||
}
|
||||
|
||||
public virtual void UpdatePlacing(SpriteBatch spriteBatch, Camera cam)
|
||||
public virtual void UpdatePlacing(Camera cam)
|
||||
{
|
||||
Vector2 placeSize = Submarine.GridSize;
|
||||
|
||||
if (placePosition == Vector2.Zero)
|
||||
{
|
||||
Vector2 position = Submarine.MouseToWorldGrid(cam, Submarine.MainSub);
|
||||
|
||||
GUI.DrawLine(spriteBatch, new Vector2(position.X-GameMain.GraphicsWidth, -position.Y), new Vector2(position.X+GameMain.GraphicsWidth, -position.Y), Color.White);
|
||||
|
||||
GUI.DrawLine(spriteBatch, new Vector2(position.X, -(position.Y - GameMain.GraphicsHeight)), new Vector2(position.X, -(position.Y + GameMain.GraphicsHeight)), Color.White);
|
||||
|
||||
|
||||
if (PlayerInput.LeftButtonHeld()) placePosition = position;
|
||||
}
|
||||
else
|
||||
@@ -167,7 +163,6 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
newRect.Y = -newRect.Y;
|
||||
GUI.DrawRectangle(spriteBatch, newRect, Color.DarkBlue);
|
||||
}
|
||||
|
||||
if (PlayerInput.RightButtonHeld())
|
||||
@@ -177,6 +172,39 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void DrawPlacing(SpriteBatch spriteBatch, Camera cam)
|
||||
{
|
||||
Vector2 placeSize = Submarine.GridSize;
|
||||
|
||||
if (placePosition == Vector2.Zero)
|
||||
{
|
||||
Vector2 position = Submarine.MouseToWorldGrid(cam, Submarine.MainSub);
|
||||
|
||||
GUI.DrawLine(spriteBatch, new Vector2(position.X - GameMain.GraphicsWidth, -position.Y), new Vector2(position.X + GameMain.GraphicsWidth, -position.Y), Color.White,0,(int)(2.0f/cam.Zoom));
|
||||
|
||||
GUI.DrawLine(spriteBatch, new Vector2(position.X, -(position.Y - GameMain.GraphicsHeight)), new Vector2(position.X, -(position.Y + GameMain.GraphicsHeight)), Color.White, 0, (int)(2.0f / cam.Zoom));
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 position = Submarine.MouseToWorldGrid(cam, Submarine.MainSub);
|
||||
|
||||
if (resizeHorizontal) placeSize.X = position.X - placePosition.X;
|
||||
if (resizeVertical) placeSize.Y = placePosition.Y - position.Y;
|
||||
|
||||
Rectangle newRect = Submarine.AbsRect(placePosition, placeSize);
|
||||
newRect.Width = (int)Math.Max(newRect.Width, Submarine.GridSize.X);
|
||||
newRect.Height = (int)Math.Max(newRect.Height, Submarine.GridSize.Y);
|
||||
|
||||
if (Submarine.MainSub != null)
|
||||
{
|
||||
newRect.Location -= Submarine.MainSub.Position.ToPoint();
|
||||
}
|
||||
|
||||
newRect.Y = -newRect.Y;
|
||||
GUI.DrawRectangle(spriteBatch, newRect, Color.DarkBlue);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CreateInstance(Rectangle rect)
|
||||
{
|
||||
object[] lobject = new object[] { this, rect };
|
||||
|
||||
Reference in New Issue
Block a user