Middle Europe Productions Library  alpha 1.3.3
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
MEP::Following Class Reference

MEP::Following keeps track of a MEP::Object position. More...

#include <Following.h>

Inheritance diagram for MEP::Following:
MEP::Sprite MEP::Text MEP::AnimationObject MEP::TextureObject MEP::Button

Public Types

enum  FollowType {
  FollowType::NotInit = 0, FollowType::Objects = 1, FollowType::X_Scale = 2, FollowType::Y_Scale = 3,
  FollowType::X_Pos = 4, FollowType::Y_Pos = 5, FollowType::Color = 6
}
 

Public Member Functions

 Following (const FollowType &followType, sf::Vector2f pos={ 0.f, 0.f }, sf::Vector2f posFixed={ 0.f, 0.f }, sf::Vector2f scale={ 1.f, 1.f }, sf::Vector2f scaleFixed={ 1.f, 1.f })
 
 Following (sf::Vector2f pos={ 0.f, 0.f }, sf::Vector2f posFixed={ 0.f, 0.f }, sf::Vector2f scale={ 1.f, 1.f }, sf::Vector2f scaleFixed={ 1.f, 1.f })
 
 Following (const Following &x)
 
void updatePosition ()
 
void addMethodPos (std::function< sf::Vector2f()> method)
 
void updateScale ()
 
void addMethodScale (std::function< sf::Vector2f()> method)
 
Followingoperator<< (const Following &x)
 
void setFollow (const AnimationPosition &base, const FollowType type, MEP::U_int32 group=-1)
 
void setFollow (const AnimationColor &base, MEP::U_int32 toFollow=MEP::ColorChannel::ALL, MEP::U_int32 group=-1)
 
void muteFollowGroup (MEP::U_int32 group)
 
void unMuteFollowGroup (MEP::U_int32 group)
 
void fullMuteFollow ()
 
void fullUnMuteFollow ()
 
virtual void setPosition (const sf::Vector2f pos)
 
virtual void setPosition (const Following &x)
 
virtual void movePosition (const sf::Vector2f pos)
 
virtual void setScale (const sf::Vector2f scale)
 
virtual void setScale (const Following &x)
 
virtual void setColor (const sf::Color &color)
 
virtual const sf::Color & getColor () const
 
sf::Vector2f getPosition () const
 
sf::Vector2f getScale () const
 
sf::Vector2f getOriginPosition () const
 
sf::Vector2f getOriginScale () const
 
bool isFollowerActive () const
 
void followingDebug (std::ostream &out, const char *skipLines="") const
 
void clearFollow ()
 

Protected Attributes

std::function< sf::Vector2f()> calc_position = [this]()->sf::Vector2f { return m_pos; }
 
std::function< sf::Vector2f()> calc_scale = [this]()->sf::Vector2f { return m_scale; }
 
MEPtools::GroupManager< Follow, std::unique_ptr< Follow >, std::list< std::unique_ptr< Follow > > > followingListv2
 
sf::Vector2f m_pos = {0.f, 0.f}
 
sf::Vector2f m_posMove = { 0.f, 0.f }
 
sf::Vector2f m_posFixed = { 0.f, 0.f }
 
sf::Vector2f m_scale = { 1.f, 1.f }
 
sf::Vector2f m_scaleFixed = { 1.f, 1.f }
 
sf::Color m_color
 
sf::Color m_colorFixed
 

Detailed Description

MEP::Following keeps track of a MEP::Object position.

Member Enumeration Documentation

◆ FollowType

Enumerator
NotInit 

Following not initialized.

Objects 

Following other Objects.

X_Scale 

Following with a change of X scale

Y_Scale 

Following with a change of Y scale

X_Pos 

Following with a change of X position

Y_Pos 

Following with a change of Y position

Color 

Following with a change of a color.

Constructor & Destructor Documentation

◆ Following() [1/3]

