mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-27 06:02:11 +00:00
13c3155db5
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action. Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them. Changed, Paste Properties Special window: only options relevant to current map format are now displayed. Changed, Paste Properties Special window, UDMF: all UI-managed options are now available. Fixed: MAPINFO parser was unable to process "include" directives. Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection. Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode. Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time. Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map. Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled. Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category. Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll. Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format. Internal: merged methods from UDMFTools into UniFields, removed UDMFTools. Updated Inno Setup script (added VC++ 2008 SP1 distributive). Updated ZDoom_DECORATE.cfg (A_CheckBlock). Updated documentation (added "System Requirements" page).
200 lines
No EOL
5.6 KiB
C#
200 lines
No EOL
5.6 KiB
C#
#region ================== Namespaces
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Reflection;
|
|
using System.Windows.Forms;
|
|
using CodeImp.DoomBuilder.Controls;
|
|
using CodeImp.DoomBuilder.Map;
|
|
using CodeImp.DoomBuilder.Windows;
|
|
|
|
#endregion
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes.Interface
|
|
{
|
|
public partial class PastePropertiesOptionsForm : DelayedForm
|
|
{
|
|
#region ================== Variables
|
|
|
|
private static Size size = Size.Empty;
|
|
private static Point location = Point.Empty;
|
|
private Dictionary<object, CheckboxArrayControl> typecontrols;
|
|
|
|
#endregion
|
|
|
|
#region ================== Constructor / Setup
|
|
|
|
public PastePropertiesOptionsForm()
|
|
{
|
|
InitializeComponent();
|
|
|
|
// Apply window size and location
|
|
if(!size.IsEmpty && !location.IsEmpty)
|
|
{
|
|
this.StartPosition = FormStartPosition.Manual;
|
|
this.Size = size;
|
|
this.Location = location;
|
|
}
|
|
}
|
|
|
|
public bool Setup(MapElementType targetmapelementtype) { return Setup(new List<MapElementType> { targetmapelementtype }); }
|
|
public bool Setup(IEnumerable<MapElementType> targetmapelementtypes)
|
|
{
|
|
// Create collections
|
|
typecontrols = new Dictionary<object, CheckboxArrayControl>();
|
|
var tabcontrols = new Dictionary<TabPage, CheckboxArrayControl>();
|
|
|
|
// Add appropriate controls
|
|
foreach(MapElementType t in targetmapelementtypes)
|
|
{
|
|
switch(t)
|
|
{
|
|
case MapElementType.THING:
|
|
if(BuilderPlug.Me.CopiedThingProps != null)
|
|
{
|
|
typecontrols.Add(ThingProperties.CopySettings, thingflags);
|
|
tabcontrols.Add(things, thingflags);
|
|
}
|
|
break;
|
|
|
|
case MapElementType.SECTOR:
|
|
if(BuilderPlug.Me.CopiedSectorProps != null)
|
|
{
|
|
typecontrols.Add(SectorProperties.CopySettings, sectorflags);
|
|
tabcontrols.Add(sectors, sectorflags);
|
|
}
|
|
break;
|
|
|
|
case MapElementType.LINEDEF:
|
|
case MapElementType.SIDEDEF:
|
|
if(BuilderPlug.Me.CopiedSidedefProps != null || BuilderPlug.Me.CopiedLinedefProps != null)
|
|
{
|
|
typecontrols.Add(LinedefProperties.CopySettings, lineflags);
|
|
typecontrols.Add(SidedefProperties.CopySettings, sideflags);
|
|
tabcontrols.Add(linedefs, lineflags);
|
|
tabcontrols.Add(sidedefs, sideflags);
|
|
}
|
|
break;
|
|
|
|
case MapElementType.VERTEX:
|
|
if(BuilderPlug.Me.CopiedVertexProps != null)
|
|
{
|
|
typecontrols.Add(VertexProperties.CopySettings, vertexflags);
|
|
tabcontrols.Add(vertices, vertexflags);
|
|
}
|
|
break;
|
|
|
|
default:
|
|
throw new NotImplementedException("Unknown map element type: " + t);
|
|
}
|
|
}
|
|
|
|
// Got anything to show?
|
|
if(typecontrols.Count == 0)
|
|
{
|
|
General.Interface.DisplayStatus(StatusType.Warning, "No copied properties to apply!");
|
|
return false;
|
|
}
|
|
|
|
// Fill flags
|
|
FillFlags();
|
|
|
|
// Select proper tab
|
|
if(!ShowTabs(tabcontrols))
|
|
{
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Current map format doesn't support any properties for selected map elements!");
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ================== Methods
|
|
|
|
private bool ShowTabs(Dictionary<TabPage, CheckboxArrayControl> pageslist)
|
|
{
|
|
List<TabPage> toshow = new List<TabPage>();
|
|
foreach(TabPage page in tabcontrol.TabPages)
|
|
{
|
|
if(pageslist.ContainsKey(page) && pageslist[page].Checkboxes.Count > 0) toshow.Add(page);
|
|
}
|
|
|
|
if(toshow.Count == 0) return false;
|
|
|
|
tabcontrol.TabPages.Clear();
|
|
tabcontrol.TabPages.AddRange(toshow.ToArray());
|
|
tabcontrol.SelectTab(toshow[0]);
|
|
|
|
return true;
|
|
}
|
|
|
|
private void FillFlags()
|
|
{
|
|
// Fill flags
|
|
foreach(KeyValuePair<object, CheckboxArrayControl> group in typecontrols)
|
|
{
|
|
FieldInfo[] props = group.Key.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
|
|
foreach(FieldInfo prop in props)
|
|
{
|
|
foreach(Attribute attr in Attribute.GetCustomAttributes(prop))
|
|
{
|
|
if(attr.GetType() == typeof(FieldDescription))
|
|
{
|
|
FieldDescription fd = (FieldDescription)attr;
|
|
if(fd.SupportsCurrentMapFormat)
|
|
{
|
|
group.Value.Add(fd.Description, prop.Name).Checked = (bool)prop.GetValue(group.Key);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(group.Value.Checkboxes.Count > 0) group.Value.PositionCheckboxes();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ================== Events
|
|
|
|
private void apply_Click(object sender, EventArgs e)
|
|
{
|
|
foreach(KeyValuePair<object, CheckboxArrayControl> group in typecontrols)
|
|
{
|
|
FieldInfo[] props = group.Key.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
|
|
var fields = new Dictionary<string, FieldInfo>(props.Length);
|
|
for(int i = 0; i < props.Length; i++) fields[props[i].Name] = props[i];
|
|
foreach(CheckBox cb in group.Value.Checkboxes) fields[cb.Tag.ToString()].SetValue(group.Key, cb.Checked);
|
|
}
|
|
|
|
this.DialogResult = DialogResult.OK;
|
|
this.Close();
|
|
}
|
|
|
|
private void cancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.DialogResult = DialogResult.Cancel;
|
|
this.Close();
|
|
}
|
|
|
|
private void enableall_Click(object sender, EventArgs e)
|
|
{
|
|
var cc = tabcontrol.SelectedTab.Controls[0] as CheckboxArrayControl;
|
|
if(cc == null) return; //just a piece of boilerplate...
|
|
bool enable = !cc.Checkboxes[0].Checked;
|
|
foreach(var cb in cc.Checkboxes) cb.Checked = enable;
|
|
}
|
|
|
|
private void PastePropertiesOptionsForm_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
size = this.Size;
|
|
location = this.Location;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |