1
0
Fork 0
mirror of https://github.com/ctruLua/ctruLua.git synced 2025-10-27 16:39:29 +00:00

Updated font and fs lib; updated editor; updated sf2dlib

Libs additions: font.load, font:unload, font:getWidth, fs.getDirectory, fs.setDirectory, fs.exists

Editor additions: syntaxic coloring and mono font

sf2dlib update: you will need the latest version of ctrulib.

Also, because of the lib font needs, the sftdlib was modified.
This commit is contained in:
Reuh 2015-09-05 19:00:36 +02:00
parent 3f995629c0
commit 45f3216ed8
14 changed files with 382 additions and 28 deletions

View file

@ -8,6 +8,8 @@
#include <lua.h>
#include <lauxlib.h>
#include "font.h"
bool isGfxInitialised = false;
void load_color_lib(lua_State *L);
@ -18,7 +20,6 @@ void load_map_lib(lua_State *L);
void unload_font_lib(lua_State *L);
u32 color_default;
sftd_font *font_default;
static int gfx_startFrame(lua_State *L) {
u8 screen = luaL_checkinteger(L, 1);
@ -124,14 +125,20 @@ static int gfx_text(lua_State *L) {
int size = luaL_optinteger(L, 4, 9);
u32 color = luaL_optinteger(L, 5, color_default);
// todo : font selection
font_userdata *font = luaL_testudata(L, 6, "LFont");
if (font == NULL) {
lua_getfield(L, LUA_REGISTRYINDEX, "LFontDefault");
font = luaL_testudata(L, -1, "LFont");
if (font == NULL) luaL_error(L, "No default font set and no font object passed");
}
if (font->font == NULL) luaL_error(L, "The font object was unloaded");
// 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);
sftd_draw_wtext(font->font, x, y, color, size, wtext);
return 0;
}