2014-12-03 23:15:26 +00:00
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
|
|
using System.Drawing;
|
2012-05-11 12:28:20 +00:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using CodeImp.DoomBuilder.Actions;
|
|
|
|
|
using CodeImp.DoomBuilder.ColorPicker.Windows;
|
2014-12-03 23:15:26 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Plugins;
|
|
|
|
|
using CodeImp.DoomBuilder.VisualModes;
|
|
|
|
|
using CodeImp.DoomBuilder.Windows;
|
|
|
|
|
|
|
|
|
|
#endregion
|
2012-05-11 12:28:20 +00:00
|
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.ColorPicker
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
public class BuilderPlug : Plug
|
|
|
|
|
{
|
|
|
|
|
private static BuilderPlug me;
|
|
|
|
|
public static BuilderPlug Me { get { return me; } }
|
|
|
|
|
|
2014-01-08 15:20:56 +00:00
|
|
|
|
public override int MinimumRevision { get { return 1869; } }
|
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
public override string Name { get { return "Color Picker"; } }
|
|
|
|
|
|
|
|
|
|
private IColorPicker form;
|
|
|
|
|
private ToolsForm toolsform;
|
|
|
|
|
|
|
|
|
|
private Point formLocation; //used to keep form's location constant
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void OnInitialize()
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
base.OnInitialize();
|
|
|
|
|
me = this;
|
|
|
|
|
|
2014-02-26 14:11:06 +00:00
|
|
|
|
// Load menus form
|
|
|
|
|
toolsform = new ToolsForm();
|
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
General.Actions.BindMethods(this);
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void OnMapOpenEnd()
|
|
|
|
|
{
|
2014-02-26 14:11:06 +00:00
|
|
|
|
base.OnMapOpenEnd();
|
|
|
|
|
toolsform.Register();
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void OnMapNewEnd()
|
|
|
|
|
{
|
2014-02-26 14:11:06 +00:00
|
|
|
|
base.OnMapNewEnd();
|
|
|
|
|
toolsform.Register();
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void OnMapCloseEnd()
|
|
|
|
|
{
|
2014-02-26 14:11:06 +00:00
|
|
|
|
base.OnMapCloseEnd();
|
|
|
|
|
toolsform.Unregister();
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void OnReloadResources()
|
|
|
|
|
{
|
2014-03-04 09:04:43 +00:00
|
|
|
|
base.OnReloadResources();
|
|
|
|
|
toolsform.Register();
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void Dispose()
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
base.Dispose();
|
|
|
|
|
General.Actions.UnbindMethods(this);
|
|
|
|
|
|
|
|
|
|
if (form != null) form.Close();
|
|
|
|
|
form = null;
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if (toolsform != null)
|
|
|
|
|
{
|
2014-02-26 14:11:06 +00:00
|
|
|
|
toolsform.Unregister();
|
|
|
|
|
toolsform.Dispose();
|
|
|
|
|
toolsform = null;
|
|
|
|
|
}
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BeginAction("togglelightpannel")]
|
2014-12-03 23:15:26 +00:00
|
|
|
|
private void ToggleLightPannel()
|
|
|
|
|
{
|
|
|
|
|
if (General.Editing.Mode == null) return;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
string currentModeName = General.Editing.Mode.GetType().Name;
|
|
|
|
|
|
|
|
|
|
//display one of colorPickers or tell the user why we can't do that
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if (currentModeName == "ThingsMode")
|
|
|
|
|
{
|
|
|
|
|
if(General.Map.Map.SelectedThingsCount == 0)
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Select some lights first!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
form = new LightColorPicker();
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else if (currentModeName == "SectorsMode")
|
|
|
|
|
{
|
|
|
|
|
if (General.Map.UDMF)
|
|
|
|
|
{
|
|
|
|
|
if (General.Map.Map.SelectedSectorsCount == 0)
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Select some sectors first!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
form = new SectorColorPicker();
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Sector colors can only be set if map is in UDMF format!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else if (currentModeName == "BaseVisualMode")
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
//nothing selected in visual mode?
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if ( ((VisualMode)General.Editing.Mode).GetSelectedVisualThings(true).Count == 0 )
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
//check sectors
|
|
|
|
|
int selectedSectorsCount = ((VisualMode)General.Editing.Mode).GetSelectedVisualSectors(true).Count;
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if (General.Map.UDMF && (selectedSectorsCount > 0 || General.Map.Map.SelectedSectorsCount > 0))
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
form = new SectorColorPicker();
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Select some lights " + (General.Map.UDMF ? ", sectors or surfaces " : "") + "first!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
form = new LightColorPicker();
|
|
|
|
|
}
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else //wrong mode
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Switch to" + (General.Map.UDMF ? " Sectors," : "") + " Things or GZDoom Visual Mode first!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if (form.Setup(currentModeName))
|
|
|
|
|
{
|
|
|
|
|
if (formLocation.X == 0 && formLocation.Y == 0)
|
|
|
|
|
{
|
2015-09-17 12:02:39 +00:00
|
|
|
|
Size displaySize = General.Interface.Display.Size;
|
|
|
|
|
Point displayLocation = General.Interface.Display.LocationAbs;
|
|
|
|
|
formLocation = new Point(displayLocation.X + displaySize.Width - form.Width - 16, displayLocation.Y + 16);
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
|
|
|
|
form.Location = formLocation;
|
2014-02-21 14:42:12 +00:00
|
|
|
|
form.FormClosed += form_FormClosed;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
form.ShowDialog(Form.ActiveForm);
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
form.Dispose();
|
|
|
|
|
form = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
private void form_FormClosed(object sender, FormClosedEventArgs e)
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
formLocation = form.Location;
|
|
|
|
|
form.Dispose();
|
|
|
|
|
form = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-05-20 00:56:59 +00:00
|
|
|
|
}
|