@ work in progress (do not use this revision for building/testing)

This commit is contained in:
codeimp 2009-05-01 20:31:17 +00:00
parent 26739a7f2d
commit ad05a43ade
16 changed files with 321 additions and 66 deletions

View file

@ -8,6 +8,8 @@ ECHO. - Microsoft HTML Help compiler
ECHO. - Inno Setup 5 ECHO. - Inno Setup 5
ECHO. ECHO.
ECHO. You have to commit your work before using this script. ECHO. You have to commit your work before using this script.
ECHO. Results will be in the 'Release' directory. Anything currently in
ECHO. the 'Release' directory may be overwritten.
ECHO. ECHO.
ECHO. ECHO.
PAUSE PAUSE
@ -87,14 +89,14 @@ GOTO LEAVE
ECHO. ECHO.
ECHO. BUILD FAILED (Tool returned error) ECHO. BUILD FAILED (Tool returned error)
ECHO. ECHO.
PAUSE PAUSE > NUL
GOTO LEAVE GOTO LEAVE
:FILEFAIL :FILEFAIL
ECHO. ECHO.
ECHO. BUILD FAILED (Output file was not built) ECHO. BUILD FAILED (Output file was not built)
ECHO. ECHO.
PAUSE PAUSE > NUL
GOTO LEAVE GOTO LEAVE
:LEAVE :LEAVE

View file

@ -323,6 +323,42 @@ namespace CodeImp.DoomBuilder.Editing
} }
} }
// This changes the description of previously made undo
public void SetUndoDescription(int ticket, string description)
{
// Anything to undo?
if(undos.Count > 0)
{
// Check if the ticket id matches
if(ticket == undos[0].TicketID)
{
lock(undos)
{
undos[0].Description = description;
}
// Update
General.MainWindow.UpdateInterface();
}
}
}
// This changes the grouping settings
public void SetUndoGrouping(int ticket, UndoGroup group, int grouptag)
{
// Anything to undo?
if(undos.Count > 0)
{
// Check if the ticket id matches
if(ticket == undos[0].TicketID)
{
// Keep grouping info
lastgroup = group;
lastgrouptag = grouptag;
}
}
}
// This performs an undo // This performs an undo
[BeginAction("undo")] [BeginAction("undo")]
public void PerformUndo() public void PerformUndo()

View file

@ -52,7 +52,7 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Properties #region ================== Properties
public string Description { get { return description; } } public string Description { get { return description; } set { description = value; } }
public int TicketID { get { return ticketid; } } public int TicketID { get { return ticketid; } }
internal bool StoreOnDisk { get { return storeondisk; } set { storeondisk = value; } } internal bool StoreOnDisk { get { return storeondisk; } set { storeondisk = value; } }
public bool IsOnDisk { get { return isondisk; } } public bool IsOnDisk { get { return isondisk; } }

View file

