Support loading bitmap fonts from an asset pack
This commit is contained in:
1 parent
ab18f92fe5
commit
c5dd826c66
4 files changed
+20
-8
No files matched your search
+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);
|
||||
|
||||
+11
-3
@@ -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,
|
||||
u64 tile_height) {
|
||||
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