Updated raylib-cpp header files

This commit is contained in:
2025-09-08 22:06:21 -04:00
parent a0a658ca8a
commit fff611cc72
45 changed files with 2533 additions and 2382 deletions

View File

@@ -3,16 +3,16 @@
#include <string>
#include "./raylib.hpp"
#include "./RaylibException.hpp"
#include "./raylib-cpp-utils.hpp"
#include "./raylib.hpp"
namespace raylib {
/**
* Text Functions.
*/
class Text {
public:
public:
/**
* The internal text.
*/
@@ -48,16 +48,16 @@ class Text {
* @param spacing The spacing of the text.
*/
Text(
const std::string& text = "",
float fontSize = 10,
const ::Color& color = WHITE,
const ::Font& font = ::GetFontDefault(),
float spacing = 0) :
text(text),
fontSize(fontSize),
color(color),
font(font),
spacing(spacing) {
const std::string& text = "",
float fontSize = 10,
const ::Color& color = WHITE,
const ::Font& font = ::GetFontDefault(),
float spacing = 0)
: text(text)
, fontSize(fontSize)
, color(color)
, font(font)
, spacing(spacing) {
// Nothing.
}
@@ -71,20 +71,20 @@ class Text {
* @param color The color of the font.
*/
Text(
const ::Font& font,
const std::string& text = "",
float fontSize = 10,
float spacing = 0,
const ::Color& color = WHITE) :
text(text),
fontSize(fontSize),
color(color),
font(font),
spacing(spacing) {
const ::Font& font,
const std::string& text = "",
float fontSize = 10,
float spacing = 0,
const ::Color& color = WHITE)
: text(text)
, fontSize(fontSize)
, color(color)
, font(font)
, spacing(spacing) {
// Nothing.
}
GETTERSETTER(std::string, Text, text)
GETTERSETTER(const std::string&, Text, text)
GETTERSETTER(float, FontSize, fontSize)
GETTERSETTER(::Font, Font, font)
GETTERSETTER(::Color, Color, color)
@@ -93,17 +93,16 @@ class Text {
/**
* Draw text with values in class.
*/
inline void Draw(const ::Vector2& position) const {
::DrawTextEx(font, text.c_str(), position, fontSize, spacing, color);
}
void Draw(const ::Vector2& position) const { ::DrawTextEx(font, text.c_str(), position, fontSize, spacing, color); }
/**
* Draw text with values in class.
*/
inline void Draw(int posX, int posY) const {
::DrawTextEx(font,
void Draw(int posX, int posY) const {
::DrawTextEx(
font,
text.c_str(),
{ static_cast<float>(posX), static_cast<float>(posY) },
{static_cast<float>(posX), static_cast<float>(posY)},
fontSize,
spacing,
color);
@@ -114,23 +113,19 @@ class Text {
*
* @see DrawTextPro()
*/
inline void Draw(const ::Vector2& position, float rotation, const ::Vector2& origin = {0, 0}) const {
void Draw(const ::Vector2& position, float rotation, const ::Vector2& origin = {0, 0}) const {
::DrawTextPro(font, text.c_str(), position, origin, rotation, fontSize, spacing, color);
}
/**
* Measure string width for default font
*/
inline int Measure() const {
return ::MeasureText(text.c_str(), static_cast<int>(fontSize));
}
[[nodiscard]] int Measure() const { return ::MeasureText(text.c_str(), static_cast<int>(fontSize)); }
/**
* Measure string size for Font
*/
inline Vector2 MeasureEx() const {
return ::MeasureTextEx(font, text.c_str(), fontSize, spacing);
}
[[nodiscard]] Vector2 MeasureEx() const { return ::MeasureTextEx(font, text.c_str(), fontSize, spacing); }
Text& operator=(const Text& other) {
if (this == &other) {
@@ -151,12 +146,8 @@ class Text {
*
* @see ::DrawText
*/
static inline void Draw(
const std::string& text,
const int posX,
const int posY,
const int fontSize,
const ::Color& color) {
static void
Draw(const std::string& text, const int posX, const int posY, const int fontSize, const ::Color& color) {
::DrawText(text.c_str(), posX, posY, fontSize, color);
}
@@ -165,11 +156,7 @@ class Text {
*
* @see ::DrawText
*/
static inline void Draw(
const std::string& text,
const ::Vector2& pos,
const int fontSize,
const ::Color& color) {
static void Draw(const std::string& text, const ::Vector2& pos, const int fontSize, const ::Color& color) {
::DrawText(text.c_str(), static_cast<int>(pos.x), static_cast<int>(pos.y), fontSize, color);
}
@@ -178,13 +165,13 @@ class Text {
*
* @see ::DrawTextEx
*/
static inline void Draw(
const ::Font& font,
const std::string& text,
const ::Vector2& position,
const float fontSize,
const float spacing,
const ::Color& color) {
static void Draw(
const ::Font& font,
const std::string& text,
const ::Vector2& position,
const float fontSize,
const float spacing,
const ::Color& color) {
::DrawTextEx(font, text.c_str(), position, fontSize, spacing, color);
}
@@ -193,20 +180,20 @@ class Text {
*
* @see ::DrawTextPro
*/
static inline void Draw(
const ::Font& font,
const std::string& text,
const ::Vector2& position,
const ::Vector2& origin,
const float rotation,
const float fontSize,
const float spacing,
const ::Color& color) {
static void Draw(
const ::Font& font,
const std::string& text,
const ::Vector2& position,
const ::Vector2& origin,
const float rotation,
const float fontSize,
const float spacing,
const ::Color& color) {
::DrawTextPro(font, text.c_str(), position, origin, rotation, fontSize, spacing, color);
}
};
} // namespace raylib
} // namespace raylib
using RText = raylib::Text;
#endif // RAYLIB_CPP_INCLUDE_TEXT_HPP_
#endif // RAYLIB_CPP_INCLUDE_TEXT_HPP_