diff options
| author | Indrajith K L | 2025-11-03 19:24:01 +0530 |
|---|---|---|
| committer | GitHub | 2025-11-03 19:24:01 +0530 |
| commit | 02d6be119fa130121a04799e81aff203472b6233 (patch) | |
| tree | db72095f2edac8344264ca22bda0b252f267040a /src/core.c | |
| parent | 929076b5766e0b9c5d8bfec3967a71e15a078bc9 (diff) | |
| parent | e51adde3efcd731d80f8ad8025d70db60554cadb (diff) | |
| download | reilua-enhanced-02d6be119fa130121a04799e81aff203472b6233.tar.gz reilua-enhanced-02d6be119fa130121a04799e81aff203472b6233.tar.bz2 reilua-enhanced-02d6be119fa130121a04799e81aff203472b6233.zip | |
Merge pull request #1 from cooljith91112/embedded-assets-support
Added asset embedding support + docs cleanup
Diffstat (limited to 'src/core.c')
| -rw-r--r-- | src/core.c | 61 |
1 files changed, 61 insertions, 0 deletions
@@ -4,6 +4,14 @@ #include "textures.h" #include "lua_core.h" +/* Forward declarations from lua_core.c for asset loading */ +extern int g_totalAssets; +extern int g_loadedAssets; +extern char g_currentAssetName[256]; +extern bool g_showLoadingScreen; +extern float g_loadingProgress; +extern void drawLoadingScreen(); + static size_t getBufferElementSize( Buffer* buffer ) { switch ( buffer->type ) { case BUFFER_UNSIGNED_CHAR: return sizeof( unsigned char ); @@ -1956,6 +1964,59 @@ int lcoreGetApplicationDirectory( lua_State* L ) { } /* +> RL.BeginAssetLoading( int totalAssets ) + +Initialize asset loading progress tracking + +- totalAssets: Total number of assets to load +*/ +int lcoreBeginAssetLoading( lua_State* L ) { + g_totalAssets = luaL_checkinteger( L, 1 ); + g_loadedAssets = 0; + g_showLoadingScreen = true; + g_loadingProgress = 0.0f; + g_currentAssetName[0] = '\0'; + + return 0; +} + +/* +> RL.UpdateAssetLoading( string assetName ) + +Update loading progress for current asset + +- assetName: Name of the asset currently being loaded +*/ +int lcoreUpdateAssetLoading( lua_State* L ) { + const char* assetName = luaL_checkstring( L, 1 ); + strncpy( g_currentAssetName, assetName, sizeof(g_currentAssetName) - 1 ); + g_currentAssetName[sizeof(g_currentAssetName) - 1] = '\0'; + + g_loadedAssets++; + g_loadingProgress = (float)g_loadedAssets / (float)g_totalAssets; + + if ( g_showLoadingScreen ) { + drawLoadingScreen(); + } + + return 0; +} + +/* +> RL.EndAssetLoading() + +Finish asset loading and hide loading screen +*/ +int lcoreEndAssetLoading( lua_State* L ) { + g_showLoadingScreen = false; + g_totalAssets = 0; + g_loadedAssets = 0; + g_currentAssetName[0] = '\0'; + + return 0; +} + +/* > success = RL.MakeDirectory( string dirPath ) Create directories (including full path requested), returns 0 on success |
