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;
|
2016-06-14 20:39:46 +00:00
|
|
|
using System.Drawing;
|
2015-03-03 09:42:54 +00:00
|
|
|
using System.Globalization;
|
2009-04-19 18:07:22 +00:00
|
|
|
using System.Windows.Forms;
|
|
|
|
using CodeImp.DoomBuilder.Data;
|
2015-07-27 09:02:28 +00:00
|
|
|
using CodeImp.DoomBuilder.GZBuilder.Data;
|
2009-04-19 18:07:22 +00:00
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
using CodeImp.DoomBuilder.Config;
|
|
|
|
using CodeImp.DoomBuilder.Types;
|
2013-04-11 11:04:16 +00:00
|
|
|
using CodeImp.DoomBuilder.GZBuilder; //mxd
|
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 ThingInfoPanel : UserControl
|
|
|
|
{
|
2015-07-27 09:02:28 +00:00
|
|
|
private readonly int hexenformatwidth;
|
|
|
|
private readonly int doomformatwidth;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Constructor
|
|
|
|
public ThingInfoPanel()
|
|
|
|
{
|
|
|
|
// Initialize
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
// Hide stuff when in Doom format
|
|
|
|
hexenformatwidth = infopanel.Width;
|
|
|
|
doomformatwidth = infopanel.Width - 190;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This shows the info
|
|
|
|
public void ShowInfo(Thing t)
|
|
|
|
{
|
|
|
|
// Show/hide stuff depending on format
|
2013-12-17 08:19:40 +00:00
|
|
|
bool hasArgs = General.Map.FormatInterface.HasActionArgs;
|
|
|
|
arglbl1.Visible = hasArgs;
|
|
|
|
arglbl2.Visible = hasArgs;
|
|
|
|
arglbl3.Visible = hasArgs;
|
|
|
|
arglbl4.Visible = hasArgs;
|
|
|
|
arglbl5.Visible = hasArgs;
|
|
|
|
arg1.Visible = hasArgs;
|
|
|
|
arg2.Visible = hasArgs;
|
|
|
|
arg3.Visible = hasArgs;
|
|
|
|
arg4.Visible = hasArgs;
|
|
|
|
arg5.Visible = hasArgs;
|
|
|
|
infopanel.Width = (hasArgs ? hexenformatwidth : doomformatwidth);
|
|
|
|
|
|
|
|
//mxd
|
2014-12-08 21:06:08 +00:00
|
|
|
action.Visible = General.Map.FormatInterface.HasThingAction;
|
|
|
|
labelaction.Visible = General.Map.FormatInterface.HasThingAction;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Move panel
|
|
|
|
spritepanel.Left = infopanel.Left + infopanel.Width + infopanel.Margin.Right + spritepanel.Margin.Left;
|
2013-12-05 09:24:55 +00:00
|
|
|
flagsPanel.Left = spritepanel.Left + spritepanel.Width + spritepanel.Margin.Right + flagsPanel.Margin.Left; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Lookup thing info
|
2014-02-21 14:42:12 +00:00
|
|
|
ThingTypeInfo ti = General.Map.Data.GetThingInfo(t.Type);
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Get thing action information
|
2015-09-02 11:28:44 +00:00
|
|
|
LinedefActionInfo act;
|
|
|
|
if(General.Map.Config.LinedefActions.ContainsKey(t.Action)) act = General.Map.Config.LinedefActions[t.Action];
|
|
|
|
else if(t.Action == 0) act = new LinedefActionInfo(0, "None", true, false);
|
|
|
|
else act = new LinedefActionInfo(t.Action, "Unknown", false, false);
|
2015-12-27 21:54:50 +00:00
|
|
|
string actioninfo = act.ToString();
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Determine z info to show
|
|
|
|
t.DetermineSector();
|
2015-12-27 21:54:50 +00:00
|
|
|
string zinfo;
|
2015-04-15 12:49:28 +00:00
|
|
|
if(ti.AbsoluteZ || t.Sector == null)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2015-04-15 12:49:28 +00:00
|
|
|
zinfo = t.Position.z.ToString(CultureInfo.InvariantCulture) + " (abs.)"; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-04-15 12:49:28 +00:00
|
|
|
// Hangs from ceiling?
|
|
|
|
if(ti.Hangs)
|
2015-07-26 23:18:13 +00:00
|
|
|
zinfo = t.Position.z + " (" + ((float)Math.Round(Sector.GetCeilingPlane(t.Sector).GetZ(t.Position) - t.Position.z - ti.Height, General.Map.FormatInterface.VertexDecimals)).ToString(CultureInfo.InvariantCulture) + ")"; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
else
|
2015-04-15 12:49:28 +00:00
|
|
|
zinfo = t.Position.z + " (" + ((float)Math.Round(Sector.GetFloorPlane(t.Sector).GetZ(t.Position) + t.Position.z, General.Map.FormatInterface.VertexDecimals)).ToString(CultureInfo.InvariantCulture) + ")"; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Thing info
|
2009-06-05 19:03:56 +00:00
|
|
|
infopanel.Text = " Thing " + t.Index + " ";
|
2009-04-19 18:07:22 +00:00
|
|
|
type.Text = t.Type + " - " + ti.Title;
|
2015-10-15 15:16:31 +00:00
|
|
|
if(ti.IsObsolete) type.Text += " - OBSOLETE"; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
action.Text = actioninfo;
|
2015-04-12 21:05:09 +00:00
|
|
|
bool displayclassname = !string.IsNullOrEmpty(ti.ClassName) && !ti.ClassName.StartsWith("$"); //mxd
|
|
|
|
labelclass.Enabled = displayclassname; //mxd
|
|
|
|
classname.Enabled = displayclassname; //mxd
|
|
|
|
classname.Text = (displayclassname ? ti.ClassName : "--"); //mxd
|
2015-03-03 09:42:54 +00:00
|
|
|
position.Text = t.Position.x.ToString(CultureInfo.InvariantCulture) + ", " + t.Position.y.ToString(CultureInfo.InvariantCulture) + ", " + zinfo;
|
2014-12-08 21:06:08 +00:00
|
|
|
tag.Text = t.Tag + (General.Map.Options.TagLabels.ContainsKey(t.Tag) ? " - " + General.Map.Options.TagLabels[t.Tag] : string.Empty);
|
2014-01-16 09:32:05 +00:00
|
|
|
angle.Text = t.AngleDoom + "\u00B0";
|
2014-01-13 08:06:56 +00:00
|
|
|
anglecontrol.Angle = t.AngleDoom;
|
|
|
|
anglecontrol.Left = angle.Right + 1;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Sprite
|
|
|
|
if(ti.Sprite.ToLowerInvariant().StartsWith(DataManager.INTERNAL_PREFIX) && (ti.Sprite.Length > DataManager.INTERNAL_PREFIX.Length))
|
|
|
|
{
|
|
|
|
spritename.Text = "";
|
2020-01-12 18:37:27 +00:00
|
|
|
spritetex.Image = General.Map.Data.GetSpriteImage(ti.Sprite).GetSpritePreview();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
else if((ti.Sprite.Length <= 8) && (ti.Sprite.Length > 0))
|
|
|
|
{
|
|
|
|
spritename.Text = ti.Sprite;
|
2015-01-18 19:51:36 +00:00
|
|
|
spritetex.Image = General.Map.Data.GetSpriteImage(ti.Sprite).GetPreview();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spritename.Text = "";
|
2015-01-18 19:51:36 +00:00
|
|
|
spritetex.Image = null;
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
2013-08-08 11:04:13 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Arguments
|
2015-07-27 09:02:28 +00:00
|
|
|
ArgumentInfo[] arginfo = ((t.Action == 0 && ti.Args[0] != null) ? ti.Args : act.Args); //mxd
|
2013-08-08 11:04:13 +00:00
|
|
|
|
2017-02-23 13:01:36 +00:00
|
|
|
//mxd. ACS script argument names
|
|
|
|
bool isacsscript = (Array.IndexOf(GZGeneral.ACS_SPECIALS, t.Action) != -1);
|
|
|
|
bool isarg0str = (General.Map.UDMF && t.Fields.ContainsKey("arg0str"));
|
|
|
|
string arg0str = isarg0str ? t.Fields.GetValue("arg0str", string.Empty) : string.Empty;
|
|
|
|
ScriptItem scriptitem = null;
|
|
|
|
|
|
|
|
//mxd. Set default label colors
|
|
|
|
arg1.ForeColor = SystemColors.ControlText;
|
|
|
|
arglbl1.ForeColor = SystemColors.ControlText;
|
|
|
|
|
|
|
|
// Named script?
|
|
|
|
if (isacsscript && isarg0str && General.Map.NamedScripts.ContainsKey(arg0str.ToLowerInvariant()))
|
|
|
|
{
|
|
|
|
scriptitem = General.Map.NamedScripts[arg0str.ToLowerInvariant()];
|
|
|
|
}
|
|
|
|
// Script number?
|
|
|
|
else if (isacsscript && General.Map.NumberedScripts.ContainsKey(t.Args[0]))
|
|
|
|
{
|
|
|
|
scriptitem = General.Map.NumberedScripts[t.Args[0]];
|
|
|
|
arg0str = (scriptitem.HasCustomName ? scriptitem.Name : scriptitem.Index.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apply script args?
|
|
|
|
Label[] arglabels = { arglbl1, arglbl2, arglbl3, arglbl4, arglbl5 };
|
|
|
|
Label[] args = { arg1, arg2, arg3, arg4, arg5 };
|
|
|
|
|
|
|
|
if (scriptitem != null)
|
|
|
|
{
|
|
|
|
int first;
|
|
|
|
string[] argnames = scriptitem.GetArgumentsDescriptions(t.Action, out first);
|
|
|
|
for (int i = 0; i < first; i++)
|
|
|
|
{
|
|
|
|
arglabels[i].Text = (isarg0str ? arginfo[i].TitleStr : arginfo[i].Title) + ":";
|
|
|
|
arglabels[i].Enabled = arginfo[i].Used;
|
|
|
|
args[i].Enabled = arginfo[i].Used;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = first; i < argnames.Length; i++)
|
|
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(argnames[i]))
|
|
|
|
{
|
|
|
|
arglabels[i].Text = argnames[i] + ":";
|
|
|
|
arglabels[i].Enabled = true;
|
|
|
|
args[i].Enabled = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
arglabels[i].Text = (isarg0str ? arginfo[i].TitleStr : arginfo[i].Title) + ":";
|
|
|
|
arglabels[i].Enabled = arginfo[i].Used;
|
|
|
|
args[i].Enabled = arginfo[i].Used;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (int i = 0; i < arginfo.Length; i++)
|
|
|
|
{
|
|
|
|
arglabels[i].Text = (isarg0str ? arginfo[i].TitleStr : arginfo[i].Title) + ":";
|
|
|
|
arglabels[i].Enabled = arginfo[i].Used;
|
|
|
|
args[i].Enabled = arginfo[i].Used;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Special cases: unknown script name/index
|
|
|
|
if (isacsscript)
|
|
|
|
{
|
|
|
|
arglbl1.Text = "Unknown script " + (isarg0str ? "name" : "number") + ":";
|
|
|
|
arg1.ForeColor = Color.DarkRed;
|
|
|
|
arglbl1.ForeColor = Color.DarkRed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//mxd. Set argument value and label
|
|
|
|
if (isarg0str) arg1.Text = arg0str;
|
|
|
|
else SetArgumentText(act.Args[0], arg1, t.Args[0]);
|
|
|
|
SetArgumentText(arginfo[1], arg2, t.Args[1]);
|
2014-12-03 23:15:26 +00:00
|
|
|
SetArgumentText(arginfo[2], arg3, t.Args[2]);
|
|
|
|
SetArgumentText(arginfo[3], arg4, t.Args[3]);
|
|
|
|
SetArgumentText(arginfo[4], arg5, t.Args[4]);
|
2009-04-19 18:07:22 +00:00
|
|
|
|
2013-12-05 09:24:55 +00:00
|
|
|
//mxd. Flags
|
|
|
|
flags.Items.Clear();
|
2016-07-15 14:07:30 +00:00
|
|
|
Dictionary<string, string> flagsrename = ti.FlagsRename;
|
2015-04-12 21:05:09 +00:00
|
|
|
foreach(KeyValuePair<string, string> group in General.Map.Config.ThingFlags)
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2015-04-12 21:05:09 +00:00
|
|
|
if(t.Flags.ContainsKey(group.Key) && t.Flags[group.Key])
|
2016-07-15 14:07:30 +00:00
|
|
|
{
|
|
|
|
ListViewItem lvi = (flagsrename != null && flagsrename.ContainsKey(group.Key))
|
|
|
|
? new ListViewItem(flagsrename[group.Key]) { ForeColor = SystemColors.HotTrack }
|
|
|
|
: new ListViewItem(group.Value);
|
|
|
|
lvi.Checked = true;
|
|
|
|
flags.Items.Add(lvi);
|
|
|
|
}
|
2013-12-05 09:24:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//mxd. Flags panel visibility and size
|
|
|
|
flagsPanel.Visible = (flags.Items.Count > 0);
|
2016-06-14 20:39:46 +00:00
|
|
|
if(flags.Items.Count > 0)
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2016-06-14 20:39:46 +00:00
|
|
|
Rectangle rect = flags.GetItemRect(0);
|
|
|
|
int itemspercolumn = 1;
|
|
|
|
|
|
|
|
// Check how many items per column we have...
|
|
|
|
for(int i = 1; i < flags.Items.Count; i++)
|
|
|
|
{
|
|
|
|
if(flags.GetItemRect(i).X != rect.X) break;
|
|
|
|
itemspercolumn++;
|
|
|
|
}
|
|
|
|
|
|
|
|
flags.Width = rect.Width * (int)Math.Ceiling(flags.Items.Count / (float)itemspercolumn);
|
2013-12-05 09:24:55 +00:00
|
|
|
flagsPanel.Width = flags.Width + flags.Left * 2;
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Show the whole thing
|
|
|
|
this.Show();
|
2017-02-08 12:18:01 +00:00
|
|
|
//this.Update(); // ano - don't think this is needed, and is slow
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
2014-01-16 13:08:41 +00:00
|
|
|
//mxd
|
2014-12-03 23:15:26 +00:00
|
|
|
private static void SetArgumentText(ArgumentInfo info, Label label, int value)
|
2014-05-20 09:09:28 +00:00
|
|
|
{
|
2014-01-16 13:08:41 +00:00
|
|
|
TypeHandler th = General.Types.GetArgumentHandler(info);
|
|
|
|
th.SetValue(value);
|
|
|
|
label.Text = th.GetStringValue();
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// When visible changed
|
|
|
|
protected override void OnVisibleChanged(EventArgs e)
|
|
|
|
{
|
|
|
|
// Hiding panels
|
|
|
|
if(!this.Visible)
|
|
|
|
{
|
2015-01-18 19:51:36 +00:00
|
|
|
spritetex.Image = null;
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Call base
|
|
|
|
base.OnVisibleChanged(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|