2009-04-19 18:07:22 +00:00
#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.Generic ;
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
using System.Drawing ;
2009-04-19 18:07:22 +00:00
using CodeImp.DoomBuilder.Config ;
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
using CodeImp.DoomBuilder.Geometry ;
using CodeImp.DoomBuilder.GZBuilder.Data ;
2009-04-19 18:07:22 +00:00
using CodeImp.DoomBuilder.IO ;
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
using CodeImp.DoomBuilder.Rendering ;
2015-05-30 10:26:16 +00:00
using CodeImp.DoomBuilder.Types ;
2009-04-19 18:07:22 +00:00
using CodeImp.DoomBuilder.VisualModes ;
#endregion
namespace CodeImp.DoomBuilder.Map
{
2016-04-09 23:18:39 +00:00
public sealed class Thing : SelectableElement , ITaggedMapElement
2009-04-19 18:07:22 +00:00
{
#region = = = = = = = = = = = = = = = = = = Constants
public const int NUM_ARGS = 5 ;
2016-07-11 22:13:43 +00:00
public static readonly HashSet < ThingRenderMode > AlignableRenderModes = new HashSet < ThingRenderMode >
Fixed, Draw Lines/Rectangle/Circle/Curve modes: line length labels displayed incorrect length.
Changed, Drag Linedefs/Vertices/Sectors/Things modes: line length labels are now displayed the same way as in Draw modes.
Changed, Drag Linedefs/Vertices/Sectors/Things modes: "lock movement to cardinal directions" mode (Alt-Shift-Drag) now locks movement in 4 directions instead of 8 and doesn't snap map elements to nearest grid intersections when they are not aligned to it.
Added, Visual mode, GZDoom, DECORATE: FORCEXYBILLBOARD flag is now supported.
Added, Visual mode, GLOOME, DECORATE: FLOORSPRITE, CEILSPRITE, WALLSPRITE, ROLLSPRITE and STICKTOPLANE flags are now supported (implementation is somewhat broken ATM and probably doesn't work the same way as in GLOOME, because Windows build with most these features is nowhere to be found...).
Fixed, Visual mode: in some cases Thing brightness was calculated incorrectly.
Updated ZDoom_DECORATE.cfg.
2015-08-25 22:05:14 +00:00
{
2016-07-04 18:25:47 +00:00
ThingRenderMode . FLATSPRITE , ThingRenderMode . WALLSPRITE , ThingRenderMode . MODEL
} ;
Fixed, Draw Lines/Rectangle/Circle/Curve modes: line length labels displayed incorrect length.
Changed, Drag Linedefs/Vertices/Sectors/Things modes: line length labels are now displayed the same way as in Draw modes.
Changed, Drag Linedefs/Vertices/Sectors/Things modes: "lock movement to cardinal directions" mode (Alt-Shift-Drag) now locks movement in 4 directions instead of 8 and doesn't snap map elements to nearest grid intersections when they are not aligned to it.
Added, Visual mode, GZDoom, DECORATE: FORCEXYBILLBOARD flag is now supported.
Added, Visual mode, GLOOME, DECORATE: FLOORSPRITE, CEILSPRITE, WALLSPRITE, ROLLSPRITE and STICKTOPLANE flags are now supported (implementation is somewhat broken ATM and probably doesn't work the same way as in GLOOME, because Windows build with most these features is nowhere to be found...).
Fixed, Visual mode: in some cases Thing brightness was calculated incorrectly.
Updated ZDoom_DECORATE.cfg.
2015-08-25 22:05:14 +00:00
#endregion
2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Variables
// Map
private MapSet map ;
// Sector
2014-02-21 14:42:12 +00:00
private Sector sector ;
2009-04-19 18:07:22 +00:00
// List items
private LinkedListNode < Thing > selecteditem ;
// Properties
private int type ;
2017-03-01 22:21:08 +00:00
private int dynamiclighttype ;
2009-04-19 18:07:22 +00:00
private Vector3D pos ;
2010-10-05 08:31:27 +00:00
private int angledoom ; // Angle as entered / stored in file
private float anglerad ; // Angle in radians
2009-04-19 18:07:22 +00:00
private Dictionary < string , bool > flags ;
private int tag ;
private int action ;
private int [ ] args ;
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
private float scaleX ; //mxd
private float scaleY ; //mxd
private SizeF spritescale ; //mxd
private int pitch ; //mxd. Used in model rendering
private int roll ; //mxd. Used in model rendering
private float pitchrad ; //mxd
private float rollrad ; //mxd
2015-08-03 22:02:39 +00:00
private bool highlighted ; //mxd
2009-04-19 18:07:22 +00:00
2016-07-04 18:25:47 +00:00
//mxd. GZDoom rendering properties
private ThingRenderMode rendermode ;
Fixed, Draw Lines/Rectangle/Circle/Curve modes: line length labels displayed incorrect length.
Changed, Drag Linedefs/Vertices/Sectors/Things modes: line length labels are now displayed the same way as in Draw modes.
Changed, Drag Linedefs/Vertices/Sectors/Things modes: "lock movement to cardinal directions" mode (Alt-Shift-Drag) now locks movement in 4 directions instead of 8 and doesn't snap map elements to nearest grid intersections when they are not aligned to it.
Added, Visual mode, GZDoom, DECORATE: FORCEXYBILLBOARD flag is now supported.
Added, Visual mode, GLOOME, DECORATE: FLOORSPRITE, CEILSPRITE, WALLSPRITE, ROLLSPRITE and STICKTOPLANE flags are now supported (implementation is somewhat broken ATM and probably doesn't work the same way as in GLOOME, because Windows build with most these features is nowhere to be found...).
Fixed, Visual mode: in some cases Thing brightness was calculated incorrectly.
Updated ZDoom_DECORATE.cfg.
2015-08-25 22:05:14 +00:00
private bool rollsprite ; //mxd
2009-04-19 18:07:22 +00:00
// Configuration
private float size ;
2015-05-30 10:26:16 +00:00
private float height ; //mxd
2009-04-19 18:07:22 +00:00
private PixelColor color ;
private bool fixedsize ;
2013-11-27 12:45:28 +00:00
private bool directional ; //mxd. If true, we need to render an arrow
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Properties
public MapSet Map { get { return map ; } }
2014-12-22 21:36:49 +00:00
public int Type { get { return type ; } set { BeforePropsChange ( ) ; type = value ; } } //mxd
2017-03-01 22:21:08 +00:00
public int DynamicLightType { get { return dynamiclighttype ; } internal set { BeforePropsChange ( ) ; dynamiclighttype = value ; } }
2009-04-19 18:07:22 +00:00
public Vector3D Position { get { return pos ; } }
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
public float ScaleX { get { return scaleX ; } } //mxd. This is UDMF property, not actual scale!
public float ScaleY { get { return scaleY ; } } //mxd. This is UDMF property, not actual scale!
public int Pitch { get { return pitch ; } } //mxd
public float PitchRad { get { return pitchrad ; } }
public int Roll { get { return roll ; } } //mxd
public float RollRad { get { return rollrad ; } }
public SizeF ActorScale { get { return spritescale ; } } //mxd. Actor scale set in DECORATE
2010-10-05 08:31:27 +00:00
public float Angle { get { return anglerad ; } }
public int AngleDoom { get { return angledoom ; } }
2009-06-11 21:21:20 +00:00
internal Dictionary < string , bool > Flags { get { return flags ; } }
public int Action { get { return action ; } set { BeforePropsChange ( ) ; action = value ; } }
2009-04-19 18:07:22 +00:00
public int [ ] Args { get { return args ; } }
public float Size { get { return size ; } }
2015-05-30 10:26:16 +00:00
public float Height { get { return height ; } } //mxd
2009-04-19 18:07:22 +00:00
public PixelColor Color { get { return color ; } }
public bool FixedSize { get { return fixedsize ; } }
2009-06-11 21:21:20 +00:00
public int Tag { get { return tag ; } set { BeforePropsChange ( ) ; tag = value ; if ( ( tag < General . Map . FormatInterface . MinTag ) | | ( tag > General . Map . FormatInterface . MaxTag ) ) throw new ArgumentOutOfRangeException ( "Tag" , "Invalid tag number" ) ; } }
2009-04-19 18:07:22 +00:00
public Sector Sector { get { return sector ; } }
2016-07-04 18:25:47 +00:00
public ThingRenderMode RenderMode { get { return rendermode ; } } //mxd
2013-11-27 12:45:28 +00:00
public bool IsDirectional { get { return directional ; } } //mxd
2015-08-03 22:02:39 +00:00
public bool Highlighted { get { return highlighted ; } set { highlighted = value ; } } //mxd
2009-04-19 18:07:22 +00:00
2013-09-11 09:47:53 +00:00
#endregion
2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Constructor / Disposer
// Constructor
2009-06-05 19:03:56 +00:00
internal Thing ( MapSet map , int listindex )
2009-04-19 18:07:22 +00:00
{
// Initialize
Removed "Paste Properties Options" action.
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).
2015-10-09 12:38:12 +00:00
this . elementtype = MapElementType . THING ; //mxd
2009-04-19 18:07:22 +00:00
this . map = map ;
2009-06-05 19:03:56 +00:00
this . listindex = listindex ;
2014-02-26 14:11:06 +00:00
this . flags = new Dictionary < string , bool > ( StringComparer . Ordinal ) ;
2009-04-19 18:07:22 +00:00
this . args = new int [ NUM_ARGS ] ;
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
this . scaleX = 1.0f ;
this . scaleY = 1.0f ;
this . spritescale = new SizeF ( 1.0f , 1.0f ) ;
2009-04-19 18:07:22 +00:00
2009-06-11 21:21:20 +00:00
if ( map = = General . Map . Map )
General . Map . UndoRedo . RecAddThing ( this ) ;
2009-04-19 18:07:22 +00:00
// We have no destructor
GC . SuppressFinalize ( this ) ;
}
// Disposer
public override void Dispose ( )
{
// Not already disposed?
if ( ! isdisposed )
{
2009-06-11 21:21:20 +00:00
if ( map = = General . Map . Map )
General . Map . UndoRedo . RecRemThing ( this ) ;
2009-04-19 18:07:22 +00:00
// Remove from main list
2009-06-05 19:03:56 +00:00
map . RemoveThing ( listindex ) ;
2009-04-19 18:07:22 +00:00
// Clean up
map = null ;
sector = null ;
// Dispose base
base . Dispose ( ) ;
}
}
#endregion
#region = = = = = = = = = = = = = = = = = = Management
2009-06-11 21:21:20 +00:00
// Call this before changing properties
protected override void BeforePropsChange ( )
{
if ( map = = General . Map . Map )
General . Map . UndoRedo . RecPrpThing ( this ) ;
}
2009-04-19 18:07:22 +00:00
// Serialize / deserialize
2013-03-18 13:52:27 +00:00
new internal void ReadWrite ( IReadWriteStream s )
2009-04-19 18:07:22 +00:00
{
2009-06-11 21:21:20 +00:00
if ( ! s . IsWriting ) BeforePropsChange ( ) ;
2009-04-19 18:07:22 +00:00
base . ReadWrite ( s ) ;
if ( s . IsWriting )
{
s . wInt ( flags . Count ) ;
foreach ( KeyValuePair < string , bool > f in flags )
{
s . wString ( f . Key ) ;
s . wBool ( f . Value ) ;
}
}
else
{
int c ; s . rInt ( out c ) ;
2014-02-26 14:11:06 +00:00
flags = new Dictionary < string , bool > ( c , StringComparer . Ordinal ) ;
2009-04-19 18:07:22 +00:00
for ( int i = 0 ; i < c ; i + + )
{
string t ; s . rString ( out t ) ;
bool b ; s . rBool ( out b ) ;
flags . Add ( t , b ) ;
}
}
2010-10-05 08:31:27 +00:00
2009-04-19 18:07:22 +00:00
s . rwInt ( ref type ) ;
s . rwVector3D ( ref pos ) ;
2010-10-05 08:31:27 +00:00
s . rwInt ( ref angledoom ) ;
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
s . rwInt ( ref pitch ) ; //mxd
s . rwInt ( ref roll ) ; //mxd
s . rwFloat ( ref scaleX ) ; //mxd
s . rwFloat ( ref scaleY ) ; //mxd
2009-04-19 18:07:22 +00:00
s . rwInt ( ref tag ) ;
s . rwInt ( ref action ) ;
for ( int i = 0 ; i < NUM_ARGS ; i + + ) s . rwInt ( ref args [ i ] ) ;
2013-07-29 08:50:50 +00:00
2014-12-03 23:15:26 +00:00
if ( ! s . IsWriting )
{
2010-10-05 08:31:27 +00:00
anglerad = Angle2D . DoomToReal ( angledoom ) ;
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
UpdateCache ( ) ; //mxd
2013-07-29 08:50:50 +00:00
}
2009-04-19 18:07:22 +00:00
}
// This copies all properties to another thing
public void CopyPropertiesTo ( Thing t )
{
2009-06-11 21:21:20 +00:00
t . BeforePropsChange ( ) ;
2009-04-19 18:07:22 +00:00
// Copy properties
t . type = type ;
2017-03-01 22:21:08 +00:00
t . dynamiclighttype = dynamiclighttype ;
2010-10-05 08:31:27 +00:00
t . anglerad = anglerad ;
t . angledoom = angledoom ;
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
t . roll = roll ; //mxd
t . pitch = pitch ; //mxd
t . rollrad = rollrad ; //mxd
t . pitchrad = pitchrad ; //mxd
t . scaleX = scaleX ; //mxd
t . scaleY = scaleY ; //mxd
t . spritescale = spritescale ; //mxd
2009-04-19 18:07:22 +00:00
t . pos = pos ;
t . flags = new Dictionary < string , bool > ( flags ) ;
t . tag = tag ;
t . action = action ;
t . args = ( int [ ] ) args . Clone ( ) ;
t . size = size ;
2015-05-30 10:26:16 +00:00
t . height = height ; //mxd
2009-04-19 18:07:22 +00:00
t . color = color ;
2013-11-27 12:45:28 +00:00
t . directional = directional ;
2009-04-19 18:07:22 +00:00
t . fixedsize = fixedsize ;
2016-07-04 18:25:47 +00:00
t . rendermode = rendermode ; //mxd
Fixed, Draw Lines/Rectangle/Circle/Curve modes: line length labels displayed incorrect length.
Changed, Drag Linedefs/Vertices/Sectors/Things modes: line length labels are now displayed the same way as in Draw modes.
Changed, Drag Linedefs/Vertices/Sectors/Things modes: "lock movement to cardinal directions" mode (Alt-Shift-Drag) now locks movement in 4 directions instead of 8 and doesn't snap map elements to nearest grid intersections when they are not aligned to it.
Added, Visual mode, GZDoom, DECORATE: FORCEXYBILLBOARD flag is now supported.
Added, Visual mode, GLOOME, DECORATE: FLOORSPRITE, CEILSPRITE, WALLSPRITE, ROLLSPRITE and STICKTOPLANE flags are now supported (implementation is somewhat broken ATM and probably doesn't work the same way as in GLOOME, because Windows build with most these features is nowhere to be found...).
Fixed, Visual mode: in some cases Thing brightness was calculated incorrectly.
Updated ZDoom_DECORATE.cfg.
2015-08-25 22:05:14 +00:00
t . rollsprite = rollsprite ; //mxd
2012-04-17 19:13:47 +00:00
2009-04-19 18:07:22 +00:00
base . CopyPropertiesTo ( t ) ;
}
// This determines which sector the thing is in and links it
public void DetermineSector ( )
{
2012-06-07 01:06:37 +00:00
//mxd
2013-09-11 09:47:53 +00:00
sector = map . GetSectorByCoordinates ( pos ) ;
2009-04-19 18:07:22 +00:00
}
// This determines which sector the thing is in and links it
public void DetermineSector ( VisualBlockMap blockmap )
{
// Find nearest sectors using the blockmap
List < Sector > possiblesectors = blockmap . GetBlock ( blockmap . GetBlockCoordinates ( pos ) ) . Sectors ;
// Check in which sector we are
sector = null ;
foreach ( Sector s in possiblesectors )
{
if ( s . Intersect ( pos ) )
{
sector = s ;
break ;
}
}
}
// This translates the flags into UDMF fields
internal void TranslateToUDMF ( )
{
// First make a single integer with all flags
int bits = 0 ;
2014-02-21 14:42:12 +00:00
int flagbit ;
2009-04-19 18:07:22 +00:00
foreach ( KeyValuePair < string , bool > f in flags )
if ( int . TryParse ( f . Key , out flagbit ) & & f . Value ) bits | = flagbit ;
// Now make the new flags
flags . Clear ( ) ;
foreach ( FlagTranslation f in General . Map . Config . ThingFlagsTranslation )
{
// Flag found in bits?
if ( ( bits & f . Flag ) = = f . Flag )
{
// Add fields and remove bits
bits & = ~ f . Flag ;
for ( int i = 0 ; i < f . Fields . Count ; i + + )
flags [ f . Fields [ i ] ] = f . FieldValues [ i ] ;
}
else
{
// Add fields with inverted value
for ( int i = 0 ; i < f . Fields . Count ; i + + )
flags [ f . Fields [ i ] ] = ! f . FieldValues [ i ] ;
}
}
}
// This translates UDMF fields back into the normal flags
internal void TranslateFromUDMF ( )
{
2014-09-16 20:26:42 +00:00
//mxd. Clear UDMF-related properties
this . Fields . Clear ( ) ;
scaleX = 1.0f ;
scaleY = 1.0f ;
pitch = 0 ;
pitchrad = 0 ;
roll = 0 ;
rollrad = 0 ;
2009-04-19 18:07:22 +00:00
// Make copy of the flags
Dictionary < string , bool > oldfields = new Dictionary < string , bool > ( flags ) ;
// Make the flags
flags . Clear ( ) ;
foreach ( KeyValuePair < string , string > f in General . Map . Config . ThingFlags )
{
// Flag must be numeric
2014-02-21 14:42:12 +00:00
int flagbit ;
2009-04-19 18:07:22 +00:00
if ( int . TryParse ( f . Key , out flagbit ) )
{
foreach ( FlagTranslation ft in General . Map . Config . ThingFlagsTranslation )
{
if ( ft . Flag = = flagbit )
{
// Only set this flag when the fields match
bool fieldsmatch = true ;
for ( int i = 0 ; i < ft . Fields . Count ; i + + )
{
if ( ! oldfields . ContainsKey ( ft . Fields [ i ] ) | | ( oldfields [ ft . Fields [ i ] ] ! = ft . FieldValues [ i ] ) )
{
fieldsmatch = false ;
break ;
}
}
// Field match? Then add the flag.
if ( fieldsmatch )
{
flags . Add ( f . Key , true ) ;
break ;
}
}
}
}
}
}
// Selected
protected override void DoSelect ( )
{
base . DoSelect ( ) ;
selecteditem = map . SelectedThings . AddLast ( this ) ;
}
// Deselect
protected override void DoUnselect ( )
{
base . DoUnselect ( ) ;
if ( selecteditem . List ! = null ) selecteditem . List . Remove ( selecteditem ) ;
selecteditem = null ;
}
#endregion
#region = = = = = = = = = = = = = = = = = = Changes
// This moves the thing
// NOTE: This does not update sector! (call DetermineSector)
public void Move ( Vector3D newpos )
{
2009-06-11 21:21:20 +00:00
BeforePropsChange ( ) ;
2009-04-19 18:07:22 +00:00
// Change position
this . pos = newpos ;
2010-09-09 15:12:31 +00:00
if ( type ! = General . Map . Config . Start3DModeThingType )
General . Map . IsChanged = true ;
2009-04-19 18:07:22 +00:00
}
// This moves the thing
// NOTE: This does not update sector! (call DetermineSector)
public void Move ( Vector2D newpos )
{
2009-06-11 21:21:20 +00:00
BeforePropsChange ( ) ;
2009-04-19 18:07:22 +00:00
// Change position
this . pos = new Vector3D ( newpos . x , newpos . y , pos . z ) ;
2010-09-09 15:12:31 +00:00
if ( type ! = General . Map . Config . Start3DModeThingType )
General . Map . IsChanged = true ;
2009-04-19 18:07:22 +00:00
}
// This moves the thing
// NOTE: This does not update sector! (call DetermineSector)
public void Move ( float x , float y , float zoffset )
{
2009-06-11 21:21:20 +00:00
BeforePropsChange ( ) ;
2009-04-19 18:07:22 +00:00
// Change position
this . pos = new Vector3D ( x , y , zoffset ) ;
2010-09-09 15:12:31 +00:00
if ( type ! = General . Map . Config . Start3DModeThingType )
General . Map . IsChanged = true ;
2009-04-19 18:07:22 +00:00
}
// This rotates the thing
public void Rotate ( float newangle )
{
2009-06-11 21:21:20 +00:00
BeforePropsChange ( ) ;
2009-04-19 18:07:22 +00:00
// Change angle
2010-10-05 08:31:27 +00:00
this . anglerad = newangle ;
this . angledoom = Angle2D . RealToDoom ( newangle ) ;
if ( type ! = General . Map . Config . Start3DModeThingType )
General . Map . IsChanged = true ;
}
// This rotates the thing
public void Rotate ( int newangle )
{
BeforePropsChange ( ) ;
// Change angle
Added, Visual mode, UDMF: added "Change Pitch Clockwise", "Change Pitch Counterclockwise", "Change Roll Clockwise" and "Change Roll Counterclockwise" actions.
Added, Visual mode, UDMF: added "Increase Scale" and "Decrease Scale" actions.
Added, Visual mode, UDMF: "Reset Texture Offsets" action now resets scale when used on things.
Added, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets scale, pitch and roll when used on things.
Changed, Visual mode, UDMF: "Reset Texture Offsets" action now only resets texture offsets (previously it also reset texture scale).
Changed, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets texture offsets, scale and brightness of sidedefs and also rotation of floors/ceilings.
Changed, Visual mode, UDMF: thing box arrow now displays pitch and roll for things, which have attached model and appropriate MODELDEF flags.
Changed, Thing Edit Form, UDMF: negative pitch and roll can now be entered.
Updated documentation.
2015-03-30 21:44:04 +00:00
anglerad = Angle2D . DoomToReal ( newangle ) ;
angledoom = newangle ;
2010-09-09 15:12:31 +00:00
if ( type ! = General . Map . Config . Start3DModeThingType )
General . Map . IsChanged = true ;
2009-04-19 18:07:22 +00:00
}
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
//mxd
Added, Visual mode, UDMF: added "Change Pitch Clockwise", "Change Pitch Counterclockwise", "Change Roll Clockwise" and "Change Roll Counterclockwise" actions.
Added, Visual mode, UDMF: added "Increase Scale" and "Decrease Scale" actions.
Added, Visual mode, UDMF: "Reset Texture Offsets" action now resets scale when used on things.
Added, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets scale, pitch and roll when used on things.
Changed, Visual mode, UDMF: "Reset Texture Offsets" action now only resets texture offsets (previously it also reset texture scale).
Changed, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets texture offsets, scale and brightness of sidedefs and also rotation of floors/ceilings.
Changed, Visual mode, UDMF: thing box arrow now displays pitch and roll for things, which have attached model and appropriate MODELDEF flags.
Changed, Thing Edit Form, UDMF: negative pitch and roll can now be entered.
Updated documentation.
2015-03-30 21:44:04 +00:00
public void SetPitch ( int newpitch )
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
{
BeforePropsChange ( ) ;
Added, Visual mode, UDMF: added "Change Pitch Clockwise", "Change Pitch Counterclockwise", "Change Roll Clockwise" and "Change Roll Counterclockwise" actions.
Added, Visual mode, UDMF: added "Increase Scale" and "Decrease Scale" actions.
Added, Visual mode, UDMF: "Reset Texture Offsets" action now resets scale when used on things.
Added, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets scale, pitch and roll when used on things.
Changed, Visual mode, UDMF: "Reset Texture Offsets" action now only resets texture offsets (previously it also reset texture scale).
Changed, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets texture offsets, scale and brightness of sidedefs and also rotation of floors/ceilings.
Changed, Visual mode, UDMF: thing box arrow now displays pitch and roll for things, which have attached model and appropriate MODELDEF flags.
Changed, Thing Edit Form, UDMF: negative pitch and roll can now be entered.
Updated documentation.
2015-03-30 21:44:04 +00:00
pitch = General . ClampAngle ( newpitch ) ;
2016-07-17 23:07:58 +00:00
switch ( rendermode )
{
case ThingRenderMode . MODEL :
ModelData md = General . Map . Data . ModeldefEntries [ type ] ;
if ( md . InheritActorPitch | | md . UseActorPitch )
pitchrad = Angle2D . DegToRad ( md . InheritActorPitch ? - pitch : pitch ) ;
else
pitchrad = 0 ;
break ;
case ThingRenderMode . FLATSPRITE :
pitchrad = Angle2D . DegToRad ( pitch ) ;
break ;
default :
pitchrad = 0 ;
break ;
}
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
2015-12-28 15:01:53 +00:00
if ( type ! = General . Map . Config . Start3DModeThingType )
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
General . Map . IsChanged = true ;
}
//mxd
Added, Visual mode, UDMF: added "Change Pitch Clockwise", "Change Pitch Counterclockwise", "Change Roll Clockwise" and "Change Roll Counterclockwise" actions.
Added, Visual mode, UDMF: added "Increase Scale" and "Decrease Scale" actions.
Added, Visual mode, UDMF: "Reset Texture Offsets" action now resets scale when used on things.
Added, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets scale, pitch and roll when used on things.
Changed, Visual mode, UDMF: "Reset Texture Offsets" action now only resets texture offsets (previously it also reset texture scale).
Changed, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets texture offsets, scale and brightness of sidedefs and also rotation of floors/ceilings.
Changed, Visual mode, UDMF: thing box arrow now displays pitch and roll for things, which have attached model and appropriate MODELDEF flags.
Changed, Thing Edit Form, UDMF: negative pitch and roll can now be entered.
Updated documentation.
2015-03-30 21:44:04 +00:00
public void SetRoll ( int newroll )
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
{
BeforePropsChange ( ) ;
Added, Visual mode, UDMF: added "Change Pitch Clockwise", "Change Pitch Counterclockwise", "Change Roll Clockwise" and "Change Roll Counterclockwise" actions.
Added, Visual mode, UDMF: added "Increase Scale" and "Decrease Scale" actions.
Added, Visual mode, UDMF: "Reset Texture Offsets" action now resets scale when used on things.
Added, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets scale, pitch and roll when used on things.
Changed, Visual mode, UDMF: "Reset Texture Offsets" action now only resets texture offsets (previously it also reset texture scale).
Changed, Visual mode, UDMF: "Reset Local Texture Offsets" action now resets texture offsets, scale and brightness of sidedefs and also rotation of floors/ceilings.
Changed, Visual mode, UDMF: thing box arrow now displays pitch and roll for things, which have attached model and appropriate MODELDEF flags.
Changed, Thing Edit Form, UDMF: negative pitch and roll can now be entered.
Updated documentation.
2015-03-30 21:44:04 +00:00
roll = General . ClampAngle ( newroll ) ;
2016-07-17 00:00:29 +00:00
rollrad = ( ( rollsprite | | ( rendermode = = ThingRenderMode . MODEL & & General . Map . Data . ModeldefEntries [ type ] . UseActorRoll ) )
2016-07-04 18:25:47 +00:00
? Angle2D . DegToRad ( roll ) : 0 ) ;
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
2015-12-28 15:01:53 +00:00
if ( type ! = General . Map . Config . Start3DModeThingType )
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
General . Map . IsChanged = true ;
}
//mxd
public void SetScale ( float scalex , float scaley )
{
BeforePropsChange ( ) ;
scaleX = scalex ;
scaleY = scaley ;
2015-12-28 15:01:53 +00:00
if ( type ! = General . Map . Config . Start3DModeThingType )
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
General . Map . IsChanged = true ;
}
2009-04-19 18:07:22 +00:00
// This updates all properties
// NOTE: This does not update sector! (call DetermineSector)
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
public void Update ( int type , float x , float y , float zoffset , int angle , int pitch , int roll , float scaleX , float scaleY ,
2009-04-19 18:07:22 +00:00
Dictionary < string , bool > flags , int tag , int action , int [ ] args )
{
// Apply changes
this . type = type ;
2010-10-05 08:31:27 +00:00
this . anglerad = Angle2D . DoomToReal ( angle ) ;
this . angledoom = angle ;
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
this . pitch = pitch ; //mxd
this . roll = roll ; //mxd
this . scaleX = ( scaleX = = 0 ? 1.0f : scaleX ) ; //mxd
this . scaleY = ( scaleY = = 0 ? 1.0f : scaleY ) ; //mxd
2009-04-19 18:07:22 +00:00
this . flags = new Dictionary < string , bool > ( flags ) ;
this . tag = tag ;
this . action = action ;
this . args = new int [ NUM_ARGS ] ;
args . CopyTo ( this . args , 0 ) ;
this . Move ( x , y , zoffset ) ;
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
UpdateCache ( ) ; //mxd
2009-04-19 18:07:22 +00:00
}
// This updates the settings from configuration
public void UpdateConfiguration ( )
{
// Lookup settings
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
ThingTypeInfo ti = General . Map . Data . GetThingInfo ( type ) ;
2017-03-01 22:21:08 +00:00
// Apply size
dynamiclighttype = ( Array . IndexOf ( GZBuilder . GZGeneral . GZ_LIGHTS , type ) ! = - 1 ) ? type : ti . DynamicLightType ;
2009-04-19 18:07:22 +00:00
size = ti . Radius ;
2015-05-30 10:26:16 +00:00
height = ti . Height ; //mxd
2009-04-19 18:07:22 +00:00
fixedsize = ti . FixedSize ;
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
spritescale = ti . SpriteScale ; //mxd
2015-05-30 10:26:16 +00:00
//mxd. Apply radius and height overrides?
for ( int i = 0 ; i < ti . Args . Length ; i + + )
{
2015-05-31 21:11:21 +00:00
if ( ti . Args [ i ] = = null ) continue ;
2015-05-30 10:26:16 +00:00
if ( ti . Args [ i ] . Type = = ( int ) UniversalType . ThingRadius & & args [ i ] > 0 )
size = args [ i ] ;
else if ( ti . Args [ i ] . Type = = ( int ) UniversalType . ThingHeight & & args [ i ] > 0 )
height = args [ i ] ;
}
2009-04-19 18:07:22 +00:00
// Color valid?
if ( ( ti . Color > = 0 ) & & ( ti . Color < ColorCollection . NUM_THING_COLORS ) )
{
// Apply color
color = General . Colors . Colors [ ti . Color + ColorCollection . THING_COLORS_OFFSET ] ;
}
else
{
// Unknown thing color
color = General . Colors . Colors [ ColorCollection . THING_COLORS_OFFSET ] ;
}
2013-11-27 12:45:28 +00:00
directional = ti . Arrow ; //mxd
2016-07-04 18:25:47 +00:00
rendermode = ti . RenderMode ; //mxd
Fixed, Draw Lines/Rectangle/Circle/Curve modes: line length labels displayed incorrect length.
Changed, Drag Linedefs/Vertices/Sectors/Things modes: line length labels are now displayed the same way as in Draw modes.
Changed, Drag Linedefs/Vertices/Sectors/Things modes: "lock movement to cardinal directions" mode (Alt-Shift-Drag) now locks movement in 4 directions instead of 8 and doesn't snap map elements to nearest grid intersections when they are not aligned to it.
Added, Visual mode, GZDoom, DECORATE: FORCEXYBILLBOARD flag is now supported.
Added, Visual mode, GLOOME, DECORATE: FLOORSPRITE, CEILSPRITE, WALLSPRITE, ROLLSPRITE and STICKTOPLANE flags are now supported (implementation is somewhat broken ATM and probably doesn't work the same way as in GLOOME, because Windows build with most these features is nowhere to be found...).
Fixed, Visual mode: in some cases Thing brightness was calculated incorrectly.
Updated ZDoom_DECORATE.cfg.
2015-08-25 22:05:14 +00:00
rollsprite = ti . RollSprite ; //mxd
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
UpdateCache ( ) ; //mxd
}
2016-07-04 18:25:47 +00:00
//mxd. This checks if the thing has model override and whether pitch/roll values should be used
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
internal void UpdateCache ( )
{
2016-07-04 18:25:47 +00:00
if ( General . Map . Data = = null ) return ;
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
2016-07-04 18:25:47 +00:00
// Check if the thing has model override
if ( General . Map . Data . ModeldefEntries . ContainsKey ( type ) )
Fixed, Draw Lines/Rectangle/Circle/Curve modes: line length labels displayed incorrect length.
Changed, Drag Linedefs/Vertices/Sectors/Things modes: line length labels are now displayed the same way as in Draw modes.
Changed, Drag Linedefs/Vertices/Sectors/Things modes: "lock movement to cardinal directions" mode (Alt-Shift-Drag) now locks movement in 4 directions instead of 8 and doesn't snap map elements to nearest grid intersections when they are not aligned to it.
Added, Visual mode, GZDoom, DECORATE: FORCEXYBILLBOARD flag is now supported.
Added, Visual mode, GLOOME, DECORATE: FLOORSPRITE, CEILSPRITE, WALLSPRITE, ROLLSPRITE and STICKTOPLANE flags are now supported (implementation is somewhat broken ATM and probably doesn't work the same way as in GLOOME, because Windows build with most these features is nowhere to be found...).
Fixed, Visual mode: in some cases Thing brightness was calculated incorrectly.
Updated ZDoom_DECORATE.cfg.
2015-08-25 22:05:14 +00:00
{
2016-07-11 22:13:43 +00:00
ModelData md = General . Map . Data . ModeldefEntries [ type ] ;
if ( ( md . LoadState = = ModelLoadState . None & & General . Map . Data . ProcessModel ( type ) ) | | md . LoadState ! = ModelLoadState . None )
rendermode = ( General . Map . Data . ModeldefEntries [ type ] . IsVoxel ? ThingRenderMode . VOXEL : ThingRenderMode . MODEL ) ;
Fixed, Draw Lines/Rectangle/Circle/Curve modes: line length labels displayed incorrect length.
Changed, Drag Linedefs/Vertices/Sectors/Things modes: line length labels are now displayed the same way as in Draw modes.
Changed, Drag Linedefs/Vertices/Sectors/Things modes: "lock movement to cardinal directions" mode (Alt-Shift-Drag) now locks movement in 4 directions instead of 8 and doesn't snap map elements to nearest grid intersections when they are not aligned to it.
Added, Visual mode, GZDoom, DECORATE: FORCEXYBILLBOARD flag is now supported.
Added, Visual mode, GLOOME, DECORATE: FLOORSPRITE, CEILSPRITE, WALLSPRITE, ROLLSPRITE and STICKTOPLANE flags are now supported (implementation is somewhat broken ATM and probably doesn't work the same way as in GLOOME, because Windows build with most these features is nowhere to be found...).
Fixed, Visual mode: in some cases Thing brightness was calculated incorrectly.
Updated ZDoom_DECORATE.cfg.
2015-08-25 22:05:14 +00:00
}
2016-07-04 18:25:47 +00:00
// Update radian versions of pitch and roll
switch ( rendermode )
2014-12-03 23:15:26 +00:00
{
2016-07-04 18:25:47 +00:00
case ThingRenderMode . MODEL :
2016-07-17 00:00:29 +00:00
ModelData md = General . Map . Data . ModeldefEntries [ type ] ;
rollrad = ( md . UseActorRoll ? Angle2D . DegToRad ( roll ) : 0 ) ;
pitchrad = ( ( md . InheritActorPitch | | md . UseActorPitch ) ? Angle2D . DegToRad ( md . InheritActorPitch ? - pitch : pitch ) : 0 ) ;
2016-07-04 18:25:47 +00:00
break ;
case ThingRenderMode . FLATSPRITE :
2016-10-04 21:02:43 +00:00
rollrad = Angle2D . DegToRad ( roll ) ;
2016-07-04 18:25:47 +00:00
pitchrad = Angle2D . DegToRad ( pitch ) ;
break ;
case ThingRenderMode . WALLSPRITE :
2016-10-04 21:02:43 +00:00
rollrad = Angle2D . DegToRad ( roll ) ;
pitchrad = 0 ;
break ;
2016-07-04 18:25:47 +00:00
case ThingRenderMode . NORMAL :
rollrad = ( rollsprite ? Angle2D . DegToRad ( roll ) : 0 ) ;
pitchrad = 0 ;
break ;
2016-07-11 22:13:43 +00:00
case ThingRenderMode . VOXEL :
rollrad = 0 ;
pitchrad = 0 ;
break ;
2016-07-04 18:25:47 +00:00
default : throw new NotImplementedException ( "Unknown ThingRenderMode" ) ;
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
}
2009-04-19 18:07:22 +00:00
}
#endregion
#region = = = = = = = = = = = = = = = = = = Methods
2009-06-11 21:21:20 +00:00
// This checks and returns a flag without creating it
public bool IsFlagSet ( string flagname )
{
2016-07-04 18:25:47 +00:00
return flags . ContainsKey ( flagname ) & & flags [ flagname ] ;
2009-06-11 21:21:20 +00:00
}
// This sets a flag
public void SetFlag ( string flagname , bool value )
{
if ( ! flags . ContainsKey ( flagname ) | | ( IsFlagSet ( flagname ) ! = value ) )
{
BeforePropsChange ( ) ;
2009-04-19 18:07:22 +00:00
2009-06-11 21:21:20 +00:00
flags [ flagname ] = value ;
}
}
// This returns a copy of the flags dictionary
public Dictionary < string , bool > GetFlags ( )
{
return new Dictionary < string , bool > ( flags ) ;
}
2016-06-15 22:57:39 +00:00
//mxd. This returns enabled flags
public HashSet < string > GetEnabledFlags ( )
{
HashSet < string > result = new HashSet < string > ( ) ;
foreach ( KeyValuePair < string , bool > group in flags )
if ( group . Value ) result . Add ( group . Key ) ;
return result ;
}
2009-06-11 21:21:20 +00:00
// This clears all flags
public void ClearFlags ( )
{
BeforePropsChange ( ) ;
flags . Clear ( ) ;
}
2009-04-19 18:07:22 +00:00
// This snaps the vertex to the grid
public void SnapToGrid ( )
{
// Calculate nearest grid coordinates
2014-02-21 14:42:12 +00:00
this . Move ( General . Map . Grid . SnappedToGrid ( pos ) ) ;
2009-04-19 18:07:22 +00:00
}
// This snaps the vertex to the map format accuracy
public void SnapToAccuracy ( )
2015-06-19 19:19:41 +00:00
{
SnapToAccuracy ( true ) ;
}
// This snaps the vertex to the map format accuracy
public void SnapToAccuracy ( bool usepreciseposition )
2009-04-19 18:07:22 +00:00
{
// Round the coordinates
2015-06-19 19:19:41 +00:00
Vector3D newpos = new Vector3D ( ( float ) Math . Round ( pos . x , ( usepreciseposition ? General . Map . FormatInterface . VertexDecimals : 0 ) ) ,
( float ) Math . Round ( pos . y , ( usepreciseposition ? General . Map . FormatInterface . VertexDecimals : 0 ) ) ,
( float ) Math . Round ( pos . z , ( usepreciseposition ? General . Map . FormatInterface . VertexDecimals : 0 ) ) ) ;
2009-04-19 18:07:22 +00:00
this . Move ( newpos ) ;
}
// This returns the distance from given coordinates
public float DistanceToSq ( Vector2D p )
{
return Vector2D . DistanceSq ( p , pos ) ;
}
// This returns the distance from given coordinates
public float DistanceTo ( Vector2D p )
{
return Vector2D . Distance ( p , pos ) ;
}
#endregion
}
}