Doom/Hexen map formats: texture offsets of walls can now be edited properly in GZDoom Visual mode.

This commit is contained in:
MaxED 2012-11-22 13:12:35 +00:00
parent c0c36eabbc
commit 082bb87c3c
9 changed files with 64 additions and 131 deletions

View file

@ -273,8 +273,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
mode.Renderer.ShowSelection = false;
mode.Renderer.ShowHighlight = false;
UpdateDragUV();
} else {
General.ShowErrorMessage(BaseVisualMode.TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK);
}
}
}
@ -488,17 +486,22 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
// Texture offset change
public virtual void OnChangeTextureOffset(int horizontal, int vertical)
{
if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
undoticket = mode.CreateUndo("Change texture offsets");
//mxd
if (General.Map.UDMF) {
if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
undoticket = mode.CreateUndo("Change texture offsets");
// Apply offsets
MoveTextureOffset(new Point(-horizontal, -vertical));
// Apply offsets
MoveTextureOffset(new Point(-horizontal, -vertical));
mode.SetActionResult("Changed texture offsets by " + -horizontal + ", " + -vertical + ".");
mode.SetActionResult("Changed texture offsets by " + -horizontal + ", " + -vertical + ".");
// Update sector geometry
Sector.UpdateSectorGeometry(false);
Sector.Rebuild();
// Update sector geometry
Sector.UpdateSectorGeometry(false);
Sector.Rebuild();
} else {
General.ShowErrorMessage("Floor/ceiling texture offsets cannot be changed in this map format!", MessageBoxButtons.OK);
}
}
#endregion

View file

@ -869,18 +869,14 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
float deltaz = General.Map.VisualCamera.AngleZ - dragstartanglez;
if((Math.Abs(deltaxy) + Math.Abs(deltaz)) > DRAG_ANGLE_TOLERANCE)
{
if(General.Map.UDMF) { //mxd
mode.PreAction(UndoGroup.TextureOffsetChange);
mode.CreateUndo("Change texture offsets");
mode.PreAction(UndoGroup.TextureOffsetChange);
mode.CreateUndo("Change texture offsets");
// Start drag now
uvdragging = true;
mode.Renderer.ShowSelection = false;
mode.Renderer.ShowHighlight = false;
UpdateDragUV();
} else {
General.ShowErrorMessage(BaseVisualMode.TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK);
}
// Start drag now
uvdragging = true;
mode.Renderer.ShowSelection = false;
mode.Renderer.ShowHighlight = false;
UpdateDragUV();
}
}
}
@ -957,10 +953,18 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
undoticket = mode.CreateUndo("Change texture offsets");
// Apply offsets
MoveTextureOffset(new Point(-horizontal, -vertical));
mode.SetActionResult("Changed texture offsets by " + -horizontal + ", " + -vertical + ".");
//mxd
if (General.Map.UDMF) {
// Apply UDMF offsets
MoveTextureOffset(new Point(-horizontal, -vertical));
Point p = GetTextureOffset();
mode.SetActionResult("Changed texture offsets to " + p.X + ", " + p.Y + ".");
} else {
// Apply classic offsets
Sidedef.OffsetX -= horizontal;
Sidedef.OffsetY -= vertical;
mode.SetActionResult("Changed texture offsets to " + Sidedef.OffsetX + ", " + Sidedef.OffsetY + ".");
}
// Update sidedef geometry
VisualSidedefParts parts = Sector.GetSidedefParts(Sidedef);

View file

