mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-28 00:39:30 +00:00
Support for special characters in gfx.text; added scrolling to the default shell; updated sftdlib.
There is a known bug with different text size in sftdlib.
This commit is contained in:
parent
56b47153b7
commit
2a5513473d
10 changed files with 516 additions and 39 deletions
36
libs/sftdlib/libsftd/include/bin_packing_2d.h
Normal file
36
libs/sftdlib/libsftd/include/bin_packing_2d.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#ifndef BIN_PACKING_2D_H
|
||||
#define BIN_PACKING_2D_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct bp2d_position {
|
||||
int x, y;
|
||||
} bp2d_position;
|
||||
|
||||
typedef struct bp2d_size {
|
||||
int w, h;
|
||||
} bp2d_size;
|
||||
|
||||
typedef struct bp2d_rectangle {
|
||||
int x, y, w, h;
|
||||
} bp2d_rectangle;
|
||||
|
||||
typedef struct bp2d_node {
|
||||
struct bp2d_node *left;
|
||||
struct bp2d_node *right;
|
||||
bp2d_rectangle rect;
|
||||
int filled;
|
||||
} bp2d_node;
|
||||
|
||||
bp2d_node *bp2d_create(const bp2d_rectangle *rect);
|
||||
void bp2d_free(bp2d_node *node);
|
||||
// 1 success, 0 failure
|
||||
int bp2d_insert(bp2d_node *node, const bp2d_size *in_size, bp2d_position *out_pos);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
34
libs/sftdlib/libsftd/include/int_htab.h
Normal file
34
libs/sftdlib/libsftd/include/int_htab.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef INT_HTAB_H
|
||||
#define INT_HTAB_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INT_HTAB_MAX_LOAD (70) // over 100
|
||||
|
||||
typedef struct int_htab_entry {
|
||||
unsigned int key;
|
||||
void *value;
|
||||
} int_htab_entry;
|
||||
|
||||
typedef struct int_htab {
|
||||
size_t size;
|
||||
size_t used;
|
||||
int_htab_entry *entries;
|
||||
} int_htab;
|
||||
|
||||
int_htab *int_htab_create(size_t size);
|
||||
void int_htab_free(int_htab *htab);
|
||||
int int_htab_insert(int_htab *htab, unsigned int key, void *value);
|
||||
void *int_htab_find(const int_htab *htab, unsigned int key);
|
||||
int int_htab_erase(const int_htab *htab, unsigned int key);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
36
libs/sftdlib/libsftd/include/texture_atlas.h
Normal file
36
libs/sftdlib/libsftd/include/texture_atlas.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#ifndef TEXTURE_ATLAS_H
|
||||
#define TEXTURE_ATLAS_H
|
||||
|
||||
#include "sf2d.h"
|
||||
#include "bin_packing_2d.h"
|
||||
#include "int_htab.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct atlas_htab_entry {
|
||||
bp2d_rectangle rect;
|
||||
int bitmap_left;
|
||||
int bitmap_top;
|
||||
int advance_x;
|
||||
int advance_y;
|
||||
} atlas_htab_entry;
|
||||
|
||||
typedef struct texture_atlas {
|
||||
sf2d_texture *tex;
|
||||
bp2d_node *bp_root;
|
||||
int_htab *htab;
|
||||
} texture_atlas;
|
||||
|
||||
texture_atlas *texture_atlas_create(int width, int height, sf2d_texfmt format, sf2d_place place);
|
||||
void texture_atlas_free(texture_atlas *atlas);
|
||||
int texture_atlas_insert(texture_atlas *atlas, unsigned int character, const void *image, int width, int height, int bitmap_left, int bitmap_top, int advance_x, int advance_y);
|
||||
int texture_atlas_exists(texture_atlas *atlas, unsigned int character);
|
||||
void texture_atlas_get(texture_atlas *atlas, unsigned int character, bp2d_rectangle *rect, int *bitmap_left, int *bitmap_top, int *advance_x, int *advance_y);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue