@ Renamed sector fixed index to resolve conflict with real index lookup functions

All info panels now show the current real index of the element (as it would be when saved or loaded at that moment)
This commit is contained in:
codeimp 2009-03-10 06:46:02 +00:00
parent 565e0a1317
commit eaffa440be
19 changed files with 68 additions and 45 deletions

View file

@ -45,6 +45,7 @@
<ItemGroup>
<Compile Include="ClassicModes\BaseClassicMode.cs" />
<Compile Include="ClassicModes\BrightnessMode.cs" />
<Compile Include="ClassicModes\HeightsMode.cs" />
<Compile Include="ClassicModes\ErrorCheckMode.cs" />
<Compile Include="ClassicModes\EditSelectionMode.cs" />
<Compile Include="ClassicModes\CurveLinedefsMode.cs" />
@ -224,6 +225,9 @@
<ItemGroup>
<None Include="Resources\FlipSelectionV.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\HeightsMode.png" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View file

@ -290,7 +290,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(update)
{
UpdateOverlay();
UpdateOverlay();
renderer.Present();
}

View file

@ -44,6 +44,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
private Sector sector;
private List<Vertex> vertices;
private int index;
#endregion
@ -62,6 +63,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.viewobjects.Add(s);
foreach(Vertex vv in v) this.viewobjects.Add(vv);
this.description = "This sector is not a closed region and could cause problems with clipping and rendering in the game. The 'leaks' in the sector are indicated by the colored vertices.";
this.index = s.Map.GetIndexForSector(s);
}
#endregion
@ -71,7 +73,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// This must return the string that is displayed in the listbox
public override string ToString()
{
return "Sector " + sector.Index + " is not closed";
return "Sector " + index + " is not closed";
}
// Rendering

View file

@ -112,7 +112,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(replacewith != null) s.Tag = replacetag;
// Add to list
objs.Add(new FindReplaceObject(s, "Sector " + s.Index));
objs.Add(new FindReplaceObject(s, "Sector " + s.Map.GetIndexForSector(s)));
}
}
}

View file