@ -131,6 +131,15 @@ namespace CodeImp.DoomBuilder.Rendering
(float)b * BYTE_TO_FLOAT); (float)b * BYTE_TO_FLOAT);
} }
// To ColorValue
public Color4 ToColorValue(float withalpha)
{
return new Color4(withalpha,
(float)r * BYTE_TO_FLOAT,
(float)g * BYTE_TO_FLOAT,
(float)b * BYTE_TO_FLOAT);
}
// This returns a new PixelColor with adjusted alpha // This returns a new PixelColor with adjusted alpha
public PixelColor WithAlpha(byte a) public PixelColor WithAlpha(byte a)
{ {

View file

@ -514,6 +514,9 @@ namespace CodeImp.DoomBuilder.Rendering
// This performs a single render pass // This performs a single render pass
private void RenderSinglePass(int pass) private void RenderSinglePass(int pass)
{ {
int currentshaderpass = shaderpass;
int highshaderpass = shaderpass + 2;
// Get geometry for this pass // Get geometry for this pass
Dictionary<ImageData, BinaryHeap<VisualGeometry>> geopass = geometry[pass]; Dictionary<ImageData, BinaryHeap<VisualGeometry>> geopass = geometry[pass];
@ -569,27 +572,26 @@ namespace CodeImp.DoomBuilder.Rendering
if(sector != null) if(sector != null)
{ {
// Highlight this object? // Determine the shader pass we want to use for this object
if(g == highlighted) int wantedshaderpass = ((g == highlighted) || g.Selected) ? highshaderpass : shaderpass;
// Switch shader pass?
if(currentshaderpass != wantedshaderpass)
{ {
// Temporarely switch shader and use a highlight color
graphics.Shaders.World3D.EndPass(); graphics.Shaders.World3D.EndPass();
Color4 highlight = General.Colors.Highlight.ToColorValue(); graphics.Shaders.World3D.BeginPass(wantedshaderpass);
highlight.Alpha = highlightglow; currentshaderpass = wantedshaderpass;
graphics.Shaders.World3D.SetHighlightColor(highlight.ToArgb());
graphics.Shaders.World3D.BeginPass(shaderpass + 2);
} }
// Set the color to use
Color4 highlightcolor = new Color4(0);
if(g.Selected) highlightcolor = General.Colors.Selection.ToColorValue(highlightglow);
if(g == highlighted) highlightcolor = Color4.Lerp(highlightcolor, General.Colors.Highlight.ToColorValue(), highlightglow);
graphics.Shaders.World3D.SetHighlightColor(highlightcolor.ToArgb());
graphics.Shaders.World3D.ApplySettings();
// Render! // Render!
graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, g.VertexOffset, g.Triangles); graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, g.VertexOffset, g.Triangles);
// Reset highlight settings
if(g == highlighted)
{
graphics.Shaders.World3D.EndPass();
graphics.Shaders.World3D.SetHighlightColor(0);
graphics.Shaders.World3D.BeginPass(shaderpass);
}
} }
} }
} }
@ -634,17 +636,23 @@ namespace CodeImp.DoomBuilder.Rendering
// Only do this sector when a vertexbuffer is created // Only do this sector when a vertexbuffer is created
if(t.GeometryBuffer != null) if(t.GeometryBuffer != null)
{ {
// Highlight this object? // Determine the shader pass we want to use for this object
if(t == highlighted) int wantedshaderpass = ((t == highlighted) || t.Selected) ? highshaderpass : shaderpass;
// Switch shader pass?
if(currentshaderpass != wantedshaderpass)
{ {
// Temporarely switch shader and use a highlight color
graphics.Shaders.World3D.EndPass(); graphics.Shaders.World3D.EndPass();
Color4 highlight = General.Colors.Highlight.ToColorValue(); graphics.Shaders.World3D.BeginPass(wantedshaderpass);
highlight.Alpha = highlightglow; currentshaderpass = wantedshaderpass;
graphics.Shaders.World3D.SetHighlightColor(highlight.ToArgb());
graphics.Shaders.World3D.BeginPass(shaderpass + 2);
} }
// Set the color to use
Color4 highlightcolor = new Color4(0);
if(t.Selected) highlightcolor = General.Colors.Selection.ToColorValue(highlightglow);
if(t == highlighted) highlightcolor = Color4.Lerp(highlightcolor, General.Colors.Highlight.ToColorValue(), highlightglow);
graphics.Shaders.World3D.SetHighlightColor(highlightcolor.ToArgb());
// Create the matrix for positioning / rotation // Create the matrix for positioning / rotation
world = t.Orientation; world = t.Orientation;
if(t.Billboard) world = Matrix.Multiply(world, billboard); if(t.Billboard) world = Matrix.Multiply(world, billboard);
@ -657,14 +665,6 @@ namespace CodeImp.DoomBuilder.Rendering
// Render! // Render!
graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, t.Triangles); graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, t.Triangles);
// Reset highlight settings
if(t == highlighted)
{
graphics.Shaders.World3D.EndPass();
graphics.Shaders.World3D.SetHighlightColor(0);
graphics.Shaders.World3D.BeginPass(shaderpass);
}
} }
} }
} }

View file

