RType
src
client
Components
Button
ButtonComponent.hpp
Go to the documentation of this file.
1
/*
2
** EPITECH PROJECT, 2023
3
** R-type
4
** File description:
5
** R-type
6
*/
7
8
#
pragma
once
9
10
#
include
"Components/AComponent.hpp"
11
#
include
"Components/Input/InputComponent.hpp"
12
#
include
"Components/Music/MusicComponent.hpp"
13
#
include
"Components/Sound/SoundComponent.hpp"
14
#
include
"Components/Text/TextComponent.hpp"
15
#
include
<
functional
>
16
#
include
<
iostream
>
17
18
class
ButtonComponent
:
public
AComponent
19
{
20
public
:
21
22
/**
23
* @brief Construct a new Button Component object
24
*
25
* @param core
26
* @param socket
27
*/
28
explicit
ButtonComponent
(
ClientCore
*core, std::shared_ptr<
ClientSocket
> socket);
29
30
/**
31
* @brief Destroy the Button Component object
32
*
33
*/
34
void
action
()
override
;
35
36
/**
37
* @brief Set the Texture object
38
*
39
* @param texture
40
*/
41
void
setTexture
(
const
sf::Texture &texture);
42
43
/**
44
* @brief Set the Position object
45
*
46
* @param position
47
*/
48
void
setPosition
(sf::Vector2f position);
49
50
/**
51
* @brief Set the Size object
52
*
53
* @param size
54
*/
55
void
setSize
(sf::Vector2f size);
56
57
/**
58
* @brief Set the Callback object
59
*
60
* @param callback
61
*/
62
void
setCallback
(std::function<
void
()> callback);
63
64
/**
65
* @brief Set the Rect object
66
*
67
* @param rect
68
*/
69
void
setRect
(sf::IntRect rect);
70
71
/**
72
* @brief display the button
73
* @param window
74
*/
75
void
display
(sf::RenderWindow &window)
override
;
76
77
/**
78
* @brief Get the Rect object
79
*
80
* @return sf::IntRect
81
*/
82
sf
::
IntRect
getRect
()
const
;
83
84
/**
85
* @brief handle event, check if the button is clicked
86
* @param event
87
* @param window
88
*/
89
void
handleEvent
(
const
sf::Event &event, sf::RenderWindow &window)
override
;
90
91
/**
92
* @brief handleClickInitServer, handle click on init server button
93
*/
94
void
handleClickInitServer
();
95
96
/**
97
* @brief handleClickMainScene, handle click on main scene button
98
*/
99
void
handleClickMainScene
();
100
101
/**
102
* @brief handleClickMenuScene, handle click on menu scene button
103
*/
104
void
handleClickAccessGame
();
105
106
/**
107
* @brief defaultCallback, default callback
108
*/
109
void
defaultCallback
();
110
111
private
:
112
sf::Texture _texture;
113
sf::Sprite _sprite;
114
sf::Vector2f _position;
115
sf::Vector2f _size;
116
sf::IntRect _rect;
117
std::function<
void
()> _callback;
118
std::shared_ptr<
ClientSocket
> _socket;
119
};
Generated by
1.9.1