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

Added the ctr.apt library, tweaked ctr.news a bit, fixed a typo in cfgu.c

This commit is contained in:
Firew0lf 2015-12-24 18:44:22 +01:00
parent 2e782ed9ea
commit 5c4da69997
4 changed files with 362 additions and 7 deletions

View file

@ -26,13 +26,13 @@ static int news_init(lua_State *L) {
Send a notification to the user. WIP, do not use !!!
@function notification
@tparam string title title of the notification
@tparam string message message of the notification
@tparam string imageData data from a JPEG image (content of a file) or raw data
@tparam[OPT=false] boolean jpeg set to `true` if the data is from a JPEG file
@tparam[opt=nil] string message message of the notification, or nil for no message
@tparam[opt=nil] string imageData data from a JPEG image (content of a file) or raw data, or nil for no image
@tparam[opt=false] boolean jpeg set to `true` if the data is from a JPEG file
*/
static int news_notification(lua_State *L) {
const char *title = luaL_checkstring(L, 1);
const char *message = luaL_checkstring(L, 2);
const char *message = luaL_optstring(L, 2, NULL);
u32 imageDataLength = 0;
const void *imageData = luaL_optlstring(L, 3, NULL, (size_t*)&imageDataLength);
@ -45,7 +45,12 @@ static int news_notification(lua_State *L) {
u32 titleLength, messageLength;
titleLength = (u32) utf8_to_utf16((uint16_t*)cTitle, (uint8_t*)title, strlen(title));
messageLength = (u32) utf8_to_utf16((uint16_t*)cMessage, (uint8_t*)message, strlen(message));
if (message != NULL) {
messageLength = (u32) utf8_to_utf16((uint16_t*)cMessage, (uint8_t*)message, strlen(message));
} else {
messageLength = 0;
cMessage = NULL;
}
NEWS_AddNotification(cTitle, titleLength, cMessage, messageLength, imageData, imageDataLength, jpeg);