// Raise/lower thing public void OnChangeTargetHeight(int amount) { if (General.Map.FormatInterface.HasThingHeight) { if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) { undoticket = mode.CreateUndo("Change thing height"); } Thing.Move(Thing.Position + new Vector3D(0.0f, 0.0f, (info.Hangs ? -amount : amount))); mode.SetActionResult("Changed thing height to " + Thing.Position.z + "."); // Update what must be updated ThingData td = mode.GetThingData(this.Thing); foreach (KeyValuePair <Sector, bool> s in td.UpdateAlso) { if (mode.VisualSectorExists(s.Key)) { BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(s.Key); vs.UpdateSectorGeometry(s.Value); } } this.Changed = true; } }
//mxd protected void ClearFields(IEnumerable <string> keys, string undodescription, string resultdescription) { if (!General.Map.UDMF) { return; } mode.CreateUndo(undodescription); mode.SetActionResult(resultdescription); level.sector.Fields.BeforeFieldsChange(); foreach (string key in keys) { if (level.sector.Fields.ContainsKey(key)) { level.sector.Fields.Remove(key); level.sector.UpdateNeeded = true; } } if (level.sector.UpdateNeeded) { if (level.sector != Sector.Sector && mode.VisualSectorExists(level.sector)) { BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector); vs.UpdateSectorGeometry(false); } else { Sector.UpdateSectorGeometry(false); } } }
//mxd public virtual void OnChangeTextureRotation(float angle) { if (!General.Map.UDMF) { return; } if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) { undoticket = mode.CreateUndo("Change texture rotation"); } string key = (GeometryType == VisualGeometryType.FLOOR ? "rotationfloor" : "rotationceiling"); mode.SetActionResult((GeometryType == VisualGeometryType.FLOOR ? "Floor" : "Ceiling") + " rotation changed to " + angle); //set value Sector s = GetControlSector(); s.Fields.BeforeFieldsChange(); UniFields.SetFloat(s.Fields, key, angle, 0.0f); if (s.Index != Sector.Sector.Index) { s.UpdateNeeded = true; s.UpdateCache(); mode.GetSectorData(s).Update(); BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(s); vs.UpdateSectorGeometry(false); } Sector.Sector.UpdateNeeded = true; Sector.Sector.UpdateCache(); Sector.UpdateSectorGeometry(false); }
//mxd. Sector brightness change public override void OnChangeTargetBrightness(bool up) { if (level != null) { // This floor is part of 3D-floor if (level.sector != Sector.Sector) { BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector); vs.Floor.OnChangeTargetBrightness(up); vs.UpdateSectorGeometry(true); } // This is actual floor of a sector with extrafloors else if (Sector.ExtraFloors.Count > 0 && !Sector.ExtraFloors[0].ExtraFloor.Floor.restrictlighting && !Sector.ExtraFloors[0].ExtraFloor.Floor.disablelighting) { Sector.ExtraFloors[0].OnChangeTargetBrightness(up); } else { base.OnChangeTargetBrightness(up); } } else { base.OnChangeTargetBrightness(up); } }
public EffectUDMFVertexOffset(SectorData data) : base(data) { // New effect added: This sector needs an update! if (data.Mode.VisualSectorExists(data.Sector)) { BaseVisualSector vs = (BaseVisualSector)data.Mode.GetVisualSector(data.Sector); vs.UpdateSectorGeometry(true); } }
// Constructor public Effect3DFloor(SectorData data, Linedef sourcelinedef) : base(data) { linedef = sourcelinedef; // New effect added: This sector needs an update! if (data.Mode.VisualSectorExists(data.Sector)) { BaseVisualSector vs = (BaseVisualSector)data.Mode.GetVisualSector(data.Sector); vs.UpdateSectorGeometry(true); } }
// Constructor public EffectTransferCeilingBrightness(SectorData data, Linedef sourcelinedef) : base(data) { linedef = sourcelinedef; // New effect added: This sector needs an update! if (data.Mode.VisualSectorExists(data.Sector)) { BaseVisualSector vs = (BaseVisualSector)data.Mode.GetVisualSector(data.Sector); vs.UpdateSectorGeometry(false); } }
// Constructor public EffectCopySlope(SectorData data, Thing sourcething) : base(data) { thing = sourcething; // New effect added: This sector needs an update! if (data.Mode.VisualSectorExists(data.Sector)) { BaseVisualSector vs = (BaseVisualSector)data.Mode.GetVisualSector(data.Sector); vs.UpdateSectorGeometry(true); } }
public EffectPlaneCopySlope(SectorData data, Linedef sourcelinedef, bool front) : base(data) { this.linedef = sourcelinedef; this.front = front; // New effect added: This sector needs an update! if (data.Mode.VisualSectorExists(data.Sector)) { BaseVisualSector vs = (BaseVisualSector)data.Mode.GetVisualSector(data.Sector); vs.UpdateSectorGeometry(true); } }
// Constructor public EffectThingVertexSlope(SectorData data, List <Thing> sourcethings, bool floor) : base(data) { things = sourcethings; slopefloor = floor; // New effect added: This sector needs an update! if (data.Mode.VisualSectorExists(data.Sector)) { BaseVisualSector vs = (BaseVisualSector)data.Mode.GetVisualSector(data.Sector); vs.UpdateSectorGeometry(true); } }
// Apply Texture public virtual void ApplyTexture(string texture) { mode.CreateUndo("Change flat \"" + texture + "\""); SetTexture(texture); // Update if (mode.VisualSectorExists(level.sector)) { BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector); vs.UpdateSectorGeometry(false); } }
private void UpdateGeometry(Vertex v) { VertexData vd = mode.GetVertexData(v); foreach (KeyValuePair <Sector, bool> s in vd.UpdateAlso) { if (mode.VisualSectorExists(s.Key)) { BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(s.Key); vs.UpdateSectorGeometry(s.Value); } } }
// Delete texture public virtual void OnDelete() { // Remove texture mode.CreateUndo("Delete texture"); mode.SetActionResult("Deleted a texture."); SetTexture("-"); // Update if (mode.VisualSectorExists(level.sector)) { BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector); vs.UpdateSectorGeometry(false); } }
// Paste texture public override void OnPasteTexture() { if (BuilderPlug.Me.CopiedFlat != null) { mode.CreateUndo("Paste floor \"" + BuilderPlug.Me.CopiedFlat + "\""); mode.SetActionResult("Pasted flat \"" + BuilderPlug.Me.CopiedFlat + "\" on floor."); SetTexture(BuilderPlug.Me.CopiedFlat); // Update if (mode.VisualSectorExists(level.sector)) { BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector); vs.UpdateSectorGeometry(false); } } }
//mxd. Texture scale change protected override void ChangeTextureScale(int incrementX, int incrementY) { if (Texture == null || !Texture.IsImageLoaded) { return; } Sector s = GetControlSector(); float scaleX = s.Fields.GetValue("xscalefloor", 1.0f); float scaleY = s.Fields.GetValue("yscalefloor", 1.0f); s.Fields.BeforeFieldsChange(); if (incrementX != 0) { float pix = (int)Math.Round(Texture.Width * scaleX) - incrementX; float newscaleX = (float)Math.Round(pix / Texture.Width, 3); scaleX = (newscaleX == 0 ? scaleX * -1 : newscaleX); UniFields.SetFloat(s.Fields, "xscalefloor", scaleX, 1.0f); } if (incrementY != 0) { float pix = (int)Math.Round(Texture.Height * scaleY) - incrementY; float newscaleY = (float)Math.Round(pix / Texture.Height, 3); scaleY = (newscaleY == 0 ? scaleY * -1 : newscaleY); UniFields.SetFloat(s.Fields, "yscalefloor", scaleY, 1.0f); } // Update geometry if (mode.VisualSectorExists(level.sector)) { BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector); vs.UpdateSectorGeometry(false); } s.UpdateNeeded = true; s.UpdateCache(); if (s.Index != Sector.Sector.Index) { Sector.Sector.UpdateNeeded = true; Sector.Sector.UpdateCache(); } mode.SetActionResult("Floor scale changed to " + scaleX.ToString("F03", CultureInfo.InvariantCulture) + ", " + scaleY.ToString("F03", CultureInfo.InvariantCulture) + " (" + (int)Math.Round(Texture.Width / scaleX) + " x " + (int)Math.Round(Texture.Height / scaleY) + ")."); }
// Paste properties public virtual void OnPasteProperties(bool usecopysettings) { if (BuilderPlug.Me.CopiedSectorProps != null) { mode.CreateUndo("Paste sector properties"); mode.SetActionResult("Pasted sector properties."); //mxd. Added "usecopysettings" BuilderPlug.Me.CopiedSectorProps.Apply(level.sector, usecopysettings); if (mode.VisualSectorExists(level.sector)) { BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector); vs.UpdateSectorGeometry(true); } mode.ShowTargetInfo(); } }
//mxd public void OnMove(Vector3D newposition) { if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) { undoticket = mode.CreateUndo("Move thing"); } Thing.Move(newposition); mode.SetActionResult("Changed thing position to " + Thing.Position + "."); // Update what must be updated ThingData td = mode.GetThingData(this.Thing); foreach (KeyValuePair <Sector, bool> s in td.UpdateAlso) { if (mode.VisualSectorExists(s.Key)) { BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(s.Key); vs.UpdateSectorGeometry(s.Value); } } this.Changed = true; }
// Texture offset change public virtual void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { if (horizontal == 0 && vertical == 0) { return; //mxd } //mxd if (!General.Map.UDMF) { General.Interface.DisplayStatus(StatusType.Warning, "Floor/ceiling texture offsets cannot be changed in this map format!"); return; } if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) { undoticket = mode.CreateUndo("Change texture offsets"); } //mxd if (doSurfaceAngleCorrection) { Point p = new Point(horizontal, vertical); float angle = Angle2D.RadToDeg(General.Map.VisualCamera.AngleXY); if (GeometryType == VisualGeometryType.CEILING) { angle += level.sector.Fields.GetValue("rotationceiling", 0f); } else { angle += level.sector.Fields.GetValue("rotationfloor", 0f); } angle = General.ClampAngle(angle); if (angle > 315 || angle < 46) { //already correct } else if (angle > 225) { vertical = p.X; horizontal = -p.Y; } else if (angle > 135) { horizontal = -p.X; vertical = -p.Y; } else { vertical = -p.X; horizontal = p.Y; } } // Apply offsets MoveTextureOffset(new Point(-horizontal, -vertical)); // Update sector geometry Sector s = GetControlSector(); if (s.Index != Sector.Sector.Index) { s.UpdateNeeded = true; s.UpdateCache(); mode.GetSectorData(s).Update(); BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(s); vs.UpdateSectorGeometry(false); vs.Rebuild(); } Sector.Sector.UpdateNeeded = true; Sector.Sector.UpdateCache(); Sector.UpdateSectorGeometry(false); Sector.Rebuild(); }