mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 22:01:45 +00:00
Visual mode: when changing height of a triangular sector all vertices of which have height offset, vertex heights will be changed instead of sector's floor/ceiling height (this allows to edit terrain without the use of vertex handles).
Visual mode: "Copy Texture", "Copy Texture Offsets" and "Copy Properties" actions now always copy properties from currently highlighted surface (previously they copied properties from the first selected surface when something was selected). Draw Rectangle mode: nothing was drawn in some cases. Drag Things mode: grid was not updated when grid size was changed in this mode.
This commit is contained in:
parent
79dcaca457
commit
1367c37b8d
7 changed files with 89 additions and 25 deletions
|
@ -7,30 +7,30 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
{
|
||||
public class VisualVertexPair
|
||||
{
|
||||
private VisualVertex v1;
|
||||
private VisualVertex v2;
|
||||
private VisualVertex floorvert;
|
||||
private VisualVertex ceilvert;
|
||||
|
||||
public VisualVertex[] Vertices { get { return new VisualVertex[] { v1, v2 }; } }
|
||||
public VisualVertex Vertex1 { get { return v1; } }
|
||||
public VisualVertex Vertex2 { get { return v2; } }
|
||||
public bool Changed { set { v1.Changed = true; v2.Changed = true; } }
|
||||
public VisualVertex[] Vertices { get { return new[] { floorvert, ceilvert }; } }
|
||||
public VisualVertex FloorVertex { get { return floorvert; } }
|
||||
public VisualVertex CeilingVertex { get { return ceilvert; } }
|
||||
public bool Changed { set { floorvert.Changed = true; ceilvert.Changed = true; } }
|
||||
|
||||
public VisualVertexPair(VisualVertex v1, VisualVertex v2) {
|
||||
if(v1.CeilingVertex == v2.CeilingVertex)
|
||||
public VisualVertexPair(VisualVertex floorvert, VisualVertex ceilvert) {
|
||||
if(floorvert.CeilingVertex == ceilvert.CeilingVertex)
|
||||
throw new Exception("VisualVertexPair: both verts have the same alignment! We cannot tolerate this!");
|
||||
|
||||
this.v1 = v1;
|
||||
this.v2 = v2;
|
||||
this.floorvert = floorvert;
|
||||
this.ceilvert = ceilvert;
|
||||
}
|
||||
|
||||
public void Update() {
|
||||
if(v1.Changed) v1.Update();
|
||||
if(v2.Changed) v2.Update();
|
||||
if(floorvert.Changed) floorvert.Update();
|
||||
if(ceilvert.Changed) ceilvert.Update();
|
||||
}
|
||||
|
||||
public void Deselect() {
|
||||
v1.Selected = false;
|
||||
v2.Selected = false;
|
||||
floorvert.Selected = false;
|
||||
ceilvert.Selected = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -272,6 +272,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// This redraws only changed things
|
||||
private void UpdateRedraw()
|
||||
{
|
||||
//mxd. Added, so grid can be rendered properly if the user changes grid size while dragging (very useful and important, I know)
|
||||
if (renderer.StartPlotter(true))
|
||||
{
|
||||
// Render lines and vertices
|
||||
renderer.PlotLinedefSet(General.Map.Map.Linedefs);
|
||||
renderer.PlotVerticesSet(General.Map.Map.Vertices);
|
||||
|
||||
// Done
|
||||
renderer.Finish();
|
||||
}
|
||||
|
||||
// Render things
|
||||
if(renderer.StartThings(true))
|
||||
{
|
||||
|
|
|
@ -168,10 +168,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//no corners
|
||||
if (bevelWidth == 0) {
|
||||
currentBevelWidth = 0;
|
||||
return new[] { pStart, new Vector2D((int)pEnd.x, (int)pStart.y), pEnd, new Vector2D((int)pStart.x, (int)pEnd.y), pStart };
|
||||
return new[] { pStart, new Vector2D((int)pStart.x, (int)pEnd.y), pEnd, new Vector2D((int)pEnd.x, (int)pStart.y), pStart };
|
||||
}
|
||||
|
||||
//got corners
|
||||
//got corners. TODO: check point order
|
||||
bool reverse = false;
|
||||
currentBevelWidth = Math.Min(Math.Abs(bevelWidth), Math.Min(width, height) / 2);
|
||||
|
||||
|
|
|
@ -356,10 +356,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//mxd
|
||||
if(General.Map.UDMF && General.Settings.GZShowVisualVertices) {
|
||||
foreach(KeyValuePair<Vertex, VisualVertexPair> pair in vertices) {
|
||||
if(pair.Value.Vertex1.Selected)
|
||||
selectedobjects.Add((BaseVisualVertex)pair.Value.Vertex1);
|
||||
if(pair.Value.Vertex2.Selected)
|
||||
selectedobjects.Add((BaseVisualVertex)pair.Value.Vertex2);
|
||||
if(pair.Value.CeilingVertex.Selected)
|
||||
selectedobjects.Add((BaseVisualVertex)pair.Value.CeilingVertex);
|
||||
if(pair.Value.FloorVertex.Selected)
|
||||
selectedobjects.Add((BaseVisualVertex)pair.Value.FloorVertex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -686,10 +686,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
return vertexdata[v];
|
||||
}
|
||||
|
||||
internal BaseVisualVertex GetVisualVertex(Vertex v, bool floor) {
|
||||
if(!vertices.ContainsKey(v))
|
||||
vertices.Add(v, new VisualVertexPair(new BaseVisualVertex(this, v, false), new BaseVisualVertex(this, v, true)));
|
||||
|
||||
return (floor ? vertices[v].FloorVertex as BaseVisualVertex : vertices[v].CeilingVertex as BaseVisualVertex);
|
||||
}
|
||||
|
||||
//mxd
|
||||
internal void UpdateVertexHandle(Vertex v) {
|
||||
if(!vertices.ContainsKey(v))
|
||||
vertices.Add(v, new VisualVertexPair(new BaseVisualVertex(this, v, true), new BaseVisualVertex(this, v, false)));
|
||||
vertices.Add(v, new VisualVertexPair(new BaseVisualVertex(this, v, false), new BaseVisualVertex(this, v, true)));
|
||||
else
|
||||
vertices[v].Changed = true;
|
||||
}
|
||||
|
@ -2413,7 +2420,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public void TextureCopy()
|
||||
{
|
||||
PreActionNoChange();
|
||||
GetTargetEventReceiver(false).OnCopyTexture();
|
||||
GetTargetEventReceiver(true).OnCopyTexture(); //mxd
|
||||
PostAction();
|
||||
}
|
||||
|
||||
|
@ -2640,7 +2647,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public void TextureCopyOffsets()
|
||||
{
|
||||
PreActionNoChange();
|
||||
GetTargetEventReceiver(false).OnCopyTextureOffsets();
|
||||
GetTargetEventReceiver(true).OnCopyTextureOffsets(); //mxd
|
||||
PostAction();
|
||||
}
|
||||
|
||||
|
@ -2657,7 +2664,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public void CopyProperties()
|
||||
{
|
||||
PreActionNoChange();
|
||||
GetTargetEventReceiver(false).OnCopyProperties();
|
||||
GetTargetEventReceiver(true).OnCopyProperties(); //mxd
|
||||
PostAction();
|
||||
}
|
||||
|
||||
|
|
|
@ -291,7 +291,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
}
|
||||
|
||||
General.Interface.OnEditFormValuesChanged += new System.EventHandler(Interface_OnEditFormValuesChanged);
|
||||
General.Interface.OnEditFormValuesChanged += Interface_OnEditFormValuesChanged;
|
||||
mode.StartRealtimeInterfaceUpdate(SelectionType.Vertices);
|
||||
General.Interface.ShowEditVertices(verts, false);
|
||||
mode.StopRealtimeInterfaceUpdate(SelectionType.Vertices);
|
||||
|
|
|
@ -282,10 +282,33 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
protected override void ChangeHeight(int amount)
|
||||
{
|
||||
mode.CreateUndo("Change ceiling height", UndoGroup.CeilingHeightChange, level.sector.FixedIndex);
|
||||
//mxd. Modify vertex offsets?
|
||||
if(General.Map.UDMF && level.sector.Sidedefs.Count == 3 && changeVertexHeight(amount)) {
|
||||
mode.SetActionResult("Changed ceiling vertex height by " + amount + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
level.sector.CeilHeight += amount;
|
||||
mode.SetActionResult("Changed ceiling height to " + level.sector.CeilHeight + ".");
|
||||
}
|
||||
|
||||
//mxd
|
||||
private bool changeVertexHeight(int amount) {
|
||||
List<Vertex> verts = new List<Vertex>(3);
|
||||
|
||||
//do this only if all 3 verts have offsets
|
||||
foreach(Sidedef side in level.sector.Sidedefs) {
|
||||
if(float.IsNaN(side.Line.Start.ZCeiling) || float.IsNaN(side.Line.End.ZCeiling)) return false;
|
||||
if(!verts.Contains(side.Line.Start)) verts.Add(side.Line.Start);
|
||||
if(!verts.Contains(side.Line.End)) verts.Add(side.Line.End);
|
||||
}
|
||||
|
||||
foreach(Vertex v in verts)
|
||||
mode.GetVisualVertex(v, false).OnChangeTargetHeight(amount);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//mxd. Sector brightness change
|
||||
public override void OnChangeTargetBrightness(bool up) {
|
||||
if (level != null && level.sector != Sector.Sector) {
|
||||
|
|
|
@ -285,10 +285,33 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
protected override void ChangeHeight(int amount)
|
||||
{
|
||||
mode.CreateUndo("Change floor height", UndoGroup.FloorHeightChange, level.sector.FixedIndex);
|
||||
//mxd. Modify vertex offsets?
|
||||
if(General.Map.UDMF && level.sector.Sidedefs.Count == 3 && changeVertexHeight(amount)) {
|
||||
mode.SetActionResult("Changed floor vertex height by " + amount + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
level.sector.FloorHeight += amount;
|
||||
mode.SetActionResult("Changed floor height to " + level.sector.FloorHeight + ".");
|
||||
}
|
||||
|
||||
//mxd
|
||||
private bool changeVertexHeight(int amount) {
|
||||
List<Vertex> verts = new List<Vertex>(3);
|
||||
|
||||
//do this only if all 3 verts have offsets
|
||||
foreach(Sidedef side in level.sector.Sidedefs) {
|
||||
if(float.IsNaN(side.Line.Start.ZFloor) || float.IsNaN(side.Line.End.ZFloor)) return false;
|
||||
if(!verts.Contains(side.Line.Start)) verts.Add(side.Line.Start);
|
||||
if(!verts.Contains(side.Line.End)) verts.Add(side.Line.End);
|
||||
}
|
||||
|
||||
foreach (Vertex v in verts)
|
||||
mode.GetVisualVertex(v, true).OnChangeTargetHeight(amount);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//mxd. Sector brightness change
|
||||
public override void OnChangeTargetBrightness(bool up) {
|
||||
if (level != null) {
|
||||
|
|
Loading…
Reference in a new issue