@ -42,6 +42,7 @@ namespace CodeImp.DoomBuilder.VisualModes
{ {
public interface IVisualPickable public interface IVisualPickable
{ {
bool Selected { get; set; }
bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir); bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir);
bool PickAccurate(Vector3D from, Vector3D to, Vector3D dir, ref float u_ray); bool PickAccurate(Vector3D from, Vector3D to, Vector3D dir, ref float u_ray);
} }

View file

@ -55,6 +55,9 @@ namespace CodeImp.DoomBuilder.VisualModes
private PixelColor modulatecolor; private PixelColor modulatecolor;
private Color4 modcolor4; private Color4 modcolor4;
// Selected?
protected bool selected;
// Elements that this geometry is bound to // Elements that this geometry is bound to
// Only the sector is required, sidedef is only for walls // Only the sector is required, sidedef is only for walls
private VisualSector sector; private VisualSector sector;
@ -112,6 +115,11 @@ namespace CodeImp.DoomBuilder.VisualModes
/// </summary> /// </summary>
public Sidedef Sidedef { get { return sidedef; } } public Sidedef Sidedef { get { return sidedef; } }
/// <summary>
/// Selected or not? This is only used by the core to determine what color to draw it with.
/// </summary>
public bool Selected { get { return selected; } set { selected = value; } }
#endregion #endregion
#region ================== Constructor / Destructor #region ================== Constructor / Destructor

View file

@ -70,6 +70,9 @@ namespace CodeImp.DoomBuilder.VisualModes
private float cameradistance; private float cameradistance;
private int cagecolor; private int cagecolor;
// Selected?
protected bool selected;
// Disposing // Disposing
private bool isdisposed = false; private bool isdisposed = false;
@ -112,6 +115,11 @@ namespace CodeImp.DoomBuilder.VisualModes
/// </summary> /// </summary>
public bool IsDisposed { get { return isdisposed; } } public bool IsDisposed { get { return isdisposed; } }
/// <summary>
/// Selected or not? This is only used by the core to determine what color to draw it with.
/// </summary>
public bool Selected { get { return selected; } set { selected = value; } }
#endregion #endregion
#region ================== Constructor / Destructor #region ================== Constructor / Destructor

View file

@ -247,6 +247,7 @@
<Compile Include="FindReplace\FindThingThingRef.cs" /> <Compile Include="FindReplace\FindThingThingRef.cs" />
<Compile Include="FindReplace\FindThingType.cs" /> <Compile Include="FindReplace\FindThingType.cs" />
<Compile Include="FindReplace\FindVertexNumber.cs" /> <Compile Include="FindReplace\FindVertexNumber.cs" />
<Compile Include="VisualModes\VisualActionResult.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Resources\ViewSelectionIndex.png" /> <None Include="Resources\ViewSelectionIndex.png" />

View file

@ -139,7 +139,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Mouse must be inside window // Mouse must be inside window
if(!mouseinside) return; if(!mouseinside) return;
General.Interface.DisplayStatus(StatusType.Action, "Places Visual Mode camera start thing."); General.Interface.DisplayStatus(StatusType.Action, "Placed Visual Mode camera start thing.");
// Go for all things // Go for all things
List<Thing> things = new List<Thing>(General.Map.Map.Things); List<Thing> things = new List<Thing>(General.Map.Map.Things);

View file

