starting draw mode with right-click now also snaps to the grid or geometry (unless shift or control is used)

This commit is contained in:
codeimp 2008-12-16 15:10:40 +00:00
parent 43754e3671
commit 94d538434c
4 changed files with 28 additions and 14 deletions

View file

@ -204,8 +204,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
renderer.Present();
}
// This gets the aligned and snapped draw position
private DrawnVertex GetCurrentPosition()
// This returns the aligned and snapped draw position
public static DrawnVertex GetCurrentPosition(Vector2D mousemappos, bool snaptonearest, bool snaptogrid, IRenderer2D renderer, List<DrawnVertex> points)
{
DrawnVertex p = new DrawnVertex();
@ -289,6 +289,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
// This gets the aligned and snapped draw position
private DrawnVertex GetCurrentPosition()
{
return GetCurrentPosition(mousemappos, snaptonearest, snaptogrid, renderer, points);
}
// This draws a point at a specific location
public void DrawPointAt(Vector2D pos, bool stitch)
{

View file

@ -342,8 +342,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
// Start drawing mode
DrawGeometryMode drawmode = new DrawGeometryMode();
drawmode.DrawPointAt(mousemappos, true);
General.Editing.ChangeMode(drawmode);
bool snaptogrid = General.Interface.ShiftState ^ General.Interface.SnapToGrid;
bool snaptonearest = General.Interface.CtrlState ^ General.Interface.AutoMerge;
DrawnVertex v = DrawGeometryMode.GetCurrentPosition(mousemappos, snaptonearest, snaptogrid, renderer, new List<DrawnVertex>());
drawmode.DrawPointAt(v.pos, v.stitch);
}
base.OnEditBegin();

View file

@ -428,7 +428,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
// Start drawing mode
DrawGeometryMode drawmode = new DrawGeometryMode();
drawmode.DrawPointAt(mousemappos, true);
bool snaptogrid = General.Interface.ShiftState ^ General.Interface.SnapToGrid;
bool snaptonearest = General.Interface.CtrlState ^ General.Interface.AutoMerge;
DrawnVertex v = DrawGeometryMode.GetCurrentPosition(mousemappos, snaptonearest, snaptogrid, renderer, new List<DrawnVertex>());
drawmode.DrawPointAt(v.pos, v.stitch);
General.Editing.ChangeMode(drawmode);
}

View file

@ -274,7 +274,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
// Start drawing mode
DrawGeometryMode drawmode = new DrawGeometryMode();
drawmode.DrawPointAt(mousemappos, true);
bool snaptogrid = General.Interface.ShiftState ^ General.Interface.SnapToGrid;
bool snaptonearest = General.Interface.CtrlState ^ General.Interface.AutoMerge;
DrawnVertex v = DrawGeometryMode.GetCurrentPosition(mousemappos, snaptonearest, snaptogrid, renderer, new List<DrawnVertex>());
drawmode.DrawPointAt(v.pos, v.stitch);
General.Editing.ChangeMode(drawmode);
}
}