mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-18 18:11:13 +00:00
generalized selectable map elements in a base class
This commit is contained in:
parent
6c8844d601
commit
800dc6a620
8 changed files with 130 additions and 50 deletions
|
@ -138,6 +138,7 @@
|
|||
<Compile Include="IO\UniversalStreamReader.cs" />
|
||||
<Compile Include="IO\UniversalStreamWriter.cs" />
|
||||
<Compile Include="Map\MapElement.cs" />
|
||||
<Compile Include="Map\SelectableElement.cs" />
|
||||
<Compile Include="Map\UniFields.cs" />
|
||||
<Compile Include="Map\UniValue.cs" />
|
||||
<Compile Include="Rendering\ViewMode.cs" />
|
||||
|
|
|
@ -30,7 +30,7 @@ using System.Drawing;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Map
|
||||
{
|
||||
public sealed class Linedef : MapElement
|
||||
public sealed class Linedef : SelectableElement
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
|
@ -73,10 +73,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
private int activate;
|
||||
private int tag;
|
||||
private int[] args;
|
||||
|
||||
// Selections
|
||||
private bool selected;
|
||||
private bool marked;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -92,8 +88,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public int Action { get { return action; } set { action = value; } }
|
||||
public int Activate { get { return activate; } set { activate = value; } }
|
||||
public int Tag { get { return tag; } set { tag = value; if((tag < 0) || (tag > MapSet.HIGHEST_TAG)) throw new ArgumentOutOfRangeException("Tag", "Invalid tag number"); } }
|
||||
public bool Selected { get { return selected; } set { selected = value; } }
|
||||
public bool Marked { get { return marked; } set { marked = value; } }
|
||||
public float LengthSq { get { return lengthsq; } }
|
||||
public float Length { get { return length; } }
|
||||
public float LengthInv { get { return lengthinv; } }
|
||||
|
@ -186,9 +180,9 @@ namespace CodeImp.DoomBuilder.Map
|
|||
endvertexlistitem = end.AttachLinedef(this);
|
||||
this.updateneeded = true;
|
||||
}
|
||||
|
||||
|
||||
// This copies all properties to another line
|
||||
public void CopyPropertiesTo(Linedef l)
|
||||
new public void CopyPropertiesTo(Linedef l)
|
||||
{
|
||||
// Copy properties
|
||||
l.action = action;
|
||||
|
@ -197,8 +191,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
l.tag = tag;
|
||||
l.updateneeded = true;
|
||||
l.activate = activate;
|
||||
l.selected = selected;
|
||||
CopyFieldsTo(l);
|
||||
base.CopyPropertiesTo(l);
|
||||
}
|
||||
|
||||
// This attaches a sidedef on the front
|
||||
|
|
|
@ -40,15 +40,19 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
// Univeral fields
|
||||
private UniFields fields;
|
||||
|
||||
|
||||
// Marking
|
||||
protected bool marked;
|
||||
|
||||
// Disposing
|
||||
protected bool isdisposed = false;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
|
||||
public UniFields Fields { get { return fields; } }
|
||||
public bool Marked { get { return marked; } set { marked = value; } }
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
|
||||
#endregion
|
||||
|
@ -77,10 +81,10 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
#endregion
|
||||
|
||||
#region ================== Fields
|
||||
|
||||
// This copies fields to any other element
|
||||
protected void CopyFieldsTo(MapElement element)
|
||||
#region ================== Methods
|
||||
|
||||
// This copies properties to any other element
|
||||
public void CopyPropertiesTo(MapElement element)
|
||||
{
|
||||
element.fields = new UniFields(this.fields);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ using SlimDX;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Map
|
||||
{
|
||||
public sealed class Sector : MapElement, ID3DResource
|
||||
public sealed class Sector : SelectableElement, ID3DResource
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
|
@ -65,10 +65,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
private int tag;
|
||||
private int brightness;
|
||||
|
||||
// Selections
|
||||
private bool selected;
|
||||
private bool marked;
|
||||
|
||||
// Cloning
|
||||
private Sector clone;
|
||||
|
||||
|
@ -98,8 +94,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public int Effect { get { return effect; } set { effect = value; } }
|
||||
public int Tag { get { return tag; } set { tag = value; if((tag < 0) || (tag > MapSet.HIGHEST_TAG)) throw new ArgumentOutOfRangeException("Tag", "Invalid tag number"); } }
|
||||
public int Brightness { get { return brightness; } set { brightness = value; updateneeded = true; } }
|
||||
public bool Selected { get { return selected; } set { selected = value; } }
|
||||
public bool Marked { get { return marked; } set { marked = value; } }
|
||||
public bool UpdateNeeded { get { return updateneeded; } set { updateneeded |= value; triangulationneeded |= value; } }
|
||||
public Sector Clone { get { return clone; } set { clone = value; } }
|
||||
public Triangulation Triangles { get { return triangles; } }
|
||||
|
@ -186,9 +180,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
s.effect = effect;
|
||||
s.tag = tag;
|
||||
s.brightness = brightness;
|
||||
s.selected = selected;
|
||||
s.updateneeded = true;
|
||||
CopyFieldsTo(s);
|
||||
base.CopyPropertiesTo(s);
|
||||
}
|
||||
|
||||
// This attaches a sidedef and returns the listitem
|
||||
|
|
107
Source/Map/SelectableElement.cs
Normal file
107
Source/Map/SelectableElement.cs
Normal file
|
@ -0,0 +1,107 @@
|
|||
|
||||
#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
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX.Direct3D9;
|
||||
using System.Drawing;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Map
|
||||
{
|
||||
public abstract class SelectableElement : MapElement
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
// Selected or not?
|
||||
protected bool selected;
|
||||
|
||||
// Group bitmask
|
||||
private int groups;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public bool Selected { get { return selected; } set { selected = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
internal SelectableElement()
|
||||
{
|
||||
}
|
||||
|
||||
// Disposer
|
||||
public override void Dispose()
|
||||
{
|
||||
if(!isdisposed)
|
||||
{
|
||||
// Clean up
|
||||
|
||||
|
||||
// Done
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// This copies properties to any other element
|
||||
new 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)
|
||||
{
|
||||
selected = ((groups & groupsmask) != 0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -59,9 +59,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
private long longtexnamemid;
|
||||
private long longtexnamelow;
|
||||
|
||||
// Selections
|
||||
private bool marked;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -80,7 +77,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public long LongHighTexture { get { return longtexnamehigh; } }
|
||||
public long LongMiddleTexture { get { return longtexnamemid; } }
|
||||
public long LongLowTexture { get { return longtexnamelow; } }
|
||||
public bool Marked { get { return marked; } set { marked = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -157,7 +153,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
s.longtexnamehigh = longtexnamehigh;
|
||||
s.longtexnamemid = longtexnamemid;
|
||||
s.longtexnamelow = longtexnamelow;
|
||||
CopyFieldsTo(s);
|
||||
base.CopyPropertiesTo(s);
|
||||
}
|
||||
|
||||
// This copies textures to another sidedef
|
||||
|
|
|
@ -30,7 +30,7 @@ using System.Drawing;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Map
|
||||
{
|
||||
public sealed class Thing : MapElement
|
||||
public sealed class Thing : SelectableElement
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
|
@ -65,10 +65,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
private float size;
|
||||
private PixelColor color;
|
||||
private float iconoffset; // Arrow or dot coordinate offset on the texture
|
||||
|
||||
// Selections
|
||||
private bool selected;
|
||||
private bool marked;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -82,8 +78,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public Dictionary<string, bool> Flags { get { return flags; } }
|
||||
public int Action { get { return action; } set { action = value; } }
|
||||
public int[] Args { get { return args; } }
|
||||
public bool Selected { get { return selected; } set { selected = value; } }
|
||||
public bool Marked { get { return marked; } set { marked = value; } }
|
||||
public float Size { get { return size; } }
|
||||
public float IconOffset { get { return iconoffset; } }
|
||||
public PixelColor Color { get { return color; } }
|
||||
|
@ -152,8 +146,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
t.color = color;
|
||||
t.iconoffset = iconoffset;
|
||||
args.CopyTo(t.args, 0);
|
||||
t.selected = selected;
|
||||
CopyFieldsTo(t);
|
||||
base.CopyPropertiesTo(t);
|
||||
}
|
||||
|
||||
// This determines which sector the thing is in and links it
|
||||
|
|
|
@ -30,7 +30,7 @@ using System.Drawing;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Map
|
||||
{
|
||||
public sealed class Vertex : MapElement
|
||||
public sealed class Vertex : SelectableElement
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
|
@ -52,10 +52,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
// References
|
||||
private LinkedList<Linedef> linedefs;
|
||||
|
||||
// Selections
|
||||
private bool selected;
|
||||
private bool marked;
|
||||
|
||||
// Cloning
|
||||
private Vertex clone;
|
||||
|
@ -67,8 +63,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public MapSet Map { get { return map; } }
|
||||
public ICollection<Linedef> Linedefs { get { return linedefs; } }
|
||||
public Vector2D Position { get { return pos; } }
|
||||
public bool Selected { get { return selected; } set { selected = value; } }
|
||||
public bool Marked { get { return marked; } set { marked = value; } }
|
||||
public Vertex Clone { get { return clone; } set { clone = value; } }
|
||||
|
||||
#endregion
|
||||
|
@ -148,8 +142,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
{
|
||||
// Copy properties
|
||||
v.pos = pos;
|
||||
v.selected = selected;
|
||||
CopyFieldsTo(v);
|
||||
base.CopyPropertiesTo(v);
|
||||
}
|
||||
|
||||
// This returns the distance from given coordinates
|
||||
|
|
Loading…
Reference in a new issue