4#include <SFML/Graphics/Font.hpp>
5#include <SFML/Graphics/View.hpp>
6#include <SFML/Graphics/Text.hpp>
7#include <SFML/Graphics/Drawable.hpp>
8#include <SFML/Graphics/VertexArray.hpp>
9#include <SFML/Graphics/Transformable.hpp>
24class GuiRender :
public sf::Drawable,
public sf::Transformable
57 const sf::FloatRect& box,
66 const std::string& text,
77 const std::string& text,
79 const uint32_t fontSize)
const;
93 sf::Vector2f
textureSize (
const std::string& texture)
const;
103 void initializeClippingLayers ();
108 void addThreeSlices (
const sf::FloatRect& box,
const std::string& widgetState,
const bool horizontal =
true,
const float percentToDraw = 1.f);
113 void addNineSlices (
const sf::FloatRect& box,
const std::string& widgetState);
117 void appendMesh (
Mesh&& mesh,
const sf::FloatRect& box,
const bool horizontal =
true,
const float percentToDraw = 1.f);
121 void computeMeshFilling (
Mesh& mesh,
const float percentToDraw,
const bool horizontal =
true);
125 void draw (sf::RenderTarget& target, sf::RenderStates states)
const override;
129 void drawLayer (sf::RenderTarget& target, sf::RenderStates states, uint32_t layer)
const;
133 std::string toString (
const Widget widget)
const;
134 std::string toString (
const ItemState state)
const;
138 std::vector <uint32_t> mWidgetLayers;
139 std::vector <uint32_t> mTooltipLayers;
141 sf::Texture* mGuiTexture;
143 std::vector <sf::VertexArray> mWidgets;
144 std::vector <std::vector <sf::Text>> mTexts;
Handle clipping layers to only draw things in a given box.
Definition ClippingLayers.h:15
Handle rendering for the gui.
Definition GuiRender.h:25
void clear()
Clear all widgets and text.
Definition GuiRender.cpp:48
uint32_t setCurrentClippingLayer(const sf::FloatRect &mask)
Set current clipping layer used to render UI. Every call will create a new layer with its own indepen...
Definition GuiRender.cpp:23
void updateView(const sf::View &newView)
Update view on which the gui is drawn.
Definition GuiRender.cpp:17
void setResources(sf::Texture &sprite)
Set resources used in render. It should be called before any draw call.
Definition GuiRender.cpp:9
sf::Vector2f textureSize(const std::string &texture) const
allow access to a texture size, as stored in the atlas
Definition GuiRender.cpp:93
sf::Vector2f textSize(const std::string &text, const sf::Font &font, const uint32_t fontSize) const
Get text size as if it was drawn on screen.
Definition GuiRender.cpp:69
void draw(const sf::FloatRect &box, const WidgetDrawOptions &options={})
interface to draw Gui standard element
Definition GuiRender.cpp:102
void setTooltipMode()
set specific render for tooltip
Definition GuiRender.cpp:81
ClippingLayers clipping
to handle clipping layers
Definition GuiRender.h:98
void setTextureAtlas(const TextureAtlas &atlas)
Set texture atlas used in render. It should be called before any draw call.
Definition GuiRender.cpp:41
void unsetTooltipMode()
unset specific render for tooltip
Definition GuiRender.cpp:87
Contains texture position and sub-box of all sprites for a given sprite sheet. Animations ca be handl...
Definition TextureAtlas.h:28
Compute texture meshes for a given texture map.
Definition TextureMeshes.h:18
Definition Interpolation.h:16
ItemState
List gui elements states.
Definition ItemStates.h:11
Widget
List widget textures available in gui.
Definition Widgets.h:11
std::array< sf::Vertex, 6 > Mesh
Definition MeshFunctions.h:9
Store options for drawing text.
Definition DrawOptions.h:21