2014-12-03 23:15:26 +00:00
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
2013-03-18 13:52:27 +00:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using CodeImp.DoomBuilder.Actions;
|
2014-12-03 23:15:26 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Plugins;
|
2013-03-18 13:52:27 +00:00
|
|
|
|
using CodeImp.DoomBuilder.VisualModes;
|
|
|
|
|
using CodeImp.DoomBuilder.Windows;
|
2014-12-03 23:15:26 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
2013-03-18 13:52:27 +00:00
|
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderEffects
|
|
|
|
|
{
|
|
|
|
|
public class BuilderPlug : Plug
|
|
|
|
|
{
|
|
|
|
|
// Static instance
|
|
|
|
|
private static BuilderPlug me;
|
|
|
|
|
|
|
|
|
|
// Main objects
|
|
|
|
|
private MenusForm menusForm;
|
|
|
|
|
private Form form;
|
|
|
|
|
|
|
|
|
|
private Point formLocation; //used to keep form's location constant
|
|
|
|
|
|
|
|
|
|
public override string Name { get { return "Builder Effects"; } }
|
|
|
|
|
public static BuilderPlug Me { get { return me; } }
|
|
|
|
|
|
|
|
|
|
// When plugin is initialized
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void OnInitialize()
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
// Setup
|
|
|
|
|
base.OnInitialize();
|
|
|
|
|
me = this;
|
|
|
|
|
|
2014-02-26 14:11:06 +00:00
|
|
|
|
// Load menus form
|
2013-03-18 13:52:27 +00:00
|
|
|
|
menusForm = new MenusForm();
|
|
|
|
|
|
|
|
|
|
General.Actions.BindMethods(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Disposer
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void Dispose()
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
// Not already disposed?
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(!IsDisposed)
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
menusForm.Unregister();
|
|
|
|
|
menusForm.Dispose();
|
|
|
|
|
menusForm = null;
|
|
|
|
|
|
|
|
|
|
// Done
|
|
|
|
|
me = null;
|
|
|
|
|
base.Dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void OnMapNewEnd()
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
base.OnMapNewEnd();
|
|
|
|
|
menusForm.Register();
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void OnMapOpenEnd()
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
base.OnMapOpenEnd();
|
|
|
|
|
menusForm.Register();
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void OnMapCloseEnd()
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
base.OnMapCloseEnd();
|
|
|
|
|
menusForm.Unregister();
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void OnReloadResources()
|
|
|
|
|
{
|
2014-03-04 09:04:43 +00:00
|
|
|
|
base.OnReloadResources();
|
|
|
|
|
menusForm.Register();
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-18 13:52:27 +00:00
|
|
|
|
//actions
|
|
|
|
|
[BeginAction("applyjitter")]
|
2014-12-03 23:15:26 +00:00
|
|
|
|
private void ApplyJitterTransform()
|
|
|
|
|
{
|
|
|
|
|
if(General.Editing.Mode == null) return;
|
2013-03-18 13:52:27 +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-03-18 13:52:27 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Select some things first!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
form = new JitterThingsForm(currentModeName);
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else if(currentModeName == "SectorsMode")
|
|
|
|
|
{
|
|
|
|
|
if(General.Map.Map.SelectedSectorsCount == 0)
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Select some sectors first!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
form = new JitterSectorsForm(currentModeName);
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else if(currentModeName == "LinedefsMode")
|
|
|
|
|
{
|
|
|
|
|
if(General.Map.Map.SelectedLinedefsCount == 0)
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Select some linedefs first!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
form = new JitterVerticesForm(currentModeName);
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else if(currentModeName == "VerticesMode")
|
|
|
|
|
{
|
|
|
|
|
if(General.Map.Map.SelectedVerticessCount == 0)
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Select some vertices first!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
form = new JitterVerticesForm(currentModeName);
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else if(currentModeName == "BaseVisualMode")
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
//no visual things selected in visual mode?
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(((VisualMode)General.Editing.Mode).GetSelectedVisualThings(true).Count == 0)
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
//check selected geometry
|
|
|
|
|
List<VisualGeometry> list = ((VisualMode)General.Editing.Mode).GetSelectedSurfaces();
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach(VisualGeometry vg in list)
|
|
|
|
|
{
|
|
|
|
|
if(vg.GeometryType == VisualGeometryType.CEILING
|
|
|
|
|
|| vg.GeometryType == VisualGeometryType.FLOOR)
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
form = new JitterSectorsForm(currentModeName);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(form == null) form = new JitterVerticesForm(currentModeName);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Select some things, sectors or surfaces first!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
form = new JitterThingsForm(currentModeName);
|
|
|
|
|
}
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else //wrong mode
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Switch to Sectors, Things, Vertices, Linedefs or Visual mode first!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//position and show form
|
2015-09-17 12:02:39 +00:00
|
|
|
|
if(formLocation.X == 0 && formLocation.Y == 0)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
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-03-18 13:52:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
form.Location = formLocation;
|
2014-02-21 14:42:12 +00:00
|
|
|
|
form.FormClosed += form_FormClosed;
|
2013-03-18 13:52:27 +00:00
|
|
|
|
form.ShowDialog(Form.ActiveForm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//events
|
2014-12-03 23:15:26 +00:00
|
|
|
|
private void form_FormClosed(object sender, FormClosedEventArgs e)
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
formLocation = form.Location;
|
|
|
|
|
form.Dispose();
|
|
|
|
|
form = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|