aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/Asset.h2
-rw-r--r--src/crepe/api/LoopManager.h7
-rw-r--r--src/crepe/api/Script.h5
-rw-r--r--src/crepe/api/Text.cpp8
-rw-r--r--src/crepe/api/Text.h15
5 files changed, 23 insertions, 14 deletions
diff --git a/src/crepe/api/Asset.h b/src/crepe/api/Asset.h
index bfd0ac7..b367a92 100644
--- a/src/crepe/api/Asset.h
+++ b/src/crepe/api/Asset.h
@@ -37,7 +37,7 @@ public:
private:
//! path to asset
- const std::string src;
+ std::string src;
private:
/**
diff --git a/src/crepe/api/LoopManager.h b/src/crepe/api/LoopManager.h
index 40e6b38..1725810 100644
--- a/src/crepe/api/LoopManager.h
+++ b/src/crepe/api/LoopManager.h
@@ -71,7 +71,9 @@ private:
private:
//! Global context
Mediator mediator;
-
+
+ //! SDLContext instance
+ SDLContext sdl_context{mediator};
//! Component manager instance
ComponentManager component_manager{mediator};
//! Scene manager instance
@@ -84,8 +86,7 @@ private:
ResourceManager resource_manager{mediator};
//! Save manager instance
SaveManager save_manager{mediator};
- //! SDLContext instance
- SDLContext sdl_context{mediator};
+
private:
/**
diff --git a/src/crepe/api/Script.h b/src/crepe/api/Script.h
index a24e32e..4503525 100644
--- a/src/crepe/api/Script.h
+++ b/src/crepe/api/Script.h
@@ -156,7 +156,7 @@ private:
void subscribe_internal(const EventHandler<EventType> & callback, event_channel_t channel);
protected:
- OptionalRef<Mediator> mediator;
+
// NOTE: This must be the only constructor on Script, see "Late references" below
Script() = default;
//! Only \c BehaviorScript instantiates Script
@@ -186,12 +186,13 @@ private:
*
* \{
*/
+
//! Game object ID of game object parent BehaviorScript is attached to
game_object_id_t game_object_id;
//! Reference to parent component
OptionalRef<bool> active;
//! Mediator reference
-
+ OptionalRef<Mediator> mediator;
//! \}
private:
diff --git a/src/crepe/api/Text.cpp b/src/crepe/api/Text.cpp
index 07d1705..1620247 100644
--- a/src/crepe/api/Text.cpp
+++ b/src/crepe/api/Text.cpp
@@ -5,11 +5,11 @@
using namespace crepe;
-Text::Text(game_object_id_t id, const vec2 & dimensions, const vec2 & offset,
- const std::string & text, const std::string & font_family, const Data & data)
+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, std::optional<Asset> font)
: UIObject(id, dimensions, offset),
text(text),
data(data),
- font(FontFacade::get_font_asset(font_family)) {
- dbg_trace();
+ font_family(font_family),
+ font(font) {
}
diff --git a/src/crepe/api/Text.h b/src/crepe/api/Text.h
index ec0bf74..ab72bc0 100644
--- a/src/crepe/api/Text.h
+++ b/src/crepe/api/Text.h
@@ -1,6 +1,7 @@
#pragma once
#include <string>
+#include <optional>
#include "../Component.h"
@@ -47,15 +48,21 @@ public:
* \param text The text to be displayed.
* \param font_family The font style name to be displayed.
* \param data Data struct containing extra text parameters.
+ * \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 & text, const std::string & font_family, const Data & data);
+ Text(game_object_id_t id, const vec2 & dimensions, const vec2 & offset,
+ const std::string & font_family, const Data & data,
+ const std::string & text = "", std::optional<Asset> font = std::nullopt);
+
//! Label text.
std::string text = "";
- //! Font asset variable
- const Asset font;
+ //! font family name
+ std::string font_family = "";
+ //! Font asset variable if this is not set, it will use the font_family to create an asset.
+ std::optional<Asset> font;
//! Data instance
Data data;
+
};
} // namespace crepe