working on visual mode

This commit is contained in:
codeimp 2008-12-06 00:28:49 +00:00
parent 0102cf3166
commit 9d8060be0c
10 changed files with 134 additions and 20 deletions

View file

@ -38,6 +38,7 @@ namespace CodeImp.DoomBuilder.Actions
// The action to bind to
protected string action;
protected bool baseaction;
protected string library;
#endregion
@ -47,6 +48,12 @@ namespace CodeImp.DoomBuilder.Actions
/// Set to true to indicate this is a core Doom Builder action when used within a plugin.
/// </summary>
public bool BaseAction { get { return baseaction; } set { baseaction = value; } }
/// <summary>
/// Set this to the name of the plugin library when this action is defined by another plugin. The library name is the filename without extension.
/// </summary>
public string Library { get { return library; } set { library = value; } }
internal string ActionName { get { return action; } }
#endregion
@ -62,6 +69,7 @@ namespace CodeImp.DoomBuilder.Actions
// Initialize
this.action = action;
this.baseaction = false;
this.library = "";
}
#endregion
@ -73,7 +81,9 @@ namespace CodeImp.DoomBuilder.Actions
{
string asmname;
if(baseaction)
if(library.Length > 0)
asmname = library.ToLowerInvariant();
else if(baseaction)
asmname = General.ThisAssembly.GetName().Name.ToLowerInvariant();
else
asmname = asm.GetName().Name.ToLowerInvariant();
@ -81,19 +91,6 @@ namespace CodeImp.DoomBuilder.Actions
return asmname + "_" + action;
}
// This makes the proper name
public string GetFullActionName(Assembly asm, bool baseaction, string actionname)
{
string asmname;
if(baseaction)
asmname = General.ThisAssembly.GetName().Name.ToLowerInvariant();
else
asmname = asm.GetName().Name.ToLowerInvariant();
return asmname + "_" + actionname;
}
#endregion
}
}

View file

@ -267,3 +267,43 @@ errorcheckmode
allowmouse = true;
allowscroll = true;
}
lowersector8
{
title = "Lower Floor/Ceiling by 8 mp";
category = "visual";
description = "Lowers the targeted or selected floors/ceilings by 8 mp.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
}
raisesector8
{
title = "Raise Floor/Ceiling by 8 mp";
category = "visual";
description = "Raises the targeted or selected floors/ceilings by 8 mp.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
}
lowersector1
{
title = "Lower Floor/Ceiling by 1 mp";
category = "visual";
description = "Lowers the targeted or selected floors/ceilings by 1 mp.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
}
raisesector1
{
title = "Raise Floor/Ceiling by 1 mp";
category = "visual";
description = "Raises the targeted or selected floors/ceilings by 1 mp.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
}

View file

@ -61,6 +61,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods
// This changes the height
public abstract void ChangeHeight(int amount);
#endregion
#region ================== Events

View file

@ -152,6 +152,29 @@ namespace CodeImp.DoomBuilder.BuilderModes
target = newtarget;
}
// This changes the target's height
private void ChangeTargetHeight(int amount)
{
if(target.geometry is BaseVisualGeometrySector)
{
BaseVisualGeometrySector vgs = (target.geometry as BaseVisualGeometrySector);
vgs.ChangeHeight(amount);
// Rebuild sector
(vgs.Sector as BaseVisualSector).Rebuild();
// Also rebuild surrounding sectors, because outside sidedefs may need to be adjusted
foreach(Sidedef sd in vgs.Sector.Sector.Sidedefs)
{
if((sd.Other != null) && VisualSectorExists(sd.Other.Sector))
{
BaseVisualSector bvs = (BaseVisualSector)GetVisualSector(sd.Other.Sector);
bvs.Rebuild();
}
}
}
}
#endregion
#region ================== Events
@ -224,6 +247,30 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(target.geometry != null) (target.geometry as BaseVisualGeometry).OnEditEnd();
}
[BeginAction("raisesector8")]
public void RaiseSector8()
{
ChangeTargetHeight(8);
}
[BeginAction("lowersector8")]
public void LowerSector8()
{
ChangeTargetHeight(-8);
}
[BeginAction("raisesector1")]
public void RaiseSector1()
{
ChangeTargetHeight(1);
}
[BeginAction("lowersector1")]
public void LowerSector1()
{
ChangeTargetHeight(-1);
}
#endregion
}
}

View file

@ -123,6 +123,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods
// This changes the height
public override void ChangeHeight(int amount)
{
General.Map.UndoRedo.CreateUndo("Change ceiling height", UndoGroup.CeilingHeightChange, this.Sector.Sector.Index);
this.Sector.Sector.CeilHeight += amount;
}
// This performs a fast test in object picking
public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)
{

View file

@ -110,6 +110,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods
// This changes the height
public override void ChangeHeight(int amount)
{
General.Map.UndoRedo.CreateUndo("Change floor height", UndoGroup.FloorHeightChange, this.Sector.Sector.Index);
this.Sector.Sector.FloorHeight += amount;
}
// This performs a fast test in object picking
public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)
{

View file

@ -32,8 +32,10 @@ namespace CodeImp.DoomBuilder.Editing
{
public enum UndoGroup : int
{
None = 0,
FloorTextureChange = 1,
CeilingTextureChange = 2
None,
FloorTextureChange,
CeilingTextureChange,
FloorHeightChange,
CeilingHeightChange,
}
}

View file

@ -567,6 +567,18 @@ namespace CodeImp.DoomBuilder.VisualModes
// This creates a visual sector
protected abstract VisualSector CreateVisualSector(Sector s);
// This returns a visual sector
protected VisualSector GetVisualSector(Sector s)
{
return allsectors[s];
}
// This returns true when a visual sector has been created for the specified sector
protected bool VisualSectorExists(Sector s)
{
return allsectors.ContainsKey(s);
}
// This fills the blockmap
protected virtual void FillBlockMap()
{

View file

@ -96,7 +96,6 @@ namespace CodeImp.DoomBuilder.VisualModes
if(!isdisposed)
{
// Clean up
foreach(VisualGeometry g in allgeometry) g.Sector = null;
if(geobuffer != null) geobuffer.Dispose();
geobuffer = null;
@ -195,7 +194,6 @@ namespace CodeImp.DoomBuilder.VisualModes
/// </summary>
public void ClearGeometry()
{
foreach(VisualGeometry g in allgeometry) g.Sector = null;
allgeometry.Clear();
fixedgeometry.Clear();
sidedefgeometry.Clear();

View file

@ -351,6 +351,7 @@ namespace CodeImp.DoomBuilder.Windows
{
// Resume any exclusive mouse input
ResumeExclusiveMouseInput();
display.Focus();
}
// Window loses focus