@ Fixed some bugs in the Floor/Ceiling align modes and the GZDoom Visual Mode

This commit is contained in:
codeimp 2011-12-17 16:47:16 +00:00
parent da1f4a76ce
commit f2d41931f4
5 changed files with 69 additions and 55 deletions

View file

@ -64,7 +64,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
public override string XOffsetName { get { return "xpanningceiling"; } }
public override string YOffsetName { get { return "ypanningceiling"; } }
public override string RotationName { get { return "rotationceiling"; } }
public override string UndoDescription { get { return "Ceiling Alignment"; } }
#endregion
#region ================== Constructor / Disposer

View file

@ -126,6 +126,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
public abstract string XOffsetName { get; }
public abstract string YOffsetName { get; }
public abstract string RotationName { get; }
public abstract string UndoDescription { get; }
#endregion
@ -613,7 +614,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
if(selection.Count == 0)
{
General.Interface.MessageBeep(MessageBeepType.Default);
General.Interface.DisplayStatus(StatusType.Info, "A selected sector is required for this action.");
General.Interface.DisplayStatus(StatusType.Action, "A selected sector is required for this action.");
General.Editing.CancelMode();
return;
}
@ -625,7 +626,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
(texture.Width <= 0) || (texture.Height <= 0) || !texture.IsImageLoaded)
{
General.Interface.MessageBeep(MessageBeepType.Default);
General.Interface.DisplayStatus(StatusType.Info, "The selected sector must have a loaded texture to align.");
General.Interface.DisplayStatus(StatusType.Action, "The selected sector must have a loaded texture to align.");
General.Editing.CancelMode();
return;
}
@ -688,29 +689,33 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
{
base.OnAccept();
// Restore original values
RestoreSectors();
General.Map.Map.Update();
// Make undo
General.Map.UndoRedo.CreateUndo("Flat Alignment");
// Resume normal undo/redo recording
General.Map.UndoRedo.IgnorePropChanges = false;
// Apply changes
UpdateSectors();
General.Map.Map.Update();
// Clear selection
if(selection.Count == 1)
General.Map.Map.ClearAllSelected();
// Done
General.Map.IsChanged = true;
if(!modealreadyswitching)
{
modealreadyswitching = true;
// Restore original values
RestoreSectors();
General.Map.Map.Update();
// Make undo
General.Map.UndoRedo.CreateUndo(UndoDescription);
// Resume normal undo/redo recording
General.Map.UndoRedo.IgnorePropChanges = false;
// Apply changes
UpdateSectors();
General.Map.Map.Update();
// Clear selection
if(selection.Count == 1)
General.Map.Map.ClearAllSelected();
// Done
General.Map.IsChanged = true;
selection = null;
sectorinfo = null;
// Return to previous stable mode
General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
}
@ -720,6 +725,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
public override void OnCancel()
{
base.OnCancel();
modealreadyswitching = true;
// Restore original values
RestoreSectors();
@ -865,7 +871,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
// This redraws the display
public override void OnRedrawDisplay()
{
UpdateRectangleComponents();
if(sectorinfo != null)
UpdateRectangleComponents();
renderer.RedrawSurface();
@ -886,41 +893,44 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
}
// Render overlay
if(renderer.StartOverlay(true))
if(sectorinfo != null)
{
// Rectangle
PixelColor rectcolor = General.Colors.Highlight.WithAlpha(RECTANGLE_ALPHA);
renderer.RenderGeometry(cornerverts, null, true);
if(extensionline.GetLengthSq() > 0.0f)
renderer.RenderLine(extensionline.v1, extensionline.v2, 1, General.Colors.Indication.WithAlpha(EXTENSION_LINE_ALPHA), true);
renderer.RenderLine(corners[0], corners[1], 4, rectcolor, true);
renderer.RenderLine(corners[1], corners[2], 4, rectcolor, true);
renderer.RenderLine(corners[2], corners[3], 4, rectcolor, true);
renderer.RenderLine(corners[3], corners[0], 4, rectcolor, true);
if(renderer.StartOverlay(true))
{
// Rectangle
PixelColor rectcolor = General.Colors.Highlight.WithAlpha(RECTANGLE_ALPHA);
renderer.RenderGeometry(cornerverts, null, true);
if(extensionline.GetLengthSq() > 0.0f)
renderer.RenderLine(extensionline.v1, extensionline.v2, 1, General.Colors.Indication.WithAlpha(EXTENSION_LINE_ALPHA), true);
renderer.RenderLine(corners[0], corners[1], 4, rectcolor, true);
renderer.RenderLine(corners[1], corners[2], 4, rectcolor, true);
renderer.RenderLine(corners[2], corners[3], 4, rectcolor, true);
renderer.RenderLine(corners[3], corners[0], 4, rectcolor, true);
// Lines
renderer.RenderLine(corners[0], extends[0], 1f, General.Colors.Highlight, true);
renderer.RenderLine(corners[0], extends[1], 1f, General.Colors.Highlight, true);
renderer.RenderLine(corners[1], corners[2], 0.5f, General.Colors.Highlight, true);
renderer.RenderLine(corners[2], corners[3], 0.5f, General.Colors.Highlight, true);
// Lines
renderer.RenderLine(corners[0], extends[0], 1f, General.Colors.Highlight, true);
renderer.RenderLine(corners[0], extends[1], 1f, General.Colors.Highlight, true);
renderer.RenderLine(corners[1], corners[2], 0.5f, General.Colors.Highlight, true);
renderer.RenderLine(corners[2], corners[3], 0.5f, General.Colors.Highlight, true);
// Handles
renderer.RenderRectangleFilled(rotategrips[0], General.Colors.Background, true);
renderer.RenderRectangleFilled(rotategrips[1], General.Colors.Background, true);
renderer.RenderRectangle(rotategrips[0], 2f, General.Colors.Indication, true);
renderer.RenderRectangle(rotategrips[1], 2f, General.Colors.Indication, true);
renderer.RenderRectangleFilled(resizegrips[0], General.Colors.Background, true);
renderer.RenderRectangleFilled(resizegrips[1], General.Colors.Background, true);
renderer.RenderRectangle(resizegrips[0], 2f, General.Colors.Highlight, true);
renderer.RenderRectangle(resizegrips[1], 2f, General.Colors.Highlight, true);
// Handles
renderer.RenderRectangleFilled(rotategrips[0], General.Colors.Background, true);
renderer.RenderRectangleFilled(rotategrips[1], General.Colors.Background, true);
renderer.RenderRectangle(rotategrips[0], 2f, General.Colors.Indication, true);
renderer.RenderRectangle(rotategrips[1], 2f, General.Colors.Indication, true);
renderer.RenderRectangleFilled(resizegrips[0], General.Colors.Background, true);
renderer.RenderRectangleFilled(resizegrips[1], General.Colors.Background, true);
renderer.RenderRectangle(resizegrips[0], 2f, General.Colors.Highlight, true);
renderer.RenderRectangle(resizegrips[1], 2f, General.Colors.Highlight, true);
// Rotate/align point
if(showalignoffset)
renderer.RenderRectangleFilled(alignrect, General.Colors.Selection, true);
renderer.Finish();
// Rotate/align point
if(showalignoffset)
renderer.RenderRectangleFilled(alignrect, General.Colors.Selection, true);
renderer.Finish();
}
}
renderer.Present();
}

View file

@ -64,6 +64,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
public override string XOffsetName { get { return "xpanningfloor"; } }
public override string YOffsetName { get { return "ypanningfloor"; } }
public override string RotationName { get { return "rotationfloor"; } }
public override string UndoDescription { get { return "Floor Alignment"; } }
#endregion

View file

@ -169,6 +169,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
float oldy = Sector.Sector.Fields.GetValue("ypanningceiling", 0.0f);
Sector.Sector.Fields["xpanningceiling"] = new UniValue(UniversalType.Float, oldx + (float)xy.X);
Sector.Sector.Fields["ypanningceiling"] = new UniValue(UniversalType.Float, oldy + (float)xy.Y);
Sector.Sector.UpdateNeeded = true;
}
// Paste texture

View file

@ -168,6 +168,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
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