2007-10-24 17:25:03 +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.Collections.Generic;
|
|
|
|
using System.ComponentModel;
|
|
|
|
using System.Drawing;
|
|
|
|
using System.Text;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
using Microsoft.Win32;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using CodeImp.DoomBuilder.Data;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
2008-05-29 22:19:29 +00:00
|
|
|
using CodeImp.DoomBuilder.Config;
|
|
|
|
using CodeImp.DoomBuilder.Types;
|
|
|
|
using CodeImp.DoomBuilder.IO;
|
2007-10-24 17:25:03 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2008-05-29 11:54:45 +00:00
|
|
|
namespace CodeImp.DoomBuilder.Controls
|
2007-10-24 17:25:03 +00:00
|
|
|
{
|
2008-01-02 21:49:43 +00:00
|
|
|
internal partial class LinedefInfoPanel : UserControl
|
2007-10-24 17:25:03 +00:00
|
|
|
{
|
2008-05-29 22:19:29 +00:00
|
|
|
private int hexenformatwidth;
|
|
|
|
private int doomformatwidth;
|
|
|
|
|
2007-10-24 17:25:03 +00:00
|
|
|
// Constructor
|
|
|
|
public LinedefInfoPanel()
|
|
|
|
{
|
|
|
|
// Initialize
|
|
|
|
InitializeComponent();
|
2008-05-29 22:19:29 +00:00
|
|
|
|
|
|
|
// Hide stuff when in Doom format
|
|
|
|
hexenformatwidth = infopanel.Width;
|
|
|
|
doomformatwidth = infopanel.Width - 190;
|
2007-10-24 17:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This shows the info
|
|
|
|
public void ShowInfo(Linedef l)
|
|
|
|
{
|
2008-05-29 22:19:29 +00:00
|
|
|
TypeHandler th;
|
2009-02-12 12:29:46 +00:00
|
|
|
bool upperunpegged, lowerunpegged;
|
|
|
|
string peggedness;
|
|
|
|
|
2008-05-29 22:19:29 +00:00
|
|
|
// Show/hide stuff depending on format
|
2009-04-08 20:49:35 +00:00
|
|
|
if(General.Map.FormatInterface.HasActionArgs)
|
2008-05-29 22:19:29 +00:00
|
|
|
{
|
|
|
|
arglbl1.Visible = false;
|
|
|
|
arglbl2.Visible = false;
|
|
|
|
arglbl3.Visible = false;
|
|
|
|
arglbl4.Visible = false;
|
|
|
|
arglbl5.Visible = false;
|
|
|
|
arg1.Visible = false;
|
|
|
|
arg2.Visible = false;
|
|
|
|
arg3.Visible = false;
|
|
|
|
arg4.Visible = false;
|
|
|
|
arg5.Visible = false;
|
|
|
|
infopanel.Width = doomformatwidth;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
arglbl1.Visible = true;
|
|
|
|
arglbl2.Visible = true;
|
|
|
|
arglbl3.Visible = true;
|
|
|
|
arglbl4.Visible = true;
|
|
|
|
arglbl5.Visible = true;
|
|
|
|
arg1.Visible = true;
|
|
|
|
arg2.Visible = true;
|
|
|
|
arg3.Visible = true;
|
|
|
|
arg4.Visible = true;
|
|
|
|
arg5.Visible = true;
|
|
|
|
infopanel.Width = hexenformatwidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Move panels
|
|
|
|
frontpanel.Left = infopanel.Left + infopanel.Width + infopanel.Margin.Right + frontpanel.Margin.Left;
|
|
|
|
backpanel.Left = frontpanel.Left + frontpanel.Width + frontpanel.Margin.Right + backpanel.Margin.Left;
|
2007-12-26 14:29:36 +00:00
|
|
|
|
|
|
|
// Get line action information
|
2009-03-12 06:22:40 +00:00
|
|
|
LinedefActionInfo act = General.Map.Config.GetLinedefActionInfo(l.Action);
|
2007-10-24 17:25:03 +00:00
|
|
|
|
2009-02-12 12:29:46 +00:00
|
|
|
// Determine peggedness
|
2009-02-15 10:32:20 +00:00
|
|
|
upperunpegged = l.IsFlagSet(General.Map.Config.UpperUnpeggedFlag);
|
|
|
|
lowerunpegged = l.IsFlagSet(General.Map.Config.LowerUnpeggedFlag);
|
2009-02-12 12:29:46 +00:00
|
|
|
if(upperunpegged && lowerunpegged)
|
|
|
|
peggedness = "Upper & Lower";
|
|
|
|
else if(upperunpegged)
|
|
|
|
peggedness = "Upper";
|
|
|
|
else if(lowerunpegged)
|
|
|
|
peggedness = "Lower";
|
|
|
|
else
|
|
|
|
peggedness = "None";
|
|
|
|
|
2007-10-24 17:25:03 +00:00
|
|
|
// Linedef info
|
2009-04-13 21:37:03 +00:00
|
|
|
infopanel.Text = " Linedef " + l.Map.GetIndexForLinedef(l) + " ";
|
2009-03-12 06:22:40 +00:00
|
|
|
action.Text = act.ToString();
|
2007-10-24 17:25:03 +00:00
|
|
|
length.Text = l.Length.ToString("0.##");
|
|
|
|
angle.Text = l.AngleDeg.ToString() + "\u00B0";
|
|
|
|
tag.Text = l.Tag.ToString();
|
2009-02-12 12:29:46 +00:00
|
|
|
unpegged.Text = peggedness;
|
|
|
|
|
2008-05-29 22:19:29 +00:00
|
|
|
// Arguments
|
2009-03-12 06:22:40 +00:00
|
|
|
arglbl1.Text = act.Args[0].Title + ":";
|
|
|
|
arglbl2.Text = act.Args[1].Title + ":";
|
|
|
|
arglbl3.Text = act.Args[2].Title + ":";
|
|
|
|
arglbl4.Text = act.Args[3].Title + ":";
|
|
|
|
arglbl5.Text = act.Args[4].Title + ":";
|
|
|
|
arglbl1.Enabled = act.Args[0].Used;
|
|
|
|
arglbl2.Enabled = act.Args[1].Used;
|
|
|
|
arglbl3.Enabled = act.Args[2].Used;
|
|
|
|
arglbl4.Enabled = act.Args[3].Used;
|
|
|
|
arglbl5.Enabled = act.Args[4].Used;
|
|
|
|
arg1.Enabled = act.Args[0].Used;
|
|
|
|
arg2.Enabled = act.Args[1].Used;
|
|
|
|
arg3.Enabled = act.Args[2].Used;
|
|
|
|
arg4.Enabled = act.Args[3].Used;
|
|
|
|
arg5.Enabled = act.Args[4].Used;
|
|
|
|
th = General.Types.GetArgumentHandler(act.Args[0]);
|
|
|
|
th.SetValue(l.Args[0]); arg1.Text = th.GetStringValue();
|
|
|
|
th = General.Types.GetArgumentHandler(act.Args[1]);
|
|
|
|
th.SetValue(l.Args[1]); arg2.Text = th.GetStringValue();
|
|
|
|
th = General.Types.GetArgumentHandler(act.Args[2]);
|
|
|
|
th.SetValue(l.Args[2]); arg3.Text = th.GetStringValue();
|
|
|
|
th = General.Types.GetArgumentHandler(act.Args[3]);
|
|
|
|
th.SetValue(l.Args[3]); arg4.Text = th.GetStringValue();
|
|
|
|
th = General.Types.GetArgumentHandler(act.Args[4]);
|
|
|
|
th.SetValue(l.Args[4]); arg5.Text = th.GetStringValue();
|
2008-05-29 22:19:29 +00:00
|
|
|
|
2007-10-24 17:25:03 +00:00
|
|
|
// Front side available?
|
|
|
|
if(l.Front != null)
|
|
|
|
{
|
|
|
|
// Show sidedef info
|
2009-03-10 06:46:02 +00:00
|
|
|
frontpanel.Text = " Front Sidedef " + l.Map.GetIndexForSidedef(l.Front) + " ";
|
2007-10-24 17:25:03 +00:00
|
|
|
frontoffset.Text = l.Front.OffsetX + ", " + l.Front.OffsetY;
|
|
|
|
fronthighname.Text = l.Front.HighTexture;
|
|
|
|
frontmidname.Text = l.Front.MiddleTexture;
|
|
|
|
frontlowname.Text = l.Front.LowTexture;
|
2007-12-26 14:29:36 +00:00
|
|
|
DisplaySidedefTexture(fronthightex, l.Front.HighTexture, l.Front.HighRequired());
|
|
|
|
DisplaySidedefTexture(frontmidtex, l.Front.MiddleTexture, l.Front.MiddleRequired());
|
|
|
|
DisplaySidedefTexture(frontlowtex, l.Front.LowTexture, l.Front.LowRequired());
|
2007-10-26 13:17:20 +00:00
|
|
|
frontoffsetlabel.Enabled = true;
|
|
|
|
frontoffset.Enabled = true;
|
|
|
|
frontpanel.Enabled = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Show no info
|
2009-03-10 06:46:02 +00:00
|
|
|
frontpanel.Text = " Front Sidedef ";
|
2007-10-26 13:17:20 +00:00
|
|
|
frontoffsetlabel.Enabled = false;
|
|
|
|
frontoffset.Enabled = false;
|
|
|
|
frontpanel.Enabled = false;
|
|
|
|
frontoffset.Text = "--, --";
|
|
|
|
fronthighname.Text = "";
|
|
|
|
frontmidname.Text = "";
|
|
|
|
frontlowname.Text = "";
|
|
|
|
fronthightex.BackgroundImage = null;
|
|
|
|
frontmidtex.BackgroundImage = null;
|
|
|
|
frontlowtex.BackgroundImage = null;
|
2007-10-24 17:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Back size available?
|
|
|
|
if(l.Back != null)
|
|
|
|
{
|
|
|
|
// Show sidedef info
|
2009-03-10 06:46:02 +00:00
|
|
|
backpanel.Text = " Back Sidedef " + l.Map.GetIndexForSidedef(l.Back) + " ";
|
2007-10-24 17:25:03 +00:00
|
|
|
backoffset.Text = l.Back.OffsetX + ", " + l.Back.OffsetY;
|
|
|
|
backhighname.Text = l.Back.HighTexture;
|
|
|
|
backmidname.Text = l.Back.MiddleTexture;
|
|
|
|
backlowname.Text = l.Back.LowTexture;
|
2007-12-26 14:29:36 +00:00
|
|
|
DisplaySidedefTexture(backhightex, l.Back.HighTexture, l.Back.HighRequired());
|
|
|
|
DisplaySidedefTexture(backmidtex, l.Back.MiddleTexture, l.Back.MiddleRequired());
|
|
|
|
DisplaySidedefTexture(backlowtex, l.Back.LowTexture, l.Back.LowRequired());
|
2007-10-26 13:17:20 +00:00
|
|
|
backoffsetlabel.Enabled = true;
|
|
|
|
backoffset.Enabled = true;
|
|
|
|
backpanel.Enabled = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Show no info
|
2009-03-10 06:46:02 +00:00
|
|
|
backpanel.Text = " Back Sidedef ";
|
2007-10-26 13:17:20 +00:00
|
|
|
backoffsetlabel.Enabled = false;
|
|
|
|
backoffset.Enabled = false;
|
|
|
|
backpanel.Enabled = false;
|
|
|
|
backoffset.Text = "--, --";
|
|
|
|
backhighname.Text = "";
|
|
|
|
backmidname.Text = "";
|
|
|
|
backlowname.Text = "";
|
|
|
|
backhightex.BackgroundImage = null;
|
|
|
|
backmidtex.BackgroundImage = null;
|
|
|
|
backlowtex.BackgroundImage = null;
|
2007-10-24 17:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Show the whole thing
|
|
|
|
this.Show();
|
|
|
|
this.Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
// When visible changed
|
|
|
|
protected override void OnVisibleChanged(EventArgs e)
|
|
|
|
{
|
2007-10-26 13:17:20 +00:00
|
|
|
// Hiding panels
|
2007-10-24 17:25:03 +00:00
|
|
|
if(!this.Visible)
|
|
|
|
{
|
2007-10-26 13:17:20 +00:00
|
|
|
fronthightex.BackgroundImage = null;
|
|
|
|
frontmidtex.BackgroundImage = null;
|
|
|
|
frontlowtex.BackgroundImage = null;
|
|
|
|
backhightex.BackgroundImage = null;
|
|
|
|
backmidtex.BackgroundImage = null;
|
|
|
|
backlowtex.BackgroundImage = null;
|
2007-10-24 17:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Call base
|
|
|
|
base.OnVisibleChanged(e);
|
|
|
|
}
|
2007-12-26 14:29:36 +00:00
|
|
|
|
|
|
|
// This shows a sidedef texture in a panel
|
|
|
|
private void DisplaySidedefTexture(Panel panel, string name, bool required)
|
|
|
|
{
|
|
|
|
// Check if name is a "none" texture
|
|
|
|
if((name.Length < 1) || (name[0] == '-'))
|
|
|
|
{
|
|
|
|
// Determine image to show
|
|
|
|
if(required)
|
|
|
|
panel.BackgroundImage = CodeImp.DoomBuilder.Properties.Resources.MissingTexture;
|
|
|
|
else
|
|
|
|
panel.BackgroundImage = null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Set the image
|
2008-09-28 21:20:56 +00:00
|
|
|
panel.BackgroundImage = General.Map.Data.GetTextureImage(name).GetPreview();
|
2007-12-26 14:29:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Image not null?
|
|
|
|
if(panel.BackgroundImage != null)
|
|
|
|
{
|
|
|
|
// Small enough to fit in panel?
|
|
|
|
if((panel.BackgroundImage.Size.Width < panel.ClientRectangle.Width) &&
|
|
|
|
(panel.BackgroundImage.Size.Height < panel.ClientRectangle.Height))
|
|
|
|
{
|
|
|
|
// Display centered
|
|
|
|
panel.BackgroundImageLayout = ImageLayout.Center;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Display zoomed
|
|
|
|
panel.BackgroundImageLayout = ImageLayout.Zoom;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-24 17:25:03 +00:00
|
|
|
}
|
|
|
|
}
|