@ -48,11 +48,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected BaseVisualMode mode; protected BaseVisualMode mode;
protected long setuponloadedtexture; protected long setuponloadedtexture;
// 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;
#endregion #endregion
#region ================== Properties #region ================== Properties
new public BaseVisualSector Sector { get { return (BaseVisualSector)base.Sector; } } new public BaseVisualSector Sector { get { return (BaseVisualSector)base.Sector; } }
public bool Changed { get { return changed; } set { changed |= value; } }
#endregion #endregion
@ -75,7 +81,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected void UpdateSectorGeometry(bool includeneighbours) protected void UpdateSectorGeometry(bool includeneighbours)
{ {
// Rebuild sector // Rebuild sector
Sector.Rebuild(); Sector.Changed = true;
// Go for all things in this sector // Go for all things in this sector
foreach(Thing t in General.Map.Map.Things) foreach(Thing t in General.Map.Map.Things)
@ -86,7 +92,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
// Update thing // Update thing
BaseVisualThing vt = (mode.GetVisualThing(t) as BaseVisualThing); BaseVisualThing vt = (mode.GetVisualThing(t) as BaseVisualThing);
vt.Setup(); vt.Changed = true;
} }
} }
} }
@ -94,16 +100,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(includeneighbours) if(includeneighbours)
{ {
// Also rebuild surrounding sectors, because outside sidedefs may need to be adjusted // Also rebuild surrounding sectors, because outside sidedefs may need to be adjusted
Dictionary<Sector, int> rebuilt = new Dictionary<Sector, int>();
foreach(Sidedef sd in Sector.Sector.Sidedefs) foreach(Sidedef sd in Sector.Sector.Sidedefs)
{ {
if((sd.Other != null) && !rebuilt.ContainsKey(sd.Other.Sector)) if(sd.Other != null)
{ {
if(mode.VisualSectorExists(sd.Other.Sector)) if(mode.VisualSectorExists(sd.Other.Sector))
{ {
BaseVisualSector bvs = (BaseVisualSector)mode.GetVisualSector(sd.Other.Sector); BaseVisualSector bvs = (BaseVisualSector)mode.GetVisualSector(sd.Other.Sector);
rebuilt.Add(sd.Other.Sector, 1); bvs.Changed = true;
bvs.Rebuild();
} }
} }
} }
@ -116,8 +120,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Unused // Unused
public abstract bool Setup(); public abstract bool Setup();
public virtual void OnSelectBegin() { } public virtual void OnSelectBegin(){ }
public virtual void OnSelectEnd() { }
public virtual void OnEditBegin() { } public virtual void OnEditBegin() { }
public virtual void OnMouseMove(MouseEventArgs e) { } public virtual void OnMouseMove(MouseEventArgs e) { }
public virtual void OnChangeTextureOffset(int horizontal, int vertical) { } public virtual void OnChangeTextureOffset(int horizontal, int vertical) { }
@ -131,6 +134,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
public virtual void OnDelete() { } public virtual void OnDelete() { }
protected virtual void SetTexture(string texturename) { } protected virtual void SetTexture(string texturename) { }
// Select or deselect
public virtual void OnSelectEnd()
{
this.selected = !this.selected;
}
// Processing // Processing
public virtual void OnProcess(double deltatime) public virtual void OnProcess(double deltatime)
{ {

View file

@ -129,7 +129,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
Sidedef.SetTextureMid(General.Settings.DefaultTexture); Sidedef.SetTextureMid(General.Settings.DefaultTexture);
// Update // Update
Sector.Rebuild(); Sector.Changed = true;
// Other side as well // Other side as well
if(string.IsNullOrEmpty(Sidedef.Other.MiddleTexture) || (Sidedef.Other.MiddleTexture[0] == '-')) if(string.IsNullOrEmpty(Sidedef.Other.MiddleTexture) || (Sidedef.Other.MiddleTexture[0] == '-'))
@ -138,7 +138,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Update // Update
VisualSector othersector = mode.GetVisualSector(Sidedef.Other.Sector); VisualSector othersector = mode.GetVisualSector(Sidedef.Other.Sector);
if(othersector is BaseVisualSector) (othersector as BaseVisualSector).Rebuild(); if(othersector is BaseVisualSector) (othersector as BaseVisualSector).Changed = true;
} }
} }
} }
@ -152,7 +152,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
SetTexture("-"); SetTexture("-");
// Update // Update
Sector.Rebuild(); Sector.Changed = true;
} }
// Processing // Processing
@ -435,11 +435,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Update sectors on both sides // Update sectors on both sides
BaseVisualSector front = (BaseVisualSector)mode.GetVisualSector(Sidedef.Sector); BaseVisualSector front = (BaseVisualSector)mode.GetVisualSector(Sidedef.Sector);
if(front != null) front.Rebuild(); if(front != null) front.Changed = true;
if(Sidedef.Other != null) if(Sidedef.Other != null)
{ {
BaseVisualSector back = (BaseVisualSector)mode.GetVisualSector(Sidedef.Other.Sector); BaseVisualSector back = (BaseVisualSector)mode.GetVisualSector(Sidedef.Other.Sector);
if(back != null) back.Rebuild(); if(back != null) back.Changed = true;
} }
mode.ShowTargetInfo(); mode.ShowTargetInfo();
} }
@ -471,6 +471,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
else else
{ {
// Add/remove selection // Add/remove selection
this.selected = !this.selected;
} }
} }
@ -485,7 +486,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
List<Linedef> lines = new List<Linedef>(); List<Linedef> lines = new List<Linedef>();
lines.Add(this.Sidedef.Line); lines.Add(this.Sidedef.Line);
DialogResult result = General.Interface.ShowEditLinedefs(lines); DialogResult result = General.Interface.ShowEditLinedefs(lines);
if(result == DialogResult.OK) (this.Sector as BaseVisualSector).Rebuild(); if(result == DialogResult.OK) (this.Sector as BaseVisualSector).Changed = true;
} }
} }
} }
@ -567,7 +568,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
Sector.Sector.UpdateCache(); Sector.Sector.UpdateCache();
// Rebuild sector // Rebuild sector
Sector.Rebuild(); Sector.Changed = true;
// Go for all things in this sector // Go for all things in this sector
foreach(Thing t in General.Map.Map.Things) foreach(Thing t in General.Map.Map.Things)
@ -578,7 +579,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
// Update thing // Update thing
BaseVisualThing vt = (mode.GetVisualThing(t) as BaseVisualThing); BaseVisualThing vt = (mode.GetVisualThing(t) as BaseVisualThing);
vt.Setup(); vt.Changed = true;
} }
} }
} }

