aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-11 22:17:43 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-11 22:17:43 +0100
commite75e355c3a59d53a1d64fd8fae3331b2234083e2 (patch)
tree24176a074d529271e7279794f7fa2dcf5aed2525 /src/crepe/api
parentbb2a6f1a0ab19f6cbc78b2747a26920f24bf13ca (diff)
text component pretty much finished
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/CMakeLists.txt2
-rw-r--r--src/crepe/api/Config.h4
-rw-r--r--src/crepe/api/Text.cpp6
-rw-r--r--src/crepe/api/Text.h8
4 files changed, 14 insertions, 6 deletions
diff --git a/src/crepe/api/CMakeLists.txt b/src/crepe/api/CMakeLists.txt
index fb11c8d..90e4d1f 100644
--- a/src/crepe/api/CMakeLists.txt
+++ b/src/crepe/api/CMakeLists.txt
@@ -20,6 +20,7 @@ target_sources(crepe PUBLIC
Button.cpp
UIObject.cpp
AI.cpp
+ Text.cpp
)
target_sources(crepe PUBLIC FILE_SET HEADERS FILES
@@ -49,4 +50,5 @@ target_sources(crepe PUBLIC FILE_SET HEADERS FILES
Button.h
UIObject.h
AI.h
+ Text.h
)
diff --git a/src/crepe/api/Config.h b/src/crepe/api/Config.h
index def4c49..159be99 100644
--- a/src/crepe/api/Config.h
+++ b/src/crepe/api/Config.h
@@ -81,11 +81,11 @@ struct Config final {
/**
* \brief Default font size
*
- * using the SDL_ttf library the font size needs to be set when loading the font.
+ * Using the SDL_ttf library the font size needs to be set when loading the font.
* This config option is the font size at which all fonts will be loaded initially.
*
*/
- int font_size = 16;
+ unsigned int size = 16;
} font;
//! Audio system settings
diff --git a/src/crepe/api/Text.cpp b/src/crepe/api/Text.cpp
index e69de29..dd44dd9 100644
--- a/src/crepe/api/Text.cpp
+++ b/src/crepe/api/Text.cpp
@@ -0,0 +1,6 @@
+#include "Text.h"
+
+using namespace crepe;
+
+Text::Text(game_object_id_t id,const vec2 & dimensions, const vec2 & offset, const Asset & font) : UIObject(id,dimensions,offset),source(font){}
+
diff --git a/src/crepe/api/Text.h b/src/crepe/api/Text.h
index 9dd275b..d5f47fa 100644
--- a/src/crepe/api/Text.h
+++ b/src/crepe/api/Text.h
@@ -11,11 +11,11 @@
namespace crepe{
class Text : public UIObject{
public:
- Text(game_object_id_t id,const vec2 & dimensions, const vec2 & offset, const Asset & font, int font_size);
+ Text(game_object_id_t id,const vec2 & dimensions, const vec2 & offset, const Asset & font);
//! Label text.
std::string text;
- //! Label text color
+ //! Label text color.
Color text_color = Color::BLACK;
/**
* \brief fontsize for text rendering
@@ -26,8 +26,8 @@ public:
* The default font size that is loaded is set in the Config.
* Instead this value is used to upscale the font texture which can cause blurring or distorted text when upscaling or downscaling too much.
*/
- int font_size = 16;
-
+ unsigned int font_size = 16;
+ //! Font asset
const Asset source;
private:
};