mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 14:31:50 +00:00
Visual Mode, UDMF: added "Fit Texture", "Fit Texture's Width" and "Fit Texture's Height" Actions.cfg
Visual Mode, UDMF, Visual Vertices: you can now press "Delete" key to clear z-offsets of selected vertices. Visual Mode, UDMF, Visual Vertices: the logic, which decides whether z-offset should be kept or removed, was not working properly. Visual Mode, UDMF: Auto-align Textures (Y) action was not working properly when targeted texture was lower wall without "Lower Unpegged" flag.
This commit is contained in:
parent
c3c7490231
commit
6b4d03baaa
12 changed files with 402 additions and 174 deletions
|
@ -743,6 +743,42 @@ visualautoaligny
|
|||
allowscroll = true;
|
||||
}
|
||||
|
||||
//mxd
|
||||
visualfittextures
|
||||
{
|
||||
title = "Fit Texture";
|
||||
category = "visual";
|
||||
description = "Scales texture to match size of selected surface.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
default = 393281; //Ctrl-Alt-A
|
||||
}
|
||||
|
||||
//mxd
|
||||
visualfittexturesx
|
||||
{
|
||||
title = "Fit Texture's Width";
|
||||
category = "visual";
|
||||
description = "Scales width of a texture to match width of selected surface.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
default = 262209; //Alt-A
|
||||
}
|
||||
|
||||
//mxd
|
||||
visualfittexturesy
|
||||
{
|
||||
title = "Fit Texture's Height";
|
||||
category = "visual";
|
||||
description = "Scales height of a texture to match height of selected surface.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
default = 327745; //Alt-Shift-A
|
||||
}
|
||||
|
||||
toggleupperunpegged
|
||||
{
|
||||
title = "Toggle Upper Unpegged";
|
||||
|
@ -849,7 +885,7 @@ toggleslope
|
|||
{
|
||||
title = "Toggle Slope";
|
||||
category = "visual";
|
||||
description = "Toggles Slope for selected surfaces. Select or highlight upper/lower walls to add a slope. Select or highlight floors or ceilings to remove slope.";
|
||||
description = "Toggles Slope for selected surfaces. Select or highlight upper/lower walls to add a slope. Select or highlight floors or ceilings to remove slope.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
|
|
|
@ -186,7 +186,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Unused
|
||||
public virtual void OnEditBegin() { }
|
||||
//public virtual void OnTextureAlign(bool alignx, bool aligny) { }
|
||||
public virtual void OnTextureFit(bool fitWidth, bool fitHeight) { } //mxd
|
||||
public virtual void OnToggleUpperUnpegged() { }
|
||||
public virtual void OnToggleLowerUnpegged() { }
|
||||
public virtual void OnResetTextureOffset() { }
|
||||
|
|
|
@ -499,6 +499,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
protected abstract void MoveTextureOffset(Point xy);
|
||||
protected abstract Point GetTextureOffset();
|
||||
public virtual void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) { } //mxd
|
||||
public virtual void OnTextureFit(bool fitWidth, bool fitHeight) { } //mxd
|
||||
|
||||
// Insert middle texture
|
||||
public virtual void OnInsert()
|
||||
|
|
|
@ -519,6 +519,55 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
PostAction();
|
||||
}
|
||||
|
||||
//mxd
|
||||
private void deleteSelectedThings() {
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, false, true, false);
|
||||
if(objs.Count == 0) return;
|
||||
|
||||
General.Map.UndoRedo.ClearAllRedos();
|
||||
string rest = objs.Count + " thing" + (objs.Count > 1 ? "s." : ".");
|
||||
//make undo
|
||||
General.Map.UndoRedo.CreateUndo("Delete " + rest);
|
||||
General.Interface.DisplayStatus(StatusType.Info, "Deleted " + rest);
|
||||
//clear selection
|
||||
ClearSelection();
|
||||
|
||||
PreActionNoChange();
|
||||
foreach(IVisualEventReceiver i in objs) i.OnDelete(); //are they deleted from BlockMap automatically?..
|
||||
|
||||
// Update cache values
|
||||
General.Map.IsChanged = true;
|
||||
General.Map.ThingsFilter.Update();
|
||||
|
||||
PostAction();
|
||||
}
|
||||
|
||||
//mxd
|
||||
private void deleteSelectedVertices() {
|
||||
if(!General.Map.UDMF) return;
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, false, false, true);
|
||||
if(objs.Count == 0) return;
|
||||
|
||||
General.Map.UndoRedo.ClearAllRedos();
|
||||
string description = "Reset height of " + objs.Count + (objs.Count > 1 ? " vertices." : " vertex.");
|
||||
//make undo
|
||||
General.Map.UndoRedo.CreateUndo(description);
|
||||
General.Interface.DisplayStatus(StatusType.Info, description);
|
||||
//clear selection
|
||||
ClearSelection();
|
||||
|
||||
PreActionNoChange();
|
||||
foreach(IVisualEventReceiver i in objs) {
|
||||
((BaseVisualVertex)i).Vertex.Fields.BeforeFieldsChange();
|
||||
i.OnDelete();
|
||||
}
|
||||
|
||||
// Update cache values
|
||||
//General.Map.IsChanged = true;
|
||||
|
||||
PostAction();
|
||||
}
|
||||
|
||||
//mxd
|
||||
private Vector3D[] translateCoordinates(Vector3D[] coordinates, Vector2D direction, bool absolutePosition) {
|
||||
if (coordinates.Length == 0) return null;
|
||||
|
@ -1305,7 +1354,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if((i is BaseVisualGeometrySector) && includesectors) objs.Add(i);
|
||||
else if((i is BaseVisualGeometrySidedef) && includesidedefs) objs.Add(i);
|
||||
else if((i is BaseVisualThing) && includethings) objs.Add(i);
|
||||
else if(i is BaseVisualVertex && includevertices) objs.Add(i);//mxd
|
||||
else if((i is BaseVisualVertex) && includevertices) objs.Add(i);//mxd
|
||||
}
|
||||
|
||||
// Add highlight?
|
||||
|
@ -1315,7 +1364,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if((i is BaseVisualGeometrySector) && includesectors) objs.Add(i);
|
||||
else if((i is BaseVisualGeometrySidedef) && includesidedefs) objs.Add(i);
|
||||
else if((i is BaseVisualThing) && includethings) objs.Add(i);
|
||||
else if(i is BaseVisualVertex && includevertices) objs.Add(i);//mxd
|
||||
else if((i is BaseVisualVertex) && includevertices) objs.Add(i);//mxd
|
||||
}
|
||||
|
||||
return objs;
|
||||
|
@ -2147,6 +2196,33 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
PostAction();
|
||||
}
|
||||
|
||||
//mxd
|
||||
[BeginAction("visualfittextures")]
|
||||
public void TextureFit() {
|
||||
PreAction(UndoGroup.None);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, true, false, false);
|
||||
foreach(IVisualEventReceiver i in objs) i.OnTextureFit(true, true);
|
||||
PostAction();
|
||||
}
|
||||
|
||||
//mxd
|
||||
[BeginAction("visualfittexturesx")]
|
||||
public void TextureFitX() {
|
||||
PreAction(UndoGroup.None);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, true, false, false);
|
||||
foreach(IVisualEventReceiver i in objs) i.OnTextureFit(true, false);
|
||||
PostAction();
|
||||
}
|
||||
|
||||
//mxd
|
||||
[BeginAction("visualfittexturesy")]
|
||||
public void TextureFitY() {
|
||||
PreAction(UndoGroup.None);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, true, false, false);
|
||||
foreach(IVisualEventReceiver i in objs) i.OnTextureFit(false, true);
|
||||
PostAction();
|
||||
}
|
||||
|
||||
[BeginAction("toggleupperunpegged")]
|
||||
public void ToggleUpperUnpegged()
|
||||
{
|
||||
|
@ -2272,29 +2348,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
PostAction();
|
||||
}
|
||||
|
||||
//mxd. now we can delete things in Visual modes
|
||||
//mxd
|
||||
[BeginAction("deleteitem", BaseAction = true)]
|
||||
public void DeleteSelectedThings()
|
||||
public void DeleteSelectedObjects()
|
||||
{
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, false, true, false);
|
||||
if (objs.Count == 0) return;
|
||||
|
||||
General.Map.UndoRedo.ClearAllRedos();
|
||||
string rest = objs.Count + " thing" + (objs.Count > 1 ? "s." : ".");
|
||||
//make undo
|
||||
General.Map.UndoRedo.CreateUndo("Delete " + rest);
|
||||
General.Interface.DisplayStatus(StatusType.Info, "Deleted " + rest);
|
||||
//clear selection
|
||||
ClearSelection();
|
||||
|
||||
PreActionNoChange();
|
||||
foreach (IVisualEventReceiver i in objs) i.OnDelete(); //are they deleted from BlockMap automatically?..
|
||||
|
||||
// Update cache values
|
||||
General.Map.IsChanged = true;
|
||||
General.Map.ThingsFilter.Update();
|
||||
|
||||
PostAction();
|
||||
deleteSelectedThings();
|
||||
deleteSelectedVertices();
|
||||
}
|
||||
|
||||
//mxd
|
||||
|
@ -2318,7 +2377,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
[BeginAction("cutselection", BaseAction = true)]
|
||||
public void CutSelection() {
|
||||
CopySelection();
|
||||
DeleteSelectedThings();
|
||||
deleteSelectedThings();
|
||||
}
|
||||
|
||||
//mxd. We'll just use currently selected objects
|
||||
|
@ -2498,8 +2557,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(vg.Sidedef.Line.Action == 0 || (vg.Sidedef.Line.Action == 181 && vg.Sidedef.Line.Args[0] == 0)) {
|
||||
//check if the sector already has floor slopes
|
||||
foreach(Sidedef side in vg.Sidedef.Sector.Sidedefs) {
|
||||
if(side == vg.Sidedef || side.Line.Action != 181)
|
||||
continue;
|
||||
if(side == vg.Sidedef || side.Line.Action != 181) continue;
|
||||
|
||||
int arg = (side == side.Line.Front ? 1 : 2);
|
||||
|
||||
|
@ -2521,8 +2579,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(vg.Sidedef.Line.Action == 0 || (vg.Sidedef.Line.Action == 181 && vg.Sidedef.Line.Args[1] == 0)) {
|
||||
//check if the sector already has ceiling slopes
|
||||
foreach(Sidedef side in vg.Sidedef.Sector.Sidedefs) {
|
||||
if(side == vg.Sidedef || side.Line.Action != 181)
|
||||
continue;
|
||||
if(side == vg.Sidedef || side.Line.Action != 181) continue;
|
||||
|
||||
int arg = (side == side.Line.Front ? 1 : 2);
|
||||
|
||||
|
@ -2543,8 +2600,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
} else if(vg.GeometryType == VisualGeometryType.CEILING) {
|
||||
//check if the sector has ceiling slopes
|
||||
foreach(Sidedef side in vg.Sector.Sector.Sidedefs) {
|
||||
if(side.Line.Action != 181)
|
||||
continue;
|
||||
if(side.Line.Action != 181) continue;
|
||||
|
||||
int arg = (side == side.Line.Front ? 1 : 2);
|
||||
|
||||
|
@ -2561,8 +2617,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
} else if(vg.GeometryType == VisualGeometryType.FLOOR) {
|
||||
//check if the sector has floor slopes
|
||||
foreach(Sidedef side in vg.Sector.Sector.Sidedefs) {
|
||||
if(side.Line.Action != 181)
|
||||
continue;
|
||||
if(side.Line.Action != 181) continue;
|
||||
|
||||
int arg = (side == side.Line.Front ? 1 : 2);
|
||||
|
||||
|
@ -2579,8 +2634,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
//add to update list
|
||||
if(update)
|
||||
toUpdate.Add(vg.Sector as BaseVisualSector);
|
||||
if(update) toUpdate.Add(vg.Sector as BaseVisualSector);
|
||||
}
|
||||
|
||||
//update changed geometry
|
||||
|
@ -2739,13 +2793,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
float ystartalign = start.OffsetY;
|
||||
switch(part) {
|
||||
case SidedefPart.Upper:
|
||||
ystartalign += getTopOffsetY(start, start.Fields.GetValue("offsety_top", 0.0f), false);//mxd
|
||||
ystartalign += GetTopOffsetY(start, start.Fields.GetValue("offsety_top", 0.0f), false);//mxd
|
||||
break;
|
||||
case SidedefPart.Middle:
|
||||
ystartalign += getMiddleOffsetY(start, start.Fields.GetValue("offsety_mid", 0.0f), false);//mxd
|
||||
ystartalign += GetMiddleOffsetY(start, start.Fields.GetValue("offsety_mid", 0.0f), false);//mxd
|
||||
break;
|
||||
case SidedefPart.Lower:
|
||||
ystartalign += getBottomOffsetY(start, start.Fields.GetValue("offsety_bottom", 0.0f), false);//mxd
|
||||
ystartalign += GetBottomOffsetY(start, start.Fields.GetValue("offsety_bottom", 0.0f), false);//mxd
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2855,16 +2909,16 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
j.sidedef.Fields.BeforeFieldsChange();
|
||||
if(matchtop)
|
||||
j.sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, getTopOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd
|
||||
j.sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, GetTopOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd
|
||||
if(matchbottom)
|
||||
j.sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, getBottomOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd
|
||||
j.sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, GetBottomOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd
|
||||
if(matchmid) {
|
||||
//mxd. Side is part of a 3D floor?
|
||||
if(j.sidedef.Index != j.controlSide.Index) {
|
||||
offset = ((float)(start.Sector.CeilHeight - j.controlSide.Sector.CeilHeight) / scaley) + ystartalign;
|
||||
offset -= j.sidedef.OffsetY;
|
||||
}
|
||||
j.sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, getMiddleOffsetY(j.sidedef, offset, true) % (float)texture.Height);//mxd
|
||||
j.sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, GetMiddleOffsetY(j.sidedef, offset, true) % (float)texture.Height);//mxd
|
||||
}
|
||||
}
|
||||
forwardoffset = j.offsetx + (int)Math.Round(j.sidedef.Line.Length / scalex * offsetscalex);
|
||||
|
@ -2901,16 +2955,16 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
j.sidedef.Fields.BeforeFieldsChange();
|
||||
if(matchtop)
|
||||
j.sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, getTopOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd
|
||||
j.sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, GetTopOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd
|
||||
if(matchbottom)
|
||||
j.sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, getBottomOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd
|
||||
j.sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, GetBottomOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd
|
||||
if(matchmid) {
|
||||
//mxd. Side is part of a 3D floor?
|
||||
if(j.sidedef.Index != j.controlSide.Index) {
|
||||
offset = ((float)(start.Sector.CeilHeight - j.controlSide.Sector.CeilHeight) / scaley) + ystartalign;
|
||||
offset -= j.sidedef.OffsetY;
|
||||
}
|
||||
j.sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, getMiddleOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd
|
||||
j.sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, GetMiddleOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd
|
||||
}
|
||||
}
|
||||
forwardoffset = j.offsetx;
|
||||
|
@ -2970,7 +3024,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
//mxd. This converts offsetY from/to "normalized" offset for given upper wall
|
||||
private float getTopOffsetY(Sidedef side, float offset, bool fromNormalized) {
|
||||
internal float GetTopOffsetY(Sidedef side, float offset, bool fromNormalized) {
|
||||
if(side.Line.IsFlagSet(General.Map.Config.UpperUnpeggedFlag) || side.Other == null || side.Other.Sector == null)
|
||||
return offset;
|
||||
|
||||
|
@ -2983,7 +3037,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
//mxd. This converts offsetY from/to "normalized" offset for given middle wall
|
||||
private float getMiddleOffsetY(Sidedef side, float offset, bool fromNormalized) {
|
||||
internal float GetMiddleOffsetY(Sidedef side, float offset, bool fromNormalized) {
|
||||
if(!side.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag) || side.Sector == null)
|
||||
return offset;
|
||||
|
||||
|
@ -2996,13 +3050,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
//mxd. This converts offsetY from/to "normalized" offset for given lower wall
|
||||
private float getBottomOffsetY(Sidedef side, float offset, bool fromNormalized) {
|
||||
internal float GetBottomOffsetY(Sidedef side, float offset, bool fromNormalized) {
|
||||
if(side.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag) || side.Other == null || side.Other.Sector == null)
|
||||
return offset;
|
||||
|
||||
//if we don't have LowerUnpegged flag, normalize offset
|
||||
//normalize offset
|
||||
float scale = side.Fields.GetValue("scaley_bottom", 1.0f);
|
||||
float surfaceHeight = (side.Sector.CeilHeight - (side.Other.Sector.FloorHeight - side.Sector.FloorHeight)) * scale;
|
||||
float surfaceHeight = (side.Sector.CeilHeight - side.Other.Sector.FloorHeight) * scale;
|
||||
|
||||
if(fromNormalized) return (float)Math.Round(offset + surfaceHeight);
|
||||
return (float)Math.Round(offset - surfaceHeight);
|
||||
|
|
|
@ -451,7 +451,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public virtual void OnProcess(float deltatime) { }
|
||||
public virtual void OnTextureFloodfill() { }
|
||||
public virtual void OnInsert() { }
|
||||
//public virtual void OnDelete() { }
|
||||
public virtual void OnTextureFit(bool fitWidth, bool fitHeight) { } //mxd
|
||||
public virtual void ApplyTexture(string texture) { }
|
||||
public virtual void ApplyUpperUnpegged(bool set) { }
|
||||
public virtual void ApplyLowerUnpegged(bool set) { }
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private float cageradius2;
|
||||
private Vector3D boxp1;
|
||||
private Vector3D boxp2;
|
||||
private int storedHeight = int.MinValue;
|
||||
|
||||
// Undo/redo
|
||||
private int undoticket;
|
||||
|
@ -45,14 +44,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(vertex.Fields.ContainsKey(key)) {
|
||||
z = vertex.Fields.GetValue(key, 0f);
|
||||
|
||||
if(z == height) { //don't create garbage data!
|
||||
if(z == height && neighboursHaveSameHeight(height)) //don't create garbage data!
|
||||
vertex.Fields.Remove(key);
|
||||
storedHeight = height;
|
||||
}
|
||||
} else if(storedHeight != int.MinValue) {
|
||||
z = storedHeight;
|
||||
vertex.Fields.Add(key, new UniValue(UniversalType.Float, z));
|
||||
storedHeight = int.MinValue;
|
||||
} else {
|
||||
z = height;
|
||||
}
|
||||
|
@ -67,6 +60,21 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
changed = false;
|
||||
}
|
||||
|
||||
private bool neighboursHaveSameHeight(int height) {
|
||||
if(ceilingVertex) {
|
||||
foreach(Linedef line in vertex.Linedefs) {
|
||||
if(line.Front != null && line.Front.Sector != null && line.Front.Sector.Sidedefs.Count == 3 && line.Front.Sector.CeilHeight != height) return false;
|
||||
if(line.Back != null && line.Back.Sector != null && line.Back.Sector.Sidedefs.Count == 3 && line.Back.Sector.CeilHeight != height) return false;
|
||||
}
|
||||
} else {
|
||||
foreach(Linedef line in vertex.Linedefs) {
|
||||
if(line.Front != null && line.Front.Sector != null && line.Front.Sector.Sidedefs.Count == 3 && line.Front.Sector.FloorHeight != height) return false;
|
||||
if(line.Back != null && line.Back.Sector != null && line.Back.Sector.Sidedefs.Count == 3 && line.Back.Sector.FloorHeight != height) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateGeometry(Vertex v) {
|
||||
VertexData vd = mode.GetVertexData(v);
|
||||
foreach(KeyValuePair<Sector, bool> s in vd.UpdateAlso) {
|
||||
|
@ -211,13 +219,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public virtual void OnCopyTextureOffsets() { }
|
||||
public virtual void OnPasteTextureOffsets() { }
|
||||
public virtual void OnTextureAlign(bool alignx, bool aligny) { }
|
||||
public virtual void OnTextureFit(bool fitWidth, bool fitHeight) { } //mxd
|
||||
public virtual void OnToggleUpperUnpegged() { }
|
||||
public virtual void OnToggleLowerUnpegged() { }
|
||||
public virtual void OnResetTextureOffset() { }
|
||||
public virtual void OnProcess(float deltatime) { }
|
||||
public virtual void OnTextureFloodfill() { }
|
||||
public virtual void OnInsert() { }
|
||||
public virtual void OnDelete() { }
|
||||
public virtual void ApplyTexture(string texture) { }
|
||||
public virtual void ApplyUpperUnpegged(bool set) { }
|
||||
public virtual void ApplyLowerUnpegged(bool set) { }
|
||||
|
@ -259,6 +267,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
}
|
||||
|
||||
//Delete key pressed - remove zoffset field
|
||||
public virtual void OnDelete() {
|
||||
string key = ceilingVertex ? "zceiling" : "zfloor";
|
||||
|
||||
if(vertex.Fields.ContainsKey(key)) {
|
||||
vertex.Fields.Remove(key);
|
||||
|
||||
//update affected sectors
|
||||
updateGeometry(vertex);
|
||||
changed = true;
|
||||
mode.ShowTargetInfo();
|
||||
}
|
||||
}
|
||||
|
||||
// Edit button released
|
||||
public virtual void OnEditEnd() {
|
||||
if(General.Interface.IsActiveWindow) {
|
||||
|
@ -304,7 +326,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Update what must be updated
|
||||
updateGeometry(vertex);
|
||||
this.Changed = true;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -42,6 +42,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
void OnCopyProperties();
|
||||
void OnPasteProperties();
|
||||
void OnTextureAlign(bool alignx, bool aligny);
|
||||
void OnTextureFit(bool fitWidth, bool fitHeight); //mxd
|
||||
void OnTextureFloodfill();
|
||||
void OnToggleUpperUnpegged();
|
||||
void OnToggleLowerUnpegged();
|
||||
|
|
|
@ -25,119 +25,35 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// This doesn't do jack shit.
|
||||
internal class NullVisualEventReceiver : IVisualEventReceiver
|
||||
{
|
||||
public NullVisualEventReceiver()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnSelectBegin()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnSelectEnd()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnEditBegin()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnEditEnd()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnChangeTargetHeight(int amount)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnChangeTargetBrightness(bool up)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnResetTextureOffset()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnSelectTexture()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnCopyTexture()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnPasteTexture()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnCopyTextureOffsets()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnPasteTextureOffsets()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnCopyProperties()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnPasteProperties()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnTextureAlign(bool alignx, bool aligny)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnTextureFloodfill()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnToggleUpperUnpegged()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnToggleLowerUnpegged()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnProcess(float deltatime)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnInsert()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnDelete()
|
||||
{
|
||||
}
|
||||
|
||||
public void ApplyTexture(string texture)
|
||||
{
|
||||
}
|
||||
|
||||
public void ApplyUpperUnpegged(bool set)
|
||||
{
|
||||
}
|
||||
|
||||
public void ApplyLowerUnpegged(bool set)
|
||||
{
|
||||
}
|
||||
|
||||
public string GetTextureName()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public NullVisualEventReceiver() { }
|
||||
public void OnSelectBegin() { }
|
||||
public void OnSelectEnd() { }
|
||||
public void OnEditBegin() { }
|
||||
public void OnEditEnd() { }
|
||||
public void OnMouseMove(MouseEventArgs e) { }
|
||||
public void OnChangeTargetHeight(int amount) { }
|
||||
public void OnChangeTargetBrightness(bool up) { }
|
||||
public void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { }
|
||||
public void OnResetTextureOffset() { }
|
||||
public void OnSelectTexture() { }
|
||||
public void OnCopyTexture() { }
|
||||
public void OnPasteTexture() { }
|
||||
public void OnCopyTextureOffsets() { }
|
||||
public void OnPasteTextureOffsets() { }
|
||||
public void OnCopyProperties() { }
|
||||
public void OnPasteProperties() { }
|
||||
public void OnTextureAlign(bool alignx, bool aligny) { }
|
||||
public void OnTextureFit(bool fitWidth, bool fitHeight) { } //mxd
|
||||
public void OnTextureFloodfill() { }
|
||||
public void OnToggleUpperUnpegged() { }
|
||||
public void OnToggleLowerUnpegged() { }
|
||||
public void OnProcess(float deltatime) { }
|
||||
public void OnInsert() { }
|
||||
public void OnDelete() { }
|
||||
public void ApplyTexture(string texture) { }
|
||||
public void ApplyUpperUnpegged(bool set) { }
|
||||
public void ApplyLowerUnpegged(bool set) { }
|
||||
public string GetTextureName() { return ""; }
|
||||
public void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) { } //mxd
|
||||
public bool IsSelected() { return false; } //mxd
|
||||
}
|
||||
|
|
|
@ -274,6 +274,57 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
Sector.UpdateSectorGeometry(false);
|
||||
}
|
||||
|
||||
//mxd
|
||||
public override void OnTextureFit(bool fitWidth, bool fitHeight) {
|
||||
if(!General.Map.UDMF) return;
|
||||
if(!Sidedef.LowRequired() || string.IsNullOrEmpty(Sidedef.LowTexture) || Sidedef.LowTexture == "-" || !Texture.IsImageLoaded) return;
|
||||
|
||||
string s;
|
||||
if(fitWidth && fitHeight) s = "width and height";
|
||||
else if(fitWidth) s = "width";
|
||||
else s = "height";
|
||||
|
||||
//create undo
|
||||
mode.CreateUndo("Fit texture (" + s + ")", UndoGroup.TextureOffsetChange, Sector.Sector.FixedIndex);
|
||||
Sidedef.Fields.BeforeFieldsChange();
|
||||
|
||||
if(fitWidth) {
|
||||
float scaleX = Texture.Width / Sidedef.Line.Length;
|
||||
|
||||
if(scaleX == 1.0f) {
|
||||
if(Sidedef.Fields.GetValue("scalex_bottom", 1.0f) != 1.0f)
|
||||
Sidedef.Fields.Remove("scalex_bottom");
|
||||
} else {
|
||||
Sidedef.Fields["scalex_bottom"] = new UniValue(UniversalType.Float, scaleX);
|
||||
}
|
||||
|
||||
if(Sidedef.Fields.ContainsKey("offsetx_bottom"))
|
||||
Sidedef.Fields.Remove("offsetx_bottom");
|
||||
}
|
||||
|
||||
if(fitHeight && Sidedef.Sector != null && Sidedef.Other.Sector != null) {
|
||||
float scaleY = (float)Texture.Height / (Sidedef.Other.Sector.FloorHeight - Sidedef.Sector.FloorHeight);
|
||||
|
||||
if(scaleY == 1.0f) {
|
||||
if(Sidedef.Fields.GetValue("scaley_bottom", 1.0f) != 1.0f)
|
||||
Sidedef.Fields.Remove("scaley_bottom");
|
||||
} else {
|
||||
Sidedef.Fields["scaley_bottom"] = new UniValue(UniversalType.Float, scaleY);
|
||||
}
|
||||
|
||||
float offsetY = 0f;
|
||||
if(Sidedef.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag))
|
||||
offsetY = -(float)Math.Round((Sidedef.Sector.CeilHeight - Sidedef.Other.Sector.FloorHeight) * scaleY) % Texture.Height;
|
||||
|
||||
if(offsetY == 0f && Sidedef.Fields.ContainsKey("offsety_bottom"))
|
||||
Sidedef.Fields.Remove("offsety_bottom");
|
||||
else
|
||||
Sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, offsetY);
|
||||
}
|
||||
|
||||
Setup();
|
||||
}
|
||||
|
||||
//mxd
|
||||
public override void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) {
|
||||
selectNeighbours(Sidedef.LowTexture, select, withSameTexture, withSameHeight);
|
||||
|
|
|
@ -319,6 +319,55 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
Sector.UpdateSectorGeometry(false);
|
||||
}
|
||||
|
||||
//mxd
|
||||
public override void OnTextureFit(bool fitWidth, bool fitHeight) {
|
||||
if(!General.Map.UDMF) return;
|
||||
if(string.IsNullOrEmpty(Sidedef.MiddleTexture) || Sidedef.MiddleTexture == "-" || !Texture.IsImageLoaded) return;
|
||||
|
||||
string s;
|
||||
if(fitWidth && fitHeight) s = "width and height";
|
||||
else if(fitWidth) s = "width";
|
||||
else s = "height";
|
||||
|
||||
//create undo
|
||||
mode.CreateUndo("Fit texture (" + s + ")", UndoGroup.TextureOffsetChange, Sector.Sector.FixedIndex);
|
||||
Sidedef.Fields.BeforeFieldsChange();
|
||||
|
||||
if(fitWidth) {
|
||||
float scaleX = Texture.Width / Sidedef.Line.Length;
|
||||
|
||||
if(scaleX == 1.0f) {
|
||||
if(Sidedef.Fields.GetValue("scalex_mid", 1.0f) != 1.0f)
|
||||
Sidedef.Fields.Remove("scalex_mid");
|
||||
} else {
|
||||
Sidedef.Fields["scalex_mid"] = new UniValue(UniversalType.Float, scaleX);
|
||||
}
|
||||
|
||||
if(Sidedef.Fields.ContainsKey("offsetx_mid"))
|
||||
Sidedef.Fields.Remove("offsetx_mid");
|
||||
}
|
||||
|
||||
if(fitHeight && Sidedef.Sector != null) {
|
||||
float scaleY = (float)Texture.Height / (Sidedef.Sector.CeilHeight - Sidedef.Sector.FloorHeight);
|
||||
|
||||
if(scaleY == 1.0f) {
|
||||
if(Sidedef.Fields.GetValue("scaley_mid", 1.0f) != 1.0f)
|
||||
Sidedef.Fields.Remove("scaley_mid");
|
||||
} else {
|
||||
Sidedef.Fields["scaley_mid"] = new UniValue(UniversalType.Float, scaleY);
|
||||
}
|
||||
|
||||
float offsetY = mode.GetMiddleOffsetY(Sidedef, 0f, true) % Texture.Height;
|
||||
|
||||
if(offsetY == 0f && Sidedef.Fields.ContainsKey("offsety_mid"))
|
||||
Sidedef.Fields.Remove("offsety_mid");
|
||||
else
|
||||
Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, offsetY);
|
||||
}
|
||||
|
||||
Setup();
|
||||
}
|
||||
|
||||
//mxd
|
||||
public override void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) {
|
||||
selectNeighbours(Sidedef.MiddleTexture, select, withSameTexture, withSameHeight);
|
||||
|
|
|
@ -270,6 +270,55 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
Sector.UpdateSectorGeometry(false);
|
||||
}
|
||||
|
||||
//mxd
|
||||
public override void OnTextureFit(bool fitWidth, bool fitHeight) {
|
||||
if(!General.Map.UDMF) return;
|
||||
if(string.IsNullOrEmpty(Sidedef.MiddleTexture) || Sidedef.MiddleTexture == "-" || !Texture.IsImageLoaded) return;
|
||||
|
||||
string s;
|
||||
if(fitWidth && fitHeight) s = "width and height";
|
||||
else if(fitWidth) s = "width";
|
||||
else s = "height";
|
||||
|
||||
//create undo
|
||||
mode.CreateUndo("Fit texture (" + s + ")", UndoGroup.TextureOffsetChange, Sector.Sector.FixedIndex);
|
||||
Sidedef.Fields.BeforeFieldsChange();
|
||||
|
||||
if(fitWidth) {
|
||||
float scaleX = Texture.Width / Sidedef.Line.Length;
|
||||
|
||||
if(scaleX == 1.0f) {
|
||||
if(Sidedef.Fields.GetValue("scalex_mid", 1.0f) != 1.0f)
|
||||
Sidedef.Fields.Remove("scalex_mid");
|
||||
} else {
|
||||
Sidedef.Fields["scalex_mid"] = new UniValue(UniversalType.Float, scaleX);
|
||||
}
|
||||
|
||||
if(Sidedef.Fields.ContainsKey("offsetx_mid"))
|
||||
Sidedef.Fields.Remove("offsetx_mid");
|
||||
}
|
||||
|
||||
if(fitHeight && Sidedef.Sector != null){
|
||||
float scaleY = (float)Texture.Height / (Sidedef.Sector.CeilHeight - Sidedef.Sector.FloorHeight);
|
||||
|
||||
if(scaleY == 1.0f) {
|
||||
if(Sidedef.Fields.GetValue("scaley_mid", 1.0f) != 1.0f)
|
||||
Sidedef.Fields.Remove("scaley_mid");
|
||||
} else {
|
||||
Sidedef.Fields["scaley_mid"] = new UniValue(UniversalType.Float, scaleY);
|
||||
}
|
||||
|
||||
float offsetY = mode.GetMiddleOffsetY(Sidedef, 0f, true) % Texture.Height;
|
||||
|
||||
if(offsetY == 0f && Sidedef.Fields.ContainsKey("offsety_mid"))
|
||||
Sidedef.Fields.Remove("offsety_mid");
|
||||
else
|
||||
Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, offsetY);
|
||||
}
|
||||
|
||||
Setup();
|
||||
}
|
||||
|
||||
//mxd
|
||||
public override void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) {
|
||||
selectNeighbours(Sidedef.MiddleTexture, select, withSameTexture, withSameHeight);
|
||||
|
|
|
@ -273,6 +273,55 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
Sector.UpdateSectorGeometry(false);
|
||||
}
|
||||
|
||||
//mxd
|
||||
public override void OnTextureFit(bool fitWidth, bool fitHeight) {
|
||||
if(!General.Map.UDMF) return;
|
||||
if(!Sidedef.HighRequired() || string.IsNullOrEmpty(Sidedef.HighTexture) || Sidedef.HighTexture == "-" || !Texture.IsImageLoaded) return;
|
||||
|
||||
string s;
|
||||
if(fitWidth && fitHeight) s = "width and height";
|
||||
else if(fitWidth) s = "width";
|
||||
else s = "height";
|
||||
|
||||
//create undo
|
||||
mode.CreateUndo("Fit texture (" + s + ")", UndoGroup.TextureOffsetChange, Sector.Sector.FixedIndex);
|
||||
Sidedef.Fields.BeforeFieldsChange();
|
||||
|
||||
if(fitWidth) {
|
||||
float scaleX = Texture.Width / Sidedef.Line.Length;
|
||||
|
||||
if(scaleX == 1.0f) {
|
||||
if(Sidedef.Fields.GetValue("scalex_top", 1.0f) != 1.0f)
|
||||
Sidedef.Fields.Remove("scalex_top");
|
||||
} else {
|
||||
Sidedef.Fields["scalex_top"] = new UniValue(UniversalType.Float, scaleX);
|
||||
}
|
||||
|
||||
if(Sidedef.Fields.ContainsKey("offsetx_top"))
|
||||
Sidedef.Fields.Remove("offsetx_top");
|
||||
}
|
||||
|
||||
if(fitHeight && Sidedef.Sector != null && Sidedef.Other.Sector != null) {
|
||||
float scaleY = (float)Texture.Height / (Sidedef.Sector.CeilHeight - Sidedef.Other.Sector.CeilHeight);
|
||||
|
||||
if(scaleY == 1.0f) {
|
||||
if(Sidedef.Fields.GetValue("scaley_top", 1.0f) != 1.0f)
|
||||
Sidedef.Fields.Remove("scaley_top");
|
||||
} else {
|
||||
Sidedef.Fields["scaley_top"] = new UniValue(UniversalType.Float, scaleY);
|
||||
}
|
||||
|
||||
float offsetY = mode.GetTopOffsetY(Sidedef, 0f, true) % Texture.Height;
|
||||
|
||||
if(offsetY == 0f && Sidedef.Fields.ContainsKey("offsety_top"))
|
||||
Sidedef.Fields.Remove("offsety_top");
|
||||
else
|
||||
Sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, offsetY);
|
||||
}
|
||||
|
||||
Setup();
|
||||
}
|
||||
|
||||
//mxd
|
||||
public override void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) {
|
||||
selectNeighbours(Sidedef.HighTexture, select, withSameTexture, withSameHeight);
|
||||
|
|
Loading…
Reference in a new issue