diff --git a/SS14.Client.Graphics/CluwneLib.cs b/SS14.Client.Graphics/CluwneLib.cs
index 92fa1e8892a..96153cf61a8 100644
--- a/SS14.Client.Graphics/CluwneLib.cs
+++ b/SS14.Client.Graphics/CluwneLib.cs
@@ -372,13 +372,15 @@ public static void drawHollowPoint(int posX, int posY, Color4 OutlineColor)
/// Line Rotation
/// Line Thickness
/// Line Color
- public static void drawLine(int posX, int posY, int rotate, float thickness, Color Color)
+ public static void drawLine(float posX, float posY, float length, float rotate, float thickness, Color4 Color)
{
RectangleShape line = new RectangleShape();
line.Position = new Vector2f(posX, posY);
+ line.Size = new Vector2f(length, thickness);
line.Rotation = rotate;
line.OutlineThickness = thickness;
- line.FillColor = Color;
+ line.FillColor = Color.Convert();
+ line.OutlineColor = Color.Convert();
CurrentRenderTarget.Draw(line);
}
diff --git a/SS14.Client/Placement/Modes/AlignSnapgridBorder.cs b/SS14.Client/Placement/Modes/AlignSnapgridBorder.cs
index a8d6afc8e6b..70d8616a376 100644
--- a/SS14.Client/Placement/Modes/AlignSnapgridBorder.cs
+++ b/SS14.Client/Placement/Modes/AlignSnapgridBorder.cs
@@ -8,15 +8,39 @@
using SS14.Shared.Utility;
using SS14.Shared.Maths;
using System;
+using OpenTK.Graphics;
namespace SS14.Client.Placement.Modes
{
public class SnapgridBorder : PlacementMode
{
+ bool ongrid;
+ float snapsize;
+
public SnapgridBorder(PlacementManager pMan) : base(pMan)
{
}
+ public override void Render()
+ {
+ base.Render();
+ if (ongrid)
+ {
+ var position = CluwneLib.ScreenToWorld(new Vector2i(0,0)); //Find world coordinates closest to screen origin
+ var gridstart = CluwneLib.WorldToScreen(new Vector2( //Find snap grid closest to screen origin and convert back to screen coords
+ (float)Math.Round((position.X / (double)snapsize), MidpointRounding.AwayFromZero) * snapsize,
+ (float)Math.Round((position.Y / (double)snapsize), MidpointRounding.AwayFromZero) * snapsize));
+ for (float a = gridstart.X; a < CluwneLib.ScreenViewportSize.X; a += snapsize * 32) //Iterate through screen creating gridlines
+ {
+ CluwneLib.drawLine(a, 0, CluwneLib.ScreenViewportSize.Y, 90, 0.5f, Color4.Blue);
+ }
+ for (float a = gridstart.Y; a < CluwneLib.ScreenViewportSize.Y; a += snapsize * 32)
+ {
+ CluwneLib.drawLine(0, a, CluwneLib.ScreenViewportSize.X, 0, 0.5f, Color4.Blue);
+ }
+ }
+ }
+
public override bool Update(Vector2i mouseS, IMapManager currentMap)
{
if (currentMap == null) return false;
@@ -24,15 +48,16 @@ public override bool Update(Vector2i mouseS, IMapManager currentMap)
mouseScreen = mouseS;
mouseWorld = CluwneLib.ScreenToWorld(mouseScreen);
- if (!currentMap.TryFindGridAt(mouseWorld, out IMapGrid currentgrid)) //Cant find a grid
+ if (! (ongrid = currentMap.TryFindGridAt(mouseWorld, out IMapGrid currentgrid))) //Cant find a grid
return false;
var mouselocal = currentgrid.WorldToLocal(mouseWorld); //Convert code to local grid coordinates
- var snapsize = currentgrid.SnapSize; //Find snap size
+ snapsize = currentgrid.SnapSize; //Find snap size.
+
mouselocal = new Vector2( //Round local coordinates onto the snap grid
(float)Math.Round((mouselocal.X / (double)snapsize), MidpointRounding.AwayFromZero) * snapsize,
(float)Math.Round((mouselocal.Y / (double)snapsize), MidpointRounding.AwayFromZero) * snapsize);
-
+
//Convert back to original world and screen coordinates after applying offset
mouseWorld = currentgrid.LocalToWorld(mouselocal) + new Vector2(pManager.CurrentPrototype.PlacementOffset.X, pManager.CurrentPrototype.PlacementOffset.Y);
mouseScreen = (Vector2i)CluwneLib.WorldToScreen(mouseWorld);
diff --git a/SS14.Client/Placement/Modes/AlignSnapgridCenter.cs b/SS14.Client/Placement/Modes/AlignSnapgridCenter.cs
index 3ecf98966c4..89f86e8b0e5 100644
--- a/SS14.Client/Placement/Modes/AlignSnapgridCenter.cs
+++ b/SS14.Client/Placement/Modes/AlignSnapgridCenter.cs
@@ -8,27 +8,52 @@
using SS14.Shared.Utility;
using SS14.Shared.Maths;
using System;
+using OpenTK.Graphics;
namespace SS14.Client.Placement.Modes
{
public class SnapgridCenter : PlacementMode
{
+ bool ongrid;
+ float snapsize;
+
public SnapgridCenter(PlacementManager pMan) : base(pMan)
{
}
+ public override void Render()
+ {
+ base.Render();
+ if (ongrid)
+ {
+ var position = CluwneLib.ScreenToWorld(new Vector2i(0, 0)); //Find world coordinates closest to screen origin
+ var gridstart = CluwneLib.WorldToScreen(new Vector2( //Find snap grid closest to screen origin and convert back to screen coords
+ (float)(Math.Round((position.X / (double)snapsize-0.5), MidpointRounding.AwayFromZero)+0.5) * snapsize,
+ (float)(Math.Round((position.Y / (double)snapsize-0.5), MidpointRounding.AwayFromZero)+0.5) * snapsize));
+ for (float a = gridstart.X; a < CluwneLib.ScreenViewportSize.X; a += snapsize * 32) //Iterate through screen creating gridlines
+ {
+ CluwneLib.drawLine(a, 0, CluwneLib.ScreenViewportSize.Y, 90, 0.5f, Color4.Blue);
+ }
+ for (float a = gridstart.Y; a < CluwneLib.ScreenViewportSize.Y; a += snapsize * 32)
+ {
+ CluwneLib.drawLine(0, a, CluwneLib.ScreenViewportSize.X, 0, 0.5f, Color4.Blue);
+ }
+ }
+ }
+
public override bool Update(Vector2i mouseS, IMapManager currentMap)
{
if (currentMap == null) return false;
mouseScreen = mouseS;
mouseWorld = CluwneLib.ScreenToWorld(mouseScreen);
-
- if (!currentMap.TryFindGridAt(mouseWorld, out IMapGrid currentgrid)) //Cant find a grid
+
+ if (! (ongrid = currentMap.TryFindGridAt(mouseWorld, out IMapGrid currentgrid))) //Cant find a grid
return false;
var mouselocal = currentgrid.WorldToLocal(mouseWorld); //Convert code to local grid coordinates
- var snapsize = currentgrid.SnapSize; //Find snap size
+ snapsize = currentgrid.SnapSize; //Find snap size.
+
mouselocal = new Vector2( //Round local coordinates onto the snap grid
(float)(Math.Round((mouselocal.X / (double)snapsize-0.5), MidpointRounding.AwayFromZero)+0.5) * snapsize,
(float)(Math.Round((mouselocal.Y / (double)snapsize-0.5), MidpointRounding.AwayFromZero)+0.5) * snapsize);