RType
Public Member Functions | List of all members
ButtonComponent Class Reference

#include <ButtonComponent.hpp>

Inheritance diagram for ButtonComponent:
Inheritance graph
[legend]
Collaboration diagram for ButtonComponent:
Collaboration graph
[legend]

Public Member Functions

 ButtonComponent (ClientCore *core, std::shared_ptr< ClientSocket > socket)
 Construct a new Button Component object. More...
 
void action () override
 Destroy the Button Component object. More...
 
void setTexture (const sf::Texture &texture)
 Set the Texture object. More...
 
void setPosition (sf::Vector2f position)
 Set the Position object. More...
 
void setSize (sf::Vector2f size)
 Set the Size object. More...
 
void setCallback (std::function< void()> callback)
 Set the Callback object. More...
 
void setRect (sf::IntRect rect)
 Set the Rect object. More...
 
void display (sf::RenderWindow &window) override
 display the button More...
 
sf::IntRect getRect () const
 Get the Rect object. More...
 
void handleEvent (const sf::Event &event, sf::RenderWindow &window) override
 handle event, check if the button is clicked More...
 
void handleClickInitServer ()
 handleClickInitServer, handle click on init server button More...
 
void handleClickMainScene ()
 handleClickMainScene, handle click on main scene button More...
 
void handleClickAccessGame ()
 handleClickMenuScene, handle click on menu scene button More...
 
void defaultCallback ()
 defaultCallback, default callback More...
 
- Public Member Functions inherited from AComponent
 AComponent (ClientCore *clientCore)
 AComponent, constructor of AComponent. More...
 
 ~AComponent () override=default
 ~AComponent, destructor of AComponent More...
 
ComponentType getType () const override
 getType, get the type of the component More...
 
void addActionTarget (std::shared_ptr< IComponent > component) override
 addActionTarget, add a target to the action More...
 
void addSubComponent (std::shared_ptr< IComponent > component) override
 addSubComponent, add a sub component More...
 
void setAttribute (std::string attribute) override
 setAttribute, set the attribute More...
 
std::string getAttribute () override
 getAttribute, get the attribute More...
 
- Public Member Functions inherited from IComponent
 IComponent (ClientCore *clientCore)
 IComponent, constructor of IComponent. More...
 
virtual ~IComponent ()=default
 ~IComponent, destructor of IComponent More...
 

Additional Inherited Members

- Protected Attributes inherited from IComponent
std::string _attribute
 
ComponentType _type
 
std::vector< std::shared_ptr< IComponent > > action_target
 
std::vector< std::shared_ptr< IComponent > > sub_components
 
ClientCore_clientCore
 

Detailed Description

Definition at line 18 of file ButtonComponent.hpp.

Constructor & Destructor Documentation

◆ ButtonComponent()

ButtonComponent::ButtonComponent ( ClientCore core,
std::shared_ptr< ClientSocket socket 
)
explicit

Construct a new Button Component object.

ButtonComponent constructor.

Parameters
core
socket

Definition at line 18 of file ButtonComponent.cpp.

References IComponent::_attribute, IComponent::_type, AComponent::AComponent(), and BUTTON.

Here is the call graph for this function:

Member Function Documentation

◆ action()

void ButtonComponent::action ( )
overridevirtual

Destroy the Button Component object.

action, call the callback function

Implements IComponent.

Definition at line 39 of file ButtonComponent.cpp.

Referenced by handleEvent().

Here is the caller graph for this function:

◆ defaultCallback()

void ButtonComponent::defaultCallback ( )

defaultCallback, default callback

Definition at line 231 of file ButtonComponent.cpp.

◆ display()

void ButtonComponent::display ( sf::RenderWindow &  window)
overridevirtual

display the button

setAttribute set the attribute of the button

Parameters
window

Implements IComponent.

Definition at line 97 of file ButtonComponent.cpp.

◆ getRect()

sf::IntRect ButtonComponent::getRect ( ) const

Get the Rect object.

getRect get the texture of the button

Returns
sf::IntRect
rect of the button

Definition at line 106 of file ButtonComponent.cpp.

◆ handleClickAccessGame()

void ButtonComponent::handleClickAccessGame ( )

handleClickMenuScene, handle click on menu scene button

handleClickAccessGame handle the click of the button for access the game scene

Definition at line 198 of file ButtonComponent.cpp.

References IComponent::_clientCore, packet::code, packet::data, packet::data_size, MESSAGE, and ClientCore::setCurrentScene().

Here is the call graph for this function:

◆ handleClickInitServer()

void ButtonComponent::handleClickInitServer ( )

handleClickInitServer, handle click on init server button

handleClickInitServer handle the click of the button

Definition at line 132 of file ButtonComponent.cpp.

◆ handleClickMainScene()

void ButtonComponent::handleClickMainScene ( )

handleClickMainScene, handle click on main scene button

handleClickMainScene handle the click of the button on the main scene

Definition at line 179 of file ButtonComponent.cpp.

References IComponent::_clientCore, and ClientCore::setCurrentScene().

Here is the call graph for this function:

◆ handleEvent()

void ButtonComponent::handleEvent ( const sf::Event event,
sf::RenderWindow &  window 
)
overridevirtual

handle event, check if the button is clicked

handleEvent handle the event of the button

Parameters
event
window
eventto handle
window

Implements IComponent.

Definition at line 116 of file ButtonComponent.cpp.

References action().

Here is the call graph for this function:

◆ setCallback()

void ButtonComponent::setCallback ( std::function< void()>  callback)

Set the Callback object.

setAttribute set the attribute of the button

Parameters
callback
attribute

Definition at line 88 of file ButtonComponent.cpp.

◆ setPosition()

void ButtonComponent::setPosition ( sf::Vector2f  position)

Set the Position object.

setPosition set the position of the button

Parameters
position

Definition at line 58 of file ButtonComponent.cpp.

◆ setRect()

void ButtonComponent::setRect ( sf::IntRect  rect)

Set the Rect object.

setRect set the rect of the button

Parameters
rect

Definition at line 78 of file ButtonComponent.cpp.

◆ setSize()

void ButtonComponent::setSize ( sf::Vector2f  size)

Set the Size object.

setSize set the size of the button

Parameters
size

Definition at line 68 of file ButtonComponent.cpp.

◆ setTexture()

void ButtonComponent::setTexture ( const sf::Texture &  texture)

Set the Texture object.

setTexture set the texture of the button

Parameters
texture

Definition at line 48 of file ButtonComponent.cpp.


The documentation for this class was generated from the following files: