2012-06-01 19:53:14 +00:00
|
|
|
|
#region === Copyright (c) 2010 Pascal van der Heiden ===
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using CodeImp.DoomBuilder.Windows;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Plugins.VisplaneExplorer
|
|
|
|
|
{
|
2014-10-22 13:07:17 +00:00
|
|
|
|
public partial class InterfaceForm : DelayedForm
|
2012-06-01 19:53:14 +00:00
|
|
|
|
{
|
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2016-09-22 20:24:32 +00:00
|
|
|
|
#region ================== mxd. Event handlers
|
|
|
|
|
|
2021-08-21 07:28:05 +00:00
|
|
|
|
public event EventHandler OnVisplaneSettingsChanged;
|
2016-09-22 20:24:32 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2012-06-01 19:53:14 +00:00
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
|
|
private ViewStats viewstats;
|
2014-09-11 11:51:02 +00:00
|
|
|
|
private Point oldttposition;
|
2021-08-21 07:28:05 +00:00
|
|
|
|
private int viewheight;
|
|
|
|
|
private int viewheightcustom;
|
|
|
|
|
private int viewheightdefault;
|
2012-06-01 19:53:14 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
|
|
internal ViewStats ViewStats { get { return viewstats; } }
|
2016-09-22 20:24:32 +00:00
|
|
|
|
internal bool OpenDoors { get { return cbopendoors.Checked; } } //mxd
|
|
|
|
|
internal bool ShowHeatmap { get { return cbheatmap.Checked; } } //mxd
|
2021-08-21 07:28:05 +00:00
|
|
|
|
internal int ViewHeight { get { return viewheight; } }
|
|
|
|
|
internal int ViewHeightDefault { get { return viewheightdefault; } }
|
2012-06-01 19:53:14 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Constructor / Destructor
|
|
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
|
public InterfaceForm()
|
|
|
|
|
{
|
2021-08-21 07:28:05 +00:00
|
|
|
|
viewheightdefault = General.Map.Config.VisplaneViewHeightDefault;
|
2012-06-01 19:53:14 +00:00
|
|
|
|
InitializeComponent();
|
2016-09-22 20:24:32 +00:00
|
|
|
|
cbopendoors.Checked = General.Settings.ReadPluginSetting("opendoors", false); //mxd
|
|
|
|
|
cbheatmap.Checked = General.Settings.ReadPluginSetting("showheatmap", false); //mxd
|
2021-08-21 07:28:05 +00:00
|
|
|
|
viewheight = General.Settings.ReadPluginSetting("viewheight", viewheightdefault);
|
|
|
|
|
viewheightcustom = General.Settings.ReadPluginSetting("viewheightcustom", 0);
|
|
|
|
|
|
|
|
|
|
RedrawViewHeightMenuItems();
|
2012-06-01 19:53:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
|
|
// This adds the buttons to the toolbar
|
|
|
|
|
public void AddToInterface()
|
|
|
|
|
{
|
2016-11-26 00:02:56 +00:00
|
|
|
|
General.Interface.BeginToolbarUpdate(); //mxd
|
2014-09-11 11:51:02 +00:00
|
|
|
|
General.Interface.AddButton(statsbutton);
|
|
|
|
|
General.Interface.AddButton(separator); //mxd
|
|
|
|
|
General.Interface.AddButton(cbopendoors); //mxd
|
|
|
|
|
General.Interface.AddButton(cbheatmap); //mxd
|
2021-08-21 07:28:05 +00:00
|
|
|
|
General.Interface.AddButton(heightbutton);
|
2016-11-26 00:02:56 +00:00
|
|
|
|
General.Interface.EndToolbarUpdate(); //mxd
|
2012-06-01 19:53:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This removes the buttons from the toolbar
|
|
|
|
|
public void RemoveFromInterface()
|
|
|
|
|
{
|
2016-11-26 00:02:56 +00:00
|
|
|
|
General.Interface.BeginToolbarUpdate(); //mxd
|
2021-08-21 07:28:05 +00:00
|
|
|
|
General.Interface.RemoveButton(heightbutton);
|
2014-09-11 11:51:02 +00:00
|
|
|
|
General.Interface.RemoveButton(cbheatmap); //mxd
|
|
|
|
|
General.Interface.RemoveButton(cbopendoors); //mxd
|
|
|
|
|
General.Interface.RemoveButton(separator); //mxd
|
2012-06-01 19:53:14 +00:00
|
|
|
|
General.Interface.RemoveButton(statsbutton);
|
2016-11-26 00:02:56 +00:00
|
|
|
|
General.Interface.EndToolbarUpdate(); //mxd
|
2016-09-22 20:24:32 +00:00
|
|
|
|
|
|
|
|
|
//mxd. Save settings
|
|
|
|
|
General.Settings.WritePluginSetting("opendoors", cbopendoors.Checked);
|
|
|
|
|
General.Settings.WritePluginSetting("showheatmap", cbheatmap.Checked);
|
2021-08-21 07:28:05 +00:00
|
|
|
|
General.Settings.WritePluginSetting("viewheight", viewheight);
|
|
|
|
|
General.Settings.WritePluginSetting("viewheightcustom", viewheightcustom);
|
2012-06-01 19:53:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This shows a tooltip
|
|
|
|
|
public void ShowTooltip(string text, Point p)
|
|
|
|
|
{
|
|
|
|
|
Point sp = General.Interface.Display.PointToScreen(p);
|
|
|
|
|
Point fp = (General.Interface as Form).Location;
|
|
|
|
|
Point tp = new Point(sp.X - fp.X, sp.Y - fp.Y);
|
|
|
|
|
|
2015-12-28 15:01:53 +00:00
|
|
|
|
if(oldttposition != tp)
|
2012-06-01 19:53:14 +00:00
|
|
|
|
{
|
|
|
|
|
tooltip.Show(text, General.Interface, tp);
|
|
|
|
|
oldttposition = tp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This hides the tooltip
|
|
|
|
|
public void HideTooltip()
|
|
|
|
|
{
|
|
|
|
|
tooltip.Hide(General.Interface);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Events
|
|
|
|
|
|
|
|
|
|
// Selecting a type of stats to view
|
|
|
|
|
private void stats_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
foreach(ToolStripMenuItem i in statsbutton.DropDownItems)
|
|
|
|
|
i.Checked = false;
|
|
|
|
|
|
|
|
|
|
ToolStripMenuItem item = (ToolStripMenuItem)sender;
|
|
|
|
|
viewstats = (ViewStats)int.Parse(item.Tag.ToString(), CultureInfo.InvariantCulture);
|
|
|
|
|
item.Checked = true;
|
|
|
|
|
statsbutton.Image = item.Image;
|
|
|
|
|
|
|
|
|
|
General.Interface.RedrawDisplay();
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-11 11:51:02 +00:00
|
|
|
|
//mxd
|
|
|
|
|
private void cbheatmap_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
General.Interface.RedrawDisplay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//mxd
|
|
|
|
|
private void cbopendoors_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2021-08-21 07:28:05 +00:00
|
|
|
|
if(OnVisplaneSettingsChanged != null) OnVisplaneSettingsChanged(this, EventArgs.Empty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Select the height above the floor the Visplane Explorer renderer draws from.
|
|
|
|
|
private void viewheight_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
foreach (ToolStripMenuItem i in heightbutton.DropDownItems)
|
|
|
|
|
i.Checked = false;
|
|
|
|
|
|
|
|
|
|
ToolStripMenuItem item = (ToolStripMenuItem)sender;
|
|
|
|
|
viewheight = int.Parse(item.Tag.ToString(), CultureInfo.InvariantCulture);
|
|
|
|
|
item.Checked = true;
|
|
|
|
|
|
|
|
|
|
RedrawViewHeightButtonText();
|
|
|
|
|
|
|
|
|
|
General.Interface.RedrawDisplay();
|
|
|
|
|
|
|
|
|
|
if(OnVisplaneSettingsChanged != null) OnVisplaneSettingsChanged(this, EventArgs.Empty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Prompt user to enter a custom height, saving to the menu dropdown.
|
|
|
|
|
private void heightcustomadd_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
customheightdialog.CustomHeight = viewheightcustom;
|
|
|
|
|
|
|
|
|
|
if (customheightdialog.ShowDialog() != DialogResult.OK)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
int oldviewheight = viewheight;
|
|
|
|
|
viewheightcustom = customheightdialog.CustomHeight;
|
|
|
|
|
|
|
|
|
|
viewheight = viewheightcustom > 0 ? viewheightcustom : viewheightdefault;
|
|
|
|
|
|
|
|
|
|
if (General.Map.Config.VisplaneViewHeights.ContainsKey(viewheightcustom.ToString()))
|
|
|
|
|
viewheightcustom = 0;
|
|
|
|
|
|
|
|
|
|
RedrawViewHeightMenuItems();
|
|
|
|
|
|
|
|
|
|
if (oldviewheight != viewheight)
|
|
|
|
|
{
|
|
|
|
|
General.Interface.RedrawDisplay();
|
|
|
|
|
|
|
|
|
|
if (OnVisplaneSettingsChanged != null) OnVisplaneSettingsChanged(this, EventArgs.Empty);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RedrawViewHeightButtonText()
|
|
|
|
|
{
|
|
|
|
|
heightbutton.Text = "View Height (" + viewheight.ToString() + ")";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RedrawViewHeightMenuItems()
|
|
|
|
|
{
|
|
|
|
|
RedrawViewHeightButtonText();
|
|
|
|
|
|
|
|
|
|
heightcustomitem.Tag = viewheightcustom.ToString();
|
|
|
|
|
heightcustomitem.Visible = viewheightcustom > 0;
|
|
|
|
|
heightcustomitem.Text = viewheightcustom.ToString() + " - Custom";
|
|
|
|
|
|
|
|
|
|
foreach (ToolStripMenuItem heightitem in heightbutton.DropDownItems)
|
|
|
|
|
heightitem.Checked = viewheight == int.Parse((string)heightitem.Tag, CultureInfo.InvariantCulture);
|
2014-09-11 11:51:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-01 19:53:14 +00:00
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|