aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-03 11:56:29 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-03 11:56:29 +0100
commit7551c98ee239963ad65123132419c3c0a9cfccb3 (patch)
treecec2c548bfd4c18707fb820f91701341ea5e37b0 /src/crepe/api
parentd1a31a3cafc9aadb047509f5cd8b2befa212add8 (diff)
world units for click
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/CMakeLists.txt3
-rw-r--r--src/crepe/api/Font.cpp45
-rw-r--r--src/crepe/api/Font.h60
-rw-r--r--src/crepe/api/Text.h42
4 files changed, 0 insertions, 150 deletions
diff --git a/src/crepe/api/CMakeLists.txt b/src/crepe/api/CMakeLists.txt
index 2d86968..aeb451d 100644
--- a/src/crepe/api/CMakeLists.txt
+++ b/src/crepe/api/CMakeLists.txt
@@ -25,7 +25,6 @@ target_sources(crepe PUBLIC
Script.cpp
Button.cpp
UiObject.cpp
- Font.cpp
)
target_sources(crepe PUBLIC FILE_SET HEADERS FILES
@@ -63,6 +62,4 @@ target_sources(crepe PUBLIC FILE_SET HEADERS FILES
Asset.h
Button.h
UiObject.h
- Font.h
- Text.h
)
diff --git a/src/crepe/api/Font.cpp b/src/crepe/api/Font.cpp
deleted file mode 100644
index 8db4b23..0000000
--- a/src/crepe/api/Font.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#include <SDL2/SDL_ttf.h>
-
-#include "facade/SDLContext.h"
-#include "util/Log.h"
-
-#include "Asset.h"
-#include "Font.h"
-
-using namespace crepe;
-using namespace std;
-
-Font::Font(const Asset &src, int size) : font_size(size) {
- dbg_trace();
- this->load(src, size);
-}
-
-Font::~Font() {
- dbg_trace();
- this->font.reset();
-}
-
-void Font::load(const Asset &res, int size) {
- SDLContext &ctx = SDLContext::get_instance();
- // Open the font using SDL's TTF_OpenFontRW, which supports loading from memory
- SDL_RWops *rw_ops = SDL_RWFromFile(res.get_path().c_str(), "rb");
- if (!rw_ops) {
- // dbg_log("Failed to create RWops for font: %s", SDL_GetError());
- return;
- }
-
- TTF_Font *loaded_font = TTF_OpenFontRW(rw_ops, 1, size); // 1 indicates SDL should free the RWops
- if (!loaded_font) {
- // dbg_log("Failed to load font from asset: %s", TTF_GetError());
- return;
- }
-
- // Wrap the TTF_Font with a unique_ptr for automatic cleanup
- this->font = unique_ptr<TTF_Font, function<void(TTF_Font *)>>(loaded_font, [](TTF_Font *f) {
- if (f) TTF_CloseFont(f);
- });
-}
-
-int Font::get_size() const {
- return this->font_size;
-}
diff --git a/src/crepe/api/Font.h b/src/crepe/api/Font.h
deleted file mode 100644
index 012c271..0000000
--- a/src/crepe/api/Font.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#pragma once
-
-#include <SDL2/SDL_ttf.h>
-#include <functional>
-#include <memory>
-
-#include "Asset.h"
-
-namespace crepe {
-
-class SDLContext;
-
-/**
- * \class Font
- * \brief Manages font loading and text rendering properties.
- *
- * The Font class is responsible for loading font resources and providing a way to render text
- * with different styles and sizes. It can be used for text rendering in the game engine.
- */
-class Font {
-
-public:
- /**
- * \brief Constructs a Font from an Asset resource.
- * \param src Asset with font data to load.
- * \param size The point size to render the font at.
- */
- Font(const Asset &src, int size);
-
- /**
- * \brief Destroys the Font instance, freeing associated resources.
- */
- ~Font();
-
- /**
- * \brief Gets the size of the font.
- * \return The point size of the font.
- */
- int get_size() const;
-
-private:
- /**
- * \brief Loads the font from an Asset resource.
- * \param res The Asset resource containing the font data.
- * \param size The point size to render the font at.
- */
- void load(const Asset &res, int size);
-
-private:
- //! The font resource from the SDL_ttf library.
- std::unique_ptr<TTF_Font, std::function<void(TTF_Font *)>> font;
-
- //! The size of the font in points.
- int font_size;
-
- //! Grants SDLContext access to private members.
- friend class SDLContext;
-};
-
-} // namespace crepe
diff --git a/src/crepe/api/Text.h b/src/crepe/api/Text.h
deleted file mode 100644
index 6bb011c..0000000
--- a/src/crepe/api/Text.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#pragma once
-
-#include <string>
-
-#include "Color.h"
-#include "UiObject.h"
-#include ""
-namespace crepe {
-
-/**
- * \class Button
- * \brief Represents a clickable UI button, derived from the UiObject class.
- *
- * This class provides functionality for a button in the UI, including toggle state,
- * click handling, and mouse hover detection. A callback function can be provided to
- * handle button clicks.
- */
-class Text : public UiObject {
-public:
- /**
- * \brief Constructs a Button with the specified game object ID and dimensions.
- *
- * \param id The unique ID of the game object associated with this button.
- * \param width The width of the button.
- * \param height The height of the button.
- */
- Text(game_object_id_t id, int width, int height);
-
- Color color = Color{0,0,0,0};
- std::string text = "";
- int size = 0;
- const std::shared_ptr<Font> sprite_image;
-public:
- /**
- * \brief Retrieves the maximum number of instances allowed for this button type.
- *
- * \return Always returns 1, as only a single instance of this type is allowed.
- */
- virtual int get_instances_max() const override { return 10; }
-};
-
-} // namespace crepe