From 9dd3fa10cee52913cb0093b2fe7a0faa31e1c17a Mon Sep 17 00:00:00 2001 From: jussi Date: Sat, 11 Jun 2022 22:13:59 +0300 Subject: Rest of the core misc functions. --- API.md | 27 ++++++++++++++++++++++++++ devnotes | 1 - include/core.h | 3 +++ src/core.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lua_core.c | 3 +++ 5 files changed, 93 insertions(+), 1 deletion(-) diff --git a/API.md b/API.md index de2cde3..3f785e9 100644 --- a/API.md +++ b/API.md @@ -1355,6 +1355,24 @@ Get elapsed time in seconds since InitWindow() --- +> success = RL_TakeScreenshot( string fileName ) + +Takes a screenshot of current screen ( filename extension defines format ) + +- Failure return false +- Success return true + +--- + +> success = RL_SetConfigFlags( int flags ) + +Setup init configuration flags ( view FLAGS ) + +- Failure return false +- Success return true + +--- + > success = RL_TraceLog( int logLevel, string text ) Show trace log messages ( LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR... ) @@ -1364,6 +1382,15 @@ Show trace log messages ( LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR... ) --- +> success = RL_SetTraceLogLevel( int logLevel ) + +Set the current threshold ( minimum ) log level + +- Failure return false +- Success return true + +--- + > success = RL_OpenURL( string url ) Open URL with default system browser ( If available ) diff --git a/devnotes b/devnotes index 6bd9277..9ed6bd2 100644 --- a/devnotes +++ b/devnotes @@ -6,6 +6,5 @@ Backlog { * Codepoints * String management. At least TextSplit. - * Physac? * VR? } diff --git a/include/core.h b/include/core.h index e433ae8..7f1be5e 100644 --- a/include/core.h +++ b/include/core.h @@ -38,7 +38,10 @@ int lcoreSetTargetFPS( lua_State *L ); int lcoreGetFrameTime( lua_State *L ); int lcoreGetTime( lua_State *L ); /* Misc. */ +int lcoreTakeScreenshot( lua_State *L ); +int lcoreSetConfigFlags( lua_State *L ); int lcoreTraceLog( lua_State *L ); +int lcoreSetTraceLogLevel( lua_State *L ); int lcoreOpenURL( lua_State *L ); /* Cursor. */ int lcoreShowCursor( lua_State *L ); diff --git a/src/core.c b/src/core.c index 8ecb47b..9999247 100644 --- a/src/core.c +++ b/src/core.c @@ -617,6 +617,46 @@ int lcoreGetTime( lua_State *L ) { ## Core - Misc */ +/* +> success = RL_TakeScreenshot( string fileName ) + +Takes a screenshot of current screen ( filename extension defines format ) + +- Failure return false +- Success return true +*/ +int lcoreTakeScreenshot( lua_State *L ) { + if ( !lua_isstring( L, -1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_TakeScreenshot( string fileName )" ); + lua_pushboolean( L, false ); + return 1; + } + TakeScreenshot( lua_tostring( L, -1 ) ); + lua_pushboolean( L, true ); + + return 1; +} + +/* +> success = RL_SetConfigFlags( int flags ) + +Setup init configuration flags ( view FLAGS ) + +- Failure return false +- Success return true +*/ +int lcoreSetConfigFlags( lua_State *L ) { + if ( !lua_isnumber( L, -1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_SetConfigFlags( int flags )" ); + lua_pushboolean( L, false ); + return 1; + } + SetConfigFlags( lua_tointeger( L, -1 ) ); + lua_pushboolean( L, true ); + + return 1; +} + /* > success = RL_TraceLog( int logLevel, string text ) @@ -637,6 +677,26 @@ int lcoreTraceLog( lua_State *L ) { return 1; } +/* +> success = RL_SetTraceLogLevel( int logLevel ) + +Set the current threshold ( minimum ) log level + +- Failure return false +- Success return true +*/ +int lcoreSetTraceLogLevel( lua_State *L ) { + if ( !lua_isnumber( L, -1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_SetTraceLogLevel( int logLevel )" ); + lua_pushboolean( L, false ); + return 1; + } + SetTraceLogLevel( lua_tointeger( L, -1 ) ); + lua_pushboolean( L, true ); + + return 1; +} + /* > success = RL_OpenURL( string url ) diff --git a/src/lua_core.c b/src/lua_core.c index 3739496..90a7c18 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -688,7 +688,10 @@ void luaRegister() { lua_register( L, "RL_GetFrameTime", lcoreGetFrameTime ); lua_register( L, "RL_GetTime", lcoreGetTime ); /* Misc. */ + lua_register( L, "RL_TakeScreenshot", lcoreTakeScreenshot ); + lua_register( L, "RL_SetConfigFlags", lcoreSetConfigFlags ); lua_register( L, "RL_TraceLog", lcoreTraceLog ); + lua_register( L, "RL_SetTraceLogLevel", lcoreSetTraceLogLevel ); lua_register( L, "RL_OpenURL", lcoreOpenURL ); /* Cursor. */ lua_register( L, "RL_ShowCursor", lcoreShowCursor ); -- cgit v1.2.3