UltimateZoneBuilder/Source/Core/Map/SelectableElement.cs

112 lines
2.4 KiB
C#
Raw Normal View History

#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
#endregion
namespace CodeImp.DoomBuilder.Map
{
public abstract class SelectableElement : MapElement
{
#region ================== Constants
#endregion
#region ================== Variables
// Selected or not?
private bool selected;
// Group bitmask
private int groups;
#endregion
#region ================== Properties
public bool Selected { get { return selected; } set { if(value && !selected) DoSelect(); else if(!value && selected) DoUnselect(); } }
#endregion
#region ================== Constructor / Disposer
// Disposer
public override void Dispose()
{
Added, Texture Browser: added "Show textures in subdirectories" checkbox (enabled by default). When enabled, textures from current PK3/PK7/Directory resource directory and it's subdirectories will be shown. Otherwise, only textures from current directory will be shown. Removed, Texture Browser: removed "Show image sizes" checkbox. "Show texture and flat sizes in browsers" preferences setting is now used instead. Fixed, Things mode: event line between pre-last and the last PatrolPoint was not drawn. Fixed, Things mode: highlight range for sizeless things (things with "fixedsize" game configuration property) was calculated incorrectly. Fixed: fixed a crash when opening Script Editor after using "Open map in current wad" command to switch to UDMF map with SCRIPTS lump when current script configuration was not saved in the wad's .dbs file. Fixed: map closing events were not triggered when using "Open map in current wad" command, which could potentially result in plugin crashes/incorrect behavior. Fixed: Sector Drawing overrides panel could trigger an exception when closing the map during resource loading. Internal: added "Debug + Profiler" solution configuration, added 2 profiling methods to DebugConsole. Internal: rewrote MainForm.DisplayStatus() / StatusInfo to handle selection info in a more structured way. Fixed, internal: some destructors could potentially be executed more than once potentially leading to exceptions. Other destructors were not called at all. Updated ZDoom_DECORATE.cfg.
2015-09-16 12:10:43 +00:00
// Not already disposed?
if(!isdisposed)
{
// Remove from selection
if(selected) Selected = false;
// Done
base.Dispose();
}
}
#endregion
#region ================== Methods
// This makes the selection
protected virtual void DoSelect()
{
selected = true;
}
// This removes the selection
protected virtual void DoUnselect()
{
selected = false;
}
// This copies properties to any other element
public void CopyPropertiesTo(SelectableElement element)
{
element.groups = this.groups;
element.Selected = this.selected;
base.CopyPropertiesTo(element);
}
// This adds the element to one or more groups
public void AddToGroup(int groupsmask)
{
groups |= groupsmask;
}
// This removes the elements from one or more groups
public void RemoveFromGroup(int groupsmask)
{
groups &= ~groupsmask;
}
// This selects by group
public void SelectByGroup(int groupsmask)
{
this.Selected = ((groups & groupsmask) != 0);
}
//mxd. This checks if given element belongs to a particular group
public bool IsInGroup(int groupsmask)
{
return ((groups & groupsmask) != 0);
}
#endregion
}
}