MEP::Following::Following ( const FollowType followType,
sf::Vector2f  pos = { 0.f, 0.f },
sf::Vector2f  posFixed = { 0.f, 0.f },
sf::Vector2f  scale = { 1.f, 1.f },
sf::Vector2f  scaleFixed = { 1.f, 1.f } 
)
inline

Constructor of a following type.

Parameters
[in]followType: MEP::Following::FollowType type of an animation.
[in]pos: Position of the follower.
[in]posFixed: Fixed position of the follower.
[in]scale: Scale of the follower.
[in]scaleFixed: Fixed scale of the follower.

◆ Following() [2/3]

MEP::Following::Following ( sf::Vector2f  pos = { 0.f, 0.f },
sf::Vector2f  posFixed = { 0.f, 0.f },
sf::Vector2f  scale = { 1.f, 1.f },
sf::Vector2f  scaleFixed = { 1.f, 1.f } 
)
inline

Constructor of a following type.

Parameters
[in]pos: Position of the follower.
[in]posFixed: Fixed position of the follower.
[in]scale: Scale of the follower.
[in]scaleFixed: Fixed scale of the follower.

◆ Following() [3/3]

MEP::Following::Following ( const Following x)
inline

Warning list of the following objects is individual for every object. Copy constructor does not copy them. Copy constructor copy position, scale and color.

Parameters
[in]x: Another MEP::Following instance.

Member Function Documentation

◆ addMethodPos()

void MEP::Following::addMethodPos ( std::function< sf::Vector2f()>  method)
inline

Adds a method of calculation the position.

Parameters
[in]method: A method of calculating the position.

◆ addMethodScale()

void MEP::Following::addMethodScale ( std::function< sf::Vector2f()>  method)
inline

Adds a method of calculation the scale.

Parameters
[in]method: A method of calculating the position.

◆ clearFollow()

void MEP::Following::clearFollow ( )
inline

Clears the follower list.

◆ followingDebug()

void MEP::Following::followingDebug ( std::ostream &  out,
const char *  skipLines = "" 
) const
inline

Following debug message.

◆ fullMuteFollow()

void MEP::Following::fullMuteFollow ( )
inline

Full mute of the following objects.

◆ fullUnMuteFollow()

void MEP::Following::fullUnMuteFollow ( )
inline

Full mute of the following objects.

◆ getColor()

virtual const sf::Color& MEP::Following::getColor ( ) const
inlinevirtual

Outputs the color of a master sprite.

Returns
: Color.

Reimplemented in MEP::Sprite, and MEP::TextureObject.

◆ getOriginPosition()

sf::Vector2f MEP::Following::getOriginPosition ( ) const
inline

Outputs the position of the MEP::Folowing

Returns
Position.

◆ getOriginScale()

sf::Vector2f MEP::Following::getOriginScale ( ) const
inline

Outputs the scale of the MEP::Folowing

Returns
Scale.

◆ getPosition()

sf::Vector2f MEP::Following::getPosition ( ) const
inline

Outputs the current position of the MEP::Folowing

Returns
Fixed position.

◆ getScale()

sf::Vector2f MEP::Following::getScale ( ) const
inline

Outputs the current scale of the MEP::Folowing

Returns
Fixed scale.

◆ isFollowerActive()

bool MEP::Following::isFollowerActive ( ) const
inline

Outputs the information about MEP::Following activity.

Returns
true - if atleast one istance of the Follwer is active, false - otherwise.

◆ movePosition()

virtual void MEP::Following::movePosition ( const sf::Vector2f  pos)
inlinevirtual

Moves the position by given value.

Parameters
[in]pos: Position change.

◆ muteFollowGroup()

void MEP::Following::muteFollowGroup ( MEP::U_int32  group)
inline

Mutes a group of objects.

◆ operator<<()

Following& MEP::Following::operator<< ( const Following x)
inline

Warning list of the following objects is indivdual for every object. Assign operator does not copy them. Assign operator copy position, scale and color.

