2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2012-11-27 21:12:20 +00:00
|
|
|
using System.Drawing;
|
2016-03-23 14:52:33 +00:00
|
|
|
using System.IO;
|
2009-04-19 18:07:22 +00:00
|
|
|
using System.Windows.Forms;
|
|
|
|
using CodeImp.DoomBuilder.Data;
|
|
|
|
using CodeImp.DoomBuilder.IO;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
|
|
using CodeImp.DoomBuilder.VisualModes;
|
2014-02-27 10:08:31 +00:00
|
|
|
using CodeImp.DoomBuilder.Windows;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
|
|
|
{
|
|
|
|
internal abstract class BaseVisualGeometrySector : VisualGeometry, IVisualEventReceiver
|
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
2012-11-27 21:12:20 +00:00
|
|
|
private const float DRAG_ANGLE_TOLERANCE = 0.06f;
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
2015-11-20 14:31:54 +00:00
|
|
|
protected readonly BaseVisualMode mode;
|
2009-04-19 18:07:22 +00:00
|
|
|
protected long setuponloadedtexture;
|
2019-12-31 02:44:36 +00:00
|
|
|
private long lastsetuponloadedtexture;
|
2009-05-01 20:31:17 +00:00
|
|
|
|
2019-12-31 02:44:36 +00:00
|
|
|
// This is only used to see if this object has already received a change
|
|
|
|
// in a multiselection. The Changed property on the BaseVisualSector is
|
|
|
|
// used to indicate a rebuild is needed.
|
|
|
|
protected bool changed;
|
2012-11-27 21:12:20 +00:00
|
|
|
|
|
|
|
protected SectorLevel level;
|
|
|
|
protected Effect3DFloor extrafloor;
|
|
|
|
|
|
|
|
// Undo/redo
|
|
|
|
private int undoticket;
|
|
|
|
|
|
|
|
// UV dragging
|
2020-05-21 12:20:02 +00:00
|
|
|
private double dragstartanglexy;
|
|
|
|
private double dragstartanglez;
|
2012-11-27 21:12:20 +00:00
|
|
|
private Vector3D dragorigin;
|
|
|
|
private int startoffsetx;
|
|
|
|
private int startoffsety;
|
|
|
|
protected bool uvdragging;
|
|
|
|
private int prevoffsetx; // We have to provide delta offsets, but I don't
|
|
|
|
private int prevoffsety; // want to calculate with delta offsets to prevent
|
|
|
|
// inaccuracy in the dragging.
|
2013-07-10 08:59:17 +00:00
|
|
|
|
2016-01-16 12:46:44 +00:00
|
|
|
private static List<BaseVisualSector> updatelist; //mxd
|
|
|
|
protected bool performautoselection; //mxd
|
2013-07-10 08:59:17 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
new public BaseVisualSector Sector { get { return (BaseVisualSector)base.Sector; } }
|
2009-05-05 11:26:50 +00:00
|
|
|
public bool Changed { get { return changed; } set { changed = value; } }
|
2012-11-27 21:12:20 +00:00
|
|
|
public SectorLevel Level { get { return level; } }
|
|
|
|
public Effect3DFloor ExtraFloor { get { return extrafloor; } }
|
2009-05-01 20:31:17 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Destructor
|
|
|
|
|
|
|
|
// Constructor
|
2012-11-27 21:12:20 +00:00
|
|
|
protected BaseVisualGeometrySector(BaseVisualMode mode, VisualSector vs) : base(vs)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
this.mode = mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
// This changes the height
|
|
|
|
protected abstract void ChangeHeight(int amount);
|
2015-03-03 09:42:54 +00:00
|
|
|
protected abstract void ChangeTextureScale(int incrementX, int incrementY); //mxd
|
2023-10-14 12:24:09 +00:00
|
|
|
public virtual void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight, bool stopatselected) { } //mxd
|
2012-11-27 21:12:20 +00:00
|
|
|
|
2016-01-16 12:46:44 +00:00
|
|
|
//mxd
|
2023-08-12 14:43:07 +00:00
|
|
|
override public void PerformAutoSelection()
|
2016-01-16 12:46:44 +00:00
|
|
|
{
|
|
|
|
if(!performautoselection) return;
|
|
|
|
if(Triangles > 0)
|
|
|
|
{
|
|
|
|
this.selected = true;
|
|
|
|
mode.AddSelectedObject(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
performautoselection = false;
|
|
|
|
}
|
|
|
|
|
2012-11-27 21:12:20 +00:00
|
|
|
// This swaps triangles so that the plane faces the other way
|
2014-12-22 21:36:49 +00:00
|
|
|
protected static void SwapTriangleVertices(WorldVertex[] verts)
|
2012-11-27 21:12:20 +00:00
|
|
|
{
|
|
|
|
// Swap some vertices to flip all triangles
|
|
|
|
for(int i = 0; i < verts.Length; i += 3)
|
|
|
|
{
|
|
|
|
// Swap
|
|
|
|
WorldVertex v = verts[i];
|
|
|
|
verts[i] = verts[i + 1];
|
|
|
|
verts[i + 1] = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is called to update UV dragging
|
|
|
|
protected virtual void UpdateDragUV()
|
|
|
|
{
|
2020-05-21 12:20:02 +00:00
|
|
|
double u_ray = 1.0f;
|
2012-11-27 21:12:20 +00:00
|
|
|
|
|
|
|
// Calculate intersection position
|
|
|
|
this.Level.plane.GetIntersection(General.Map.VisualCamera.Position, General.Map.VisualCamera.Target, ref u_ray);
|
|
|
|
Vector3D intersect = General.Map.VisualCamera.Position + (General.Map.VisualCamera.Target - General.Map.VisualCamera.Position) * u_ray;
|
|
|
|
|
|
|
|
// Calculate offsets
|
|
|
|
Vector3D dragdelta = intersect - dragorigin;
|
2020-05-21 12:20:02 +00:00
|
|
|
double offsetx = dragdelta.x;
|
|
|
|
double offsety = dragdelta.y;
|
2012-11-27 21:12:20 +00:00
|
|
|
|
2013-07-01 09:34:17 +00:00
|
|
|
bool lockX = General.Interface.CtrlState && !General.Interface.ShiftState;
|
|
|
|
bool lockY = !General.Interface.CtrlState && General.Interface.ShiftState;
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
if(lockX || lockY)
|
|
|
|
{
|
2020-05-21 12:20:02 +00:00
|
|
|
double camAngle = Angle2D.RadToDeg(General.Map.VisualCamera.AngleXY);
|
2013-07-01 09:34:17 +00:00
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
if(camAngle > 315 || camAngle < 46)
|
|
|
|
{
|
2013-07-01 09:34:17 +00:00
|
|
|
if(lockX) offsetx = 0;
|
|
|
|
if(lockY) offsety = 0;
|
2014-12-03 23:15:26 +00:00
|
|
|
}
|
|
|
|
else if(camAngle > 225)
|
|
|
|
{
|
2013-07-01 09:34:17 +00:00
|
|
|
if(lockX) offsety = 0;
|
|
|
|
if(lockY) offsetx = 0;
|
2014-12-03 23:15:26 +00:00
|
|
|
}
|
|
|
|
else if(camAngle > 135)
|
|
|
|
{
|
2013-07-01 09:34:17 +00:00
|
|
|
if(lockX) offsetx = 0;
|
|
|
|
if(lockY) offsety = 0;
|
2014-12-03 23:15:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-01 09:34:17 +00:00
|
|
|
if(lockX) offsety = 0;
|
|
|
|
if(lockY) offsetx = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
//mxd. Modify offsets based on surface and camera angles
|
2020-05-21 12:20:02 +00:00
|
|
|
double angle;
|
2013-04-26 12:32:51 +00:00
|
|
|
|
2013-12-05 09:24:55 +00:00
|
|
|
if(GeometryType == VisualGeometryType.CEILING)
|
2020-05-22 19:39:18 +00:00
|
|
|
angle = Angle2D.DegToRad(level.sector.Fields.GetValue("rotationceiling", 0.0));
|
2013-12-05 09:24:55 +00:00
|
|
|
else
|
2020-05-22 19:39:18 +00:00
|
|
|
angle = Angle2D.DegToRad(level.sector.Fields.GetValue("rotationfloor", 0.0));
|
2013-04-26 12:32:51 +00:00
|
|
|
|
2013-12-05 09:24:55 +00:00
|
|
|
Vector2D v = new Vector2D(offsetx, offsety).GetRotated(angle);
|
2013-04-26 12:32:51 +00:00
|
|
|
|
2013-12-05 09:24:55 +00:00
|
|
|
offsetx = (int)Math.Round(v.x);
|
|
|
|
offsety = (int)Math.Round(v.y);
|
2012-11-27 21:12:20 +00:00
|
|
|
|
2016-09-06 12:05:47 +00:00
|
|
|
// Calculate deltas
|
|
|
|
int deltax, deltay;
|
2014-12-03 23:15:26 +00:00
|
|
|
if(General.Interface.CtrlState && General.Interface.ShiftState)
|
|
|
|
{
|
|
|
|
//mxd. Clamp to grid size?
|
2013-12-05 09:24:55 +00:00
|
|
|
int newoffsetx = startoffsetx - (int)Math.Round(offsetx);
|
|
|
|
int newoffsety = startoffsety + (int)Math.Round(offsety);
|
2016-09-06 12:05:47 +00:00
|
|
|
deltax = prevoffsetx - newoffsetx;
|
|
|
|
deltay = prevoffsety - newoffsety;
|
2013-12-05 09:24:55 +00:00
|
|
|
|
2017-01-06 10:01:59 +00:00
|
|
|
if(Math.Abs(deltax) >= General.Map.Grid.GridSize)
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2017-01-06 10:01:59 +00:00
|
|
|
deltax = General.Map.Grid.GridSize * Math.Sign(deltax);
|
2013-12-05 09:24:55 +00:00
|
|
|
prevoffsetx = newoffsetx;
|
2014-12-03 23:15:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-06 12:05:47 +00:00
|
|
|
deltax = 0;
|
2013-12-05 09:24:55 +00:00
|
|
|
}
|
|
|
|
|
2017-01-06 10:01:59 +00:00
|
|
|
if(Math.Abs(deltay) >= General.Map.Grid.GridSize)
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2017-01-06 10:01:59 +00:00
|
|
|
deltay = General.Map.Grid.GridSize * Math.Sign(deltay);
|
2013-12-05 09:24:55 +00:00
|
|
|
prevoffsety = newoffsety;
|
2014-12-03 23:15:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-06 12:05:47 +00:00
|
|
|
deltay = 0;
|
2013-12-05 09:24:55 +00:00
|
|
|
}
|
2014-12-03 23:15:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-05 09:24:55 +00:00
|
|
|
int newoffsetx = startoffsetx - (int)Math.Round(offsetx);
|
|
|
|
int newoffsety = startoffsety + (int)Math.Round(offsety);
|
2016-09-06 12:05:47 +00:00
|
|
|
|
|
|
|
deltax = prevoffsetx - newoffsetx;
|
|
|
|
deltay = prevoffsety - newoffsety;
|
|
|
|
|
2013-12-05 09:24:55 +00:00
|
|
|
prevoffsetx = newoffsetx;
|
|
|
|
prevoffsety = newoffsety;
|
|
|
|
}
|
2012-11-27 21:12:20 +00:00
|
|
|
|
2016-09-06 12:05:47 +00:00
|
|
|
//mxd. Apply offset?
|
2016-09-08 19:28:47 +00:00
|
|
|
if(deltax != 0 || deltay != 0) mode.ApplyFlatOffsetChange(deltax, deltay);
|
2016-09-06 12:05:47 +00:00
|
|
|
mode.ShowTargetInfo();
|
2013-09-11 09:47:53 +00:00
|
|
|
}
|
2012-11-27 21:12:20 +00:00
|
|
|
|
2013-04-01 11:06:01 +00:00
|
|
|
//mxd
|
2016-09-06 12:05:47 +00:00
|
|
|
public override Sector GetControlSector() { return level.sector; }
|
2013-05-29 14:18:49 +00:00
|
|
|
|
|
|
|
//mxd
|
2014-12-03 23:15:26 +00:00
|
|
|
protected void AlignTextureToClosestLine(bool alignx, bool aligny)
|
|
|
|
{
|
2013-05-30 09:34:44 +00:00
|
|
|
if(!(mode.HighlightedObject is BaseVisualSector)) return;
|
2020-05-21 12:20:02 +00:00
|
|
|
|
2016-03-18 12:52:12 +00:00
|
|
|
// Do we need to align this? (and also grab texture scale while we are at it)
|
2020-05-21 12:20:02 +00:00
|
|
|
double scaleX, scaleY;
|
2014-12-22 21:36:49 +00:00
|
|
|
bool isFloor = (geometrytype == VisualGeometryType.FLOOR);
|
2013-05-30 09:34:44 +00:00
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
if(mode.HighlightedTarget is VisualFloor)
|
|
|
|
{
|
2019-12-27 17:49:12 +00:00
|
|
|
Sector target;
|
|
|
|
VisualFloor vf = (VisualFloor)mode.HighlightedTarget;
|
|
|
|
|
|
|
|
// Use the control sector if the floor belongs to a 3D floor
|
|
|
|
if (vf.ExtraFloor == null)
|
|
|
|
target = vf.Sector.Sector;
|
|
|
|
else
|
|
|
|
target = vf.GetControlSector();
|
2013-05-30 09:34:44 +00:00
|
|
|
|
2016-03-18 12:52:12 +00:00
|
|
|
// Check texture
|
2019-12-27 17:49:12 +00:00
|
|
|
if(target.FloorTexture != (isFloor ? Sector.Sector.FloorTexture : Sector.Sector.CeilTexture)) return;
|
2013-05-30 09:34:44 +00:00
|
|
|
|
2020-05-22 19:39:18 +00:00
|
|
|
scaleX = target.Fields.GetValue("xscalefloor", 1.0);
|
|
|
|
scaleY = target.Fields.GetValue("yscalefloor", 1.0);
|
2014-12-03 23:15:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-27 17:49:12 +00:00
|
|
|
Sector target;
|
|
|
|
VisualCeiling vc = (VisualCeiling)mode.HighlightedTarget;
|
|
|
|
|
|
|
|
// Use the control sector if the ceiling belongs to a 3D floor
|
|
|
|
if (vc.ExtraFloor == null)
|
|
|
|
target = vc.Sector.Sector;
|
|
|
|
else
|
|
|
|
target = vc.GetControlSector();
|
2013-05-30 09:34:44 +00:00
|
|
|
|
2016-03-18 12:52:12 +00:00
|
|
|
// Check texture
|
2019-12-27 17:49:12 +00:00
|
|
|
if(target.CeilTexture != (isFloor ? Sector.Sector.FloorTexture : Sector.Sector.CeilTexture)) return;
|
2013-05-30 09:34:44 +00:00
|
|
|
|
2020-05-22 19:39:18 +00:00
|
|
|
scaleX = target.Fields.GetValue("xscaleceiling", 1.0);
|
|
|
|
scaleY = target.Fields.GetValue("yscaleceiling", 1.0);
|
2013-05-30 09:34:44 +00:00
|
|
|
}
|
|
|
|
|
2013-05-29 14:18:49 +00:00
|
|
|
//find a linedef to align to
|
|
|
|
Vector2D hitpos = mode.GetHitPosition();
|
2013-05-30 09:34:44 +00:00
|
|
|
if(!hitpos.IsFinite()) return;
|
2013-05-29 14:18:49 +00:00
|
|
|
|
|
|
|
//align to line of highlighted sector, which is closest to hitpos
|
|
|
|
Sector highlightedSector = ((BaseVisualSector)mode.HighlightedObject).Sector;
|
|
|
|
List<Linedef> lines = new List<Linedef>();
|
|
|
|
foreach(Sidedef side in highlightedSector.Sidedefs) lines.Add(side.Line);
|
|
|
|
|
|
|
|
Linedef targetLine = MapSet.NearestLinedef(lines, hitpos);
|
|
|
|
if(targetLine == null) return;
|
|
|
|
|
2014-02-21 14:42:12 +00:00
|
|
|
bool isFront = targetLine.SideOfLine(hitpos) > 0;
|
2013-05-29 14:18:49 +00:00
|
|
|
Sector.Sector.Fields.BeforeFieldsChange();
|
|
|
|
|
|
|
|
//find an angle to rotate texture
|
2020-05-22 20:30:32 +00:00
|
|
|
double sourceAngle = Math.Round(General.ClampAngle(isFront ? -Angle2D.RadToDeg(targetLine.Angle) + 90 : -Angle2D.RadToDeg(targetLine.Angle) - 90), 1);
|
2013-05-29 14:18:49 +00:00
|
|
|
if(!isFront) sourceAngle = General.ClampAngle(sourceAngle + 180);
|
|
|
|
|
|
|
|
//update angle
|
2020-05-22 20:30:32 +00:00
|
|
|
UniFields.SetFloat(Sector.Sector.Fields, (isFloor ? "rotationfloor" : "rotationceiling"), sourceAngle, 0.0);
|
2013-05-29 14:18:49 +00:00
|
|
|
|
2020-04-04 16:03:40 +00:00
|
|
|
// Scale texture if it's a slope and the appropriate option is set
|
2020-06-25 19:02:56 +00:00
|
|
|
if (level.plane.Normal.z != 1.0 && BuilderPlug.Me.ScaleTexturesOnSlopes != 2)
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2020-05-22 20:30:32 +00:00
|
|
|
Vector2D basescale = new Vector2D(1.0, 1.0);
|
2013-05-29 14:18:49 +00:00
|
|
|
|
2020-04-04 16:03:40 +00:00
|
|
|
// User wants to use the current scale as a base?
|
|
|
|
if(BuilderPlug.Me.ScaleTexturesOnSlopes == 1)
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2020-04-04 16:03:40 +00:00
|
|
|
basescale.x = scaleX;
|
|
|
|
basescale.y = scaleY;
|
2013-05-29 14:18:49 +00:00
|
|
|
}
|
|
|
|
|
2020-04-04 16:03:40 +00:00
|
|
|
// Create a unit vector of the direction of the target line in 3D space
|
|
|
|
Vector3D targetlinevector = new Line3D(new Vector3D(targetLine.Start.Position, level.plane.GetZ(targetLine.Start.Position)), new Vector3D(targetLine.End.Position, level.plane.GetZ(targetLine.End.Position))).GetDelta().GetNormal();
|
2013-05-29 14:18:49 +00:00
|
|
|
|
2020-04-04 16:03:40 +00:00
|
|
|
// Get a perpendicular vector of the target line in 3D space. This is used to get the slope angle relative to the target line
|
|
|
|
Vector3D targetlineperpendicular = Vector3D.CrossProduct(targetlinevector, level.plane.Normal);
|
2013-05-29 14:18:49 +00:00
|
|
|
|
2020-04-04 16:03:40 +00:00
|
|
|
if (alignx)
|
2020-06-25 19:02:56 +00:00
|
|
|
scaleX = Math.Abs(basescale.x * (1.0 / Math.Cos(targetlinevector.GetAngleZ())));
|
2013-05-29 14:18:49 +00:00
|
|
|
|
2020-04-04 16:03:40 +00:00
|
|
|
if (aligny)
|
2020-06-25 19:02:56 +00:00
|
|
|
scaleY = Math.Abs(basescale.y * (1.0 / Math.Cos(targetlineperpendicular.GetAngleZ())));
|
2013-05-29 14:18:49 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-04 16:03:40 +00:00
|
|
|
//set scale
|
2020-05-22 20:30:32 +00:00
|
|
|
UniFields.SetFloat(Sector.Sector.Fields, (isFloor ? "xscalefloor" : "xscaleceiling"), scaleX, 1.0);
|
|
|
|
UniFields.SetFloat(Sector.Sector.Fields, (isFloor ? "yscalefloor" : "yscaleceiling"), scaleY, 1.0);
|
2020-04-04 16:03:40 +00:00
|
|
|
|
|
|
|
//update offset
|
2020-05-21 12:20:02 +00:00
|
|
|
double distToStart = Vector2D.Distance(hitpos, targetLine.Start.Position);
|
|
|
|
double distToEnd = Vector2D.Distance(hitpos, targetLine.End.Position);
|
2020-04-04 16:03:40 +00:00
|
|
|
Vector2D offset = (distToStart < distToEnd ? targetLine.Start.Position : targetLine.End.Position).GetRotated(Angle2D.DegToRad(sourceAngle));
|
2013-05-29 14:18:49 +00:00
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
if(alignx)
|
|
|
|
{
|
2016-09-02 19:18:37 +00:00
|
|
|
if(Texture != null && Texture.IsImageLoaded) offset.x %= Texture.Width / scaleX;
|
2020-06-25 19:02:56 +00:00
|
|
|
UniFields.SetFloat(Sector.Sector.Fields, (isFloor ? "xpanningfloor" : "xpanningceiling"), Math.Round(-offset.x, 6), 0.0);
|
2013-05-29 14:18:49 +00:00
|
|
|
}
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
if(aligny)
|
|
|
|
{
|
2016-09-02 19:18:37 +00:00
|
|
|
if(Texture != null && Texture.IsImageLoaded) offset.y %= Texture.Height / scaleY;
|
2020-06-25 19:02:56 +00:00
|
|
|
UniFields.SetFloat(Sector.Sector.Fields, (isFloor ? "ypanningfloor" : "ypanningceiling"), Math.Round(offset.y, 6), 0.0);
|
2013-05-29 14:18:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//update geometry
|
|
|
|
Sector.UpdateSectorGeometry(false);
|
|
|
|
}
|
Added, Visual mode, UDMF: added "Change Pitch Clockwise", "Change Pitch Counterclockwise", "Change Roll Clockwise" and "Change Roll Counterclockwise" actions.
Added, Visual mode, UDMF: added "Increase Scale" and "Decrease Scale" actions.
Added, Visual mode, UDMF: "Reset Texture Offsets" action now resets scale when used on things.
Added, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets scale, pitch and roll when used on things.
Changed, Visual mode, UDMF: "Reset Texture Offsets" action now only resets texture offsets (previously it also reset texture scale).
Changed, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets texture offsets, scale and brightness of sidedefs and also rotation of floors/ceilings.
Changed, Visual mode, UDMF: thing box arrow now displays pitch and roll for things, which have attached model and appropriate MODELDEF flags.
Changed, Thing Edit Form, UDMF: negative pitch and roll can now be entered.
Updated documentation.
2015-03-30 21:44:04 +00:00
|
|
|
|
|
|
|
//mxd
|
|
|
|
protected void ClearFields(IEnumerable<string> keys, string undodescription, string resultdescription)
|
|
|
|
{
|
|
|
|
if(!General.Map.UDMF) return;
|
|
|
|
|
|
|
|
mode.CreateUndo(undodescription);
|
|
|
|
mode.SetActionResult(resultdescription);
|
2016-04-19 20:40:42 +00:00
|
|
|
level.sector.Fields.BeforeFieldsChange();
|
Added, Visual mode, UDMF: added "Change Pitch Clockwise", "Change Pitch Counterclockwise", "Change Roll Clockwise" and "Change Roll Counterclockwise" actions.
Added, Visual mode, UDMF: added "Increase Scale" and "Decrease Scale" actions.
Added, Visual mode, UDMF: "Reset Texture Offsets" action now resets scale when used on things.
Added, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets scale, pitch and roll when used on things.
Changed, Visual mode, UDMF: "Reset Texture Offsets" action now only resets texture offsets (previously it also reset texture scale).
Changed, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets texture offsets, scale and brightness of sidedefs and also rotation of floors/ceilings.
Changed, Visual mode, UDMF: thing box arrow now displays pitch and roll for things, which have attached model and appropriate MODELDEF flags.
Changed, Thing Edit Form, UDMF: negative pitch and roll can now be entered.
Updated documentation.
2015-03-30 21:44:04 +00:00
|
|
|
|
2016-04-19 20:40:42 +00:00
|
|
|
foreach(string key in keys)
|
Added, Visual mode, UDMF: added "Change Pitch Clockwise", "Change Pitch Counterclockwise", "Change Roll Clockwise" and "Change Roll Counterclockwise" actions.
Added, Visual mode, UDMF: added "Increase Scale" and "Decrease Scale" actions.
Added, Visual mode, UDMF: "Reset Texture Offsets" action now resets scale when used on things.
Added, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets scale, pitch and roll when used on things.
Changed, Visual mode, UDMF: "Reset Texture Offsets" action now only resets texture offsets (previously it also reset texture scale).
Changed, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets texture offsets, scale and brightness of sidedefs and also rotation of floors/ceilings.
Changed, Visual mode, UDMF: thing box arrow now displays pitch and roll for things, which have attached model and appropriate MODELDEF flags.
Changed, Thing Edit Form, UDMF: negative pitch and roll can now be entered.
Updated documentation.
2015-03-30 21:44:04 +00:00
|
|
|
{
|
2016-04-19 20:40:42 +00:00
|
|
|
if(level.sector.Fields.ContainsKey(key))
|
Added, Visual mode, UDMF: added "Change Pitch Clockwise", "Change Pitch Counterclockwise", "Change Roll Clockwise" and "Change Roll Counterclockwise" actions.
Added, Visual mode, UDMF: added "Increase Scale" and "Decrease Scale" actions.
Added, Visual mode, UDMF: "Reset Texture Offsets" action now resets scale when used on things.
Added, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets scale, pitch and roll when used on things.
Changed, Visual mode, UDMF: "Reset Texture Offsets" action now only resets texture offsets (previously it also reset texture scale).
Changed, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets texture offsets, scale and brightness of sidedefs and also rotation of floors/ceilings.
Changed, Visual mode, UDMF: thing box arrow now displays pitch and roll for things, which have attached model and appropriate MODELDEF flags.
Changed, Thing Edit Form, UDMF: negative pitch and roll can now be entered.
Updated documentation.
2015-03-30 21:44:04 +00:00
|
|
|
{
|
2016-04-19 20:40:42 +00:00
|
|
|
level.sector.Fields.Remove(key);
|
|
|
|
level.sector.UpdateNeeded = true;
|
Added, Visual mode, UDMF: added "Change Pitch Clockwise", "Change Pitch Counterclockwise", "Change Roll Clockwise" and "Change Roll Counterclockwise" actions.
Added, Visual mode, UDMF: added "Increase Scale" and "Decrease Scale" actions.
Added, Visual mode, UDMF: "Reset Texture Offsets" action now resets scale when used on things.
Added, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets scale, pitch and roll when used on things.
Changed, Visual mode, UDMF: "Reset Texture Offsets" action now only resets texture offsets (previously it also reset texture scale).
Changed, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets texture offsets, scale and brightness of sidedefs and also rotation of floors/ceilings.
Changed, Visual mode, UDMF: thing box arrow now displays pitch and roll for things, which have attached model and appropriate MODELDEF flags.
Changed, Thing Edit Form, UDMF: negative pitch and roll can now be entered.
Updated documentation.
2015-03-30 21:44:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-19 20:40:42 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
Added, Visual mode, UDMF: added "Change Pitch Clockwise", "Change Pitch Counterclockwise", "Change Roll Clockwise" and "Change Roll Counterclockwise" actions.
Added, Visual mode, UDMF: added "Increase Scale" and "Decrease Scale" actions.
Added, Visual mode, UDMF: "Reset Texture Offsets" action now resets scale when used on things.
Added, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets scale, pitch and roll when used on things.
Changed, Visual mode, UDMF: "Reset Texture Offsets" action now only resets texture offsets (previously it also reset texture scale).
Changed, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets texture offsets, scale and brightness of sidedefs and also rotation of floors/ceilings.
Changed, Visual mode, UDMF: thing box arrow now displays pitch and roll for things, which have attached model and appropriate MODELDEF flags.
Changed, Thing Edit Form, UDMF: negative pitch and roll can now be entered.
Updated documentation.
2015-03-30 21:44:04 +00:00
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Events
|
|
|
|
|
|
|
|
// Unused
|
|
|
|
public virtual void OnEditBegin() { }
|
2014-12-22 21:36:49 +00:00
|
|
|
public virtual void OnTextureFit(FitTextureOptions options) { } //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
public virtual void OnToggleUpperUnpegged() { }
|
|
|
|
public virtual void OnToggleLowerUnpegged() { }
|
|
|
|
public virtual void OnResetTextureOffset() { }
|
2013-09-19 09:17:49 +00:00
|
|
|
public virtual void OnResetLocalTextureOffset() { } //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
public virtual void OnCopyTextureOffsets() { }
|
|
|
|
public virtual void OnPasteTextureOffsets() { }
|
|
|
|
public virtual void OnInsert() { }
|
|
|
|
protected virtual void SetTexture(string texturename) { }
|
2009-05-03 19:22:32 +00:00
|
|
|
public virtual void ApplyUpperUnpegged(bool set) { }
|
|
|
|
public virtual void ApplyLowerUnpegged(bool set) { }
|
2016-09-06 12:05:47 +00:00
|
|
|
protected abstract void MoveTextureOffset(int offsetx, int offsety);
|
2012-11-27 21:12:20 +00:00
|
|
|
protected abstract Point GetTextureOffset();
|
2019-01-19 07:56:13 +00:00
|
|
|
public virtual void OnPaintSelectEnd() { } // biwa
|
2012-11-27 21:12:20 +00:00
|
|
|
|
|
|
|
// Setup this plane
|
|
|
|
public bool Setup() { return this.Setup(this.level, this.extrafloor); }
|
|
|
|
public virtual bool Setup(SectorLevel level, Effect3DFloor extrafloor)
|
|
|
|
{
|
|
|
|
this.level = level;
|
|
|
|
this.extrafloor = extrafloor;
|
|
|
|
return false;
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
|
2012-11-27 21:12:20 +00:00
|
|
|
// Begin select
|
|
|
|
public virtual void OnSelectBegin()
|
|
|
|
{
|
|
|
|
mode.LockTarget();
|
|
|
|
dragstartanglexy = General.Map.VisualCamera.AngleXY;
|
|
|
|
dragstartanglez = General.Map.VisualCamera.AngleZ;
|
|
|
|
dragorigin = pickintersect;
|
|
|
|
startoffsetx = GetTextureOffset().X;
|
|
|
|
startoffsety = GetTextureOffset().Y;
|
|
|
|
prevoffsetx = GetTextureOffset().X;
|
|
|
|
prevoffsety = GetTextureOffset().Y;
|
|
|
|
}
|
|
|
|
|
2009-05-01 20:31:17 +00:00
|
|
|
// Select or deselect
|
|
|
|
public virtual void OnSelectEnd()
|
|
|
|
{
|
2012-11-27 21:12:20 +00:00
|
|
|
mode.UnlockTarget();
|
|
|
|
|
|
|
|
// Was dragging?
|
|
|
|
if(uvdragging)
|
|
|
|
{
|
|
|
|
// Dragging stops now
|
|
|
|
uvdragging = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(this.selected)
|
|
|
|
{
|
|
|
|
this.selected = false;
|
|
|
|
mode.RemoveSelectedObject(this);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.selected = true;
|
|
|
|
mode.AddSelectedObject(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Moving the mouse
|
|
|
|
public virtual void OnMouseMove(MouseEventArgs e)
|
|
|
|
{
|
2019-01-19 07:56:13 +00:00
|
|
|
// biwa. Paint selection going on?
|
|
|
|
if(mode.PaintSelectPressed)
|
|
|
|
{
|
|
|
|
// toggle selected state
|
|
|
|
if (mode.PaintSelectType == this.GetType().BaseType && mode.Highlighted != this) // using BaseType so that both floor and ceiling can be selected in one go
|
|
|
|
{
|
2019-06-20 13:38:41 +00:00
|
|
|
if (General.Interface.ShiftState ^ BuilderPlug.Me.AdditivePaintSelect)
|
2019-01-19 07:56:13 +00:00
|
|
|
{
|
2021-02-13 21:59:06 +00:00
|
|
|
if (!selected)
|
|
|
|
{
|
|
|
|
selected = true;
|
|
|
|
mode.AddSelectedObject(this);
|
|
|
|
}
|
2019-01-19 07:56:13 +00:00
|
|
|
}
|
|
|
|
else if (General.Interface.CtrlState)
|
|
|
|
{
|
2021-02-13 21:59:06 +00:00
|
|
|
if (selected)
|
|
|
|
{
|
|
|
|
selected = false;
|
|
|
|
mode.RemoveSelectedObject(this);
|
|
|
|
}
|
2019-01-19 07:56:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-13 21:59:06 +00:00
|
|
|
if (selected)
|
2019-01-19 07:56:13 +00:00
|
|
|
mode.RemoveSelectedObject(this);
|
|
|
|
else
|
|
|
|
mode.AddSelectedObject(this);
|
|
|
|
|
2021-02-13 21:59:06 +00:00
|
|
|
selected = !selected;
|
2019-01-19 07:56:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-05 09:24:55 +00:00
|
|
|
if(!General.Map.UDMF) return; //mxd. Cannot change texture offsets in other map formats...
|
|
|
|
|
2012-11-27 21:12:20 +00:00
|
|
|
// Dragging UV?
|
|
|
|
if(uvdragging)
|
2009-07-07 11:29:56 +00:00
|
|
|
{
|
2012-11-27 21:12:20 +00:00
|
|
|
UpdateDragUV();
|
2009-07-07 11:29:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-27 21:12:20 +00:00
|
|
|
// Select button pressed?
|
|
|
|
if(General.Actions.CheckActionActive(General.ThisAssembly, "visualselect"))
|
|
|
|
{
|
|
|
|
// Check if tolerance is exceeded to start UV dragging
|
2020-05-21 12:20:02 +00:00
|
|
|
double deltaxy = General.Map.VisualCamera.AngleXY - dragstartanglexy;
|
|
|
|
double deltaz = General.Map.VisualCamera.AngleZ - dragstartanglez;
|
2012-11-27 21:12:20 +00:00
|
|
|
if((Math.Abs(deltaxy) + Math.Abs(deltaz)) > DRAG_ANGLE_TOLERANCE)
|
|
|
|
{
|
2013-12-05 09:24:55 +00:00
|
|
|
mode.PreAction(UndoGroup.TextureOffsetChange);
|
|
|
|
mode.CreateUndo("Change texture offsets");
|
|
|
|
|
|
|
|
// Start drag now
|
|
|
|
uvdragging = true;
|
|
|
|
mode.Renderer.ShowSelection = false;
|
|
|
|
mode.Renderer.ShowHighlight = false;
|
|
|
|
UpdateDragUV();
|
2012-11-27 21:12:20 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-07 11:29:56 +00:00
|
|
|
}
|
2009-05-01 20:31:17 +00:00
|
|
|
}
|
2013-07-31 12:38:47 +00:00
|
|
|
|
|
|
|
// Delete texture
|
2014-12-03 23:15:26 +00:00
|
|
|
public virtual void OnDelete()
|
|
|
|
{
|
2013-07-31 12:38:47 +00:00
|
|
|
// Remove texture
|
|
|
|
mode.CreateUndo("Delete texture");
|
|
|
|
mode.SetActionResult("Deleted a texture.");
|
|
|
|
SetTexture("-");
|
|
|
|
|
|
|
|
// Update
|
2015-02-07 17:52:39 +00:00
|
|
|
if(mode.VisualSectorExists(level.sector))
|
|
|
|
{
|
|
|
|
BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector);
|
2016-04-19 20:40:42 +00:00
|
|
|
vs.UpdateSectorGeometry(false);
|
2015-02-07 17:52:39 +00:00
|
|
|
}
|
2013-07-31 12:38:47 +00:00
|
|
|
}
|
2009-05-01 20:31:17 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Processing
|
2016-03-14 10:25:27 +00:00
|
|
|
public virtual void OnProcess(long deltatime)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
// If the texture was not loaded, but is loaded now, then re-setup geometry
|
2019-12-31 02:44:36 +00:00
|
|
|
if(setuponloadedtexture != lastsetuponloadedtexture)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2019-12-31 02:44:36 +00:00
|
|
|
if (setuponloadedtexture != 0)
|
|
|
|
{
|
|
|
|
ImageData t = General.Map.Data.GetFlatImage(setuponloadedtexture);
|
|
|
|
if (t != null && t.IsImageLoaded)
|
|
|
|
{
|
|
|
|
lastsetuponloadedtexture = setuponloadedtexture;
|
|
|
|
Setup();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lastsetuponloadedtexture = setuponloadedtexture;
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Flood-fill textures
|
|
|
|
public virtual void OnTextureFloodfill()
|
|
|
|
{
|
|
|
|
if(BuilderPlug.Me.CopiedFlat != null)
|
|
|
|
{
|
|
|
|
string oldtexture = GetTextureName();
|
|
|
|
string newtexture = BuilderPlug.Me.CopiedFlat;
|
|
|
|
if(newtexture != oldtexture)
|
|
|
|
{
|
|
|
|
// Get the texture
|
|
|
|
ImageData newtextureimage = General.Map.Data.GetFlatImage(newtexture);
|
|
|
|
if(newtextureimage != null)
|
|
|
|
{
|
|
|
|
bool fillceilings = (this is VisualCeiling);
|
|
|
|
|
|
|
|
if(fillceilings)
|
|
|
|
{
|
2009-05-03 19:22:32 +00:00
|
|
|
mode.CreateUndo("Flood-fill ceilings with " + newtexture);
|
2009-05-02 14:59:05 +00:00
|
|
|
mode.SetActionResult("Flood-filled ceilings with " + newtexture + ".");
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-05-03 19:22:32 +00:00
|
|
|
mode.CreateUndo("Flood-fill floors with " + newtexture);
|
2009-05-02 14:59:05 +00:00
|
|
|
mode.SetActionResult("Flood-filled floors with " + newtexture + ".");
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mode.Renderer.SetCrosshairBusy(true);
|
|
|
|
General.Interface.RedrawDisplay();
|
|
|
|
|
2009-06-12 09:44:38 +00:00
|
|
|
if(mode.IsSingleSelection)
|
|
|
|
{
|
|
|
|
// Clear all marks, this will align everything it can
|
|
|
|
General.Map.Map.ClearMarkedSectors(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Limit the alignment to selection only
|
|
|
|
General.Map.Map.ClearMarkedSectors(true);
|
|
|
|
List<Sector> sectors = mode.GetSelectedSectors();
|
|
|
|
foreach(Sector s in sectors) s.Marked = false;
|
|
|
|
}
|
2016-04-07 20:01:59 +00:00
|
|
|
|
|
|
|
//mxd. We potentially need to deal with 2 textures (because of long and short texture names)...
|
|
|
|
HashSet<long> oldtexturehashes = new HashSet<long> { Texture.LongName, Lump.MakeLongName(oldtexture) };
|
2009-06-12 09:44:38 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Do the fill
|
2016-04-07 20:01:59 +00:00
|
|
|
Tools.FloodfillFlats(this.Sector.Sector, fillceilings, oldtexturehashes, newtexture, false);
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Get the changed sectors
|
|
|
|
List<Sector> changes = General.Map.Map.GetMarkedSectors(true);
|
|
|
|
foreach(Sector s in changes)
|
|
|
|
{
|
|
|
|
// Update the visual sector
|
|
|
|
if(mode.VisualSectorExists(s))
|
|
|
|
{
|
2015-11-20 14:31:54 +00:00
|
|
|
BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(s);
|
|
|
|
if(fillceilings) vs.Ceiling.Setup();
|
|
|
|
else vs.Floor.Setup();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
General.Map.Data.UpdateUsedTextures();
|
|
|
|
mode.Renderer.SetCrosshairBusy(false);
|
|
|
|
mode.ShowTargetInfo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-04-26 12:32:51 +00:00
|
|
|
|
|
|
|
//mxd. Auto-align texture offsets
|
2014-12-03 23:15:26 +00:00
|
|
|
public virtual void OnTextureAlign(bool alignx, bool aligny)
|
|
|
|
{
|
2013-04-26 12:32:51 +00:00
|
|
|
if(!General.Map.UDMF) return;
|
|
|
|
|
|
|
|
//create undo
|
2014-02-21 14:42:12 +00:00
|
|
|
string rest;
|
2013-04-26 12:32:51 +00:00
|
|
|
if(alignx && aligny) rest = "(X and Y)";
|
|
|
|
else if(alignx) rest = "(X)";
|
|
|
|
else rest = "(Y)";
|
|
|
|
|
|
|
|
mode.CreateUndo("Auto-align textures " + rest);
|
|
|
|
mode.SetActionResult("Auto-aligned textures " + rest + ".");
|
|
|
|
|
|
|
|
//get selection
|
|
|
|
List<VisualGeometry> selection = mode.GetSelectedSurfaces();
|
|
|
|
|
|
|
|
//align textures on slopes
|
2014-12-03 23:15:26 +00:00
|
|
|
foreach(VisualGeometry vg in selection)
|
|
|
|
{
|
|
|
|
if(vg.GeometryType == VisualGeometryType.FLOOR || vg.GeometryType == VisualGeometryType.CEILING)
|
|
|
|
{
|
2019-12-27 17:49:12 +00:00
|
|
|
// Might be a 3D floor, so we might need another VisualGeometry
|
|
|
|
VisualGeometry realvg;
|
|
|
|
|
|
|
|
if (vg.GeometryType == VisualGeometryType.FLOOR)
|
|
|
|
{
|
|
|
|
if (((VisualFloor)vg).ExtraFloor == null)
|
|
|
|
realvg = vg;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Sector s = ((VisualFloor)vg).GetControlSector();
|
|
|
|
BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(s);
|
|
|
|
realvg = vs.Floor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (((VisualCeiling)vg).ExtraFloor == null)
|
|
|
|
realvg = vg;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Sector s = ((VisualCeiling)vg).GetControlSector();
|
|
|
|
BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(s);
|
|
|
|
realvg = vs.Ceiling;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(realvg.GeometryType == VisualGeometryType.FLOOR)
|
|
|
|
((VisualFloor)realvg).AlignTexture(alignx, aligny);
|
2013-04-26 12:32:51 +00:00
|
|
|
else
|
2019-12-27 17:49:12 +00:00
|
|
|
((VisualCeiling)realvg).AlignTexture(alignx, aligny);
|
2013-04-26 12:32:51 +00:00
|
|
|
|
2019-12-27 17:49:12 +00:00
|
|
|
realvg.Sector.Sector.UpdateNeeded = true;
|
|
|
|
realvg.Sector.Sector.UpdateCache();
|
2013-04-26 12:32:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Map is changed
|
|
|
|
General.Map.Map.Update();
|
|
|
|
General.Map.IsChanged = true;
|
|
|
|
General.Interface.RefreshInfo();
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Copy properties
|
|
|
|
public virtual void OnCopyProperties()
|
|
|
|
{
|
2012-11-27 21:12:20 +00:00
|
|
|
BuilderPlug.Me.CopiedSectorProps = new SectorProperties(level.sector);
|
2009-05-02 14:59:05 +00:00
|
|
|
mode.SetActionResult("Copied sector properties.");
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Paste properties
|
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
|
|
|
public virtual void OnPasteProperties(bool usecopysettings)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
if(BuilderPlug.Me.CopiedSectorProps != null)
|
|
|
|
{
|
2009-05-03 19:22:32 +00:00
|
|
|
mode.CreateUndo("Paste sector properties");
|
2009-05-02 14:59:05 +00:00
|
|
|
mode.SetActionResult("Pasted sector properties.");
|
Added, Visual mode, GLDEFS, GLOOME: subtractive glow is now supported.
Changed, Visual mode: changed thing fog calculation logic. Should be closer to GZDoom now.
Fixed, GLDEFS parser: "height" texture parameter was not treated as optional.
Fixed, text lump parsers: in some cases incorrect line number was displayed in error and warning messages.
Fixed, Visual mode: glow effect was not applied to sectors with 3 sidedefs.
Fixed, Visual mode: in some cases glow effect was not updated when replacing textures.
Fixed, general interface: "Full Brightness" button state was not updated during map loading.
Fixed, Drag Linedefs/Vertices/Sectors/Things modes: positions of line length labels were not updated while panning the view.
Cosmetic: added a bunch of new icons.
Cosmetic: changed Visual mode crosshair.
2015-08-27 20:46:49 +00:00
|
|
|
|
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
|
|
|
//mxd. Added "usecopysettings"
|
2016-10-11 12:58:35 +00:00
|
|
|
BuilderPlug.Me.CopiedSectorProps.Apply(new List<Sector> { level.sector }, usecopysettings);
|
Added, Visual mode, GLDEFS, GLOOME: subtractive glow is now supported.
Changed, Visual mode: changed thing fog calculation logic. Should be closer to GZDoom now.
Fixed, GLDEFS parser: "height" texture parameter was not treated as optional.
Fixed, text lump parsers: in some cases incorrect line number was displayed in error and warning messages.
Fixed, Visual mode: glow effect was not applied to sectors with 3 sidedefs.
Fixed, Visual mode: in some cases glow effect was not updated when replacing textures.
Fixed, general interface: "Full Brightness" button state was not updated during map loading.
Fixed, Drag Linedefs/Vertices/Sectors/Things modes: positions of line length labels were not updated while panning the view.
Cosmetic: added a bunch of new icons.
Cosmetic: changed Visual mode crosshair.
2015-08-27 20:46:49 +00:00
|
|
|
|
2012-11-27 21:12:20 +00:00
|
|
|
if(mode.VisualSectorExists(level.sector))
|
|
|
|
{
|
|
|
|
BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector);
|
|
|
|
vs.UpdateSectorGeometry(true);
|
|
|
|
}
|
Added, Visual mode, GLDEFS, GLOOME: subtractive glow is now supported.
Changed, Visual mode: changed thing fog calculation logic. Should be closer to GZDoom now.
Fixed, GLDEFS parser: "height" texture parameter was not treated as optional.
Fixed, text lump parsers: in some cases incorrect line number was displayed in error and warning messages.
Fixed, Visual mode: glow effect was not applied to sectors with 3 sidedefs.
Fixed, Visual mode: in some cases glow effect was not updated when replacing textures.
Fixed, general interface: "Full Brightness" button state was not updated during map loading.
Fixed, Drag Linedefs/Vertices/Sectors/Things modes: positions of line length labels were not updated while panning the view.
Cosmetic: added a bunch of new icons.
Cosmetic: changed Visual mode crosshair.
2015-08-27 20:46:49 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
mode.ShowTargetInfo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Select texture
|
|
|
|
public virtual void OnSelectTexture()
|
|
|
|
{
|
|
|
|
if(General.Interface.IsActiveWindow)
|
|
|
|
{
|
|
|
|
string oldtexture = GetTextureName();
|
|
|
|
string newtexture = General.Interface.BrowseFlat(General.Interface, oldtexture);
|
|
|
|
if(newtexture != oldtexture)
|
|
|
|
{
|
2009-05-03 19:22:32 +00:00
|
|
|
mode.ApplySelectTexture(newtexture, true);
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-05-03 19:22:32 +00:00
|
|
|
|
|
|
|
// Apply Texture
|
|
|
|
public virtual void ApplyTexture(string texture)
|
|
|
|
{
|
2016-03-08 20:41:06 +00:00
|
|
|
mode.CreateUndo("Change flat \"" + texture + "\"");
|
2009-05-03 19:22:32 +00:00
|
|
|
SetTexture(texture);
|
2016-04-19 20:40:42 +00:00
|
|
|
|
|
|
|
// Update
|
|
|
|
if(mode.VisualSectorExists(level.sector))
|
|
|
|
{
|
|
|
|
BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector);
|
|
|
|
vs.UpdateSectorGeometry(false);
|
|
|
|
}
|
2009-05-03 19:22:32 +00:00
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Copy texture
|
|
|
|
public virtual void OnCopyTexture()
|
|
|
|
{
|
2016-03-23 14:52:33 +00:00
|
|
|
//mxd. When UseLongTextureNames is enabled and the image filename is longer than 8 chars, use full name,
|
|
|
|
// otherwise use texture name as stored in Sector
|
|
|
|
string texturename = ((General.Map.Options.UseLongTextureNames && Texture != null && Texture.UsedInMap
|
|
|
|
&& Path.GetFileNameWithoutExtension(Texture.Name).Length > DataManager.CLASIC_IMAGE_NAME_LENGTH)
|
|
|
|
? Texture.Name : GetTextureName());
|
|
|
|
|
2015-02-19 13:00:19 +00:00
|
|
|
BuilderPlug.Me.CopiedFlat = texturename;
|
|
|
|
if(General.Map.Config.MixTexturesFlats) BuilderPlug.Me.CopiedTexture = texturename;
|
2016-03-08 20:41:06 +00:00
|
|
|
mode.SetActionResult("Copied flat \"" + texturename + "\".");
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public virtual void OnPasteTexture() { }
|
|
|
|
|
|
|
|
// Return texture name
|
|
|
|
public virtual string GetTextureName() { return ""; }
|
|
|
|
|
|
|
|
// Edit button released
|
|
|
|
public virtual void OnEditEnd()
|
|
|
|
{
|
2010-08-14 18:07:38 +00:00
|
|
|
if(General.Interface.IsActiveWindow)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2013-07-09 11:29:10 +00:00
|
|
|
//mxd
|
2010-08-14 18:07:38 +00:00
|
|
|
List<Sector> sectors = mode.GetSelectedSectors();
|
2016-01-16 12:46:44 +00:00
|
|
|
updatelist = new List<BaseVisualSector>();
|
2013-07-10 08:59:17 +00:00
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
foreach(Sector s in sectors)
|
|
|
|
{
|
|
|
|
if(mode.VisualSectorExists(s))
|
2016-01-16 12:46:44 +00:00
|
|
|
updatelist.Add((BaseVisualSector)mode.GetVisualSector(s));
|
2013-07-10 08:59:17 +00:00
|
|
|
}
|
|
|
|
|
2014-02-21 14:42:12 +00:00
|
|
|
General.Interface.OnEditFormValuesChanged += Interface_OnEditFormValuesChanged; //mxd
|
2013-07-19 15:30:58 +00:00
|
|
|
mode.StartRealtimeInterfaceUpdate(SelectionType.Sectors); //mxd
|
2015-04-14 11:33:57 +00:00
|
|
|
DialogResult result = General.Interface.ShowEditSectors(sectors);
|
2013-07-19 15:30:58 +00:00
|
|
|
mode.StopRealtimeInterfaceUpdate(SelectionType.Sectors); //mxd
|
|
|
|
General.Interface.OnEditFormValuesChanged -= Interface_OnEditFormValuesChanged; //mxd
|
2013-07-10 08:59:17 +00:00
|
|
|
|
2016-01-16 12:46:44 +00:00
|
|
|
updatelist.Clear(); //mxd
|
|
|
|
updatelist = null; //mxd
|
2015-04-14 11:33:57 +00:00
|
|
|
|
|
|
|
if(result == DialogResult.OK) mode.RebuildElementData(); //mxd
|
2013-07-09 11:29:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//mxd
|
2014-12-03 23:15:26 +00:00
|
|
|
private void Interface_OnEditFormValuesChanged(object sender, EventArgs e)
|
|
|
|
{
|
2016-01-16 12:46:44 +00:00
|
|
|
foreach(BaseVisualSector vs in updatelist) vs.UpdateSectorGeometry(true);
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sector height change
|
|
|
|
public virtual void OnChangeTargetHeight(int amount)
|
|
|
|
{
|
2009-05-03 19:22:32 +00:00
|
|
|
changed = true;
|
2012-11-27 21:12:20 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
ChangeHeight(amount);
|
|
|
|
|
|
|
|
// Rebuild sector
|
2012-11-27 21:12:20 +00:00
|
|
|
BaseVisualSector vs;
|
2014-12-03 23:15:26 +00:00
|
|
|
if(mode.VisualSectorExists(level.sector))
|
|
|
|
{
|
2012-11-27 21:12:20 +00:00
|
|
|
vs = (BaseVisualSector)mode.GetVisualSector(level.sector);
|
2014-12-03 23:15:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-19 20:40:42 +00:00
|
|
|
//mxd. Need this to apply changes to 3d-floor even if control sector doesn't exist as BaseVisualSector
|
2012-11-27 21:12:20 +00:00
|
|
|
vs = mode.CreateBaseVisualSector(level.sector);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(vs != null) vs.UpdateSectorGeometry(true);
|
2019-12-30 23:08:17 +00:00
|
|
|
|
|
|
|
// Visual slope handles need to be updated, too
|
|
|
|
if (General.Map.UDMF)
|
|
|
|
{
|
|
|
|
if (mode.AllSlopeHandles.ContainsKey(level.sector))
|
2021-01-30 21:45:08 +00:00
|
|
|
foreach (VisualSlope handle in mode.AllSlopeHandles[level.sector])
|
2019-12-30 23:08:17 +00:00
|
|
|
handle.Changed = true;
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
2019-12-30 23:08:17 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Sector brightness change
|
2023-09-19 15:53:27 +00:00
|
|
|
public virtual void OnChangeTargetBrightness(bool up, bool local)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2009-05-03 19:22:32 +00:00
|
|
|
mode.CreateUndo("Change sector brightness", UndoGroup.SectorBrightnessChange, Sector.Sector.FixedIndex);
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
if(up)
|
|
|
|
Sector.Sector.Brightness = General.Map.Config.BrightnessLevels.GetNextHigher(Sector.Sector.Brightness);
|
|
|
|
else
|
|
|
|
Sector.Sector.Brightness = General.Map.Config.BrightnessLevels.GetNextLower(Sector.Sector.Brightness);
|
|
|
|
|
2009-05-02 14:59:05 +00:00
|
|
|
mode.SetActionResult("Changed sector brightness to " + Sector.Sector.Brightness + ".");
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
Sector.Sector.UpdateCache();
|
|
|
|
|
|
|
|
// Rebuild sector
|
2009-05-09 13:41:26 +00:00
|
|
|
Sector.UpdateSectorGeometry(false);
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
2012-11-27 21:12:20 +00:00
|
|
|
|
|
|
|
// Texture offset change
|
2023-09-29 18:44:04 +00:00
|
|
|
public virtual bool OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection)
|
2012-11-27 21:12:20 +00:00
|
|
|
{
|
2023-09-29 18:44:04 +00:00
|
|
|
if(horizontal == 0 && vertical == 0) return false; //mxd
|
Visual mode, UDMF: added "Scale Texture Up (X)", "Scale Texture Down (X)", "Scale Texture Up (Y)", "Scale Texture Down (Y)" actions. Default keys are Num6, Num4, Num8, Num5.
Visual mode, UDMF: renamed "Rotate Thing Clockwise" and "Rotate Thing Counterclockwise" actions to "Rotate Clockwise" and "Rotate Counterclockwise". These actions can now be used to change rotation of floor/ceiling textures.
Visual mode, UDMF: "Reset Texture Offsets" action now also resets sidedef's scale and floor/ceiling's scale and rotation.
Visual mode, UDMF: control line's OffsetX and OffsetY were not taken into account when calculating texture offsets of 3d floors' sides.
Visual mode, UDMF: fixed a ton of bugs in Auto align functions.
Visual mode, UDMF: when using "Move Texture Left/Right/Up/Down by 1" actions texture offsets were not updated properly when texture's scale was < 1.0.
Visual mode, UDMF: OffsetX and OffsetY were not taken into account in "Fit Texture Width/Height" actions.
Dockers Panel: added Pin/Unpin button, which acts the same as "Preferences -> Interface -> Side panels -> Auto hide" checkbox.
Texture size labels can now be disabled by unchecking "Preferences -> Interface -> Show texture and flat sizes in browsers" checkbox.
Texture size labels now are not shown for unknown textures.
Most of texture size labels had incorrect bg color.
ZDoom_linedefs.cfg: action specials 223 and 224 had incorrect Arg0.
2013-06-24 14:21:13 +00:00
|
|
|
|
2012-11-27 21:12:20 +00:00
|
|
|
//mxd
|
2015-12-28 15:01:53 +00:00
|
|
|
if(!General.Map.UDMF)
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2014-02-27 10:08:31 +00:00
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Floor/ceiling texture offsets cannot be changed in this map format!");
|
2023-09-29 18:44:04 +00:00
|
|
|
return false;
|
2013-04-26 12:32:51 +00:00
|
|
|
}
|
2012-11-27 21:12:20 +00:00
|
|
|
|
2013-04-26 12:32:51 +00:00
|
|
|
if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
|
|
|
|
undoticket = mode.CreateUndo("Change texture offsets");
|
2012-11-27 21:12:20 +00:00
|
|
|
|
2013-04-26 12:32:51 +00:00
|
|
|
//mxd
|
2016-09-06 12:05:47 +00:00
|
|
|
changed = true;
|
|
|
|
|
|
|
|
//mxd
|
|
|
|
if(doSurfaceAngleCorrection)
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2013-04-26 12:32:51 +00:00
|
|
|
Point p = new Point(horizontal, vertical);
|
2020-05-21 12:20:02 +00:00
|
|
|
double angle = Angle2D.RadToDeg(General.Map.VisualCamera.AngleXY);
|
2014-12-03 23:15:26 +00:00
|
|
|
if(GeometryType == VisualGeometryType.CEILING)
|
2020-05-22 19:39:18 +00:00
|
|
|
angle += level.sector.Fields.GetValue("rotationceiling", 0.0);
|
2014-12-03 23:15:26 +00:00
|
|
|
else
|
2020-05-22 19:39:18 +00:00
|
|
|
angle += level.sector.Fields.GetValue("rotationfloor", 0.0);
|
2013-04-26 12:32:51 +00:00
|
|
|
|
|
|
|
angle = General.ClampAngle(angle);
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
if(angle > 315 || angle < 46)
|
|
|
|
{
|
|
|
|
//already correct
|
|
|
|
}
|
|
|
|
else if(angle > 225)
|
|
|
|
{
|
2013-04-26 12:32:51 +00:00
|
|
|
vertical = p.X;
|
|
|
|
horizontal = -p.Y;
|
2014-12-03 23:15:26 +00:00
|
|
|
}
|
|
|
|
else if(angle > 135)
|
|
|
|
{
|
2013-04-26 12:32:51 +00:00
|
|
|
horizontal = -p.X;
|
|
|
|
vertical = -p.Y;
|
2014-12-03 23:15:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-04-26 12:32:51 +00:00
|
|
|
vertical = -p.X;
|
|
|
|
horizontal = p.Y;
|
|
|
|
}
|
|
|
|
}
|
2012-11-27 21:12:20 +00:00
|
|
|
|
2013-04-26 12:32:51 +00:00
|
|
|
// Apply offsets
|
2016-09-06 12:05:47 +00:00
|
|
|
MoveTextureOffset(-horizontal, -vertical);
|
2013-04-26 12:32:51 +00:00
|
|
|
|
2016-09-06 12:05:47 +00:00
|
|
|
// Rebuild sector
|
|
|
|
BaseVisualSector vs;
|
|
|
|
if(mode.VisualSectorExists(level.sector))
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2016-09-06 12:05:47 +00:00
|
|
|
vs = (BaseVisualSector)mode.GetVisualSector(level.sector);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//mxd. Need this to apply changes to 3d-floor even if control sector doesn't exist as BaseVisualSector
|
|
|
|
vs = mode.CreateBaseVisualSector(level.sector);
|
Visual mode, UDMF: added "Scale Texture Up (X)", "Scale Texture Down (X)", "Scale Texture Up (Y)", "Scale Texture Down (Y)" actions. Default keys are Num6, Num4, Num8, Num5.
Visual mode, UDMF: renamed "Rotate Thing Clockwise" and "Rotate Thing Counterclockwise" actions to "Rotate Clockwise" and "Rotate Counterclockwise". These actions can now be used to change rotation of floor/ceiling textures.
Visual mode, UDMF: "Reset Texture Offsets" action now also resets sidedef's scale and floor/ceiling's scale and rotation.
Visual mode, UDMF: control line's OffsetX and OffsetY were not taken into account when calculating texture offsets of 3d floors' sides.
Visual mode, UDMF: fixed a ton of bugs in Auto align functions.
Visual mode, UDMF: when using "Move Texture Left/Right/Up/Down by 1" actions texture offsets were not updated properly when texture's scale was < 1.0.
Visual mode, UDMF: OffsetX and OffsetY were not taken into account in "Fit Texture Width/Height" actions.
Dockers Panel: added Pin/Unpin button, which acts the same as "Preferences -> Interface -> Side panels -> Auto hide" checkbox.
Texture size labels can now be disabled by unchecking "Preferences -> Interface -> Show texture and flat sizes in browsers" checkbox.
Texture size labels now are not shown for unknown textures.
Most of texture size labels had incorrect bg color.
ZDoom_linedefs.cfg: action specials 223 and 224 had incorrect Arg0.
2013-06-24 14:21:13 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 12:05:47 +00:00
|
|
|
if(vs != null) vs.UpdateSectorGeometry(false);
|
2023-09-29 18:44:04 +00:00
|
|
|
|
|
|
|
return true;
|
2012-11-27 21:12:20 +00:00
|
|
|
}
|
Visual mode, UDMF: added "Scale Texture Up (X)", "Scale Texture Down (X)", "Scale Texture Up (Y)", "Scale Texture Down (Y)" actions. Default keys are Num6, Num4, Num8, Num5.
Visual mode, UDMF: renamed "Rotate Thing Clockwise" and "Rotate Thing Counterclockwise" actions to "Rotate Clockwise" and "Rotate Counterclockwise". These actions can now be used to change rotation of floor/ceiling textures.
Visual mode, UDMF: "Reset Texture Offsets" action now also resets sidedef's scale and floor/ceiling's scale and rotation.
Visual mode, UDMF: control line's OffsetX and OffsetY were not taken into account when calculating texture offsets of 3d floors' sides.
Visual mode, UDMF: fixed a ton of bugs in Auto align functions.
Visual mode, UDMF: when using "Move Texture Left/Right/Up/Down by 1" actions texture offsets were not updated properly when texture's scale was < 1.0.
Visual mode, UDMF: OffsetX and OffsetY were not taken into account in "Fit Texture Width/Height" actions.
Dockers Panel: added Pin/Unpin button, which acts the same as "Preferences -> Interface -> Side panels -> Auto hide" checkbox.
Texture size labels can now be disabled by unchecking "Preferences -> Interface -> Show texture and flat sizes in browsers" checkbox.
Texture size labels now are not shown for unknown textures.
Most of texture size labels had incorrect bg color.
ZDoom_linedefs.cfg: action specials 223 and 224 had incorrect Arg0.
2013-06-24 14:21:13 +00:00
|
|
|
|
2015-11-20 14:31:54 +00:00
|
|
|
//mxd
|
2020-05-22 19:39:18 +00:00
|
|
|
public virtual void OnChangeTextureRotation(double angle)
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
Visual mode, UDMF: added "Scale Texture Up (X)", "Scale Texture Down (X)", "Scale Texture Up (Y)", "Scale Texture Down (Y)" actions. Default keys are Num6, Num4, Num8, Num5.
Visual mode, UDMF: renamed "Rotate Thing Clockwise" and "Rotate Thing Counterclockwise" actions to "Rotate Clockwise" and "Rotate Counterclockwise". These actions can now be used to change rotation of floor/ceiling textures.
Visual mode, UDMF: "Reset Texture Offsets" action now also resets sidedef's scale and floor/ceiling's scale and rotation.
Visual mode, UDMF: control line's OffsetX and OffsetY were not taken into account when calculating texture offsets of 3d floors' sides.
Visual mode, UDMF: fixed a ton of bugs in Auto align functions.
Visual mode, UDMF: when using "Move Texture Left/Right/Up/Down by 1" actions texture offsets were not updated properly when texture's scale was < 1.0.
Visual mode, UDMF: OffsetX and OffsetY were not taken into account in "Fit Texture Width/Height" actions.
Dockers Panel: added Pin/Unpin button, which acts the same as "Preferences -> Interface -> Side panels -> Auto hide" checkbox.
Texture size labels can now be disabled by unchecking "Preferences -> Interface -> Show texture and flat sizes in browsers" checkbox.
Texture size labels now are not shown for unknown textures.
Most of texture size labels had incorrect bg color.
ZDoom_linedefs.cfg: action specials 223 and 224 had incorrect Arg0.
2013-06-24 14:21:13 +00:00
|
|
|
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);
|
|
|
|
|
2016-09-06 12:05:47 +00:00
|
|
|
// Set new angle
|
Visual mode, UDMF: added "Scale Texture Up (X)", "Scale Texture Down (X)", "Scale Texture Up (Y)", "Scale Texture Down (Y)" actions. Default keys are Num6, Num4, Num8, Num5.
Visual mode, UDMF: renamed "Rotate Thing Clockwise" and "Rotate Thing Counterclockwise" actions to "Rotate Clockwise" and "Rotate Counterclockwise". These actions can now be used to change rotation of floor/ceiling textures.
Visual mode, UDMF: "Reset Texture Offsets" action now also resets sidedef's scale and floor/ceiling's scale and rotation.
Visual mode, UDMF: control line's OffsetX and OffsetY were not taken into account when calculating texture offsets of 3d floors' sides.
Visual mode, UDMF: fixed a ton of bugs in Auto align functions.
Visual mode, UDMF: when using "Move Texture Left/Right/Up/Down by 1" actions texture offsets were not updated properly when texture's scale was < 1.0.
Visual mode, UDMF: OffsetX and OffsetY were not taken into account in "Fit Texture Width/Height" actions.
Dockers Panel: added Pin/Unpin button, which acts the same as "Preferences -> Interface -> Side panels -> Auto hide" checkbox.
Texture size labels can now be disabled by unchecking "Preferences -> Interface -> Show texture and flat sizes in browsers" checkbox.
Texture size labels now are not shown for unknown textures.
Most of texture size labels had incorrect bg color.
ZDoom_linedefs.cfg: action specials 223 and 224 had incorrect Arg0.
2013-06-24 14:21:13 +00:00
|
|
|
Sector s = GetControlSector();
|
2013-08-10 11:28:51 +00:00
|
|
|
s.Fields.BeforeFieldsChange();
|
2020-05-22 20:30:32 +00:00
|
|
|
UniFields.SetFloat(s.Fields, key, angle, 0.0);
|
Visual mode, UDMF: added "Scale Texture Up (X)", "Scale Texture Down (X)", "Scale Texture Up (Y)", "Scale Texture Down (Y)" actions. Default keys are Num6, Num4, Num8, Num5.
Visual mode, UDMF: renamed "Rotate Thing Clockwise" and "Rotate Thing Counterclockwise" actions to "Rotate Clockwise" and "Rotate Counterclockwise". These actions can now be used to change rotation of floor/ceiling textures.
Visual mode, UDMF: "Reset Texture Offsets" action now also resets sidedef's scale and floor/ceiling's scale and rotation.
Visual mode, UDMF: control line's OffsetX and OffsetY were not taken into account when calculating texture offsets of 3d floors' sides.
Visual mode, UDMF: fixed a ton of bugs in Auto align functions.
Visual mode, UDMF: when using "Move Texture Left/Right/Up/Down by 1" actions texture offsets were not updated properly when texture's scale was < 1.0.
Visual mode, UDMF: OffsetX and OffsetY were not taken into account in "Fit Texture Width/Height" actions.
Dockers Panel: added Pin/Unpin button, which acts the same as "Preferences -> Interface -> Side panels -> Auto hide" checkbox.
Texture size labels can now be disabled by unchecking "Preferences -> Interface -> Show texture and flat sizes in browsers" checkbox.
Texture size labels now are not shown for unknown textures.
Most of texture size labels had incorrect bg color.
ZDoom_linedefs.cfg: action specials 223 and 224 had incorrect Arg0.
2013-06-24 14:21:13 +00:00
|
|
|
|
2016-09-06 12:05:47 +00:00
|
|
|
// Mark as changed
|
|
|
|
changed = true;
|
|
|
|
|
|
|
|
// Rebuild sector
|
|
|
|
BaseVisualSector vs;
|
|
|
|
if(mode.VisualSectorExists(level.sector))
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2016-09-06 12:05:47 +00:00
|
|
|
vs = (BaseVisualSector)mode.GetVisualSector(level.sector);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//mxd. Need this to apply changes to 3d-floor even if control sector doesn't exist as BaseVisualSector
|
|
|
|
vs = mode.CreateBaseVisualSector(level.sector);
|
Visual mode, UDMF: added "Scale Texture Up (X)", "Scale Texture Down (X)", "Scale Texture Up (Y)", "Scale Texture Down (Y)" actions. Default keys are Num6, Num4, Num8, Num5.
Visual mode, UDMF: renamed "Rotate Thing Clockwise" and "Rotate Thing Counterclockwise" actions to "Rotate Clockwise" and "Rotate Counterclockwise". These actions can now be used to change rotation of floor/ceiling textures.
Visual mode, UDMF: "Reset Texture Offsets" action now also resets sidedef's scale and floor/ceiling's scale and rotation.
Visual mode, UDMF: control line's OffsetX and OffsetY were not taken into account when calculating texture offsets of 3d floors' sides.
Visual mode, UDMF: fixed a ton of bugs in Auto align functions.
Visual mode, UDMF: when using "Move Texture Left/Right/Up/Down by 1" actions texture offsets were not updated properly when texture's scale was < 1.0.
Visual mode, UDMF: OffsetX and OffsetY were not taken into account in "Fit Texture Width/Height" actions.
Dockers Panel: added Pin/Unpin button, which acts the same as "Preferences -> Interface -> Side panels -> Auto hide" checkbox.
Texture size labels can now be disabled by unchecking "Preferences -> Interface -> Show texture and flat sizes in browsers" checkbox.
Texture size labels now are not shown for unknown textures.
Most of texture size labels had incorrect bg color.
ZDoom_linedefs.cfg: action specials 223 and 224 had incorrect Arg0.
2013-06-24 14:21:13 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 12:05:47 +00:00
|
|
|
if(vs != null) vs.UpdateSectorGeometry(false);
|
Visual mode, UDMF: added "Scale Texture Up (X)", "Scale Texture Down (X)", "Scale Texture Up (Y)", "Scale Texture Down (Y)" actions. Default keys are Num6, Num4, Num8, Num5.
Visual mode, UDMF: renamed "Rotate Thing Clockwise" and "Rotate Thing Counterclockwise" actions to "Rotate Clockwise" and "Rotate Counterclockwise". These actions can now be used to change rotation of floor/ceiling textures.
Visual mode, UDMF: "Reset Texture Offsets" action now also resets sidedef's scale and floor/ceiling's scale and rotation.
Visual mode, UDMF: control line's OffsetX and OffsetY were not taken into account when calculating texture offsets of 3d floors' sides.
Visual mode, UDMF: fixed a ton of bugs in Auto align functions.
Visual mode, UDMF: when using "Move Texture Left/Right/Up/Down by 1" actions texture offsets were not updated properly when texture's scale was < 1.0.
Visual mode, UDMF: OffsetX and OffsetY were not taken into account in "Fit Texture Width/Height" actions.
Dockers Panel: added Pin/Unpin button, which acts the same as "Preferences -> Interface -> Side panels -> Auto hide" checkbox.
Texture size labels can now be disabled by unchecking "Preferences -> Interface -> Show texture and flat sizes in browsers" checkbox.
Texture size labels now are not shown for unknown textures.
Most of texture size labels had incorrect bg color.
ZDoom_linedefs.cfg: action specials 223 and 224 had incorrect Arg0.
2013-06-24 14:21:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//mxd
|
2015-03-03 09:42:54 +00:00
|
|
|
public virtual void OnChangeScale(int incrementX, int incrementY)
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2015-03-03 09:42:54 +00:00
|
|
|
if(!General.Map.UDMF || !Texture.IsImageLoaded) return;
|
Visual mode, UDMF: added "Scale Texture Up (X)", "Scale Texture Down (X)", "Scale Texture Up (Y)", "Scale Texture Down (Y)" actions. Default keys are Num6, Num4, Num8, Num5.
Visual mode, UDMF: renamed "Rotate Thing Clockwise" and "Rotate Thing Counterclockwise" actions to "Rotate Clockwise" and "Rotate Counterclockwise". These actions can now be used to change rotation of floor/ceiling textures.
Visual mode, UDMF: "Reset Texture Offsets" action now also resets sidedef's scale and floor/ceiling's scale and rotation.
Visual mode, UDMF: control line's OffsetX and OffsetY were not taken into account when calculating texture offsets of 3d floors' sides.
Visual mode, UDMF: fixed a ton of bugs in Auto align functions.
Visual mode, UDMF: when using "Move Texture Left/Right/Up/Down by 1" actions texture offsets were not updated properly when texture's scale was < 1.0.
Visual mode, UDMF: OffsetX and OffsetY were not taken into account in "Fit Texture Width/Height" actions.
Dockers Panel: added Pin/Unpin button, which acts the same as "Preferences -> Interface -> Side panels -> Auto hide" checkbox.
Texture size labels can now be disabled by unchecking "Preferences -> Interface -> Show texture and flat sizes in browsers" checkbox.
Texture size labels now are not shown for unknown textures.
Most of texture size labels had incorrect bg color.
ZDoom_linedefs.cfg: action specials 223 and 224 had incorrect Arg0.
2013-06-24 14:21:13 +00:00
|
|
|
|
2016-09-06 12:05:47 +00:00
|
|
|
changed = true;
|
|
|
|
|
Visual mode, UDMF: added "Scale Texture Up (X)", "Scale Texture Down (X)", "Scale Texture Up (Y)", "Scale Texture Down (Y)" actions. Default keys are Num6, Num4, Num8, Num5.
Visual mode, UDMF: renamed "Rotate Thing Clockwise" and "Rotate Thing Counterclockwise" actions to "Rotate Clockwise" and "Rotate Counterclockwise". These actions can now be used to change rotation of floor/ceiling textures.
Visual mode, UDMF: "Reset Texture Offsets" action now also resets sidedef's scale and floor/ceiling's scale and rotation.
Visual mode, UDMF: control line's OffsetX and OffsetY were not taken into account when calculating texture offsets of 3d floors' sides.
Visual mode, UDMF: fixed a ton of bugs in Auto align functions.
Visual mode, UDMF: when using "Move Texture Left/Right/Up/Down by 1" actions texture offsets were not updated properly when texture's scale was < 1.0.
Visual mode, UDMF: OffsetX and OffsetY were not taken into account in "Fit Texture Width/Height" actions.
Dockers Panel: added Pin/Unpin button, which acts the same as "Preferences -> Interface -> Side panels -> Auto hide" checkbox.
Texture size labels can now be disabled by unchecking "Preferences -> Interface -> Show texture and flat sizes in browsers" checkbox.
Texture size labels now are not shown for unknown textures.
Most of texture size labels had incorrect bg color.
ZDoom_linedefs.cfg: action specials 223 and 224 had incorrect Arg0.
2013-06-24 14:21:13 +00:00
|
|
|
if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
|
|
|
|
undoticket = mode.CreateUndo("Change texture scale");
|
|
|
|
|
2016-09-06 12:05:47 +00:00
|
|
|
// Adjust to camera view
|
2020-05-21 12:20:02 +00:00
|
|
|
double angle = Angle2D.RadToDeg(General.Map.VisualCamera.AngleXY);
|
2020-05-22 19:39:18 +00:00
|
|
|
if(GeometryType == VisualGeometryType.CEILING) angle += level.sector.Fields.GetValue("rotationceiling", 0.0);
|
|
|
|
else angle += level.sector.Fields.GetValue("rotationfloor", 0.0);
|
2016-09-06 12:05:47 +00:00
|
|
|
angle = General.ClampAngle(angle);
|
|
|
|
|
|
|
|
if(angle > 315 || angle < 46)
|
|
|
|
{
|
|
|
|
ChangeTextureScale(incrementX, incrementY);
|
|
|
|
}
|
|
|
|
else if(angle > 225)
|
|
|
|
{
|
|
|
|
ChangeTextureScale(incrementY, incrementX);
|
|
|
|
}
|
|
|
|
else if(angle > 135)
|
|
|
|
{
|
|
|
|
ChangeTextureScale(incrementX, incrementY);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ChangeTextureScale(incrementY, incrementX);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Rebuild sector
|
|
|
|
BaseVisualSector vs;
|
|
|
|
if(mode.VisualSectorExists(level.sector))
|
|
|
|
{
|
|
|
|
vs = (BaseVisualSector)mode.GetVisualSector(level.sector);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//mxd. Need this to apply changes to 3d-floor even if control sector doesn't exist as BaseVisualSector
|
|
|
|
vs = mode.CreateBaseVisualSector(level.sector);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(vs != null) vs.UpdateSectorGeometry(false);
|
Visual mode, UDMF: added "Scale Texture Up (X)", "Scale Texture Down (X)", "Scale Texture Up (Y)", "Scale Texture Down (Y)" actions. Default keys are Num6, Num4, Num8, Num5.
Visual mode, UDMF: renamed "Rotate Thing Clockwise" and "Rotate Thing Counterclockwise" actions to "Rotate Clockwise" and "Rotate Counterclockwise". These actions can now be used to change rotation of floor/ceiling textures.
Visual mode, UDMF: "Reset Texture Offsets" action now also resets sidedef's scale and floor/ceiling's scale and rotation.
Visual mode, UDMF: control line's OffsetX and OffsetY were not taken into account when calculating texture offsets of 3d floors' sides.
Visual mode, UDMF: fixed a ton of bugs in Auto align functions.
Visual mode, UDMF: when using "Move Texture Left/Right/Up/Down by 1" actions texture offsets were not updated properly when texture's scale was < 1.0.
Visual mode, UDMF: OffsetX and OffsetY were not taken into account in "Fit Texture Width/Height" actions.
Dockers Panel: added Pin/Unpin button, which acts the same as "Preferences -> Interface -> Side panels -> Auto hide" checkbox.
Texture size labels can now be disabled by unchecking "Preferences -> Interface -> Show texture and flat sizes in browsers" checkbox.
Texture size labels now are not shown for unknown textures.
Most of texture size labels had incorrect bg color.
ZDoom_linedefs.cfg: action specials 223 and 224 had incorrect Arg0.
2013-06-24 14:21:13 +00:00
|
|
|
}
|
2019-01-19 07:56:13 +00:00
|
|
|
|
|
|
|
// biwa
|
|
|
|
public virtual void OnPaintSelectBegin()
|
|
|
|
{
|
|
|
|
mode.PaintSelectType = this.GetType().BaseType; // using BaseType so that both floor and ceiling can be selected in one go
|
|
|
|
|
|
|
|
// toggle selected state
|
2019-06-20 13:38:41 +00:00
|
|
|
if (General.Interface.ShiftState ^ BuilderPlug.Me.AdditivePaintSelect)
|
2019-01-19 07:56:13 +00:00
|
|
|
{
|
2021-01-30 23:12:07 +00:00
|
|
|
if (!selected)
|
|
|
|
{
|
|
|
|
selected = true;
|
|
|
|
mode.AddSelectedObject(this);
|
|
|
|
}
|
2019-01-19 07:56:13 +00:00
|
|
|
}
|
|
|
|
else if (General.Interface.CtrlState)
|
|
|
|
{
|
2021-01-30 23:12:07 +00:00
|
|
|
if (selected)
|
|
|
|
{
|
|
|
|
selected = false;
|
|
|
|
mode.RemoveSelectedObject(this);
|
|
|
|
}
|
2019-01-19 07:56:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-30 23:12:07 +00:00
|
|
|
if (selected)
|
2019-01-19 07:56:13 +00:00
|
|
|
mode.RemoveSelectedObject(this);
|
|
|
|
else
|
|
|
|
mode.AddSelectedObject(this);
|
|
|
|
|
2021-01-30 23:12:07 +00:00
|
|
|
selected = !selected;
|
2019-01-19 07:56:13 +00:00
|
|
|
}
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|