mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-27 16:39:29 +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
12
source/gfx.c
12
source/gfx.c
|
|
@ -1,3 +1,5 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include <sf2d.h>
|
||||
#include <sftd.h>
|
||||
|
||||
|
|
@ -105,13 +107,19 @@ static int gfx_circle(lua_State *L) {
|
|||
static int gfx_text(lua_State *L) {
|
||||
int x = luaL_checkinteger(L, 1);
|
||||
int y = luaL_checkinteger(L, 2);
|
||||
const char *text = luaL_checkstring(L, 3);
|
||||
size_t len;
|
||||
const char *text = luaL_checklstring(L, 3, &len);
|
||||
|
||||
int size = luaL_optinteger(L, 4, 9);
|
||||
u32 color = luaL_optinteger(L, 5, color_default);
|
||||
// todo : font selection
|
||||
|
||||
sftd_draw_text(font_default, x, y, color, size, text);
|
||||
// Wide caracters support. (wchar = UTF32 on 3DS.)
|
||||
wchar_t wtext[len];
|
||||
len = mbstowcs(wtext, text, len);
|
||||
*(wtext+len) = 0x0; // text end
|
||||
|
||||
sftd_draw_wtext(font_default, x, y, color, size, wtext);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue