2012-06-01 19:53:14 +00:00
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
2014-09-12 21:08:11 +00:00
using System ;
2009-04-19 18:07:22 +00:00
using CodeImp.DoomBuilder.Map ;
using CodeImp.DoomBuilder.Rendering ;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
2012-06-01 19:53:14 +00:00
public class ResultStuckThingInThing : ErrorResult
2009-04-19 18:07:22 +00:00
{
#region = = = = = = = = = = = = = = = = = = Variables
2014-09-12 21:08:11 +00:00
private readonly Thing thing1 ;
private readonly Thing thing2 ; //mxd
2012-06-01 19:53:14 +00:00
2009-04-19 18:07:22 +00:00
#endregion
2012-06-01 19:53:14 +00:00
2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Properties
2014-09-29 20:49:41 +00:00
public override int Buttons { get { return 2 ; } }
public override string Button1Text { get { return "Delete 1-st Thing" ; } }
public override string Button2Text { get { return "Delete 2-nd Thing" ; } } //mxd
2009-04-19 18:07:22 +00:00
#endregion
2012-06-01 19:53:14 +00:00
2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Constructor / Destructor
2012-06-01 19:53:14 +00:00
2009-04-19 18:07:22 +00:00
// Constructor
2014-08-11 10:30:52 +00:00
public ResultStuckThingInThing ( Thing t1 , Thing t2 )
2009-04-19 18:07:22 +00:00
{
// Initialize
2014-08-11 10:30:52 +00:00
this . thing1 = t1 ;
this . thing2 = t2 ; //mxd
this . viewobjects . Add ( t1 ) ;
2014-09-12 21:08:11 +00:00
hidden = ( t1 . IgnoredErrorChecks . Contains ( this . GetType ( ) ) & & t2 . IgnoredErrorChecks . Contains ( this . GetType ( ) ) ) ; //mxd
2012-06-01 19:53:14 +00:00
this . description = "This thing is stuck in another thing. Both will likely not be able to move around." ;
2009-04-19 18:07:22 +00:00
}
2012-06-01 19:53:14 +00:00
2009-04-19 18:07:22 +00:00
#endregion
2012-06-01 19:53:14 +00:00
2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Methods
2012-06-01 19:53:14 +00:00
2014-09-12 21:08:11 +00:00
// This sets if this result is displayed in ErrorCheckForm (mxd)
internal override void Hide ( bool hide )
{
hidden = hide ;
Type t = this . GetType ( ) ;
if ( hide )
{
thing1 . IgnoredErrorChecks . Add ( t ) ;
thing2 . IgnoredErrorChecks . Add ( t ) ;
}
else
{
if ( thing1 . IgnoredErrorChecks . Contains ( t ) ) thing1 . IgnoredErrorChecks . Remove ( t ) ;
if ( thing2 . IgnoredErrorChecks . Contains ( t ) ) thing2 . IgnoredErrorChecks . Remove ( t ) ;
}
}
2009-04-19 18:07:22 +00:00
// This must return the string that is displayed in the listbox
public override string ToString ( )
{
2014-08-11 10:30:52 +00:00
return "Thing " + thing1 . Index + " (" + General . Map . Data . GetThingInfo ( thing1 . Type ) . Title + ") is stuck in thing " + thing2 . Index + " (" + General . Map . Data . GetThingInfo ( thing2 . Type ) . Title + ") at " + thing1 . Position . x + ", " + thing1 . Position . y ;
2009-04-19 18:07:22 +00:00
}
// Rendering
public override void RenderOverlaySelection ( IRenderer2D renderer )
{
2014-08-11 10:30:52 +00:00
renderer . RenderThing ( thing1 , renderer . DetermineThingColor ( thing1 ) , 1.0f ) ;
2014-09-29 20:49:41 +00:00
renderer . RenderThing ( thing2 , renderer . DetermineThingColor ( thing2 ) , 1.0f ) ;
2009-04-19 18:07:22 +00:00
}
2014-09-29 20:49:41 +00:00
// This removes the first thing
2013-06-04 14:43:26 +00:00
public override bool Button1Click ( bool batchMode )
2009-04-19 18:07:22 +00:00
{
2013-06-04 14:43:26 +00:00
if ( ! batchMode ) General . Map . UndoRedo . CreateUndo ( "Delete thing" ) ;
2014-08-11 10:30:52 +00:00
thing1 . Dispose ( ) ;
2009-04-19 18:07:22 +00:00
General . Map . IsChanged = true ;
General . Map . ThingsFilter . Update ( ) ;
return true ;
}
2012-06-01 19:53:14 +00:00
2014-09-29 20:49:41 +00:00
// This removes the thing
public override bool Button2Click ( bool batchMode )
{
if ( ! batchMode ) General . Map . UndoRedo . CreateUndo ( "Delete thing" ) ;
thing2 . Dispose ( ) ;
General . Map . IsChanged = true ;
General . Map . ThingsFilter . Update ( ) ;
return true ;
}
2009-04-19 18:07:22 +00:00
#endregion
}
}