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;
|
2016-11-16 20:31:04 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
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
|
|
|
|
|
{
|
2016-11-16 20:31:04 +00:00
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
2013-03-18 13:52:27 +00:00
|
|
|
|
// Static instance
|
|
|
|
|
private static BuilderPlug me;
|
|
|
|
|
|
|
|
|
|
// Main objects
|
2016-11-16 20:31:04 +00:00
|
|
|
|
private MenusForm menusform;
|
|
|
|
|
|
|
|
|
|
#endregion
|
2013-03-18 13:52:27 +00:00
|
|
|
|
|
2016-11-16 20:31:04 +00:00
|
|
|
|
#region ================== Properties
|
2013-03-18 13:52:27 +00:00
|
|
|
|
|
|
|
|
|
public override string Name { get { return "Builder Effects"; } }
|
|
|
|
|
public static BuilderPlug Me { get { return me; } }
|
|
|
|
|
|
2016-11-16 20:31:04 +00:00
|
|
|
|
#endregion
|
2013-03-18 13:52:27 +00:00
|
|
|
|
|
2016-11-16 20:31:04 +00:00
|
|
|
|
#region ================== Disposer
|
2013-03-18 13:52:27 +00:00
|
|
|
|
|
2016-11-16 20:31:04 +00:00
|
|
|
|
public override void Dispose()
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
// Not already disposed?
|
2016-11-16 20:31:04 +00:00
|
|
|
|
if(!IsDisposed)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-11-16 20:31:04 +00:00
|
|
|
|
menusform.Unregister();
|
|
|
|
|
menusform.Dispose();
|
|
|
|
|
menusform = null;
|
2013-03-18 13:52:27 +00:00
|
|
|
|
|
|
|
|
|
// Done
|
|
|
|
|
me = null;
|
|
|
|
|
base.Dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-16 20:31:04 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Events
|
|
|
|
|
|
|
|
|
|
// When plugin is initialized
|
|
|
|
|
public override void OnInitialize()
|
|
|
|
|
{
|
|
|
|
|
// Setup
|
|
|
|
|
base.OnInitialize();
|
|
|
|
|
me = this;
|
|
|
|
|
|
|
|
|
|
// Load menus form
|
|
|
|
|
menusform = new MenusForm();
|
|
|
|
|
|
|
|
|
|
General.Actions.BindMethods(this);
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void OnMapNewEnd()
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
base.OnMapNewEnd();
|
2016-11-16 20:31:04 +00:00
|
|
|
|
menusform.Register();
|
2013-03-18 13:52:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void OnMapOpenEnd()
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
base.OnMapOpenEnd();
|
2016-11-16 20:31:04 +00:00
|
|
|
|
menusform.Register();
|
2013-03-18 13:52:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void OnMapCloseEnd()
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
base.OnMapCloseEnd();
|
2016-11-16 20:31:04 +00:00
|
|
|
|
menusform.Unregister();
|
2013-03-18 13:52:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void OnReloadResources()
|
|
|
|
|
{
|
2014-03-04 09:04:43 +00:00
|
|
|
|
base.OnReloadResources();
|
2016-11-16 20:31:04 +00:00
|
|
|
|
menusform.Register();
|
2014-03-04 09:04:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-16 20:31:04 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Actions
|
|
|
|
|
|
2013-03-18 13:52:27 +00:00
|
|
|
|
[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;
|
2016-11-16 20:31:04 +00:00
|
|
|
|
DelayedForm form = null;
|
2013-03-18 13:52:27 +00:00
|
|
|
|
|
2016-11-16 20:31:04 +00:00
|
|
|
|
// 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")
|
|
|
|
|
{
|
2016-11-16 20:31:04 +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)
|
|
|
|
|
{
|
2016-11-16 20:31:04 +00:00
|
|
|
|
// Check selected geometry
|
2013-03-18 13:52:27 +00:00
|
|
|
|
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
|
|
|
|
}
|
2016-11-16 20:31:04 +00:00
|
|
|
|
else // Wrong mode
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Switch to Sectors, Things, Vertices, Linedefs or Visual mode first!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-16 20:31:04 +00:00
|
|
|
|
form.ShowDialog(General.Interface);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BeginAction("applydirectionalshading")]
|
|
|
|
|
private void ApplyDirectionalShading()
|
|
|
|
|
{
|
|
|
|
|
// Boilerplate
|
|
|
|
|
if(General.Editing.Mode == null) return;
|
|
|
|
|
if(!General.Map.UDMF)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-11-16 20:31:04 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "This action is available only in UDMF map format!");
|
|
|
|
|
return;
|
2013-03-18 13:52:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-16 20:31:04 +00:00
|
|
|
|
DirectionalShadingForm form;
|
|
|
|
|
string currentmodename = General.Editing.Mode.GetType().Name;
|
|
|
|
|
|
|
|
|
|
// Create the form or tell the user why we can't do that
|
|
|
|
|
if(currentmodename == "SectorsMode")
|
|
|
|
|
{
|
|
|
|
|
if(General.Map.Map.SelectedSectorsCount == 0)
|
|
|
|
|
{
|
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Select some sectors first!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Collect sectors
|
|
|
|
|
ICollection<Sector> sectors = General.Map.Map.GetSelectedSectors(true);
|
|
|
|
|
|
|
|
|
|
// Collect sidedefs
|
|
|
|
|
HashSet<Sidedef> sides = new HashSet<Sidedef>();
|
|
|
|
|
foreach(Sector s in sectors)
|
|
|
|
|
{
|
|
|
|
|
foreach(Sidedef sd in s.Sidedefs)
|
|
|
|
|
{
|
|
|
|
|
sides.Add(sd);
|
|
|
|
|
if(sd.Other != null) sides.Add(sd.Other);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create the form
|
|
|
|
|
form = new DirectionalShadingForm(sectors, sides, null);
|
|
|
|
|
}
|
|
|
|
|
else if(currentmodename == "LinedefsMode")
|
|
|
|
|
{
|
|
|
|
|
if(General.Map.Map.SelectedLinedefsCount == 0)
|
|
|
|
|
{
|
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Select some linedefs first!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Collect linedefs
|
|
|
|
|
ICollection<Linedef> linedefs = General.Map.Map.GetSelectedLinedefs(true);
|
|
|
|
|
|
|
|
|
|
// Collect sectors
|
|
|
|
|
ICollection<Sector> sectors = General.Map.Map.GetSectorsFromLinedefs(linedefs);
|
|
|
|
|
|
|
|
|
|
// Collect sidedefs from linedefs
|
|
|
|
|
HashSet<Sidedef> sides = new HashSet<Sidedef>();
|
|
|
|
|
foreach(Linedef l in linedefs)
|
|
|
|
|
{
|
|
|
|
|
if(l.Front != null) sides.Add(l.Front);
|
|
|
|
|
if(l.Back != null) sides.Add(l.Back);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Collect sidedefs from sectors
|
|
|
|
|
foreach(Sector s in sectors)
|
|
|
|
|
{
|
|
|
|
|
foreach(Sidedef sd in s.Sidedefs)
|
|
|
|
|
{
|
|
|
|
|
sides.Add(sd);
|
|
|
|
|
if(sd.Other != null) sides.Add(sd.Other);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create the form
|
|
|
|
|
form = new DirectionalShadingForm(sectors, sides, null);
|
|
|
|
|
}
|
|
|
|
|
else if(currentmodename == "BaseVisualMode")
|
|
|
|
|
{
|
|
|
|
|
// Check selected geometry
|
|
|
|
|
VisualMode mode = (VisualMode)General.Editing.Mode;
|
|
|
|
|
List<VisualGeometry> list = mode.GetSelectedSurfaces();
|
|
|
|
|
HashSet<VisualSector> selectedgeo = new HashSet<VisualSector>();
|
|
|
|
|
List<Sector> sectors = new List<Sector>();
|
|
|
|
|
HashSet<Sidedef> sides = new HashSet<Sidedef>();
|
|
|
|
|
|
|
|
|
|
// Collect sectors and sides
|
|
|
|
|
if(list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach(VisualGeometry vg in list)
|
|
|
|
|
{
|
|
|
|
|
switch(vg.GeometryType)
|
|
|
|
|
{
|
|
|
|
|
case VisualGeometryType.FLOOR:
|
|
|
|
|
selectedgeo.Add(vg.Sector);
|
|
|
|
|
sectors.Add(vg.Sector.Sector);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case VisualGeometryType.WALL_UPPER:
|
|
|
|
|
case VisualGeometryType.WALL_MIDDLE:
|
|
|
|
|
case VisualGeometryType.WALL_LOWER:
|
|
|
|
|
sides.Add(vg.Sidedef);
|
|
|
|
|
selectedgeo.Add(mode.GetVisualSector(vg.Sidedef.Sector));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add sides from selected sectors
|
|
|
|
|
foreach(Sector s in sectors)
|
|
|
|
|
{
|
|
|
|
|
foreach(Sidedef sd in s.Sidedefs)
|
|
|
|
|
{
|
|
|
|
|
sides.Add(sd);
|
|
|
|
|
if(sd.Other != null) sides.Add(sd.Other);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create the form?
|
|
|
|
|
if(sectors.Count > 0 || sides.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
form = new DirectionalShadingForm(sectors, sides, selectedgeo);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Select some floor or wall surfaces first!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // Wrong mode
|
|
|
|
|
{
|
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Switch to Sectors, Linedefs or Visual mode first!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Show the form
|
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
|
|
|
|
form.ShowDialog(General.Interface);
|
2013-03-18 13:52:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-16 20:31:04 +00:00
|
|
|
|
#endregion
|
2013-03-18 13:52:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|