lxgui
gui_animated_texture_parser.cpp
1 #include "lxgui/gui_animated_texture.hpp"
2 #include "lxgui/gui_layout_node.hpp"
3 #include "lxgui/gui_manager.hpp"
4 #include "lxgui/gui_out.hpp"
5 
6 namespace lxgui::gui {
7 
10 }
11 
12 void animated_texture::parse_attributes_(const layout_node& node) {
14 
15  if (const auto attr = node.try_get_attribute_value<std::string>("file"))
16  set_texture(attr.value());
17 
18  if (const auto attr = node.try_get_attribute_value<float>("speed"))
19  set_speed(attr.value());
20 
21  if (const auto attr = node.try_get_attribute_value<float>("state"))
22  set_state(attr.value());
23 
24  if (const auto attr = node.try_get_attribute_value<bool>("paused"))
25  set_paused(attr.value());
26 }
27 
28 } // namespace lxgui::gui
void parse_layout(const layout_node &node) override
Parses data from a layout_node.
void set_state(float state)
Returns this animated_texture's state (0: begin, 1: end).
void set_texture(const std::string &file_name)
Sets this texture's texture file.
void set_speed(float speed)
Set this animated_texture's animation speed (frame per second).
void set_paused(bool is_paused)
Play or pause this animated_texture.
void parse_attributes_(const layout_node &node) override
void parse_layout(const layout_node &node) override
Parses data from a layout_node.
An node in a layout file.
std::optional< std::string_view > try_get_attribute_value(std::string_view name) const noexcept
Returns the value of the attribute with the provided name, nullopt if not found.