Parameters
[in]x: Another MEP::Following instance.

◆ setColor()

virtual void MEP::Following::setColor ( const sf::Color &  color)
inlinevirtual

Changes the color of a master sprite.

Parameters
[in]color: Color.

Reimplemented in MEP::Text, MEP::Sprite, and MEP::TextureObject.

◆ setFollow() [1/2]

void MEP::Following::setFollow ( const AnimationColor base,
MEP::U_int32  toFollow = MEP::ColorChannel::ALL,
MEP::U_int32  group = -1 
)
inline

Sets the object to follow using another MEP::AnimationColor instance. Use MEP::ColorChannel here.

Parameters
[in]base: MEP::AnimationPosition object to follow.
[in]type: Type of a follow.
[in]toFollow: Channels to be followed.

◆ setFollow() [2/2]

void MEP::Following::setFollow ( const AnimationPosition base,
const FollowType  type,
MEP::U_int32  group = -1 
)
inline

Sets the object to follow using another MEP::AnimationPosition instance.

Parameters
[in]base: MEP::AnimationPosition object to follow.
[in]type: Type of a follow.

◆ setPosition() [1/2]

virtual void MEP::Following::setPosition ( const Following x)
inlinevirtual

Sets the position and fixed position of an MEP::Following.

Parameters
[in]x: MEP::Following object.

Reimplemented in MEP::Sprite.

◆ setPosition() [2/2]

virtual void MEP::Following::setPosition ( const sf::Vector2f  pos)
inlinevirtual

Sets the position and fixed position of an MEP::Following.

Parameters
[in]pos: Position.

Reimplemented in MEP::Sprite.

◆ setScale() [1/2]

virtual void MEP::Following::setScale ( const Following x)
inlinevirtual

Sets the scale and fixed scale of the MEP::Following.

Parameters
[in]x: MEP::Following object.

Reimplemented in MEP::AnimationObject, and MEP::Sprite.

◆ setScale() [2/2]

virtual void MEP::Following::setScale ( const sf::Vector2f  scale)
inlinevirtual

Sets the scale and fixed scale of the MEP::Following.

Parameters
[in]scale: Scale.

Reimplemented in MEP::AnimationObject, and MEP::Sprite.

◆ unMuteFollowGroup()

void MEP::Following::unMuteFollowGroup ( MEP::U_int32  group)
inline

Unmutes a group of objects.

◆ updatePosition()

void MEP::Following::updatePosition ( )
inline

Updates the position of an object according the the given method. If method is not specified does not change anything.

◆ updateScale()

void MEP::Following::updateScale ( )
inline

Updates the scale of an object according the the given method. If method is not specified does not change anything.

Member Data Documentation

◆ calc_position

std::function<sf::Vector2f()> MEP::Following::calc_position = [this]()->sf::Vector2f { return m_pos; }
protected

◆ calc_scale

std::function<sf::Vector2f()> MEP::Following::calc_scale = [this]()->sf::Vector2f { return m_scale; }
protected

◆ followingListv2

MEPtools::GroupManager<Follow, std::unique_ptr<Follow>, std::list<std::unique_ptr<Follow> > > MEP::Following::followingListv2
protected

◆ m_color

sf::Color MEP::Following::m_color
protected

◆ m_colorFixed

sf::Color MEP::Following::m_colorFixed
protected

◆ m_pos

sf::Vector2f MEP::Following::m_pos = {0.f, 0.f}
protected

◆ m_posFixed

sf::Vector2f MEP::Following::m_posFixed = { 0.f, 0.f }
protected

◆ m_posMove

sf::Vector2f MEP::Following::m_posMove = { 0.f, 0.f }
protected

◆ m_scale

sf::Vector2f MEP::Following::m_scale = { 1.f, 1.f }
protected

◆ m_scaleFixed

sf::Vector2f MEP::Following::m_scaleFixed = { 1.f, 1.f }
protected