@ -50,9 +50,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
public class BaseVisualMode : VisualMode
{
#region ================== Constants
//mxd
public const string TEXTURE_OFFSET_CHANGE_ERROR = "Texture offsets cannot be changed in this mode if the map is not in UDMF format.\nPlease use Visual mode to change them.";
// Object picking
private const float PICK_INTERVAL = 80.0f;
private const float PICK_RANGE = 0.98f;
@ -1431,105 +1428,73 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
[BeginAction("movetextureleft", Library = "BuilderModes")]
public void MoveTextureLeft1()
{
if(General.Map.UDMF) {
PreAction(UndoGroup.TextureOffsetChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(-1, 0);
PostAction();
} else {
General.ShowErrorMessage(TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK);
}
PreAction(UndoGroup.TextureOffsetChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach (IVisualEventReceiver i in objs) i.OnChangeTextureOffset(-1, 0);
PostAction();
}
[BeginAction("movetextureright", Library = "BuilderModes")]
public void MoveTextureRight1()
{
if(General.Map.UDMF) {
PreAction(UndoGroup.TextureOffsetChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(1, 0);
PostAction();
} else {
General.ShowErrorMessage(TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK);
}
PreAction(UndoGroup.TextureOffsetChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach (IVisualEventReceiver i in objs) i.OnChangeTextureOffset(1, 0);
PostAction();
}
[BeginAction("movetextureup", Library = "BuilderModes")]
public void MoveTextureUp1()
{
if(General.Map.UDMF) {
PreAction(UndoGroup.TextureOffsetChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, -1);
PostAction();
} else {
General.ShowErrorMessage(TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK);
}
PreAction(UndoGroup.TextureOffsetChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach (IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, -1);
PostAction();
}
[BeginAction("movetexturedown", Library = "BuilderModes")]
public void MoveTextureDown1()
{
if(General.Map.UDMF) {
PreAction(UndoGroup.TextureOffsetChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, 1);
PostAction();
} else {
General.ShowErrorMessage(TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK);
}
PreAction(UndoGroup.TextureOffsetChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach (IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, 1);
PostAction();
}
[BeginAction("movetextureleft8", Library = "BuilderModes")]
public void MoveTextureLeft8()
{
if(General.Map.UDMF) {
PreAction(UndoGroup.TextureOffsetChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(-8, 0);
PostAction();
} else {
General.ShowErrorMessage(TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK);
}
PreAction(UndoGroup.TextureOffsetChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach (IVisualEventReceiver i in objs) i.OnChangeTextureOffset(-8, 0);
PostAction();
}
[BeginAction("movetextureright8", Library = "BuilderModes")]
public void MoveTextureRight8()
{
if(General.Map.UDMF) {
PreAction(UndoGroup.TextureOffsetChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(8, 0);
PostAction();
} else {
General.ShowErrorMessage(TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK);
}
PreAction(UndoGroup.TextureOffsetChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach (IVisualEventReceiver i in objs) i.OnChangeTextureOffset(8, 0);
PostAction();
}
[BeginAction("movetextureup8", Library = "BuilderModes")]
public void MoveTextureUp8()
{
if(General.Map.UDMF) {
PreAction(UndoGroup.TextureOffsetChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, -8);
PostAction();
} else {
General.ShowErrorMessage(TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK);
}
PreAction(UndoGroup.TextureOffsetChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach (IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, -8);
PostAction();
}
[BeginAction("movetexturedown8", Library = "BuilderModes")]
public void MoveTextureDown8()
{
if(General.Map.UDMF) {
PreAction(UndoGroup.TextureOffsetChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, 8);
PostAction();
} else {
General.ShowErrorMessage(TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK);
}
PreAction(UndoGroup.TextureOffsetChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach (IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, 8);
PostAction();
}
[BeginAction("textureselect", Library = "BuilderModes")]

View file

@ -175,13 +175,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
s.Fields["xpanningfloor"] = new UniValue(UniversalType.Float, oldx + (float)xy.X);
s.Fields["ypanningfloor"] = new UniValue(UniversalType.Float, oldy + (float)xy.Y);
s.UpdateNeeded = true;
/*Sector.Sector.Fields.BeforeFieldsChange();
float oldx = Sector.Sector.Fields.GetValue("xpanningfloor", 0.0f);
float oldy = Sector.Sector.Fields.GetValue("ypanningfloor", 0.0f);
Sector.Sector.Fields["xpanningfloor"] = new UniValue(UniversalType.Float, oldx + (float)xy.X);
Sector.Sector.Fields["ypanningfloor"] = new UniValue(UniversalType.Float, oldy + (float)xy.Y);
Sector.Sector.UpdateNeeded = true;*/
}
// Paste texture

View file

@ -240,10 +240,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
float scaley = Sidedef.Fields.GetValue("scaley_bottom", 1.0f);
Sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldx, (float)xy.X, scalex)); //mxd
Sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, (float)xy.Y, scaley)); //mxd
//Sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, oldx + getRoundedTextureOffset((float)xy.X, scalex)); //mxd
//Sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, oldy + getRoundedTextureOffset((float)xy.Y, scaley)); //mxd
//Sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, oldx + (float)xy.X * scalex);
//Sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, oldy + (float)xy.Y * scaley);
}
protected override Point GetTextureOffset()

View file

@ -76,9 +76,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
Sidedef sourceside = extrafloor.Linedef.Front;
this.extrafloor = extrafloor;
//int lightvalue = Sidedef.Fields.GetValue("light", 0);
//bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false);
//mxd. lightfog flag support
bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false);
bool ignoreUDMFLight = (!Sidedef.Fields.GetValue("lightfog", false) || !lightabsolute) && Sector.Sector.Fields.ContainsKey("fadecolor");
@ -197,7 +194,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
// Determine initial color
int lightlevel = lightabsolute ? lightvalue : sd.Ceiling.brightnessbelow + lightvalue;
//mxd. This calculates light with doom-style wall shading
//PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel));
PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef));
PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness);
poly.color = wallcolor.WithAlpha(255).ToInt();

View file

@ -77,9 +77,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
public override bool Setup()
{
Vector2D vl, vr;
//int lightvalue = Sidedef.Fields.GetValue("light", 0);
//bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false);
//mxd. lightfog flag support
bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false);
@ -194,7 +191,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
// Determine initial color
int lightlevel = lightabsolute ? lightvalue : sd.Ceiling.brightnessbelow + lightvalue;
//mxd
//PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel));
PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef));
PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness);
poly.color = wallcolor.WithAlpha(255).ToInt();
@ -317,10 +313,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
float scaley = Sidedef.Fields.GetValue("scaley_mid", 1.0f);
Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldx, (float)xy.X, scalex)); //mxd
Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, (float)xy.Y, scaley)); //mxd
//Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, oldx + getRoundedTextureOffset((float)xy.X, scalex)); //mxd
//Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, oldy + getRoundedTextureOffset((float)xy.Y, scaley)); //mxd
//Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, oldx + (float)xy.X * scalex);
//Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, oldy + (float)xy.Y * scaley);
}
protected override Point GetTextureOffset()

