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;
|
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;
|
|
|
|
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
|
|
|
|
{
|
|
|
|
private int hexenformatwidth;
|
|
|
|
private int doomformatwidth;
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
{
|
|
|
|
LinedefActionInfo act = null;
|
2014-02-21 14:42:12 +00:00
|
|
|
string actioninfo;
|
2009-04-19 18:07:22 +00:00
|
|
|
string zinfo;
|
|
|
|
float zvalue;
|
|
|
|
|
|
|
|
// 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
|
|
|
|
if(General.Map.Config.LinedefActions.ContainsKey(t.Action))
|
|
|
|
{
|
|
|
|
act = General.Map.Config.LinedefActions[t.Action];
|
|
|
|
actioninfo = act.ToString();
|
|
|
|
}
|
|
|
|
else if(t.Action == 0)
|
2014-02-21 14:42:12 +00:00
|
|
|
actioninfo = t.Action + " - None";
|
2009-04-19 18:07:22 +00:00
|
|
|
else
|
2014-02-21 14:42:12 +00:00
|
|
|
actioninfo = t.Action + " - Unknown";
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Determine z info to show
|
|
|
|
t.DetermineSector();
|
|
|
|
if(ti.AbsoluteZ)
|
|
|
|
{
|
|
|
|
zvalue = t.Position.z;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(t.Sector != null)
|
|
|
|
{
|
|
|
|
// Hangs from ceiling?
|
|
|
|
if(ti.Hangs)
|
|
|
|
{
|
2014-01-16 13:08:41 +00:00
|
|
|
zvalue = t.Sector.CeilHeight - t.Position.z - ti.Height; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-16 13:08:41 +00:00
|
|
|
zvalue = t.Sector.FloorHeight + t.Position.z;
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
zvalue = t.Position.z;
|
|
|
|
}
|
|
|
|
}
|
2015-03-03 09:42:54 +00:00
|
|
|
zinfo = zvalue.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;
|
|
|
|
action.Text = actioninfo;
|
2015-02-26 08:49:13 +00:00
|
|
|
labelclass.Enabled = !string.IsNullOrEmpty(ti.ClassName); //mxd
|
|
|
|
classname.Enabled = labelclass.Enabled; //mxd
|
|
|
|
classname.Text = (!string.IsNullOrEmpty(ti.ClassName) ? 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 = "";
|
2015-01-18 19:51:36 +00:00
|
|
|
spritetex.Image = General.Map.Data.GetSpriteImage(ti.Sprite).GetBitmap();
|
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
|
2013-08-08 11:04:13 +00:00
|
|
|
ArgumentInfo[] arginfo = (((t.Action == 0 || act == null) && ti.Args[0] != null) ? ti.Args : act.Args); //mxd
|
|
|
|
|
|
|
|
//mxd
|
|
|
|
bool hasArg0Str = General.Map.UDMF && Array.IndexOf(GZGeneral.ACS_SPECIALS, t.Action) != -1 && t.Fields.ContainsKey("arg0str");
|
|
|
|
|
|
|
|
arglbl1.Text = hasArg0Str ? "Script name:" : arginfo[0].Title + ":"; //mxd
|
|
|
|
arglbl2.Text = arginfo[1].Title + ":";
|
|
|
|
arglbl3.Text = arginfo[2].Title + ":";
|
|
|
|
arglbl4.Text = arginfo[3].Title + ":";
|
|
|
|
arglbl5.Text = arginfo[4].Title + ":";
|
|
|
|
arglbl1.Enabled = arginfo[0].Used;
|
|
|
|
arglbl2.Enabled = arginfo[1].Used;
|
|
|
|
arglbl3.Enabled = arginfo[2].Used;
|
|
|
|
arglbl4.Enabled = arginfo[3].Used;
|
|
|
|
arglbl5.Enabled = arginfo[4].Used;
|
|
|
|
arg1.Enabled = arginfo[0].Used;
|
|
|
|
arg2.Enabled = arginfo[1].Used;
|
|
|
|
arg3.Enabled = arginfo[2].Used;
|
|
|
|
arg4.Enabled = arginfo[3].Used;
|
|
|
|
arg5.Enabled = arginfo[4].Used;
|
|
|
|
|
|
|
|
//mxd
|
2014-12-03 23:15:26 +00:00
|
|
|
if(hasArg0Str)
|
|
|
|
{
|
2013-08-08 11:04:13 +00:00
|
|
|
arg1.Text = '"' + t.Fields["arg0str"].Value.ToString() + '"';
|
2014-12-03 23:15:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetArgumentText(arginfo[0], arg1, t.Args[0]);
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
2014-12-03 23:15:26 +00:00
|
|
|
SetArgumentText(arginfo[1], arg2, t.Args[1]);
|
|
|
|
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();
|
2014-12-03 23:15:26 +00:00
|
|
|
foreach(KeyValuePair<string, bool> group in t.Flags)
|
|
|
|
{
|
|
|
|
if(group.Value)
|
|
|
|
{
|
2013-12-17 08:19:40 +00:00
|
|
|
ListViewItem item = new ListViewItem(General.Map.Config.ThingFlags.ContainsKey(group.Key) ? General.Map.Config.ThingFlags[group.Key] : group.Key);
|
2013-12-05 09:24:55 +00:00
|
|
|
item.Checked = true;
|
|
|
|
flags.Items.Add(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//mxd. Flags panel visibility and size
|
|
|
|
flagsPanel.Visible = (flags.Items.Count > 0);
|
2014-12-03 23:15:26 +00:00
|
|
|
if(flags.Items.Count > 0)
|
|
|
|
{
|
2015-03-23 20:16:14 +00:00
|
|
|
flags.Width = flags.GetItemRect(0).Width * (int)Math.Ceiling(flags.Items.Count / 5.0f);
|
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();
|
|
|
|
this.Update();
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|