aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic-extension/singletons/AssetManager.hpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-08-30 23:29:57 +0200
committer GitHub <noreply@github.com>2024-08-30 23:29:57 +0200
commitf54e454afb90f8868e7c62529e2a388fdaadf20b (patch)
treef19dbcdfe613397e86dc52cc34e0a443bd0f3e96 /extension/src/openvic-extension/singletons/AssetManager.hpp
parent855e5b087459da19caf230cf22d99462680b268e (diff)
parentd7672f406406eea46625bc725690651f28211e19 (diff)
Merge pull request #251 from OpenVicProject/gui-text-label
Add GUILabel (colour code + currency icon support)
Diffstat (limited to 'extension/src/openvic-extension/singletons/AssetManager.hpp')
-rw-r--r--extension/src/openvic-extension/singletons/AssetManager.hpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/extension/src/openvic-extension/singletons/AssetManager.hpp b/extension/src/openvic-extension/singletons/AssetManager.hpp
index 0856d05..deca309 100644
--- a/extension/src/openvic-extension/singletons/AssetManager.hpp
+++ b/extension/src/openvic-extension/singletons/AssetManager.hpp
@@ -1,12 +1,14 @@
#pragma once
#include <godot_cpp/classes/atlas_texture.hpp>
-#include <godot_cpp/classes/font.hpp>
+#include <godot_cpp/classes/font_file.hpp>
#include <godot_cpp/classes/image_texture.hpp>
#include <godot_cpp/core/class_db.hpp>
#include <openvic-simulation/interface/GFXSprite.hpp>
+#include "openvic-extension/classes/GFXSpriteTexture.hpp"
+
namespace OpenVic {
class AssetManager : public godot::Object {
GDCLASS(AssetManager, godot::Object)
@@ -32,7 +34,7 @@ namespace OpenVic {
};
/* deque_ordered_map to avoid the need to reallocate. */
using image_asset_map_t = deque_ordered_map<godot::StringName, image_asset_t>;
- using font_map_t = deque_ordered_map<godot::StringName, godot::Ref<godot::Font>>;
+ using font_map_t = deque_ordered_map<godot::StringName, godot::Ref<godot::FontFile>>;
image_asset_map_t image_assets;
font_map_t fonts;
@@ -68,7 +70,18 @@ namespace OpenVic {
/* Search for and load a font with the specified name from the game defines' font directory, first checking the
* AssetManager's font cache in case it has already been loaded, and returning nullptr if font loading fails. */
- godot::Ref<godot::Font> get_font(godot::StringName const& name);
+ godot::Ref<godot::FontFile> get_font(godot::StringName const& name);
+
+ private:
+ godot::Ref<GFXSpriteTexture> PROPERTY(currency_texture_big); // 32x32
+ godot::Ref<GFXSpriteTexture> PROPERTY(currency_texture_medium); // 24x24
+ godot::Ref<GFXSpriteTexture> PROPERTY(currency_texture_small); // 16x16
+
+ public:
+ godot::Error preload_textures();
+
+ /* Get the largest currency texture with height less than the specified font height. */
+ godot::Ref<GFXSpriteTexture> const& get_currency_texture(real_t height) const;
};
}