View file

@ -70,9 +70,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
public override bool Setup()
{
Vector2D vl, vr;
//int lightvalue = Sidedef.Fields.GetValue("light", 0);
//bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false);
//mxd. lightfog flag support
bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false);
@ -189,7 +186,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
// Determine initial color
int lightlevel = lightabsolute ? lightvalue : sd.Ceiling.brightnessbelow + lightvalue;
//mxd
//PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel));
PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef));
PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness);
poly.color = wallcolor.WithAlpha(255).ToInt();
@ -245,10 +241,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
float scaley = Sidedef.Fields.GetValue("scaley_mid", 1.0f);
Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldx, (float)xy.X, scalex)); //mxd
Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, (float)xy.Y, scaley)); //mxd
//Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, oldx + getRoundedTextureOffset((float)xy.X, scalex)); //mxd
//Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, oldy + getRoundedTextureOffset((float)xy.Y, scaley)); //mxd
//Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, oldx + (float)xy.X * scalex);
//Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, oldy + (float)xy.Y * scaley);
}
protected override Point GetTextureOffset()

View file

@ -71,9 +71,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
public override bool Setup()
{
Vector2D vl, vr;
//int lightvalue = Sidedef.Fields.GetValue("light", 0);
//bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false);
//mxd. lightfog flag support
bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false);
@ -179,7 +176,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
// Determine initial color
int lightlevel = lightabsolute ? lightvalue : sd.Ceiling.brightnessbelow + lightvalue;
//mxd
//PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel));
PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef));
PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness);
poly.color = wallcolor.WithAlpha(255).ToInt();
@ -244,10 +240,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
float scaley = Sidedef.Fields.GetValue("scaley_top", 1.0f);
Sidedef.Fields["offsetx_top"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldx, (float)xy.X, scalex)); //mxd
Sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, (float)xy.Y, scaley)); //mxd
//Sidedef.Fields["offsetx_top"] = new UniValue(UniversalType.Float, oldx + getRoundedTextureOffset((float)xy.X, scalex)); //mxd
//Sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, oldy + getRoundedTextureOffset((float)xy.Y, scaley)); //mxd
//Sidedef.Fields["offsetx_top"] = new UniValue(UniversalType.Float, oldx + (float)xy.X * scalex);
//Sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, oldy + (float)xy.Y * scaley);
}
protected override Point GetTextureOffset()