2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#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.Windows.Forms;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
2013-06-17 13:17:53 +00:00
|
|
|
using CodeImp.DoomBuilder.Data;
|
2013-09-11 08:49:45 +00:00
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
2013-12-05 09:24:55 +00:00
|
|
|
using System.Collections.Generic;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Controls
|
|
|
|
{
|
|
|
|
internal partial class SectorInfoPanel : UserControl
|
|
|
|
{
|
2012-10-03 18:46:13 +00:00
|
|
|
private int fullWidth; //mxd
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Constructor
|
|
|
|
public SectorInfoPanel()
|
|
|
|
{
|
|
|
|
// Initialize
|
|
|
|
InitializeComponent();
|
2012-10-03 18:46:13 +00:00
|
|
|
fullWidth = floorpanel.Width; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This shows the info
|
|
|
|
public void ShowInfo(Sector s)
|
|
|
|
{
|
2014-02-21 14:42:12 +00:00
|
|
|
string effectinfo;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
int sheight = s.CeilHeight - s.FloorHeight;
|
|
|
|
|
|
|
|
// Lookup effect description in config
|
|
|
|
if(General.Map.Config.SectorEffects.ContainsKey(s.Effect))
|
|
|
|
effectinfo = General.Map.Config.SectorEffects[s.Effect].ToString();
|
|
|
|
else if(s.Effect == 0)
|
2014-02-21 14:42:12 +00:00
|
|
|
effectinfo = s.Effect + " - Normal";
|
2009-04-19 18:07:22 +00:00
|
|
|
else
|
2014-02-21 14:42:12 +00:00
|
|
|
effectinfo = s.Effect + " - Unknown";
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Sector info
|
2013-09-09 14:03:02 +00:00
|
|
|
sectorinfo.Text = " Sector " + s.Index + " (" + (s.Sidedefs == null ? "no" : s.Sidedefs.Count.ToString()) + " sidedefs)"; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
effect.Text = effectinfo;
|
|
|
|
ceiling.Text = s.CeilHeight.ToString();
|
|
|
|
floor.Text = s.FloorHeight.ToString();
|
2014-01-16 09:32:05 +00:00
|
|
|
tag.Text = s.Tag + (General.Map.Options.TagLabels.ContainsKey(s.Tag) ? " (" + General.Map.Options.TagLabels[s.Tag] + ")" : string.Empty);
|
2009-04-19 18:07:22 +00:00
|
|
|
height.Text = sheight.ToString();
|
|
|
|
brightness.Text = s.Brightness.ToString();
|
|
|
|
floorname.Text = s.FloorTexture;
|
|
|
|
ceilingname.Text = s.CeilTexture;
|
2013-06-17 13:17:53 +00:00
|
|
|
|
2013-07-31 12:38:47 +00:00
|
|
|
//mxd. Texture info
|
2014-03-05 09:21:28 +00:00
|
|
|
if (s.LongFloorTexture == MapSet.EmptyLongName){
|
2013-08-26 11:09:37 +00:00
|
|
|
labelFloorTextureSize.Visible = false;
|
2013-07-31 12:38:47 +00:00
|
|
|
General.DisplayZoomedImage(floortex, Properties.Resources.MissingTexture);
|
|
|
|
} else {
|
|
|
|
ImageData floorImage = General.Map.Data.GetFlatImage(s.FloorTexture);
|
|
|
|
DisplayTextureSize(labelFloorTextureSize, floorImage);
|
|
|
|
General.DisplayZoomedImage(floortex, floorImage.GetPreview());
|
|
|
|
}
|
2013-06-17 13:17:53 +00:00
|
|
|
|
2014-03-05 09:21:28 +00:00
|
|
|
if (s.LongCeilTexture == MapSet.EmptyLongName) {
|
2013-08-26 11:09:37 +00:00
|
|
|
labelCeilTextureSize.Visible = false;
|
2013-07-31 12:38:47 +00:00
|
|
|
General.DisplayZoomedImage(ceilingtex, Properties.Resources.MissingTexture);
|
|
|
|
} else {
|
|
|
|
ImageData ceilingImage = General.Map.Data.GetFlatImage(s.CeilTexture);
|
|
|
|
DisplayTextureSize(labelCeilTextureSize, ceilingImage); //mxd
|
|
|
|
General.DisplayZoomedImage(ceilingtex, ceilingImage.GetPreview());
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
|
2012-10-03 18:46:13 +00:00
|
|
|
//mxd
|
|
|
|
bool showExtededFloorInfo = false;
|
|
|
|
bool showExtededCeilingInfo = false;
|
2013-12-05 09:24:55 +00:00
|
|
|
if(General.Map.UDMF) {
|
|
|
|
if(s.Fields != null) {
|
|
|
|
//sector colors
|
|
|
|
labelLight.Visible = true;
|
|
|
|
labelFade.Visible = true;
|
|
|
|
panelLightColor.Visible = true;
|
|
|
|
panelFadeColor.Visible = true;
|
|
|
|
|
|
|
|
if(s.Fields.ContainsKey("lightcolor")) {
|
|
|
|
panelLightColor.BackColor = PixelColor.FromInt(s.Fields.GetValue("lightcolor", 0xFFFFFF)).WithAlpha(255).ToColor();
|
|
|
|
labelLight.Enabled = true;
|
|
|
|
} else {
|
|
|
|
panelLightColor.BackColor = System.Drawing.SystemColors.Control;
|
|
|
|
labelLight.Enabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(s.Fields.ContainsKey("fadecolor")) {
|
|
|
|
panelFadeColor.BackColor = PixelColor.FromInt(s.Fields.GetValue("fadecolor", 0)).WithAlpha(255).ToColor();
|
|
|
|
labelFade.Enabled = true;
|
|
|
|
} else {
|
|
|
|
panelFadeColor.BackColor = System.Drawing.SystemColors.Control;
|
|
|
|
labelFade.Enabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//light
|
|
|
|
if(s.Fields.ContainsKey("lightceiling") || s.Fields.ContainsKey("lightceilingabsolute")) {
|
|
|
|
showExtededCeilingInfo = true;
|
|
|
|
ceilingLight.Enabled = true;
|
|
|
|
ceilingLightLabel.Enabled = true;
|
|
|
|
|
|
|
|
int cl = s.Fields.GetValue("lightceiling", 0);
|
|
|
|
|
|
|
|
if(s.Fields.GetValue("lightceilingabsolute", false))
|
|
|
|
ceilingLight.Text = cl + " (abs.)";
|
|
|
|
else
|
|
|
|
ceilingLight.Text = cl + " (" + Math.Min(255, Math.Max(0, (cl + s.Brightness))) + ")";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
ceilingLight.Text = "--";
|
|
|
|
ceilingLight.Enabled = false;
|
|
|
|
ceilingLightLabel.Enabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(s.Fields.ContainsKey("lightfloor") || s.Fields.ContainsKey("lightfloorabsolute")) {
|
|
|
|
showExtededFloorInfo = true;
|
|
|
|
floorLight.Enabled = true;
|
|
|
|
floorLightLabel.Enabled = true;
|
|
|
|
|
|
|
|
int fl = s.Fields.GetValue("lightfloor", 0);
|
|
|
|
|
|
|
|
if(s.Fields.GetValue("lightfloorabsolute", false))
|
|
|
|
floorLight.Text = fl + " (abs.)";
|
|
|
|
else
|
|
|
|
floorLight.Text = fl + " (" + Math.Min(255, Math.Max(0, (fl + s.Brightness))) + ")";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
floorLight.Text = "--";
|
|
|
|
floorLight.Enabled = false;
|
|
|
|
floorLightLabel.Enabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//ceiling offsets
|
|
|
|
float panX = s.Fields.GetValue("xpanningceiling", 0f);
|
|
|
|
float panY = s.Fields.GetValue("ypanningceiling", 0f);
|
|
|
|
|
|
|
|
if(panX != 0 || panY != 0) {
|
|
|
|
showExtededCeilingInfo = true;
|
|
|
|
ceilingOffset.Enabled = true;
|
|
|
|
ceilingOffsetLabel.Enabled = true;
|
|
|
|
ceilingOffset.Text = String.Format("{0:0.##}", panX) + ", " + String.Format("{0:0.##}", panY);
|
|
|
|
} else {
|
|
|
|
ceilingOffset.Text = "--, --";
|
|
|
|
ceilingOffset.Enabled = false;
|
|
|
|
ceilingOffsetLabel.Enabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//floor offsets
|
|
|
|
panX = s.Fields.GetValue("xpanningfloor", 0f);
|
|
|
|
panY = s.Fields.GetValue("ypanningfloor", 0f);
|
|
|
|
|
|
|
|
if(panX != 0 || panY != 0) {
|
|
|
|
showExtededFloorInfo = true;
|
|
|
|
floorOffset.Enabled = true;
|
|
|
|
floorOffsetLabel.Enabled = true;
|
|
|
|
floorOffset.Text = String.Format("{0:0.##}", panX) + ", " + String.Format("{0:0.##}", panY);
|
|
|
|
} else {
|
|
|
|
floorOffset.Text = "--, --";
|
|
|
|
floorOffset.Enabled = false;
|
|
|
|
floorOffsetLabel.Enabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//ceiling scale
|
|
|
|
float scaleX = s.Fields.GetValue("xscaleceiling", 1.0f);//1.0f;
|
|
|
|
float scaleY = s.Fields.GetValue("yscaleceiling", 1.0f);
|
|
|
|
|
|
|
|
if(scaleX != 1.0f || scaleY != 1.0f) {
|
|
|
|
showExtededCeilingInfo = true;
|
|
|
|
ceilingScale.Enabled = true;
|
|
|
|
ceilingScaleLabel.Enabled = true;
|
|
|
|
ceilingScale.Text = String.Format("{0:0.##}", scaleX) + ", " + String.Format("{0:0.##}", scaleY);
|
|
|
|
} else {
|
|
|
|
ceilingScale.Text = "--, --";
|
|
|
|
ceilingScale.Enabled = false;
|
|
|
|
ceilingScaleLabel.Enabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//floor scale
|
|
|
|
scaleX = s.Fields.GetValue("xscalefloor", 1.0f);
|
|
|
|
scaleY = s.Fields.GetValue("yscalefloor", 1.0f);
|
|
|
|
|
|
|
|
if(scaleX != 1.0f || scaleY != 1.0f) {
|
|
|
|
showExtededFloorInfo = true;
|
|
|
|
floorScale.Enabled = true;
|
|
|
|
floorScaleLabel.Enabled = true;
|
|
|
|
floorScale.Text = String.Format("{0:0.##}", scaleX) + ", " + String.Format("{0:0.##}", scaleY);
|
|
|
|
} else {
|
|
|
|
floorScale.Text = "--, --";
|
|
|
|
floorScale.Enabled = false;
|
|
|
|
floorScaleLabel.Enabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//rotation
|
|
|
|
if(s.Fields.ContainsKey("rotationceiling")) {
|
|
|
|
showExtededCeilingInfo = true;
|
|
|
|
ceilingAngle.Enabled = true;
|
|
|
|
ceilingAngleLabel.Enabled = true;
|
2014-02-21 14:42:12 +00:00
|
|
|
ceilingAngle.Text = s.Fields["rotationceiling"].Value + "\u00B0";
|
2013-12-05 09:24:55 +00:00
|
|
|
} else {
|
|
|
|
ceilingAngle.Text = "-";
|
|
|
|
ceilingAngle.Enabled = false;
|
|
|
|
ceilingAngleLabel.Enabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(s.Fields.ContainsKey("rotationfloor")) {
|
|
|
|
showExtededFloorInfo = true;
|
|
|
|
floorAngle.Enabled = true;
|
|
|
|
floorAngleLabel.Enabled = true;
|
2014-02-21 14:42:12 +00:00
|
|
|
floorAngle.Text = s.Fields["rotationfloor"].Value + "\u00B0";
|
2013-12-05 09:24:55 +00:00
|
|
|
} else {
|
|
|
|
floorAngle.Text = "-";
|
|
|
|
floorAngle.Enabled = false;
|
|
|
|
floorAngleLabel.Enabled = false;
|
|
|
|
}
|
2013-09-11 08:49:45 +00:00
|
|
|
}
|
|
|
|
|
2013-12-05 09:24:55 +00:00
|
|
|
//Flags
|
|
|
|
flags.Items.Clear();
|
|
|
|
foreach(KeyValuePair<string, bool> group in s.Flags) {
|
|
|
|
if(group.Value) {
|
2013-12-17 08:19:40 +00:00
|
|
|
ListViewItem item = new ListViewItem(General.Map.Config.SectorFlags.ContainsKey(group.Key) ? General.Map.Config.SectorFlags[group.Key] : group.Key);
|
2013-12-05 09:24:55 +00:00
|
|
|
item.Checked = true;
|
|
|
|
flags.Items.Add(item);
|
|
|
|
}
|
2012-10-03 18:46:13 +00:00
|
|
|
}
|
|
|
|
|
2013-12-05 09:24:55 +00:00
|
|
|
//mxd. Flags panel visibility and size
|
|
|
|
flagsPanel.Visible = (flags.Items.Count > 0);
|
|
|
|
if(flags.Items.Count > 0) {
|
|
|
|
int itemWidth = flags.Items[0].GetBounds(ItemBoundsPortion.Entire).Width;
|
|
|
|
if(itemWidth == 0) itemWidth = 96;
|
|
|
|
flags.Width = itemWidth * (int)Math.Ceiling(flags.Items.Count / 5.0f);
|
|
|
|
flagsPanel.Width = flags.Width + flags.Left * 2;
|
2012-10-03 18:46:13 +00:00
|
|
|
}
|
|
|
|
|
2013-09-11 08:49:45 +00:00
|
|
|
} else {
|
|
|
|
panelFadeColor.Visible = false;
|
|
|
|
panelLightColor.Visible = false;
|
|
|
|
labelFade.Visible = false;
|
|
|
|
labelLight.Visible = false;
|
2013-12-05 09:24:55 +00:00
|
|
|
flagsPanel.Visible = false;
|
2012-10-03 18:46:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//panels size
|
|
|
|
if(showExtededCeilingInfo) {
|
|
|
|
ceilingpanel.Width = fullWidth;
|
|
|
|
ceilingInfo.Visible = true;
|
|
|
|
} else {
|
|
|
|
ceilingInfo.Visible = false;
|
|
|
|
ceilingpanel.Width = 84;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(showExtededFloorInfo) {
|
|
|
|
floorpanel.Width = fullWidth;
|
|
|
|
floorInfo.Visible = true;
|
|
|
|
} else {
|
|
|
|
floorInfo.Visible = false;
|
|
|
|
floorpanel.Width = 84;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Show the whole thing
|
|
|
|
this.Show();
|
|
|
|
this.Update();
|
|
|
|
}
|
|
|
|
|
2013-06-17 13:17:53 +00:00
|
|
|
protected void DisplayTextureSize(Label label, ImageData texture) {
|
2013-07-29 08:50:50 +00:00
|
|
|
if(General.Settings.ShowTextureSizes && texture.ImageState == ImageLoadState.Ready && !string.IsNullOrEmpty(texture.Name) && !(texture is UnknownImage)) {
|
2013-06-17 13:17:53 +00:00
|
|
|
label.Visible = true;
|
2013-06-17 14:09:29 +00:00
|
|
|
label.Text = texture.ScaledWidth + "x" + texture.ScaledHeight;
|
2013-06-17 13:17:53 +00:00
|
|
|
} else {
|
|
|
|
label.Visible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// When visible changed
|
|
|
|
protected override void OnVisibleChanged(EventArgs e)
|
|
|
|
{
|
|
|
|
// Hiding panels
|
|
|
|
if(!this.Visible)
|
|
|
|
{
|
|
|
|
floortex.BackgroundImage = null;
|
|
|
|
ceilingtex.BackgroundImage = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Call base
|
|
|
|
base.OnVisibleChanged(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|