mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 22:01:45 +00:00
Cosmetic: renamed Drawing mode to Draw Lines mode.
Changed: current 2D position and zoom is now stored in the .dbs file when saving the map and restored when opening it (should this be turned into toggleable option?). Draw Lines mode, Draw Curve mode: you can now hold Alt - Shift to snap to 8 cardinal directions. Draw Rectangle mode, Draw Grid mode: you can now hold Alt - Shift to draw square shapes. Draw Ellipse mode: you can now hold Alt - Shift to draw circle shapes. You can now hold Alt - Shift to snap to 8 cardinal directions while dragging map objects. Fixed, Draw Lines mode: line angle is now displayed in 0..359 range (was -45..314). Fixed, Linedef info panel: line angle is now displayed in 0..359 range (was -45..314).
This commit is contained in:
parent
66eef4410a
commit
712dbd03e8
19 changed files with 168 additions and 55 deletions
|
@ -145,7 +145,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
infopanel.Text = " Linedef " + l.Index + " ";
|
||||
action.Text = act.ToString();
|
||||
length.Text = l.Length.ToString("0.##");
|
||||
angle.Text = l.AngleDeg + "\u00B0";
|
||||
angle.Text = General.ClampAngle(l.AngleDeg) + "\u00B0";
|
||||
unpegged.Text = peggedness;
|
||||
unpegged.Enabled = (peggedness != "None"); //mxd
|
||||
peglabel.Enabled = (peggedness != "None"); //mxd
|
||||
|
|
|
@ -363,9 +363,16 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
scaleh = General.Map.Graphics.RenderTarget.ClientSize.Height / area.Height;
|
||||
scale = scalew < scaleh ? scalew : scaleh;
|
||||
|
||||
// Change the view to see the whole map
|
||||
//mxd. Change the view to see the whole map
|
||||
CenterOnCoordinates(new Vector2D(area.Left + area.Width * 0.5f, area.Top + area.Height * 0.5f), scale);
|
||||
}
|
||||
|
||||
//mxd
|
||||
public void CenterOnCoordinates(Vector2D offset, float scale)
|
||||
{
|
||||
// Change the view
|
||||
renderer2d.ScaleView(scale);
|
||||
renderer2d.PositionView(area.Left + area.Width * 0.5f, area.Top + area.Height * 0.5f);
|
||||
renderer2d.PositionView(offset.x, offset.y);
|
||||
this.OnViewChanged();
|
||||
|
||||
// Redraw
|
||||
|
|
|
@ -1404,14 +1404,21 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// All done
|
||||
mainwindow.SetupInterface();
|
||||
//mainwindow.RedrawDisplay();
|
||||
mainwindow.UpdateThingsFilters();
|
||||
mainwindow.UpdateInterface();
|
||||
mainwindow.HideInfo();
|
||||
mainwindow.AddHintsDocker(); //mxd
|
||||
|
||||
//mxd. Center map in screen. Done here to avoid the view jerking around when updating the interface.
|
||||
if(Editing.Mode is ClassicMode) (Editing.Mode as ClassicMode).CenterInScreen();
|
||||
//mxd. Center map in screen or on stored coordinates. Done here to avoid the view jerking around when updating the interface.
|
||||
if(Editing.Mode is ClassicMode)
|
||||
{
|
||||
ClassicMode mode = Editing.Mode as ClassicMode;
|
||||
if(options != null && options.ViewPosition.IsFinite() && !float.IsNaN(options.ViewScale))
|
||||
mode.CenterOnCoordinates(options.ViewPosition, options.ViewScale);
|
||||
else
|
||||
mode.CenterInScreen();
|
||||
}
|
||||
|
||||
mainwindow.RedrawDisplay();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -544,12 +544,16 @@ namespace CodeImp.DoomBuilder
|
|||
//mxd. Restore selection groups
|
||||
options.ReadSelectionGroups();
|
||||
|
||||
// Center map in screen
|
||||
//mxd. Center map in screen or on stored coordinates
|
||||
if (General.Editing.Mode is ClassicMode)
|
||||
{
|
||||
ClassicMode mode = General.Editing.Mode as ClassicMode;
|
||||
mode.OnRedoEnd();
|
||||
mode.CenterInScreen();
|
||||
|
||||
if(options.ViewPosition.IsFinite() && !float.IsNaN(options.ViewScale))
|
||||
mode.CenterOnCoordinates(options.ViewPosition, options.ViewScale);
|
||||
else
|
||||
mode.CenterInScreen();
|
||||
}
|
||||
|
||||
// Success
|
||||
|
|
|
@ -20,6 +20,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
using System.IO;
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
|
@ -82,6 +83,10 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
//mxd.
|
||||
private bool uselongtexturenames;
|
||||
|
||||
//mxd. Position and scale
|
||||
private Vector2D viewposition;
|
||||
private float viewscale;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -136,6 +141,10 @@ namespace CodeImp.DoomBuilder.Map
|
|||
//mxd
|
||||
public bool UseLongTextureNames { get { return uselongtexturenames; } set { uselongtexturenames = value; } }
|
||||
|
||||
//mxd. Position and scale
|
||||
public Vector2D ViewPosition { get { return viewposition; } }
|
||||
public float ViewScale { get { return viewscale; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
@ -153,6 +162,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
this.scriptfiles = new List<string>();
|
||||
this.scriptcompiler = ""; //mxd
|
||||
this.tagLabels = new Dictionary<int, string>(); //mxd
|
||||
this.viewposition = new Vector2D(float.NaN, float.NaN); //mxd
|
||||
this.viewscale = float.NaN; //mxd
|
||||
|
||||
//mxd. Sector drawing options
|
||||
this.custombrightness = 196;
|
||||
|
@ -222,6 +233,12 @@ namespace CodeImp.DoomBuilder.Map
|
|||
//mxd
|
||||
uselongtexturenames = longtexturenamessupported && this.mapconfig.ReadSetting("uselongtexturenames", false);
|
||||
|
||||
//mxd. Position and scale
|
||||
float vpx = this.mapconfig.ReadSetting("viewpositionx", float.NaN);
|
||||
float vpy = this.mapconfig.ReadSetting("viewpositiony", float.NaN);
|
||||
if(!float.IsNaN(vpx) && !float.IsNaN(vpy)) viewposition = new Vector2D(vpx, vpy);
|
||||
viewscale = this.mapconfig.ReadSetting("viewscale", float.NaN);
|
||||
|
||||
// Resources
|
||||
IDictionary reslist = this.mapconfig.ReadSetting("resources", new Hashtable());
|
||||
foreach(DictionaryEntry mp in reslist)
|
||||
|
@ -346,6 +363,11 @@ namespace CodeImp.DoomBuilder.Map
|
|||
//mxd
|
||||
mapconfig.WriteSetting("uselongtexturenames", uselongtexturenames);
|
||||
|
||||
//mxd. Position and scale
|
||||
mapconfig.WriteSetting("viewpositionx", General.Map.Renderer2D.OffsetX);
|
||||
mapconfig.WriteSetting("viewpositiony", General.Map.Renderer2D.OffsetY);
|
||||
mapconfig.WriteSetting("viewscale", General.Map.Renderer2D.Scale);
|
||||
|
||||
//mxd. Write script compiler
|
||||
if(!string.IsNullOrEmpty(scriptcompiler))
|
||||
mapconfig.WriteSetting("scriptcompiler", scriptcompiler);
|
||||
|
|
|
@ -198,7 +198,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.ClassicModes
|
|||
{
|
||||
points = new List<DrawnVertex>();
|
||||
for (int p = 0; p < shapes[i][c].Length; p++)
|
||||
points.Add(DrawGeometryMode.GetCurrentPosition(shapes[i][c][p], true, false, renderer, points));
|
||||
points.Add(DrawGeometryMode.GetCurrentPosition(shapes[i][c][p], true, false, false, renderer, points));
|
||||
shapesRow.Add(points);
|
||||
}
|
||||
drawShapes.Add(shapesRow);
|
||||
|
|
|
@ -83,6 +83,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private bool snaptogrid; // SHIFT to toggle
|
||||
private bool snaptonearest; // CTRL to enable
|
||||
private bool snaptogridincrement; //mxd. ALT to toggle
|
||||
private bool snaptocardinaldirection; //mxd. ALT-SHIFT to enable
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -214,8 +215,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// This moves the selected geometry relatively
|
||||
// Returns true when geometry has actually moved
|
||||
private bool MoveGeometryRelative(Vector2D offset, bool snapgrid, bool snapgridincrement, bool snapnearest)
|
||||
private bool MoveGeometryRelative(Vector2D offset, bool snapgrid, bool snapgridincrement, bool snapnearest, bool snapcardinal)
|
||||
{
|
||||
//mxd. If snap to cardinal directions is enabled, modify the offset
|
||||
if(snapcardinal)
|
||||
{
|
||||
float angle = Angle2D.DegToRad((General.ClampAngle((int)Angle2D.RadToDeg(offset.GetAngle()) + 22)) / 45 * 45);
|
||||
offset = new Vector2D(0, -offset.GetLength()).GetRotated(angle);
|
||||
}
|
||||
|
||||
Vector2D oldpos = dragitem.Position;
|
||||
Vector2D anchorpos = dragitemposition + offset;
|
||||
Vector2D tl, br;
|
||||
|
@ -364,7 +372,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public override void OnCancel()
|
||||
{
|
||||
// Move geometry back to original position
|
||||
MoveGeometryRelative(new Vector2D(0f, 0f), false, false, false);
|
||||
MoveGeometryRelative(new Vector2D(0f, 0f), false, false, false, false);
|
||||
|
||||
// Resume normal undo/redo recording
|
||||
General.Map.UndoRedo.IgnorePropChanges = false;
|
||||
|
@ -402,7 +410,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
Cursor.Current = Cursors.AppStarting;
|
||||
|
||||
// Move geometry back to original position
|
||||
MoveGeometryRelative(new Vector2D(0f, 0f), false, false, false);
|
||||
MoveGeometryRelative(new Vector2D(0f, 0f), false, false, false, false);
|
||||
|
||||
// Resume normal undo/redo recording
|
||||
General.Map.UndoRedo.IgnorePropChanges = false;
|
||||
|
@ -411,7 +419,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Map.UndoRedo.CreateUndo("Drag geometry");
|
||||
|
||||
// Move selected geometry to final position
|
||||
MoveGeometryRelative(mousemappos - dragstartmappos, snaptogrid, snaptogridincrement, snaptonearest);
|
||||
MoveGeometryRelative(mousemappos - dragstartmappos, snaptogrid, snaptogridincrement, snaptonearest, snaptocardinaldirection);
|
||||
|
||||
// Stitch geometry
|
||||
if(snaptonearest) General.Map.Map.StitchGeometry();
|
||||
|
@ -539,12 +547,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// This updates the dragging
|
||||
private void Update()
|
||||
{
|
||||
snaptogrid = General.Interface.ShiftState ^ General.Interface.SnapToGrid;
|
||||
snaptocardinaldirection = (General.Interface.ShiftState && General.Interface.AltState); //mxd
|
||||
snaptogrid = (snaptocardinaldirection || General.Interface.ShiftState ^ General.Interface.SnapToGrid);
|
||||
snaptonearest = General.Interface.CtrlState ^ General.Interface.AutoMerge;
|
||||
snaptogridincrement = General.Interface.AltState; //mxd
|
||||
snaptogridincrement = (!snaptocardinaldirection && General.Interface.AltState); //mxd
|
||||
|
||||
// Move selected geometry
|
||||
if(MoveGeometryRelative(mousemappos - dragstartmappos, snaptogrid, snaptogridincrement, snaptonearest))
|
||||
if(MoveGeometryRelative(mousemappos - dragstartmappos, snaptogrid, snaptogridincrement, snaptonearest, snaptocardinaldirection))
|
||||
{
|
||||
// Update cached values
|
||||
General.Map.Map.Update(true, false);
|
||||
|
@ -580,7 +589,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
base.OnKeyUp(e);
|
||||
if((snaptogrid != (General.Interface.ShiftState ^ General.Interface.SnapToGrid)) ||
|
||||
(snaptonearest != (General.Interface.CtrlState ^ General.Interface.AutoMerge)) ||
|
||||
(snaptogridincrement != General.Interface.AltState)) Update();
|
||||
(snaptogridincrement != General.Interface.AltState) ||
|
||||
(snaptocardinaldirection != (General.Interface.AltState && General.Interface.ShiftState))) Update();
|
||||
}
|
||||
|
||||
// When a key is pressed
|
||||
|
@ -589,7 +599,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
base.OnKeyDown(e);
|
||||
if((snaptogrid != (General.Interface.ShiftState ^ General.Interface.SnapToGrid)) ||
|
||||
(snaptonearest != (General.Interface.CtrlState ^ General.Interface.AutoMerge)) ||
|
||||
(snaptogridincrement != General.Interface.AltState)) Update();
|
||||
(snaptogridincrement != General.Interface.AltState) ||
|
||||
(snaptocardinaldirection != (General.Interface.AltState && General.Interface.ShiftState))) Update();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -97,6 +97,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private bool snaptogrid; // SHIFT to toggle
|
||||
private bool snaptonearest; // CTRL to enable
|
||||
private bool snaptogridincrement; //mxd. ALT to toggle
|
||||
private bool snaptocardinaldirection; //mxd. ALT-SHIFT to enable
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -173,8 +174,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// This moves the selected things relatively
|
||||
// Returns true when things has actually moved
|
||||
private bool MoveThingsRelative(Vector2D offset, bool snapgrid, bool snapgridincrement, bool snapnearest)
|
||||
private bool MoveThingsRelative(Vector2D offset, bool snapgrid, bool snapgridincrement, bool snapnearest, bool snapcardinal)
|
||||
{
|
||||
//mxd. If snap to cardinal directions is enabled, modify the offset
|
||||
if(snapcardinal)
|
||||
{
|
||||
float angle = Angle2D.DegToRad((General.ClampAngle((int)Angle2D.RadToDeg(offset.GetAngle()) + 22)) / 45 * 45);
|
||||
offset = new Vector2D(0, -offset.GetLength()).GetRotated(angle);
|
||||
}
|
||||
|
||||
Vector2D oldpos = dragitem.Position;
|
||||
Thing nearest;
|
||||
Vector2D tl, br;
|
||||
|
@ -321,7 +329,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public override void OnCancel()
|
||||
{
|
||||
// Move geometry back to original position
|
||||
MoveThingsRelative(new Vector2D(0f, 0f), false, false, false);
|
||||
MoveThingsRelative(new Vector2D(0f, 0f), false, false, false, false);
|
||||
|
||||
// If only a single vertex was selected, deselect it now
|
||||
if(selectedthings.Count == 1) General.Map.Map.ClearSelectedThings();
|
||||
|
@ -353,7 +361,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(!cancelled)
|
||||
{
|
||||
// Move geometry back to original position
|
||||
MoveThingsRelative(new Vector2D(0f, 0f), false, false, false);
|
||||
MoveThingsRelative(new Vector2D(0f, 0f), false, false, false, false);
|
||||
|
||||
if(alignData != null && alignData.Active)
|
||||
{
|
||||
|
@ -377,7 +385,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
else
|
||||
{
|
||||
MoveThingsRelative(mousemappos - dragstartmappos, snaptogrid, snaptogridincrement, snaptonearest);
|
||||
MoveThingsRelative(mousemappos - dragstartmappos, snaptogrid, snaptogridincrement, snaptonearest, snaptocardinaldirection);
|
||||
}
|
||||
|
||||
// Snap to map format accuracy
|
||||
|
@ -415,12 +423,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// This updates the dragging
|
||||
private void Update()
|
||||
{
|
||||
snaptogrid = General.Interface.ShiftState ^ General.Interface.SnapToGrid;
|
||||
snaptocardinaldirection = (General.Interface.ShiftState && General.Interface.AltState); //mxd
|
||||
snaptogrid = (snaptocardinaldirection || General.Interface.ShiftState ^ General.Interface.SnapToGrid);
|
||||
snaptonearest = General.Interface.CtrlState;
|
||||
snaptogridincrement = General.Interface.AltState; //mxd
|
||||
snaptogridincrement = (!snaptocardinaldirection && General.Interface.AltState); //mxd
|
||||
|
||||
//mxd. Snap to nearest linedef
|
||||
if(selectedthings.Count == 1 && dragitem.IsModel && snaptonearest && MoveThingsRelative(mousemappos - dragstartmappos, snaptogrid, snaptogridincrement, false))
|
||||
if(selectedthings.Count == 1 && dragitem.IsModel && snaptonearest && !snaptocardinaldirection && MoveThingsRelative(mousemappos - dragstartmappos, snaptogrid, snaptogridincrement, false, false))
|
||||
{
|
||||
Linedef l = General.Map.Map.NearestLinedefRange(oldpositions[0] + mousemappos - dragstartmappos, BuilderPlug.Me.StitchRange / renderer.Scale);
|
||||
bool restoreSettings = false;
|
||||
|
@ -461,7 +470,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
// Move selected geometry
|
||||
if(MoveThingsRelative(mousemappos - dragstartmappos, snaptogrid, snaptogridincrement, snaptonearest))
|
||||
if(MoveThingsRelative(mousemappos - dragstartmappos, snaptogrid, snaptogridincrement, snaptonearest, snaptocardinaldirection))
|
||||
{
|
||||
// Update cached values
|
||||
General.Map.Map.Update();
|
||||
|
@ -494,7 +503,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
base.OnKeyUp(e);
|
||||
if(snaptogrid != General.Interface.ShiftState ^ General.Interface.SnapToGrid ||
|
||||
snaptonearest != General.Interface.CtrlState ||
|
||||
snaptogridincrement != General.Interface.AltState) Update();
|
||||
snaptogridincrement != General.Interface.AltState ||
|
||||
snaptocardinaldirection != (General.Interface.AltState && General.Interface.ShiftState)) Update();
|
||||
}
|
||||
|
||||
// When a key is pressed
|
||||
|
@ -503,7 +513,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
base.OnKeyDown(e);
|
||||
if(snaptogrid != General.Interface.ShiftState ^ General.Interface.SnapToGrid ||
|
||||
snaptonearest != General.Interface.CtrlState ||
|
||||
snaptogridincrement != General.Interface.AltState) Update();
|
||||
snaptogridincrement != General.Interface.AltState ||
|
||||
snaptocardinaldirection != (General.Interface.AltState && General.Interface.ShiftState)) Update();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -67,7 +67,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
PixelColor losecolor = General.Colors.Selection;
|
||||
PixelColor color;
|
||||
|
||||
snaptogrid = General.Interface.ShiftState ^ General.Interface.SnapToGrid;
|
||||
snaptocardinaldirection = General.Interface.ShiftState && General.Interface.AltState;
|
||||
snaptogrid = snaptocardinaldirection || General.Interface.ShiftState ^ General.Interface.SnapToGrid;
|
||||
snaptonearest = General.Interface.CtrlState ^ General.Interface.AutoMerge;
|
||||
|
||||
DrawnVertex curp = GetCurrentPosition();
|
||||
|
|
|
@ -32,6 +32,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
undoName = "Ellipse draw";
|
||||
shapeName = "ellipse";
|
||||
usefourcardinaldirections = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -32,7 +32,7 @@ using CodeImp.DoomBuilder.Actions;
|
|||
|
||||
namespace CodeImp.DoomBuilder.BuilderModes
|
||||
{
|
||||
[EditMode(DisplayName = "Drawing Mode",
|
||||
[EditMode(DisplayName = "Draw Lines Mode",
|
||||
SwitchAction = "drawlinesmode",
|
||||
ButtonImage = "DrawGeometryMode.png", //mxd
|
||||
ButtonOrder = int.MinValue + 1, //mxd
|
||||
|
@ -64,6 +64,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Options
|
||||
protected bool snaptogrid; // SHIFT to toggle
|
||||
protected bool snaptonearest; // CTRL to enable
|
||||
protected bool snaptocardinaldirection; //mxd. ALT-SHIFT to enable
|
||||
protected static bool usefourcardinaldirections;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -129,7 +131,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
PixelColor losecolor = General.Colors.Selection;
|
||||
PixelColor color;
|
||||
|
||||
snaptogrid = General.Interface.ShiftState ^ General.Interface.SnapToGrid;
|
||||
snaptocardinaldirection = General.Interface.ShiftState && General.Interface.AltState; //mxd
|
||||
snaptogrid = (snaptocardinaldirection || General.Interface.ShiftState ^ General.Interface.SnapToGrid);
|
||||
snaptonearest = General.Interface.CtrlState ^ General.Interface.AutoMerge;
|
||||
|
||||
DrawnVertex curp = GetCurrentPosition();
|
||||
|
@ -216,12 +219,32 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
// This returns the aligned and snapped draw position
|
||||
public static DrawnVertex GetCurrentPosition(Vector2D mousemappos, bool snaptonearest, bool snaptogrid, IRenderer2D renderer, List<DrawnVertex> points)
|
||||
public static DrawnVertex GetCurrentPosition(Vector2D mousemappos, bool snaptonearest, bool snaptogrid, bool snaptocardinal, IRenderer2D renderer, List<DrawnVertex> points)
|
||||
{
|
||||
DrawnVertex p = new DrawnVertex();
|
||||
p.stitch = true; //mxd. Setting these to false seems to be a good way to create invalid geometry...
|
||||
p.stitchline = true; //mxd
|
||||
Vector2D vm = mousemappos;
|
||||
|
||||
//mxd. If snap to cardinal directions is enabled and we have points, modify mouse position
|
||||
Vector2D vm;
|
||||
if(snaptocardinal && points.Count > 0)
|
||||
{
|
||||
Vector2D offset = mousemappos - points[points.Count - 1].pos;
|
||||
|
||||
float angle;
|
||||
if(usefourcardinaldirections)
|
||||
angle = Angle2D.DegToRad((General.ClampAngle((int)Angle2D.RadToDeg(offset.GetAngle()))) / 90 * 90 + 45);
|
||||
else
|
||||
angle = Angle2D.DegToRad((General.ClampAngle((int)Angle2D.RadToDeg(offset.GetAngle()) + 22)) / 45 * 45);
|
||||
|
||||
offset = new Vector2D(0, -offset.GetLength()).GetRotated(angle);
|
||||
vm = points[points.Count - 1].pos + offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
vm = mousemappos;
|
||||
}
|
||||
|
||||
float vrange = BuilderPlug.Me.StitchRange / renderer.Scale;
|
||||
|
||||
// Snap to nearest?
|
||||
|
@ -319,7 +342,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
float u = 0.0f;
|
||||
List<Line2D> blines = new List<Line2D>();
|
||||
|
||||
// lines for left, top, right and bottom bondaries
|
||||
// lines for left, top, right and bottom boundaries
|
||||
blines.Add(new Line2D(General.Map.Config.LeftBoundary, General.Map.Config.BottomBoundary, General.Map.Config.LeftBoundary, General.Map.Config.TopBoundary));
|
||||
blines.Add(new Line2D(General.Map.Config.LeftBoundary, General.Map.Config.TopBoundary, General.Map.Config.RightBoundary, General.Map.Config.TopBoundary));
|
||||
blines.Add(new Line2D(General.Map.Config.RightBoundary, General.Map.Config.TopBoundary, General.Map.Config.RightBoundary, General.Map.Config.BottomBoundary));
|
||||
|
@ -376,7 +399,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// This gets the aligned and snapped draw position
|
||||
protected DrawnVertex GetCurrentPosition()
|
||||
{
|
||||
return GetCurrentPosition(mousemappos, snaptonearest, snaptogrid, renderer, points);
|
||||
return GetCurrentPosition(mousemappos, snaptonearest, snaptogrid, snaptocardinaldirection, renderer, points);
|
||||
}
|
||||
|
||||
// This draws a point at a specific location
|
||||
|
@ -558,7 +581,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
base.OnKeyUp(e);
|
||||
if((snaptogrid != (General.Interface.ShiftState ^ General.Interface.SnapToGrid)) ||
|
||||
(snaptonearest != (General.Interface.CtrlState ^ General.Interface.AutoMerge))) Update();
|
||||
(snaptonearest != (General.Interface.CtrlState ^ General.Interface.AutoMerge)) ||
|
||||
(snaptocardinaldirection != (General.Interface.AltState && General.Interface.ShiftState))) Update();
|
||||
}
|
||||
|
||||
// When a key is pressed
|
||||
|
@ -566,7 +590,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
base.OnKeyDown(e);
|
||||
if((snaptogrid != (General.Interface.ShiftState ^ General.Interface.SnapToGrid)) ||
|
||||
(snaptonearest != (General.Interface.CtrlState ^ General.Interface.AutoMerge))) Update();
|
||||
(snaptonearest != (General.Interface.CtrlState ^ General.Interface.AutoMerge)) ||
|
||||
(snaptocardinaldirection != (General.Interface.AltState && General.Interface.ShiftState))) Update();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -581,7 +606,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(General.Interface.MouseInDisplay)
|
||||
{
|
||||
DrawnVertex newpoint = GetCurrentPosition();
|
||||
|
||||
if(!DrawPointAt(newpoint)) General.Interface.DisplayStatus(StatusType.Warning, "Failed to draw point: outside of map boundaries.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ using System.Collections.Generic;
|
|||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.Actions;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
using CodeImp.DoomBuilder.Controls;
|
||||
using CodeImp.DoomBuilder.Editing;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
@ -58,6 +57,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public DrawGridMode()
|
||||
{
|
||||
snaptogrid = true;
|
||||
usefourcardinaldirections = true;
|
||||
gridpoints = new List<DrawnVertex[]>();
|
||||
}
|
||||
|
||||
|
@ -191,15 +191,16 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
PixelColor losecolor = General.Colors.Selection;
|
||||
|
||||
// We WANT snaptogrid and DON'T WANT snaptonearest when lock to grid is enabled
|
||||
snaptogrid = gridlock || (General.Interface.ShiftState ^ General.Interface.SnapToGrid);
|
||||
snaptonearest = !gridlock && (General.Interface.CtrlState ^ General.Interface.AutoMerge);
|
||||
snaptocardinaldirection = General.Interface.ShiftState && General.Interface.AltState; //mxd
|
||||
snaptogrid = (snaptocardinaldirection || gridlock || (General.Interface.ShiftState ^ General.Interface.SnapToGrid));
|
||||
snaptonearest = (!gridlock && (General.Interface.CtrlState ^ General.Interface.AutoMerge));
|
||||
|
||||
DrawnVertex curp;
|
||||
if (points.Count == 1)
|
||||
{
|
||||
// Handle the case when start point is not on current grid.
|
||||
Vector2D gridoffset = General.Map.Grid.SnappedToGrid(points[0].pos) - points[0].pos;
|
||||
curp = GetCurrentPosition(mousemappos + gridoffset, snaptonearest, snaptogrid, renderer, points);
|
||||
curp = GetCurrentPosition(mousemappos + gridoffset, snaptonearest, snaptogrid, snaptocardinaldirection, renderer, points);
|
||||
curp.pos -= gridoffset;
|
||||
}
|
||||
else
|
||||
|
@ -297,7 +298,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Handle the case when start point is not on current grid.
|
||||
Vector2D gridoffset = General.Map.Grid.SnappedToGrid(points[0].pos) - points[0].pos;
|
||||
newpoint = GetCurrentPosition(mousemappos + gridoffset, snaptonearest, snaptogrid, renderer, points);
|
||||
newpoint = GetCurrentPosition(mousemappos + gridoffset, snaptonearest, snaptogrid, snaptocardinaldirection, renderer, new List<DrawnVertex> { points[0] });
|
||||
newpoint.pos -= gridoffset;
|
||||
|
||||
// Create vertices for final shape.
|
||||
|
|
|
@ -55,6 +55,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public DrawRectangleMode()
|
||||
{
|
||||
snaptogrid = true;
|
||||
usefourcardinaldirections = true;
|
||||
SetupInterface();
|
||||
}
|
||||
|
||||
|
@ -104,7 +105,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
PixelColor stitchcolor = General.Colors.Highlight;
|
||||
PixelColor losecolor = General.Colors.Selection;
|
||||
|
||||
snaptogrid = General.Interface.ShiftState ^ General.Interface.SnapToGrid;
|
||||
snaptocardinaldirection = General.Interface.ShiftState && General.Interface.AltState; //mxd
|
||||
snaptogrid = (snaptocardinaldirection || General.Interface.ShiftState ^ General.Interface.SnapToGrid);
|
||||
snaptonearest = General.Interface.CtrlState ^ General.Interface.AutoMerge;
|
||||
|
||||
DrawnVertex curp = GetCurrentPosition();
|
||||
|
|
|
@ -510,7 +510,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
DrawGeometryMode drawmode = new DrawGeometryMode();
|
||||
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>());
|
||||
DrawnVertex v = DrawGeometryMode.GetCurrentPosition(mousemappos, snaptonearest, snaptogrid, false, renderer, new List<DrawnVertex>());
|
||||
|
||||
if (drawmode.DrawPointAt(v))
|
||||
General.Editing.ChangeMode(drawmode);
|
||||
|
@ -621,7 +621,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
bool snaptogrid = General.Interface.ShiftState ^ General.Interface.SnapToGrid;
|
||||
bool snaptonearest = General.Interface.CtrlState ^ General.Interface.AutoMerge;
|
||||
Vector2D v = DrawGeometryMode.GetCurrentPosition(mousemappos, snaptonearest, snaptogrid, renderer, new List<DrawnVertex>()).pos;
|
||||
Vector2D v = DrawGeometryMode.GetCurrentPosition(mousemappos, snaptonearest, snaptogrid, false, renderer, new List<DrawnVertex>()).pos;
|
||||
|
||||
if(v != insertpreview)
|
||||
{
|
||||
|
@ -945,7 +945,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
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>());
|
||||
DrawnVertex v = DrawGeometryMode.GetCurrentPosition(mousemappos, snaptonearest, snaptogrid, false, renderer, new List<DrawnVertex>());
|
||||
drawmode.DrawPointAt(v);
|
||||
}
|
||||
General.Editing.ChangeMode(drawmode);
|
||||
|
|
|
@ -853,7 +853,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
DrawGeometryMode drawmode = new DrawGeometryMode();
|
||||
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>());
|
||||
DrawnVertex v = DrawGeometryMode.GetCurrentPosition(mousemappos, snaptonearest, snaptogrid, false, renderer, new List<DrawnVertex>());
|
||||
|
||||
if(drawmode.DrawPointAt(v))
|
||||
General.Editing.ChangeMode(drawmode);
|
||||
|
@ -1385,7 +1385,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
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>());
|
||||
DrawnVertex v = DrawGeometryMode.GetCurrentPosition(mousemappos, snaptonearest, snaptogrid, false, renderer, new List<DrawnVertex>());
|
||||
drawmode.DrawPointAt(v);
|
||||
}
|
||||
General.Editing.ChangeMode(drawmode);
|
||||
|
|
|
@ -350,7 +350,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Start drawing mode
|
||||
DrawGeometryMode drawmode = new DrawGeometryMode();
|
||||
DrawnVertex v = DrawGeometryMode.GetCurrentPosition(mousemappos, snaptonearest, snaptogrid, renderer, new List<DrawnVertex>());
|
||||
DrawnVertex v = DrawGeometryMode.GetCurrentPosition(mousemappos, snaptonearest, snaptogrid, false, renderer, new List<DrawnVertex>());
|
||||
|
||||
if (drawmode.DrawPointAt(v))
|
||||
General.Editing.ChangeMode(drawmode);
|
||||
|
|
|
@ -101,7 +101,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//mxd
|
||||
if(showAngle)
|
||||
{
|
||||
int angle = (int)Math.Round(Angle2D.RadToDeg(delta.GetAngle()));
|
||||
int angle = General.ClampAngle((int)Math.Round(Angle2D.RadToDeg(delta.GetAngle())));
|
||||
label.Text = "l:" + length.ToString(VALUE_FORMAT) + "; a:" + angle;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -243,6 +243,7 @@ drawpoint
|
|||
allowscroll = true;
|
||||
disregardshift = true;
|
||||
disregardcontrol = true;
|
||||
disregardalt = true;
|
||||
}
|
||||
|
||||
removepoint
|
||||
|
|
|
@ -162,19 +162,23 @@ class DragGeometryMode
|
|||
group general
|
||||
"Hold <b>Shift</b> to toggle grid snapping"
|
||||
"Hold <b>Ctrl</b> to toggle snapping to nearest vertex"
|
||||
"Hold <b>Alt</b> to toggle snapping by grid increment"
|
||||
|
||||
"Hold <b>Alt</b> to snap by grid increment"
|
||||
"Hold <b>Alt - Shift</b> to snap to 8 cardinal directions"
|
||||
|
||||
class DragThingsMode
|
||||
group general
|
||||
"Hold <b>Shift</b> to toggle grid snapping"
|
||||
"Hold <b>Ctrl</b> to toggle snapping to nearest vertex"
|
||||
|
||||
"Hold <b>Alt</b> to snap by grid increment"
|
||||
"Hold <b>Alt - Shift</b> to snap to 8 cardinal directions"
|
||||
|
||||
class DrawGeometryMode
|
||||
group general
|
||||
"Press <k>builder_classicselect</k> to place a vertex"
|
||||
"Press <k>buildermodes_removepoint</k> to remove last vertex"
|
||||
"Hold <b>Shift</b> to toggle grid snapping"
|
||||
"Hold <b>Ctrl</b> to toggle snapping to nearest vertex"
|
||||
"Hold <b>Alt - Shift</b> to snap to 8 cardinal directions"
|
||||
"Press <k>builder_acceptmode</k> to accept"
|
||||
"Press <k>builder_cancelmode</k> or <k>builder_classicedit</k> to cancel"
|
||||
|
||||
|
@ -184,6 +188,9 @@ group general
|
|||
"Press <k>builder_classicselect</k> to place a vertex"
|
||||
"Use <k>buildermodes_increasesubdivlevel</k> and <k>buildermodes_decreasesubdivlevel</k> to change detail level of the curve"
|
||||
"Press <k>buildermodes_removepoint</k> to remove last vertex"
|
||||
"Hold <b>Shift</b> to toggle grid snapping"
|
||||
"Hold <b>Ctrl</b> to toggle snapping to nearest vertex"
|
||||
"Hold <b>Alt - Shift</b> to snap to 8 cardinal directions"
|
||||
"Press <k>builder_acceptmode</k> to accept"
|
||||
"Press <k>builder_cancelmode</k> or <k>builder_classicedit</k> to cancel"
|
||||
|
||||
|
@ -193,6 +200,9 @@ group general
|
|||
"Press <k>builder_classicselect</k> to place a vertex"
|
||||
"Use <k>buildermodes_increasebevel</k> and <k>buildermodes_decreasebevel</k> to change corners bevel by current grid size"
|
||||
"Use <k>buildermodes_increasesubdivlevel</k> and <k>buildermodes_decreasesubdivlevel</k> to change bevel detail level"
|
||||
"Hold <b>Shift</b> to toggle grid snapping"
|
||||
"Hold <b>Ctrl</b> to toggle snapping to nearest vertex"
|
||||
"Hold <b>Alt - Shift</b> to snap to 4 cardinal directions"
|
||||
"Place second vertex to finish drawing"
|
||||
"Press <k>builder_cancelmode</k> or <k>builder_classicedit</k> to cancel"
|
||||
|
||||
|
@ -202,6 +212,9 @@ group general
|
|||
"Press <k>builder_classicselect</k> to place a vertex"
|
||||
"Use <k>buildermodes_increasebevel</k> and <k>buildermodes_decreasebevel</k> to change bevel by current grid size"
|
||||
"Use <k>buildermodes_increasesubdivlevel</k> and <k>buildermodes_decreasesubdivlevel</k> to change the number of points in ellipse"
|
||||
"Hold <b>Shift</b> to toggle grid snapping"
|
||||
"Hold <b>Ctrl</b> to toggle snapping to nearest vertex"
|
||||
"Hold <b>Alt - Shift</b> to snap to 4 cardinal directions"
|
||||
"Place second vertex to finish drawing"
|
||||
"Press <k>builder_cancelmode</k> or <k>builder_classicedit</k> to cancel"
|
||||
|
||||
|
@ -210,6 +223,14 @@ class DrawGridMode
|
|||
group general
|
||||
"Use <k>buildermodes_increasebevel</k> and <k>buildermodes_decreasebevel</k> to change the number of horizontal slices"
|
||||
"Use <k>buildermodes_increasesubdivlevel</k> and <k>buildermodes_decreasesubdivlevel</k> to change the number of vertical slices"
|
||||
"Hold <b>Shift</b> to toggle grid snapping"
|
||||
"Hold <b>Ctrl</b> to toggle snapping to nearest vertex"
|
||||
"Hold <b>Alt - Shift</b> to snap to 4 cardinal directions"
|
||||
"Place second vertex to finish drawing"
|
||||
"Press <k>builder_cancelmode</k> or <k>builder_classicedit</k> to cancel"
|
||||
|
||||
group gridlockhelp
|
||||
"Use <k>builder_griddec</k> and <k>builder_gridinc</k> to change grid size."
|
||||
"Use <k>builder_griddec</k> and <k>builder_gridinc</k> to change grid size."
|
||||
"Hold <b>Alt - Shift</b> to snap to 4 cardinal directions"
|
||||
"Place second vertex to finish drawing"
|
||||
"Press <k>builder_cancelmode</k> or <k>builder_classicedit</k> to cancel"
|
Loading…
Reference in a new issue