@ -66,6 +66,16 @@ brightnessmode
allowscroll = true;
}
heightsmode
{
title = "Sector Heights Mode";
category = "modes";
description = "Switches to sectors heights editing mode.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
}
thingsmode
{
title = "Things Mode";

View file

@ -285,7 +285,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Sector brightness change
public virtual void OnChangeTargetBrightness(bool up)
{
General.Map.UndoRedo.CreateUndo("Change sector brightness", UndoGroup.SectorBrightnessChange, Sector.Sector.Index);
General.Map.UndoRedo.CreateUndo("Change sector brightness", UndoGroup.SectorBrightnessChange, Sector.Sector.FixedIndex);
if(up)
Sector.Sector.Brightness = General.Map.Config.BrightnessLevels.GetNextHigher(Sector.Sector.Brightness);

View file

@ -533,7 +533,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public virtual void OnChangeTargetBrightness(bool up)
{
// Change brightness
General.Map.UndoRedo.CreateUndo("Change sector brightness", UndoGroup.SectorBrightnessChange, Sector.Sector.Index);
General.Map.UndoRedo.CreateUndo("Change sector brightness", UndoGroup.SectorBrightnessChange, Sector.Sector.FixedIndex);
if(up)
Sector.Sector.Brightness = General.Map.Config.BrightnessLevels.GetNextHigher(Sector.Sector.Brightness);

View file

@ -147,7 +147,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// This changes the height
protected override void ChangeHeight(int amount)
{
General.Map.UndoRedo.CreateUndo("Change ceiling height", UndoGroup.CeilingHeightChange, this.Sector.Sector.Index);
General.Map.UndoRedo.CreateUndo("Change ceiling height", UndoGroup.CeilingHeightChange, this.Sector.Sector.FixedIndex);
this.Sector.Sector.CeilHeight += amount;
General.Interface.DisplayStatus(StatusType.Action, "Changed ceiling height to " + Sector.Sector.CeilHeight + ".");
}

View file

@ -134,7 +134,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// This changes the height
protected override void ChangeHeight(int amount)
{
General.Map.UndoRedo.CreateUndo("Change floor height", UndoGroup.FloorHeightChange, this.Sector.Sector.Index);
General.Map.UndoRedo.CreateUndo("Change floor height", UndoGroup.FloorHeightChange, this.Sector.Sector.FixedIndex);
this.Sector.Sector.FloorHeight += amount;
General.Interface.DisplayStatus(StatusType.Action, "Changed floor height to " + Sector.Sector.FloorHeight + ".");
}

View file

@ -119,6 +119,7 @@ namespace CodeImp.DoomBuilder.Controls
peggedness = "None";
// Linedef info
infopanel.Text = " Lindedef " + l.Map.GetIndexForLinedef(l) + " ";
action.Text = actioninfo;
length.Text = l.Length.ToString("0.##");
angle.Text = l.AngleDeg.ToString() + "\u00B0";
@ -182,6 +183,7 @@ namespace CodeImp.DoomBuilder.Controls
if(l.Front != null)
{
// Show sidedef info
frontpanel.Text = " Front Sidedef " + l.Map.GetIndexForSidedef(l.Front) + " ";
frontoffset.Text = l.Front.OffsetX + ", " + l.Front.OffsetY;
fronthighname.Text = l.Front.HighTexture;
frontmidname.Text = l.Front.MiddleTexture;
@ -196,6 +198,7 @@ namespace CodeImp.DoomBuilder.Controls
else
{
// Show no info
frontpanel.Text = " Front Sidedef ";
frontoffsetlabel.Enabled = false;
frontoffset.Enabled = false;
frontpanel.Enabled = false;
@ -212,6 +215,7 @@ namespace CodeImp.DoomBuilder.Controls
if(l.Back != null)
{
// Show sidedef info
backpanel.Text = " Back Sidedef " + l.Map.GetIndexForSidedef(l.Back) + " ";
backoffset.Text = l.Back.OffsetX + ", " + l.Back.OffsetY;
backhighname.Text = l.Back.HighTexture;
backmidname.Text = l.Back.MiddleTexture;
@ -226,6 +230,7 @@ namespace CodeImp.DoomBuilder.Controls
else
{
// Show no info
backpanel.Text = " Back Sidedef ";
backoffsetlabel.Enabled = false;
backoffset.Enabled = false;
backpanel.Enabled = false;

View file

@ -56,7 +56,7 @@ namespace CodeImp.DoomBuilder.Controls
effectinfo = s.Effect.ToString() + " - Unknown";
// Sector info
sectorinfo.Text = " Sector " + s.Index.ToString() + " ";
sectorinfo.Text = " Sector " + s.Map.GetIndexForSector(s) + " ";
effect.Text = effectinfo;
ceiling.Text = s.CeilHeight.ToString();
floor.Text = s.FloorHeight.ToString();

View file

@ -131,6 +131,7 @@ namespace CodeImp.DoomBuilder.Controls
}
// Thing info
infopanel.Text = " Thing " + t.Map.GetIndexForThing(t) + " ";
type.Text = t.Type + " - " + ti.Title;
action.Text = actioninfo;
position.Text = t.Position.x.ToString() + ", " + t.Position.y.ToString() + ", " + zinfo;

View file

@ -28,24 +28,23 @@ namespace CodeImp.DoomBuilder.Controls
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.GroupBox groupBox1;
System.Windows.Forms.Label label1;
this.vertexinfo = new System.Windows.Forms.GroupBox();
this.position = new System.Windows.Forms.Label();
groupBox1 = new System.Windows.Forms.GroupBox();
label1 = new System.Windows.Forms.Label();
groupBox1.SuspendLayout();
this.vertexinfo.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
// vertexinfo
//
groupBox1.Controls.Add(this.position);
groupBox1.Controls.Add(label1);
groupBox1.Location = new System.Drawing.Point(0, 0);
groupBox1.Name = "groupBox1";
groupBox1.Size = new System.Drawing.Size(163, 100);
groupBox1.TabIndex = 0;
groupBox1.TabStop = false;
groupBox1.Text = " Vertex ";
this.vertexinfo.Controls.Add(this.position);
this.vertexinfo.Controls.Add(label1);
this.vertexinfo.Location = new System.Drawing.Point(0, 0);
this.vertexinfo.Name = "vertexinfo";
this.vertexinfo.Size = new System.Drawing.Size(163, 100);
this.vertexinfo.TabIndex = 0;
this.vertexinfo.TabStop = false;
this.vertexinfo.Text = " Vertex ";
//
// position
//
@ -68,14 +67,14 @@ namespace CodeImp.DoomBuilder.Controls
// VertexInfoPanel
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Controls.Add(groupBox1);
this.Controls.Add(this.vertexinfo);
this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.MaximumSize = new System.Drawing.Size(10000, 100);
this.MinimumSize = new System.Drawing.Size(100, 100);
this.Name = "VertexInfoPanel";
this.Size = new System.Drawing.Size(393, 100);
groupBox1.ResumeLayout(false);
groupBox1.PerformLayout();
this.vertexinfo.ResumeLayout(false);
this.vertexinfo.PerformLayout();
this.ResumeLayout(false);
}
@ -83,6 +82,7 @@ namespace CodeImp.DoomBuilder.Controls
#endregion
private System.Windows.Forms.Label position;
private System.Windows.Forms.GroupBox vertexinfo;
}
}

View file

@ -44,6 +44,7 @@ namespace CodeImp.DoomBuilder.Controls
public void ShowInfo(Vertex v)
{
// Vertex info
vertexinfo.Text = " Vertex " + v.Map.GetIndexForVertex(v) + " ";
position.Text = v.Position.x.ToString("0.##") + ", " + v.Position.y.ToString("0.##");
// Show the whole thing

View file

@ -117,10 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="groupBox1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="groupBox1.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="vertexinfo.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="position.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

View file

@ -1326,7 +1326,7 @@ namespace CodeImp.DoomBuilder.Map
/// <summary>
/// Returns the thing at the specified index. Returns null when index is out of range. This is a O(n) operation.
/// </summary>
public Sector GetThingByIndex(int index)
public Thing GetThingByIndex(int index)
{
if(index < things.Count)
return General.GetByIndex<Thing>(things, index);
@ -1340,7 +1340,7 @@ namespace CodeImp.DoomBuilder.Map
public int GetIndexForVertex(Vertex v)
{
int index = 0;
foreach(LinkedListNode<Vertex> vn in vertices)
foreach(Vertex vn in vertices)
{
if(object.ReferenceEquals(vn, v)) return index;
index++;
@ -1354,7 +1354,7 @@ namespace CodeImp.DoomBuilder.Map
public int GetIndexForLinedef(Linedef l)
{
int index = 0;
foreach(LinkedListNode<Linedef> ln in linedefs)
foreach(Linedef ln in linedefs)
{
if(object.ReferenceEquals(ln, l)) return index;
index++;
@ -1368,7 +1368,7 @@ namespace CodeImp.DoomBuilder.Map
public int GetIndexForSidedef(Sidedef sd)
{
int index = 0;
foreach(LinkedListNode<Sidedef> sn in sidedefs)
foreach(Sidedef sn in sidedefs)
{
if(object.ReferenceEquals(sn, sd)) return index;
index++;
@ -1382,7 +1382,7 @@ namespace CodeImp.DoomBuilder.Map
public int GetIndexForSector(Sector s)
{
int index = 0;
foreach(LinkedListNode<Sector> sn in sectors)
foreach(Sector sn in sectors)
{
if(object.ReferenceEquals(sn, s)) return index;
index++;
@ -1396,7 +1396,7 @@ namespace CodeImp.DoomBuilder.Map
public int GetIndexForThing(Thing t)
{
int index = 0;
foreach(LinkedListNode<Thing> tn in things)
foreach(Thing tn in things)
{
if(object.ReferenceEquals(tn, t)) return index;
index++;

View file

@ -51,7 +51,7 @@ namespace CodeImp.DoomBuilder.Map
private LinkedList<Sidedef> sidedefs;
// Properties
private int index;
private int fixedindex;
private int floorheight;
private int ceilheight;
private string floortexname;
@ -82,7 +82,11 @@ namespace CodeImp.DoomBuilder.Map
public MapSet Map { get { return map; } }
public ICollection<Sidedef> Sidedefs { get { return sidedefs; } }
public int Index { get { return index; } }
/// <summary>
/// An unique index that does not change when other sectors are removed.
/// </summary>
public int FixedIndex { get { return fixedindex; } }
public int FloorHeight { get { return floorheight; } set { floorheight = value; } }
public int CeilHeight { get { return ceilheight; } set { ceilheight = value; } }
public string FloorTexture { get { return floortexname; } }
@ -113,7 +117,7 @@ namespace CodeImp.DoomBuilder.Map
this.map = map;
this.mainlistitem = listitem;
this.sidedefs = new LinkedList<Sidedef>();
this.index = index;
this.fixedindex = index;
this.floortexname = "-";
this.ceiltexname = "-";
this.longfloortexname = MapSet.EmptyLongName;
@ -156,7 +160,7 @@ namespace CodeImp.DoomBuilder.Map
mainlistitem.List.Remove(mainlistitem);
// Register the index as free
map.AddSectorIndexHole(index);
map.AddSectorIndexHole(fixedindex);
// Dispose the sidedefs that are attached to this sector
// because a sidedef cannot exist without reference to its sector.
@ -187,7 +191,7 @@ namespace CodeImp.DoomBuilder.Map
{
base.ReadWrite(s);
s.rwInt(ref index);
s.rwInt(ref fixedindex);
s.rwInt(ref floorheight);
s.rwInt(ref ceilheight);
s.rwString(ref floortexname);

View file

@ -142,7 +142,7 @@ namespace CodeImp.DoomBuilder.VisualModes
public int CompareTo(VisualGeometry other)
{
// Compare sectors
return this.sector.Sector.Index - other.sector.Sector.Index;
return this.sector.Sector.FixedIndex - other.sector.Sector.FixedIndex;
}
// This keeps the results for a sidedef intersection

View file

@ -164,7 +164,7 @@ namespace CodeImp.DoomBuilder.Windows
fronthigh.Required = fl.Front.HighRequired();
frontmid.Required = fl.Front.MiddleRequired();
frontlow.Required = fl.Front.LowRequired();
frontsector.Text = fl.Front.Sector.Index.ToString();
frontsector.Text = fl.Map.GetIndexForSector(fl.Front.Sector).ToString();
frontoffsetx.Text = fl.Front.OffsetX.ToString();
frontoffsety.Text = fl.Front.OffsetY.ToString();
}
@ -178,7 +178,7 @@ namespace CodeImp.DoomBuilder.Windows
backhigh.Required = fl.Back.HighRequired();
backmid.Required = fl.Back.MiddleRequired();
backlow.Required = fl.Back.LowRequired();
backsector.Text = fl.Back.Sector.Index.ToString();
backsector.Text = fl.Map.GetIndexForSector(fl.Back.Sector).ToString();
backoffsetx.Text = fl.Back.OffsetX.ToString();
backoffsety.Text = fl.Back.OffsetY.ToString();
}
@ -263,7 +263,7 @@ namespace CodeImp.DoomBuilder.Windows
if(fronthigh.Required != l.Front.HighRequired()) fronthigh.Required = false;
if(frontmid.Required != l.Front.MiddleRequired()) frontmid.Required = false;
if(frontlow.Required != l.Front.LowRequired()) frontlow.Required = false;
if(frontsector.Text != l.Front.Sector.Index.ToString()) frontsector.Text = "";
if(frontsector.Text != l.Map.GetIndexForSector(l.Front.Sector).ToString()) frontsector.Text = "";
if(frontoffsetx.Text != l.Front.OffsetX.ToString()) frontoffsetx.Text = "";
if(frontoffsety.Text != l.Front.OffsetY.ToString()) frontoffsety.Text = "";
if(General.Map.IsType(typeof(UniversalMapSetIO))) customfrontbutton.Visible = true;
@ -278,7 +278,7 @@ namespace CodeImp.DoomBuilder.Windows
if(backhigh.Required != l.Back.HighRequired()) backhigh.Required = false;
if(backmid.Required != l.Back.MiddleRequired()) backmid.Required = false;
if(backlow.Required != l.Back.LowRequired()) backlow.Required = false;
if(backsector.Text != l.Back.Sector.Index.ToString()) backsector.Text = "";
if(backsector.Text != l.Map.GetIndexForSector(l.Back.Sector).ToString()) backsector.Text = "";
if(backoffsetx.Text != l.Back.OffsetX.ToString()) backoffsetx.Text = "";
if(backoffsety.Text != l.Back.OffsetY.ToString()) backoffsety.Text = "";
if(General.Map.IsType(typeof(UniversalMapSetIO))) custombackbutton.Visible = true;
@ -381,7 +381,7 @@ namespace CodeImp.DoomBuilder.Windows
else if(frontside.CheckState == CheckState.Checked)
{
// Make sure we have a valid sector (make a new one if needed)
if(l.Front != null) index = l.Front.Sector.Index; else index = -1;
if(l.Front != null) index = l.Map.GetIndexForSector(l.Front.Sector); else index = -1;
s = General.Map.Map.GetSectorByIndex(frontsector.GetResult(index));
if(s == null) s = General.Map.Map.CreateSector();
@ -408,7 +408,7 @@ namespace CodeImp.DoomBuilder.Windows
else if(backside.CheckState == CheckState.Checked)
{
// Make sure we have a valid sector (make a new one if needed)
if(l.Back != null) index = l.Back.Sector.Index; else index = -1;
if(l.Back != null) index = l.Map.GetIndexForSector(l.Back.Sector); else index = -1;
s = General.Map.Map.GetSectorByIndex(backsector.GetResult(index));
if(s == null) s = General.Map.Map.CreateSector();