View file

@ -61,13 +61,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Variables #region ================== Variables
// Gravity vector
private Vector3D gravity;
// Object picking // Object picking
private VisualPickResult target; private VisualPickResult target;
private double lastpicktime; private double lastpicktime;
private bool locktarget; private bool locktarget;
// Gravity vector // This is true when a selection was made because the action is performed
private Vector3D gravity; // on an object that was not selected. In this case the previous selection
// is cleared and the targeted object is temporarely selected to perform
// the action on. After the action is completed, the object is deselected.
private bool temporaryselection;
// Actions
private int lastchangeoffsetticket;
#endregion #endregion
@ -75,6 +84,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public IRenderer3D Renderer { get { return renderer; } } public IRenderer3D Renderer { get { return renderer; } }
public bool IsTemporarySelection { get { return temporaryselection; } }
#endregion #endregion
#region ================== Constructor / Disposer #region ================== Constructor / Disposer
@ -106,6 +117,36 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods #region ================== Methods
// This is called before an action is performed
private void PreAction(string multiundodescription)
{
int undogrouptag = 0;
PickTargetUnlocked();
// If the action is not performed on a selected object, clear the
// current selection and make a temporary selection for the target.
if(!target.picked.Selected)
{
temporaryselection = true;
ClearSelection();
target.picked.Selected = true;
if(target.picked is BaseVisualGeometrySector)
undogrouptag = (target.picked as BaseVisualGeometrySector).Sector.Sector.FixedIndex;
}
// Make an undo level
//lastundoticket = General.Map.UndoRedo.CreateUndo(multiundodescription, undogroup, undogrouptag);
}
// This is called after an action is performed
private void PostAction(VisualActionResult result)
{
UpdateChangedObjects();
ShowTargetInfo();
}
// This creates a visual sector // This creates a visual sector
protected override VisualSector CreateVisualSector(Sector s) protected override VisualSector CreateVisualSector(Sector s)
{ {
@ -117,7 +158,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected override VisualThing CreateVisualThing(Thing t) protected override VisualThing CreateVisualThing(Thing t)
{ {
BaseVisualThing vt = new BaseVisualThing(this, t); BaseVisualThing vt = new BaseVisualThing(this, t);
if(vt.Setup()) return vt; else return null; return vt.Setup() ? vt : null;
} }
// This locks the target so that it isn't changed until unlocked // This locks the target so that it isn't changed until unlocked
@ -188,6 +229,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
} }
// This updates the VisualSectors and VisualThings that have their Changed property set
private void UpdateChangedObjects()
{
foreach(KeyValuePair<Sector, VisualSector> vs in allsectors)
{
BaseVisualSector bvs = (BaseVisualSector)vs.Value;
if(bvs.Changed) bvs.Rebuild();
}
foreach(KeyValuePair<Thing, VisualThing> vt in allthings)
{
BaseVisualThing bvt = (BaseVisualThing)vt.Value;
if(bvt.Changed) bvt.Setup();
}
}
#endregion #endregion
#region ================== Events #region ================== Events
@ -321,17 +378,44 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Actions #region ================== Actions
[BeginAction("clearselection", BaseAction = true)]
public void ClearSelection()
{
foreach(KeyValuePair<Sector, VisualSector> vs in allsectors)
{
BaseVisualSector bvs = (BaseVisualSector)vs.Value;
if(bvs.Floor != null) bvs.Floor.Selected = false;
if(bvs.Ceiling != null) bvs.Ceiling.Selected = false;
foreach(Sidedef sd in vs.Key.Sidedefs)
{
List<VisualGeometry> sidedefgeos = bvs.GetSidedefGeometry(sd);
foreach(VisualGeometry sdg in sidedefgeos)
{
sdg.Selected = false;
}
}
}
foreach(KeyValuePair<Thing, VisualThing> vt in allthings)
{
BaseVisualThing bvt = (BaseVisualThing)vt.Value;
bvt.Selected = false;
}
}
[BeginAction("visualselect", BaseAction = true)] [BeginAction("visualselect", BaseAction = true)]
public void BeginSelect() public void BeginSelect()
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnSelectBegin(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnSelectBegin();
UpdateChangedObjects();
} }
[EndAction("visualselect", BaseAction = true)] [EndAction("visualselect", BaseAction = true)]
public void EndSelect() public void EndSelect()
{ {
if(target.picked != null) (target.picked as IVisualEventReceiver).OnSelectEnd(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnSelectEnd();
UpdateChangedObjects();
} }
[BeginAction("visualedit", BaseAction = true)] [BeginAction("visualedit", BaseAction = true)]
@ -339,12 +423,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnEditBegin(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnEditBegin();
UpdateChangedObjects();
} }
[EndAction("visualedit", BaseAction = true)] [EndAction("visualedit", BaseAction = true)]
public void EndEdit() public void EndEdit()
{ {
if(target.picked != null) (target.picked as IVisualEventReceiver).OnEditEnd(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnEditEnd();
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -353,6 +439,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTargetHeight(8); if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTargetHeight(8);
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -361,6 +448,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTargetHeight(-8); if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTargetHeight(-8);
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -369,6 +457,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTargetHeight(1); if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTargetHeight(1);
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -377,6 +466,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTargetHeight(-1); if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTargetHeight(-1);
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -392,6 +482,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTargetBrightness(true); if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTargetBrightness(true);
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -400,6 +491,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTargetBrightness(false); if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTargetBrightness(false);
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -408,6 +500,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(-1, 0); if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(-1, 0);
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -416,6 +509,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(1, 0); if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(1, 0);
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -424,6 +518,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(0, -1); if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(0, -1);
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -432,6 +527,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(0, 1); if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(0, 1);
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -440,6 +536,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(-8, 0); if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(-8, 0);
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -448,6 +545,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(8, 0); if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(8, 0);
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -456,6 +554,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(0, -8); if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(0, -8);
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -464,6 +563,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(0, 8); if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(0, 8);
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -474,6 +574,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
renderer.SetCrosshairBusy(true); renderer.SetCrosshairBusy(true);
General.Interface.RedrawDisplay(); General.Interface.RedrawDisplay();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnSelectTexture(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnSelectTexture();
UpdateChangedObjects();
renderer.SetCrosshairBusy(false); renderer.SetCrosshairBusy(false);
ShowTargetInfo(); ShowTargetInfo();
} }
@ -483,6 +584,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnCopyTexture(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnCopyTexture();
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -491,6 +593,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnPasteTexture(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnPasteTexture();
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -501,6 +604,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
renderer.SetCrosshairBusy(true); renderer.SetCrosshairBusy(true);
General.Interface.RedrawDisplay(); General.Interface.RedrawDisplay();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnTextureAlign(true, false); if(target.picked != null) (target.picked as IVisualEventReceiver).OnTextureAlign(true, false);
UpdateChangedObjects();
renderer.SetCrosshairBusy(false); renderer.SetCrosshairBusy(false);
ShowTargetInfo(); ShowTargetInfo();
} }
@ -512,6 +616,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
renderer.SetCrosshairBusy(true); renderer.SetCrosshairBusy(true);
General.Interface.RedrawDisplay(); General.Interface.RedrawDisplay();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnTextureAlign(false, true); if(target.picked != null) (target.picked as IVisualEventReceiver).OnTextureAlign(false, true);
UpdateChangedObjects();
renderer.SetCrosshairBusy(false); renderer.SetCrosshairBusy(false);
ShowTargetInfo(); ShowTargetInfo();
} }
@ -521,6 +626,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnToggleUpperUnpegged(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnToggleUpperUnpegged();
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -529,6 +635,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnToggleLowerUnpegged(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnToggleLowerUnpegged();
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -553,6 +660,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnResetTextureOffset(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnResetTextureOffset();
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -561,6 +669,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnTextureFloodfill(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnTextureFloodfill();
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -569,6 +678,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnCopyTextureOffsets(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnCopyTextureOffsets();
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -577,6 +687,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnPasteTextureOffsets(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnPasteTextureOffsets();
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -585,6 +696,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnCopyProperties(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnCopyProperties();
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -593,6 +705,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnPasteProperties(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnPasteProperties();
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -601,6 +714,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnInsert(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnInsert();
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }
@ -609,6 +723,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
PickTargetUnlocked(); PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnDelete(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnDelete();
UpdateChangedObjects();
ShowTargetInfo(); ShowTargetInfo();
} }

View file

@ -50,12 +50,16 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected VisualCeiling ceiling; protected VisualCeiling ceiling;
protected Dictionary<Sidedef, VisualSidedefParts> sides; protected Dictionary<Sidedef, VisualSidedefParts> sides;
// If this is set to true, the sector will be rebuilt after the action is performed.
protected bool changed;
#endregion #endregion
#region ================== Properties #region ================== Properties
public VisualFloor Floor { get { return floor; } } public VisualFloor Floor { get { return floor; } }
public VisualCeiling Ceiling { get { return ceiling; } } public VisualCeiling Ceiling { get { return ceiling; } }
public bool Changed { get { return changed; } set { changed |= value; } }
#endregion #endregion
@ -100,30 +104,34 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.ClearGeometry(); base.ClearGeometry();
// Create floor // Create floor
floor = new VisualFloor(mode, this); if(floor == null) floor = new VisualFloor(mode, this);
if(floor.Setup()) base.AddGeometry(floor); if(floor.Setup()) base.AddGeometry(floor);
// Create ceiling // Create ceiling
ceiling = new VisualCeiling(mode, this); if(ceiling == null) ceiling = new VisualCeiling(mode, this);
if(ceiling.Setup()) base.AddGeometry(ceiling); if(ceiling.Setup()) base.AddGeometry(ceiling);
// Go for all sidedefs // Go for all sidedefs
Dictionary<Sidedef, VisualSidedefParts> oldsides = sides ?? new Dictionary<Sidedef, VisualSidedefParts>(1);
sides = new Dictionary<Sidedef, VisualSidedefParts>(base.Sector.Sidedefs.Count); sides = new Dictionary<Sidedef, VisualSidedefParts>(base.Sector.Sidedefs.Count);
foreach(Sidedef sd in base.Sector.Sidedefs) foreach(Sidedef sd in base.Sector.Sidedefs)
{ {
// VisualSidedef already exists?
VisualSidedefParts parts = oldsides.ContainsKey(sd) ? oldsides[sd] : new VisualSidedefParts();
// Doublesided or singlesided? // Doublesided or singlesided?
if(sd.Other != null) if(sd.Other != null)
{ {
// Create upper part // Create upper part
VisualUpper vu = new VisualUpper(mode, this, sd); VisualUpper vu = parts.upper ?? new VisualUpper(mode, this, sd);
if(vu.Setup()) base.AddGeometry(vu); if(vu.Setup()) base.AddGeometry(vu);
// Create lower part // Create lower part
VisualLower vl = new VisualLower(mode, this, sd); VisualLower vl = parts.lower ?? new VisualLower(mode, this, sd);
if(vl.Setup()) base.AddGeometry(vl); if(vl.Setup()) base.AddGeometry(vl);
// Create middle part // Create middle part
VisualMiddleDouble vm = new VisualMiddleDouble(mode, this, sd); VisualMiddleDouble vm = parts.middledouble ?? new VisualMiddleDouble(mode, this, sd);
if(vm.Setup()) base.AddGeometry(vm); if(vm.Setup()) base.AddGeometry(vm);
// Store // Store
@ -132,13 +140,16 @@ namespace CodeImp.DoomBuilder.BuilderModes
else else
{ {
// Create middle part // Create middle part
VisualMiddleSingle vm = new VisualMiddleSingle(mode, this, sd); VisualMiddleSingle vm = parts.middlesingle ?? new VisualMiddleSingle(mode, this, sd);
if(vm.Setup()) base.AddGeometry(vm); if(vm.Setup()) base.AddGeometry(vm);
// Store // Store
sides.Add(sd, new VisualSidedefParts(vm)); sides.Add(sd, new VisualSidedefParts(vm));
} }
} }
// Done
changed = false;
} }
// This returns the visual sidedef parts for a given sidedef // This returns the visual sidedef parts for a given sidedef

View file

@ -59,10 +59,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Undo/redo // Undo/redo
private int undoticket; private int undoticket;
// If this is set to true, the thing will be rebuilt after the action is performed.
protected bool changed;
#endregion #endregion
#region ================== Properties #region ================== Properties
public bool Changed { get { return changed; } set { changed |= value; } }
#endregion #endregion
#region ================== Constructor / Setup #region ================== Constructor / Setup
@ -193,6 +198,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
boxp2 = new Vector3D(pos.x + info.Radius, pos.y + info.Radius, pos.z + info.Height); boxp2 = new Vector3D(pos.x + info.Radius, pos.y + info.Radius, pos.z + info.Height);
// Done // Done
changed = false;
return true; return true;
} }
@ -348,7 +354,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Unused // Unused
public virtual void OnSelectBegin() { } public virtual void OnSelectBegin() { }
public virtual void OnSelectEnd() { }
public virtual void OnEditBegin() { } public virtual void OnEditBegin() { }
public virtual void OnMouseMove(MouseEventArgs e) { } public virtual void OnMouseMove(MouseEventArgs e) { }
public virtual void OnChangeTargetBrightness(bool up) { } public virtual void OnChangeTargetBrightness(bool up) { }
@ -370,6 +375,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Return texture name // Return texture name
public virtual string GetTextureName() { return ""; } public virtual string GetTextureName() { return ""; }
// Select or deselect
public virtual void OnSelectEnd()
{
this.selected = !this.selected;
}
// Copy properties // Copy properties
public virtual void OnCopyProperties() public virtual void OnCopyProperties()
{ {
@ -419,7 +430,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.DisplayStatus(StatusType.Action, "Changed thing height to " + Thing.Position.z + "."); General.Interface.DisplayStatus(StatusType.Action, "Changed thing height to " + Thing.Position.z + ".");
this.Setup(); this.Changed = true;
} }
} }

View file

@ -0,0 +1,43 @@

#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;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using CodeImp.DoomBuilder.Windows;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.VisualModes;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
internal struct VisualActionResult
{
public string displaystatus;
}
}