Sector edit forms: sector height label was showing incorrect values when relative values were used.

This commit is contained in:
MaxED 2013-09-17 08:21:12 +00:00
parent 7f775bbbd2
commit 3f66656b3b
2 changed files with 34 additions and 42 deletions

View file

@ -153,43 +153,34 @@ namespace CodeImp.DoomBuilder.Windows
// This updates the sector height field
private void UpdateSectorHeight()
{
bool showheight = true;
int delta = 0;
Sector first = null;
int index = -1; //mxd
int i = 0; //mxd
// Check all selected sectors
foreach(Sector s in sectors)
{
if(first == null)
{
foreach(Sector s in sectors) {
if(index == -1) {
// First sector in list
delta = s.CeilHeight - s.FloorHeight;
showheight = true;
first = s;
}
else
{
if(delta != (s.CeilHeight - s.FloorHeight))
{
// We can't show heights because the delta
// heights for the sectors is different
showheight = false;
break;
}
index = i; //mxd
} else if(delta != (s.CeilHeight - s.FloorHeight)) {
// We can't show heights because the delta
// heights for the sectors is different
index = -1;
break;
}
i++;
}
if(showheight)
{
int fh = floorheight.GetResult(first.FloorHeight);
int ch = ceilingheight.GetResult(first.CeilHeight);
if(index > -1) {
int fh = floorheight.GetResult(sectorProps[index].FloorHeight); //mxd
int ch = ceilingheight.GetResult(sectorProps[index].CeilHeight); //mxd
int height = ch - fh;
sectorheight.Text = height.ToString();
sectorheight.Visible = true;
sectorheightlabel.Visible = true;
}
else
{
} else {
sectorheight.Visible = false;
sectorheightlabel.Visible = false;
}
@ -263,8 +254,6 @@ namespace CodeImp.DoomBuilder.Windows
// Ceiling height changes
private void ceilingheight_TextChanged(object sender, EventArgs e)
{
UpdateSectorHeight();
if(blockUpdate) return;
int i = 0;
@ -278,6 +267,8 @@ namespace CodeImp.DoomBuilder.Windows
s.CeilHeight = ceilingheight.GetResult(sectorProps[i++].CeilHeight);
}
UpdateSectorHeight();
General.Map.IsChanged = true;
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
}
@ -285,8 +276,6 @@ namespace CodeImp.DoomBuilder.Windows
// Floor height changes
private void floorheight_TextChanged(object sender, EventArgs e)
{
UpdateSectorHeight();
if(blockUpdate) return;
int i = 0;
@ -300,6 +289,8 @@ namespace CodeImp.DoomBuilder.Windows
s.FloorHeight = floorheight.GetResult(sectorProps[i++].FloorHeight);
}
UpdateSectorHeight();
General.Map.IsChanged = true;
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
}

View file

@ -329,28 +329,29 @@ namespace CodeImp.DoomBuilder.Windows
// This updates the sector height field
private void UpdateSectorHeight() {
bool showheight = true;
int delta = 0;
Sector first = null;
int index = -1; //mxd
int i = 0; //mxd
// Check all selected sectors
foreach(Sector s in sectors) {
if(first == null) {
if(index == -1) {
// First sector in list
delta = s.CeilHeight - s.FloorHeight;
showheight = true;
first = s;
index = i; //mxd
} else if(delta != (s.CeilHeight - s.FloorHeight)) {
// We can't show heights because the delta
// heights for the sectors is different
showheight = false;
index = -1;
break;
}
i++;
}
if(showheight) {
int fh = floorheight.GetResult(first.FloorHeight);
int ch = ceilingheight.GetResult(first.CeilHeight);
if(index > -1) {
int fh = floorheight.GetResult(sectorProps[index].FloorHeight); //mxd
int ch = ceilingheight.GetResult(sectorProps[index].CeilHeight); //mxd
int height = ch - fh;
sectorheight.Text = height.ToString();
sectorheight.Visible = true;
@ -490,8 +491,6 @@ namespace CodeImp.DoomBuilder.Windows
#region mxd. Sector Realtime events
private void ceilingheight_WhenTextChanged(object sender, EventArgs e) {
UpdateSectorHeight();
if(blockUpdate) return;
int i = 0;
@ -505,13 +504,13 @@ namespace CodeImp.DoomBuilder.Windows
s.CeilHeight = ceilingheight.GetResult(sectorProps[i++].CeilHeight);
}
UpdateSectorHeight();
General.Map.IsChanged = true;
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
}
private void floorheight_WhenTextChanged(object sender, EventArgs e) {
UpdateSectorHeight();
if(blockUpdate) return;
int i = 0;
@ -525,6 +524,8 @@ namespace CodeImp.DoomBuilder.Windows
s.FloorHeight = floorheight.GetResult(sectorProps[i++].FloorHeight);
}
UpdateSectorHeight();
General.Map.IsChanged = true;
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
}