From e5b57f6a0aadf4f5ca597e4ffa3e557eec87b54b Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Fri, 20 Dec 2024 15:26:51 +0100 Subject: add world space to text rendering and removedlayers on text --- src/crepe/api/Text.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/crepe/api/Text.h') diff --git a/src/crepe/api/Text.h b/src/crepe/api/Text.h index da40141..fb5c7e5 100644 --- a/src/crepe/api/Text.h +++ b/src/crepe/api/Text.h @@ -28,12 +28,6 @@ public: */ unsigned int font_size = 16; - //! Layer sorting level of the text - const int sorting_in_layer = 0; - - //! Order within the sorting text - const int order_in_layer = 0; - //! Label text color. Color text_color = Color::BLACK; }; -- cgit v1.2.3 From 296c80edd6727d6808ed0c98c001a8b456f1c037 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Sat, 21 Dec 2024 10:27:16 +0100 Subject: implemented feedback --- src/crepe/api/Button.h | 6 +++--- src/crepe/api/Text.h | 12 ++---------- src/crepe/api/UIObject.h | 2 -- src/crepe/facade/SDLContext.cpp | 2 +- 4 files changed, 6 insertions(+), 16 deletions(-) (limited to 'src/crepe/api/Text.h') diff --git a/src/crepe/api/Button.h b/src/crepe/api/Button.h index d42527e..25709a4 100644 --- a/src/crepe/api/Button.h +++ b/src/crepe/api/Button.h @@ -1,8 +1,5 @@ #pragma once -#include - -#include "Event.h" #include "UIObject.h" namespace crepe { @@ -43,6 +40,9 @@ private: friend class InputSystem; //! Indicates whether the mouse is currently hovering over the button bool hover = false; + + //! variable indicating if transform is relative to camera(false) or world(true) + bool world_space = false; }; } // namespace crepe diff --git a/src/crepe/api/Text.h b/src/crepe/api/Text.h index fb5c7e5..9d8573f 100644 --- a/src/crepe/api/Text.h +++ b/src/crepe/api/Text.h @@ -17,16 +17,8 @@ class Text : public UIObject { public: //! Text data that does not have to be set in the constructor struct Data { - /** - * \brief fontsize for text rendering - * - * \note this is not the actual font size that is loaded in. - * - * Since SDL_TTF requires the font size when loading in the font it is not possible to switch the font size. - * 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. - */ - unsigned int font_size = 16; + //! variable indicating if transform is relative to camera(false) or world(true) + bool world_space = false; //! Label text color. Color text_color = Color::BLACK; diff --git a/src/crepe/api/UIObject.h b/src/crepe/api/UIObject.h index f1318ab..f7f4fba 100644 --- a/src/crepe/api/UIObject.h +++ b/src/crepe/api/UIObject.h @@ -20,8 +20,6 @@ public: vec2 dimensions; //! Position offset relative to this GameObjects Transform vec2 offset; - //! variable indicating if transform is relative to camera(false) or world(true) - bool world_space = false; }; } // namespace crepe diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index 8e2e8a2..17dcd04 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -233,7 +233,7 @@ void SDLContext::draw_text(const RenderText & data) { vec2 size = text.dimensions * cam_aux_data.render_scale * data.transform.scale; vec2 screen_pos = absoluut_pos; - if (text.world_space) { + if (text.data.world_space) { screen_pos = (screen_pos - cam_aux_data.cam_pos + (cam_aux_data.zoomed_viewport) / 2) * cam_aux_data.render_scale - size / 2 + cam_aux_data.bar_size; -- cgit v1.2.3 From a5f8b34f4701863901e89abe5b0b604fd9e553b2 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Sun, 22 Dec 2024 20:18:44 +0100 Subject: ui fixes for offset --- src/crepe/api/Button.cpp | 2 +- src/crepe/api/Button.h | 4 +++- src/crepe/api/Text.cpp | 5 +++-- src/crepe/api/Text.h | 5 +++-- src/crepe/api/UIObject.h | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src/crepe/api/Text.h') diff --git a/src/crepe/api/Button.cpp b/src/crepe/api/Button.cpp index c4f7f2d..8eadd89 100644 --- a/src/crepe/api/Button.cpp +++ b/src/crepe/api/Button.cpp @@ -3,7 +3,7 @@ namespace crepe { Button::Button( - game_object_id_t id, const vec2 & dimensions, const vec2 & offset, const Data & data + game_object_id_t id, const vec2 & dimensions, const Data & data, const vec2 & offset ) : UIObject(id, dimensions, offset), data(data) {} diff --git a/src/crepe/api/Button.h b/src/crepe/api/Button.h index f6d363a..d7dc747 100644 --- a/src/crepe/api/Button.h +++ b/src/crepe/api/Button.h @@ -1,6 +1,7 @@ #pragma once #include "UIObject.h" +#include "types.h" namespace crepe { @@ -33,7 +34,8 @@ public: * \param data additional data the button has */ Button( - game_object_id_t id, const vec2 & dimensions, const vec2 & offset, const Data & data + game_object_id_t id, const vec2 & dimensions, const Data & data, + const vec2 & offset = {0, 0} ); /** * \brief Get the maximum number of instances for this component diff --git a/src/crepe/api/Text.cpp b/src/crepe/api/Text.cpp index b24f0ac..29e36f1 100644 --- a/src/crepe/api/Text.cpp +++ b/src/crepe/api/Text.cpp @@ -1,10 +1,11 @@ #include "Text.h" +#include "types.h" using namespace crepe; Text::Text( - game_object_id_t id, const vec2 & dimensions, const vec2 & offset, - const std::string & font_family, const Data & data, const std::string & text + game_object_id_t id, const vec2 & dimensions, const std::string & font_family, + const Data & data, const vec2 & offset, const std::string & text ) : UIObject(id, dimensions, offset), text(text), diff --git a/src/crepe/api/Text.h b/src/crepe/api/Text.h index 0163bbb..37d86b4 100644 --- a/src/crepe/api/Text.h +++ b/src/crepe/api/Text.h @@ -6,6 +6,7 @@ #include "Asset.h" #include "Color.h" #include "UIObject.h" +#include "types.h" namespace crepe { /** @@ -35,8 +36,8 @@ public: * \param font Optional font asset that can be passed or left empty. */ Text( - game_object_id_t id, const vec2 & dimensions, const vec2 & offset, - const std::string & font_family, const Data & data, const std::string & text = "" + game_object_id_t id, const vec2 & dimensions, const std::string & font_family, + const Data & data, const vec2 & offset = {0, 0}, const std::string & text = "" ); //! Label text. diff --git a/src/crepe/api/UIObject.h b/src/crepe/api/UIObject.h index f7f4fba..5c1fdf7 100644 --- a/src/crepe/api/UIObject.h +++ b/src/crepe/api/UIObject.h @@ -15,7 +15,7 @@ public: * \param dimensions width and height of the UIObject * \param offset Offset relative to the GameObject Transform */ - UIObject(game_object_id_t id, const vec2 & dimensions, const vec2 & offset); + UIObject(game_object_id_t id, const vec2 & dimensions, const vec2 & offset = {0,0}); //! Width and height of the UIObject vec2 dimensions; //! Position offset relative to this GameObjects Transform -- cgit v1.2.3 From b9051627db1741fe373c08ab43170c257625073f Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Tue, 24 Dec 2024 09:49:49 +0100 Subject: feedback --- src/crepe/api/Button.h | 8 +++++--- src/crepe/api/Text.cpp | 3 ++- src/crepe/api/Text.h | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src/crepe/api/Text.h') diff --git a/src/crepe/api/Button.h b/src/crepe/api/Button.h index d7dc747..e986c04 100644 --- a/src/crepe/api/Button.h +++ b/src/crepe/api/Button.h @@ -1,7 +1,8 @@ #pragma once +#include "../types.h" + #include "UIObject.h" -#include "types.h" namespace crepe { @@ -46,13 +47,14 @@ public: */ virtual int get_instances_max() const { return 1; } +public: + Data data; + private: //! friend relation hover variable friend class InputSystem; //! Indicates whether the mouse is currently hovering over the button bool hover = false; - - Data data; }; } // namespace crepe diff --git a/src/crepe/api/Text.cpp b/src/crepe/api/Text.cpp index 29e36f1..e5b623d 100644 --- a/src/crepe/api/Text.cpp +++ b/src/crepe/api/Text.cpp @@ -1,5 +1,6 @@ +#include "../types.h" + #include "Text.h" -#include "types.h" using namespace crepe; diff --git a/src/crepe/api/Text.h b/src/crepe/api/Text.h index 37d86b4..8b3d53e 100644 --- a/src/crepe/api/Text.h +++ b/src/crepe/api/Text.h @@ -3,10 +3,11 @@ #include #include +#include "../types.h" + #include "Asset.h" #include "Color.h" #include "UIObject.h" -#include "types.h" namespace crepe { /** -- cgit v1.2.3