Support loading bitmap fonts from an asset pack
This commit is contained in:
1 parent
ab18f92fe5
commit
c5dd826c66
4 files changed
+18
-6
No files matched your search
@@ -6,6 +6,7 @@
|
||||
#include "AssetManager.h"
|
||||
#include "Renderer.h"
|
||||
#include "SDL_pixels.h"
|
||||
#include "pak.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -15,7 +16,7 @@ typedef struct bitmap_font BitmapFont;
|
||||
|
||||
BitmapFont *create_bitmap_font(AssetManager *am, const Renderer *renderer,
|
||||
const char *filepath, u64 tile_width,
|
||||
u64 tile_height);
|
||||
u64 tile_height, asset_pack_t *pack);
|
||||
|
||||
TextSize get_text_size_from_bitmap_font(BitmapFont *font, u64 font_size,
|
||||
const char *text);
|
||||
|
||||
@@ -52,8 +52,10 @@ AssetID load_asset_from_pack(asset_pack_t *pack, const char *filename,
|
||||
void unload_asset(AssetID *id);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
BitmapFont *load_bitmap_font(const char *filepath, u64 tile_width,
|
||||
BitmapFont *load_bitmap_font_from_file(const char *filepath, u64 tile_width,
|
||||
u64 tile_height);
|
||||
BitmapFont *load_bitmap_font_from_pack(const char *filepath, u64 tile_width,
|
||||
u64 tile_height, asset_pack_t *pack);
|
||||
void unload_bitmap_font(BitmapFont **font);
|
||||
#endif // __ANDROID__
|
||||
// END ASSET MANAGEMENT API
|
||||
|
||||
+3
-2
@@ -5,6 +5,7 @@
|
||||
#include "Renderer.h"
|
||||
#include "SDL_render.h"
|
||||
#include "aliases.h"
|
||||
#include "pak.h"
|
||||
#include "reusable_ids.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -23,14 +24,14 @@ RenderRect get_character_sprite(BitmapFont *font, u64 index);
|
||||
|
||||
BitmapFont *create_bitmap_font(AssetManager *am, const Renderer *renderer,
|
||||
const char *filepath, u64 tile_width,
|
||||
u64 tile_height) {
|
||||
u64 tile_height, asset_pack_t *pack) {
|
||||
BitmapFont *font = (BitmapFont *)malloc(sizeof(BitmapFont));
|
||||
if (!font) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
font->font_atlas =
|
||||
load_asset_to_manager(am, filepath, ASSET_TYPE_IMAGE, renderer);
|
||||
load_asset_to_manager(am, filepath, ASSET_TYPE_IMAGE, renderer, pack);
|
||||
|
||||
if (font->font_atlas == INVALID_ID) {
|
||||
destroy_bitmap_font(am, &font);
|
||||
|
||||
+10
-2
@@ -22,6 +22,7 @@
|
||||
#include "Window.h"
|
||||
#include "aliases.h"
|
||||
#include "constants.h"
|
||||
#include "pak.h"
|
||||
#include "reusable_ids.h"
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
@@ -237,11 +238,18 @@ void unload_asset(AssetID *id) {
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
BitmapFont *load_bitmap_font(const char *filepath, u64 tile_width,
|
||||
BitmapFont *load_bitmap_font_from_file(const char *filepath, u64 tile_width,
|
||||
u64 tile_height) {
|
||||
return create_bitmap_font(GameEngine.asset_manager,
|
||||
GameEngine.window.renderer, filepath, tile_width,
|
||||
tile_height);
|
||||
tile_height, NULL);
|
||||
}
|
||||
|
||||
BitmapFont *load_bitmap_font_from_pack(const char *filepath, u64 tile_width,
|
||||
u64 tile_height, asset_pack_t *pack) {
|
||||
return create_bitmap_font(GameEngine.asset_manager,
|
||||
GameEngine.window.renderer, filepath, tile_width,
|
||||
tile_height, pack);
|
||||
}
|
||||
|
||||
void unload_bitmap_font(BitmapFont **font) {
|
||||
|
||||
Reference in new issue
Block a user