mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +00:00
working on visual mode
This commit is contained in:
parent
5032c58797
commit
97735e5764
31 changed files with 237 additions and 76 deletions
|
@ -660,7 +660,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(orderedselection.Count > 0)
|
||||
{
|
||||
// Create undo
|
||||
undoticket = General.Map.UndoRedo.CreateUndo("Adjust brightness", UndoGroup.None, 0);
|
||||
undoticket = General.Map.UndoRedo.CreateUndo("Adjust brightness");
|
||||
|
||||
// Start editing
|
||||
mode = ModifyMode.Adjusting;
|
||||
|
|
|
@ -188,7 +188,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public override void OnAccept()
|
||||
{
|
||||
// Create undo
|
||||
General.Map.UndoRedo.CreateUndo("Curve linedefs", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Curve linedefs");
|
||||
|
||||
// Go for all selected lines
|
||||
foreach(Linedef ld in selectedlines)
|
||||
|
|
|
@ -307,7 +307,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
MoveGeometryRelative(new Vector2D(0f, 0f), false, false);
|
||||
|
||||
// Make undo for the dragging
|
||||
General.Map.UndoRedo.CreateUndo("Drag geometry", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Drag geometry");
|
||||
|
||||
// Move selected geometry to final position
|
||||
MoveGeometryRelative(mousemappos - dragstartmappos, snaptogrid, snaptonearest);
|
||||
|
|
|
@ -291,7 +291,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
MoveThingsRelative(new Vector2D(0f, 0f), false, false);
|
||||
|
||||
// Make undo for the dragging
|
||||
General.Map.UndoRedo.CreateUndo("Drag things", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Drag things");
|
||||
|
||||
// Move selected geometry to final position
|
||||
MoveThingsRelative(mousemappos - dragstartmappos, snaptogrid, snaptonearest);
|
||||
|
|
|
@ -356,7 +356,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(points.Count > 0)
|
||||
{
|
||||
// Make undo for the draw
|
||||
General.Map.UndoRedo.CreateUndo("Line draw", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Line draw");
|
||||
|
||||
// Make the drawing
|
||||
Tools.DrawLines(points);
|
||||
|
|
|
@ -736,7 +736,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
t.Move(thingpos[index++]);
|
||||
|
||||
// Make undo
|
||||
General.Map.UndoRedo.CreateUndo("Edit selection", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Edit selection");
|
||||
|
||||
// Mark selected geometry
|
||||
General.Map.Map.ClearAllMarks(false);
|
||||
|
|
|
@ -545,9 +545,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Make undo
|
||||
if(selected.Count > 1)
|
||||
General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " linedefs", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " linedefs");
|
||||
else
|
||||
General.Map.UndoRedo.CreateUndo("Delete linedef", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Delete linedef");
|
||||
|
||||
// Dispose selected linedefs
|
||||
foreach(Linedef ld in selected) ld.Dispose();
|
||||
|
@ -577,9 +577,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Make undo
|
||||
if(selected.Count > 1)
|
||||
General.Map.UndoRedo.CreateUndo("Split " + selected.Count + " linedefs", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Split " + selected.Count + " linedefs");
|
||||
else
|
||||
General.Map.UndoRedo.CreateUndo("Split linedef", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Split linedef");
|
||||
|
||||
// Go for all linedefs to split
|
||||
foreach(Linedef ld in selected)
|
||||
|
@ -648,9 +648,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Make undo
|
||||
if(selected.Count > 1)
|
||||
General.Map.UndoRedo.CreateUndo("Flip " + selected.Count + " linedefs", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Flip " + selected.Count + " linedefs");
|
||||
else
|
||||
General.Map.UndoRedo.CreateUndo("Flip linedef", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Flip linedef");
|
||||
|
||||
// Flip all selected linedefs
|
||||
foreach(Linedef l in selected)
|
||||
|
@ -674,9 +674,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Make undo
|
||||
if(selected.Count > 1)
|
||||
General.Map.UndoRedo.CreateUndo("Flip " + selected.Count + " sidedefs", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Flip " + selected.Count + " sidedefs");
|
||||
else
|
||||
General.Map.UndoRedo.CreateUndo("Flip sidedef", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Flip sidedef");
|
||||
|
||||
// Flip sidedefs in all selected linedefs
|
||||
foreach(Linedef l in selected)
|
||||
|
|
|
@ -326,7 +326,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Make the sector
|
||||
General.Interface.SetCursor(Cursors.WaitCursor);
|
||||
General.Settings.FindDefaultDrawSettings();
|
||||
General.Map.UndoRedo.CreateUndo("Make Sector", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Make Sector");
|
||||
Sector s = Tools.MakeSector(allsides);
|
||||
General.Interface.SetCursor(Cursors.Default);
|
||||
|
||||
|
@ -371,7 +371,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Make the sector
|
||||
General.Interface.SetCursor(Cursors.WaitCursor);
|
||||
General.Settings.FindDefaultDrawSettings();
|
||||
General.Map.UndoRedo.CreateUndo("Make Sector", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Make Sector");
|
||||
Sector s = Tools.MakeSector(allsides);
|
||||
General.Interface.SetCursor(Cursors.Default);
|
||||
|
||||
|
|
|
@ -730,7 +730,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
floortex = form.FloorTexture;
|
||||
|
||||
// Create undo
|
||||
General.Map.UndoRedo.CreateUndo("Make door (" + doortex + ")", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Make door (" + doortex + ")");
|
||||
|
||||
// Go for all selected sectors
|
||||
foreach(Sector s in orderedselection)
|
||||
|
@ -824,9 +824,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Make undo
|
||||
if(selected.Count > 1)
|
||||
General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " sectors", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " sectors");
|
||||
else
|
||||
General.Map.UndoRedo.CreateUndo("Delete sector", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Delete sector");
|
||||
|
||||
// Dispose selected sectors
|
||||
foreach(Sector s in selected)
|
||||
|
@ -874,7 +874,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(count > 1)
|
||||
{
|
||||
// Make undo
|
||||
General.Map.UndoRedo.CreateUndo("Join " + count + " sectors", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Join " + count + " sectors");
|
||||
|
||||
// Merge
|
||||
JoinMergeSectors(false);
|
||||
|
@ -898,7 +898,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(count > 1)
|
||||
{
|
||||
// Make undo
|
||||
General.Map.UndoRedo.CreateUndo("Merge " + count + " sectors", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Merge " + count + " sectors");
|
||||
|
||||
// Merge
|
||||
JoinMergeSectors(true);
|
||||
|
|
|
@ -552,9 +552,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Make undo
|
||||
if(selected.Count > 1)
|
||||
General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " things", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " things");
|
||||
else
|
||||
General.Map.UndoRedo.CreateUndo("Delete thing", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Delete thing");
|
||||
|
||||
// Dispose selected things
|
||||
foreach(Thing t in selected) t.Dispose();
|
||||
|
|
|
@ -252,7 +252,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(l != null)
|
||||
{
|
||||
// Create undo
|
||||
General.Map.UndoRedo.CreateUndo("Split linedef", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Split linedef");
|
||||
|
||||
// Create vertex at nearest point on line
|
||||
Vector2D nearestpos = l.NearestOnLine(mousemappos);
|
||||
|
@ -457,9 +457,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Make undo
|
||||
if(selected.Count > 1)
|
||||
General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " vertices", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " vertices");
|
||||
else
|
||||
General.Map.UndoRedo.CreateUndo("Delete vertex", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Delete vertex");
|
||||
|
||||
// Dispose selected vertices
|
||||
foreach(Vertex v in selected) v.Dispose();
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// This removes the thing
|
||||
public override bool Button1Click()
|
||||
{
|
||||
General.Map.UndoRedo.CreateUndo("Delete thing", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Delete thing");
|
||||
thing.Dispose();
|
||||
General.Map.IsChanged = true;
|
||||
General.Map.ThingsFilter.Update();
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// This removes the thing
|
||||
public override bool Button1Click()
|
||||
{
|
||||
General.Map.UndoRedo.CreateUndo("Delete thing", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Delete thing");
|
||||
thing.Dispose();
|
||||
General.Map.IsChanged = true;
|
||||
General.Map.ThingsFilter.Update();
|
||||
|
|
|
@ -272,37 +272,40 @@ lowersector8
|
|||
{
|
||||
title = "Lower Floor/Ceiling by 8 mp";
|
||||
category = "visual";
|
||||
description = "Lowers the targeted or selected floors/ceilings by 8 mp.";
|
||||
description = "Lowers the targeted or selected floors/ceilings by 8 mp. This also lowers selected or targeted things.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
repeat = true;
|
||||
}
|
||||
|
||||
raisesector8
|
||||
{
|
||||
title = "Raise Floor/Ceiling by 8 mp";
|
||||
category = "visual";
|
||||
description = "Raises the targeted or selected floors/ceilings by 8 mp.";
|
||||
description = "Raises the targeted or selected floors/ceilings by 8 mp. This also raises selected or targeted things.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
repeat = true;
|
||||
}
|
||||
|
||||
lowersector1
|
||||
{
|
||||
title = "Lower Floor/Ceiling by 1 mp";
|
||||
category = "visual";
|
||||
description = "Lowers the targeted or selected floors/ceilings by 1 mp.";
|
||||
description = "Lowers the targeted or selected floors/ceilings by 1 mp. This also lowers selected or targeted things.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
repeat = true;
|
||||
}
|
||||
|
||||
raisesector1
|
||||
{
|
||||
title = "Raise Floor/Ceiling by 1 mp";
|
||||
category = "visual";
|
||||
description = "Raises the targeted or selected floors/ceilings by 1 mp.";
|
||||
description = "Raises the targeted or selected floors/ceilings by 1 mp. This also raises selected or targeted things.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
|
@ -320,22 +323,24 @@ showvisualthings
|
|||
|
||||
lowerbrightness8
|
||||
{
|
||||
title = "Lower Brightness by 8";
|
||||
title = "Increase Brightness by 8";
|
||||
category = "visual";
|
||||
description = "Lowers the targeted or selected sector brightness level by 8.";
|
||||
description = "Increases the targeted or selected sector brightness level by 8.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
repeat = true;
|
||||
}
|
||||
|
||||
raisebrightness8
|
||||
{
|
||||
title = "Raise Brightness by 8";
|
||||
title = "Decrease Brightness by 8";
|
||||
category = "visual";
|
||||
description = "Raises the targeted or selected sector brightness level by 8.";
|
||||
description = "Decreases the targeted or selected sector brightness level by 8.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
repeat = true;
|
||||
}
|
||||
|
||||
movetextureleft
|
||||
|
@ -346,6 +351,7 @@ movetextureleft
|
|||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
repeat = true;
|
||||
}
|
||||
|
||||
movetextureright
|
||||
|
@ -356,6 +362,7 @@ movetextureright
|
|||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
repeat = true;
|
||||
}
|
||||
|
||||
movetextureup
|
||||
|
@ -366,6 +373,7 @@ movetextureup
|
|||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
repeat = true;
|
||||
}
|
||||
|
||||
movetexturedown
|
||||
|
@ -376,4 +384,5 @@ movetexturedown
|
|||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
repeat = true;
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public virtual void OnSelectEnd() { }
|
||||
public virtual void OnEditBegin() { }
|
||||
public virtual void OnMouseMove(MouseEventArgs e) { }
|
||||
public virtual void OnChangeTextureOffset(int horizontal, int vertical) { }
|
||||
|
||||
// Edit button released
|
||||
public virtual void OnEditEnd()
|
||||
|
@ -96,6 +97,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Rebuild sector
|
||||
Sector.Rebuild();
|
||||
|
||||
// Go for all things in this sector
|
||||
foreach(Thing t in General.Map.Map.Things)
|
||||
{
|
||||
if(t.Sector == Sector.Sector)
|
||||
{
|
||||
if(mode.VisualThingExists(t))
|
||||
{
|
||||
// Update thing
|
||||
BaseVisualThing vt = (mode.GetVisualThing(t) as BaseVisualThing);
|
||||
vt.Setup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Also rebuild surrounding sectors, because outside sidedefs may need to be adjusted
|
||||
foreach(Sidedef sd in Sector.Sector.Sidedefs)
|
||||
{
|
||||
|
@ -116,6 +131,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Rebuild sector
|
||||
Sector.Rebuild();
|
||||
|
||||
// Go for all things in this sector
|
||||
foreach(Thing t in General.Map.Map.Things)
|
||||
{
|
||||
if(t.Sector == Sector.Sector)
|
||||
{
|
||||
if(mode.VisualThingExists(t))
|
||||
{
|
||||
// Update thing
|
||||
BaseVisualThing vt = (mode.GetVisualThing(t) as BaseVisualThing);
|
||||
vt.Setup();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
#region ================== Constants
|
||||
|
||||
private const float DRAG_ANGLE_TOLERANCE = 0.02f;
|
||||
private const float DRAG_ANGLE_TOLERANCE = 0.1f;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -60,6 +60,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private int startoffsetx;
|
||||
private int startoffsety;
|
||||
protected bool uvdragging;
|
||||
|
||||
// Undo/redo
|
||||
private int undoticket;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -162,6 +165,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
float deltaz = mode.CameraAngleZ - dragstartanglez;
|
||||
if((Math.Abs(deltaxy) + Math.Abs(deltaz)) > DRAG_ANGLE_TOLERANCE)
|
||||
{
|
||||
General.Map.UndoRedo.CreateUndo("Change texture offsets");
|
||||
|
||||
// Start drag now
|
||||
uvdragging = true;
|
||||
mode.LockTarget();
|
||||
|
@ -211,6 +216,38 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Rebuild sector
|
||||
Sector.Rebuild();
|
||||
|
||||
// Go for all things in this sector
|
||||
foreach(Thing t in General.Map.Map.Things)
|
||||
{
|
||||
if(t.Sector == Sector.Sector)
|
||||
{
|
||||
if(mode.VisualThingExists(t))
|
||||
{
|
||||
// Update thing
|
||||
BaseVisualThing vt = (mode.GetVisualThing(t) as BaseVisualThing);
|
||||
vt.Setup();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Texture offset change
|
||||
public virtual void OnChangeTextureOffset(int horizontal, int vertical)
|
||||
{
|
||||
if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
|
||||
undoticket = General.Map.UndoRedo.CreateUndo("Change texture offsets");
|
||||
|
||||
// Apply offsets
|
||||
Sidedef.OffsetX -= horizontal;
|
||||
Sidedef.OffsetY -= vertical;
|
||||
|
||||
// Update sidedef geometry
|
||||
VisualSidedefParts parts = Sector.GetSidedefParts(Sidedef);
|
||||
if(parts.lower != null) parts.lower.Setup();
|
||||
if(parts.middledouble != null) parts.middledouble.Setup();
|
||||
if(parts.middlesingle != null) parts.middlesingle.Setup();
|
||||
if(parts.upper != null) parts.upper.Setup();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -343,6 +343,34 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
PickTargetUnlocked();
|
||||
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTargetBrightness(-8);
|
||||
}
|
||||
|
||||
[BeginAction("movetextureleft")]
|
||||
public void MoveTextureLeft()
|
||||
{
|
||||
PickTargetUnlocked();
|
||||
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(-1, 0);
|
||||
}
|
||||
|
||||
[BeginAction("movetextureright")]
|
||||
public void MoveTextureRight()
|
||||
{
|
||||
PickTargetUnlocked();
|
||||
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(1, 0);
|
||||
}
|
||||
|
||||
[BeginAction("movetextureup")]
|
||||
public void MoveTextureUp()
|
||||
{
|
||||
PickTargetUnlocked();
|
||||
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(0, -1);
|
||||
}
|
||||
|
||||
[BeginAction("movetexturedown")]
|
||||
public void MoveTextureDown()
|
||||
{
|
||||
PickTargetUnlocked();
|
||||
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(0, 1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -56,6 +56,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private Vector3D boxp1;
|
||||
private Vector3D boxp2;
|
||||
|
||||
// Undo/redo
|
||||
private int undoticket;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -93,6 +96,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
// Check if the texture is loaded
|
||||
sprite.LoadImage();
|
||||
isloaded = sprite.IsImageLoaded;
|
||||
if(isloaded)
|
||||
{
|
||||
|
@ -332,8 +336,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public virtual void OnSelectEnd() { }
|
||||
public virtual void OnEditBegin() { }
|
||||
public virtual void OnMouseMove(MouseEventArgs e) { }
|
||||
public virtual void OnChangeTargetHeight(int amount) { }
|
||||
public virtual void OnChangeTargetBrightness(int amount) { }
|
||||
public virtual void OnChangeTextureOffset(int horizontal, int vertical) { }
|
||||
|
||||
// Edit button released
|
||||
public virtual void OnEditEnd()
|
||||
|
@ -344,6 +348,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(result == DialogResult.OK) this.Rebuild();
|
||||
}
|
||||
|
||||
// Raise/lower thing
|
||||
public virtual void OnChangeTargetHeight(int amount)
|
||||
{
|
||||
if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
|
||||
undoticket = General.Map.UndoRedo.CreateUndo("Change thing height");
|
||||
|
||||
Thing.Move(Thing.Position + new Vector3D(0.0f, 0.0f, (float)amount));
|
||||
|
||||
this.Setup();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,5 +46,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
void OnMouseMove(MouseEventArgs e);
|
||||
void OnChangeTargetHeight(int amount);
|
||||
void OnChangeTargetBrightness(int amount);
|
||||
void OnChangeTextureOffset(int horizontal, int vertical);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -206,6 +206,8 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
|
||||
// Generic events
|
||||
public virtual void OnReloadResources() { }
|
||||
public virtual void OnMapSetChangeBegin() { }
|
||||
public virtual void OnMapSetChangeEnd() { }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -35,6 +35,6 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
None,
|
||||
FloorHeightChange,
|
||||
CeilingHeightChange,
|
||||
SectorBrightnessChange,
|
||||
SectorBrightnessChange
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,8 +61,8 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
|
||||
#region ================== Properties
|
||||
|
||||
internal UndoSnapshot NextUndo { get { if(undos.Count > 0) return undos[0]; else return null; } }
|
||||
internal UndoSnapshot NextRedo { get { if(redos.Count > 0) return redos[0]; else return null; } }
|
||||
public UndoSnapshot NextUndo { get { if(undos.Count > 0) return undos[0]; else return null; } }
|
||||
public UndoSnapshot NextRedo { get { if(redos.Count > 0) return redos[0]; else return null; } }
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
|
||||
#endregion
|
||||
|
@ -111,7 +111,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
private void ClearRedos()
|
||||
{
|
||||
// Dispose all redos
|
||||
foreach(UndoSnapshot u in redos) u.mapdata.Dispose();
|
||||
foreach(UndoSnapshot u in redos) u.Dispose();
|
||||
redos.Clear();
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
private void ClearUndos()
|
||||
{
|
||||
// Dispose all undos
|
||||
foreach(UndoSnapshot u in undos) u.mapdata.Dispose();
|
||||
foreach(UndoSnapshot u in undos) u.Dispose();
|
||||
undos.Clear();
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
{
|
||||
// Remove one and dispose map
|
||||
u = list[list.Count - 1];
|
||||
u.mapdata.Dispose();
|
||||
u.Dispose();
|
||||
list.RemoveAt(list.Count - 1);
|
||||
}
|
||||
}
|
||||
|
@ -149,6 +149,12 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
General.MainWindow.UpdateInterface();
|
||||
}
|
||||
|
||||
// This makes an undo and returns the unique ticket id
|
||||
public int CreateUndo(string description)
|
||||
{
|
||||
return CreateUndo(description, UndoGroup.None, 0);
|
||||
}
|
||||
|
||||
// This makes an undo and returns the unique ticket id
|
||||
public int CreateUndo(string description, UndoGroup group, int grouptag)
|
||||
{
|
||||
|
@ -197,12 +203,12 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
if(undos.Count > 0)
|
||||
{
|
||||
// Check if the ticket id matches
|
||||
if(ticket == undos[0].ticketid)
|
||||
if(ticket == undos[0].TicketID)
|
||||
{
|
||||
General.WriteLogLine("Withdrawing undo snapshot \"" + undos[0].description + "\", Ticket ID " + ticket + "...");
|
||||
General.WriteLogLine("Withdrawing undo snapshot \"" + undos[0].Description + "\", Ticket ID " + ticket + "...");
|
||||
|
||||
// Remove the last made undo
|
||||
undos[0].mapdata.Dispose();
|
||||
undos[0].Dispose();
|
||||
undos.RemoveAt(0);
|
||||
|
||||
// Update
|
||||
|
@ -236,7 +242,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
u = undos[0];
|
||||
undos.RemoveAt(0);
|
||||
|
||||
General.WriteLogLine("Performing undo \"" + u.description + "\", Ticket ID " + u.ticketid + "...");
|
||||
General.WriteLogLine("Performing undo \"" + u.Description + "\", Ticket ID " + u.TicketID + "...");
|
||||
|
||||
// Make a snapshot for redo
|
||||
r = new UndoSnapshot(u, General.Map.Map.Serialize());
|
||||
|
@ -249,7 +255,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
lastgroup = UndoGroup.None;
|
||||
|
||||
// Change map set
|
||||
General.Map.ChangeMapSet(new MapSet(u.mapdata));
|
||||
General.Map.ChangeMapSet(new MapSet(u.MapData));
|
||||
|
||||
// Remove selection
|
||||
General.Map.Map.ClearAllMarks(false);
|
||||
|
@ -294,7 +300,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
r = redos[0];
|
||||
redos.RemoveAt(0);
|
||||
|
||||
General.WriteLogLine("Performing redo \"" + r.description + "\", Ticket ID " + r.ticketid + "...");
|
||||
General.WriteLogLine("Performing redo \"" + r.Description + "\", Ticket ID " + r.TicketID + "...");
|
||||
|
||||
// Make a snapshot for undo
|
||||
u = new UndoSnapshot(r, General.Map.Map.Serialize());
|
||||
|
@ -307,7 +313,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
lastgroup = UndoGroup.None;
|
||||
|
||||
// Change map set
|
||||
General.Map.ChangeMapSet(new MapSet(r.mapdata));
|
||||
General.Map.ChangeMapSet(new MapSet(r.MapData));
|
||||
|
||||
// Remove selection
|
||||
General.Map.Map.ClearAllMarks(false);
|
||||
|
|
|
@ -35,14 +35,20 @@ using CodeImp.DoomBuilder.Actions;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Editing
|
||||
{
|
||||
internal class UndoSnapshot
|
||||
public class UndoSnapshot
|
||||
{
|
||||
public MemoryStream mapdata;
|
||||
public string description;
|
||||
public int ticketid; // For safe withdrawing
|
||||
// Variables
|
||||
private MemoryStream mapdata;
|
||||
private string description;
|
||||
private int ticketid; // For safe withdrawing
|
||||
|
||||
// Properties
|
||||
internal MemoryStream MapData { get { return mapdata; } }
|
||||
public string Description { get { return description; } }
|
||||
public int TicketID { get { return ticketid; } }
|
||||
|
||||
// Constructor
|
||||
public UndoSnapshot(string description, MemoryStream mapdata, int ticketid)
|
||||
internal UndoSnapshot(string description, MemoryStream mapdata, int ticketid)
|
||||
{
|
||||
this.ticketid = ticketid;
|
||||
this.description = description;
|
||||
|
@ -50,11 +56,18 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
}
|
||||
|
||||
// Constructor
|
||||
public UndoSnapshot(UndoSnapshot info, MemoryStream mapdata)
|
||||
internal UndoSnapshot(UndoSnapshot info, MemoryStream mapdata)
|
||||
{
|
||||
this.ticketid = info.ticketid;
|
||||
this.description = info.description;
|
||||
this.mapdata = mapdata;
|
||||
}
|
||||
|
||||
// Disposer
|
||||
public void Dispose()
|
||||
{
|
||||
if(mapdata != null) mapdata.Dispose();
|
||||
mapdata = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -938,7 +938,7 @@ namespace CodeImp.DoomBuilder
|
|||
General.Interface.SetCursor(Cursors.WaitCursor);
|
||||
|
||||
// Make undo
|
||||
undoredo.CreateUndo("Assign to group " + groupindex, UndoGroup.None, 0);
|
||||
undoredo.CreateUndo("Assign to group " + groupindex);
|
||||
|
||||
// Make selection
|
||||
map.AddSelectionToGroup(0x01 << groupindex);
|
||||
|
@ -1240,6 +1240,10 @@ namespace CodeImp.DoomBuilder
|
|||
// This sets a new mapset for editing
|
||||
internal void ChangeMapSet(MapSet newmap)
|
||||
{
|
||||
// Let the plugin and editing mode know
|
||||
General.Plugins.OnMapSetChangeBegin();
|
||||
if(General.Editing.Mode != null) General.Editing.Mode.OnMapSetChangeBegin();
|
||||
|
||||
// Can't have a selection in an old map set
|
||||
map.ClearAllSelected();
|
||||
|
||||
|
@ -1249,6 +1253,10 @@ namespace CodeImp.DoomBuilder
|
|||
map.UpdateConfiguration();
|
||||
map.Update();
|
||||
thingsfilter.Update();
|
||||
|
||||
// Let the plugin and editing mode know
|
||||
General.Plugins.OnMapSetChangeEnd();
|
||||
if(General.Editing.Mode != null) General.Editing.Mode.OnMapSetChangeEnd();
|
||||
}
|
||||
|
||||
// This reloads resources
|
||||
|
|
|
@ -49,9 +49,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
// Sidedefs
|
||||
private LinkedList<Sidedef> sidedefs;
|
||||
|
||||
// Things
|
||||
//private LinkedList<Thing> things;
|
||||
|
||||
// Properties
|
||||
private int index;
|
||||
|
@ -85,7 +82,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
public MapSet Map { get { return map; } }
|
||||
public ICollection<Sidedef> Sidedefs { get { return sidedefs; } }
|
||||
//public ICollection<Thing> Things { get { return things; } }
|
||||
public int Index { get { return index; } }
|
||||
public int FloorHeight { get { return floorheight; } set { floorheight = value; } }
|
||||
public int CeilHeight { get { return ceilheight; } set { ceilheight = value; } }
|
||||
|
@ -117,7 +113,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
this.map = map;
|
||||
this.mainlistitem = listitem;
|
||||
this.sidedefs = new LinkedList<Sidedef>();
|
||||
//this.things = new LinkedList<Thing>();
|
||||
this.index = index;
|
||||
this.floortexname = "-";
|
||||
this.ceiltexname = "-";
|
||||
|
@ -138,7 +133,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
this.map = map;
|
||||
this.mainlistitem = listitem;
|
||||
this.sidedefs = new LinkedList<Sidedef>();
|
||||
//this.things = new LinkedList<Thing>();
|
||||
this.triangulationneeded = true;
|
||||
|
||||
ReadWrite(stream);
|
||||
|
@ -177,7 +171,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
flatfloorbuffer = null;
|
||||
mainlistitem = null;
|
||||
sidedefs = null;
|
||||
//things = null;
|
||||
map = null;
|
||||
|
||||
// Dispose base
|
||||
|
@ -251,12 +244,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
}
|
||||
|
||||
// This attaches a thing and returns the listitem
|
||||
//public LinkedListNode<Thing> AttachThing(Thing t) { return things.AddLast(t); }
|
||||
|
||||
// This detaches a thing
|
||||
//public void DetachThing(LinkedListNode<Thing> l) { if(!isdisposed) things.Remove(l); }
|
||||
|
||||
// This updates the sector when changes have been made
|
||||
public void UpdateCache()
|
||||
{
|
||||
|
|
|
@ -152,6 +152,20 @@ namespace CodeImp.DoomBuilder.Plugins
|
|||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before the MapSet is changed. This means that the active MapSet will be disposed and changed to a new one.
|
||||
/// </summary>
|
||||
public virtual void OnMapSetChangeBegin()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs after the MapSet is changed.
|
||||
/// </summary>
|
||||
public virtual void OnMapSetChangeEnd()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is called after the constructor to allow a plugin to initialize.
|
||||
/// </summary>
|
||||
|
|
|
@ -256,6 +256,18 @@ namespace CodeImp.DoomBuilder.Plugins
|
|||
{
|
||||
foreach(Plugin p in plugins) p.Plug.OnMapNewEnd();
|
||||
}
|
||||
|
||||
|
||||
public void OnMapSetChangeBegin()
|
||||
{
|
||||
foreach(Plugin p in plugins) p.Plug.OnMapSetChangeBegin();
|
||||
}
|
||||
|
||||
|
||||
public void OnMapSetChangeEnd()
|
||||
{
|
||||
foreach(Plugin p in plugins) p.Plug.OnMapSetChangeEnd();
|
||||
}
|
||||
|
||||
|
||||
public void OnSectorCeilingSurfaceUpdate(Sector s, ref FlatVertex[] vertices)
|
||||
|
|
|
@ -308,7 +308,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
|
||||
// Make undo
|
||||
if(lines.Count > 1) undodesc = lines.Count + " linedefs";
|
||||
General.Map.UndoRedo.CreateUndo("Edit " + undodesc, UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Edit " + undodesc);
|
||||
|
||||
// Go for all the lines
|
||||
foreach(Linedef l in lines)
|
||||
|
|
|
@ -1690,13 +1690,13 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
|
||||
// Determine undo description
|
||||
if(itemundo.Enabled)
|
||||
itemundo.Text = "Undo " + General.Map.UndoRedo.NextUndo.description;
|
||||
itemundo.Text = "Undo " + General.Map.UndoRedo.NextUndo.Description;
|
||||
else
|
||||
itemundo.Text = "Undo";
|
||||
|
||||
// Determine redo description
|
||||
if(itemredo.Enabled)
|
||||
itemredo.Text = "Redo " + General.Map.UndoRedo.NextRedo.description;
|
||||
itemredo.Text = "Redo " + General.Map.UndoRedo.NextRedo.Description;
|
||||
else
|
||||
itemredo.Text = "Redo";
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
|
||||
// Make undo
|
||||
if(sectors.Count > 1) undodesc = sectors.Count + " sectors";
|
||||
General.Map.UndoRedo.CreateUndo("Edit " + undodesc, UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Edit " + undodesc);
|
||||
|
||||
// Go for all sectors
|
||||
foreach(Sector s in sectors)
|
||||
|
|
|
@ -331,7 +331,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
|
||||
// Make undo
|
||||
if(things.Count > 1) undodesc = things.Count + " things";
|
||||
General.Map.UndoRedo.CreateUndo("Edit " + undodesc, UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Edit " + undodesc);
|
||||
|
||||
// Go for all the things
|
||||
foreach(Thing t in things)
|
||||
|
|
Loading…
Reference in a new issue