GuiGetIcons fix and added GuiSetIcons.
This commit is contained in:
15
API.md
15
API.md
@@ -9414,11 +9414,20 @@ Set icon scale (1 by default)
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
> icons = RL.GuiGetIcons()
|
> iconsBuffer = RL.GuiGetIcons()
|
||||||
|
|
||||||
Get raygui icons data pointer
|
Get raygui icons data in buffer. guiIcons size is by default: 256*(16*16/32) = 2048*4 = 8192 bytes = 8 KB
|
||||||
|
|
||||||
- Success return int
|
- Success return Buffer
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> success = RL.GuiSetIcons( Buffer iconBuffer )
|
||||||
|
|
||||||
|
Set raygui icons data in buffer. guiIcons size is by default: 256*(16*16/32) = 2048*4 = 8192 bytes = 8 KB
|
||||||
|
|
||||||
|
- Failure return false
|
||||||
|
- Success return true
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -6328,11 +6328,18 @@ function RL.GuiIconText( iconId, text ) end
|
|||||||
---@return any RL.GuiSetIconScale
|
---@return any RL.GuiSetIconScale
|
||||||
function RL.GuiSetIconScale( scale ) end
|
function RL.GuiSetIconScale( scale ) end
|
||||||
|
|
||||||
---Get raygui icons data pointer
|
---Get raygui icons data in buffer. guiIcons size is by default: 256*(16*16/32) = 2048*4 = 8192 bytes = 8 KB
|
||||||
---- Success return int
|
---- Success return Buffer
|
||||||
---@return any icons
|
---@return any iconsBuffer
|
||||||
function RL.GuiGetIcons() end
|
function RL.GuiGetIcons() end
|
||||||
|
|
||||||
|
---Set raygui icons data in buffer. guiIcons size is by default: 256*(16*16/32) = 2048*4 = 8192 bytes = 8 KB
|
||||||
|
---- Failure return false
|
||||||
|
---- Success return true
|
||||||
|
---@param iconBuffer any
|
||||||
|
---@return any success
|
||||||
|
function RL.GuiSetIcons( iconBuffer ) end
|
||||||
|
|
||||||
---Load raygui icons file (.rgi) into internal icons data
|
---Load raygui icons file (.rgi) into internal icons data
|
||||||
---- Failure return nil
|
---- Failure return nil
|
||||||
---- Success return strings{}
|
---- Success return strings{}
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ DETAILED CHANGES:
|
|||||||
- REMOVED: DrawTextBoxedTinted. DrawTextBoxedEx can do same much more efficiently.
|
- REMOVED: DrawTextBoxedTinted. DrawTextBoxedEx can do same much more efficiently.
|
||||||
- ADDED: DrawTextBoxedEx.
|
- ADDED: DrawTextBoxedEx.
|
||||||
- CHANGE: Naming of gui functions set2Top and set2Back to setToTop and setToBack.
|
- CHANGE: Naming of gui functions set2Top and set2Back to setToTop and setToBack.
|
||||||
|
- FIXED: GuiGetIcons was returning just first int. Now returns a Buffer.
|
||||||
|
- ADDED: GuiSetIcons.
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0
|
Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ int lguiGuiSetTooltip( lua_State* L );
|
|||||||
int lguiGuiIconText( lua_State* L );
|
int lguiGuiIconText( lua_State* L );
|
||||||
int lguiGuiSetIconScale( lua_State* L );
|
int lguiGuiSetIconScale( lua_State* L );
|
||||||
int lguiGuiGetIcons( lua_State* L );
|
int lguiGuiGetIcons( lua_State* L );
|
||||||
|
int lguiGuiSetIcons( lua_State* L );
|
||||||
int lguiGuiLoadIcons( lua_State* L );
|
int lguiGuiLoadIcons( lua_State* L );
|
||||||
int lguiGuiDrawIcon( lua_State* L );
|
int lguiGuiDrawIcon( lua_State* L );
|
||||||
/* Container/separator controls, useful for controls organization. */
|
/* Container/separator controls, useful for controls organization. */
|
||||||
|
|||||||
@@ -2082,6 +2082,7 @@ void luaRegister() {
|
|||||||
assingGlobalFunction( "GuiIconText", lguiGuiIconText );
|
assingGlobalFunction( "GuiIconText", lguiGuiIconText );
|
||||||
assingGlobalFunction( "GuiSetIconScale", lguiGuiSetIconScale );
|
assingGlobalFunction( "GuiSetIconScale", lguiGuiSetIconScale );
|
||||||
assingGlobalFunction( "GuiGetIcons", lguiGuiGetIcons );
|
assingGlobalFunction( "GuiGetIcons", lguiGuiGetIcons );
|
||||||
|
assingGlobalFunction( "GuiSetIcons", lguiGuiSetIcons );
|
||||||
assingGlobalFunction( "GuiLoadIcons", lguiGuiLoadIcons );
|
assingGlobalFunction( "GuiLoadIcons", lguiGuiLoadIcons );
|
||||||
assingGlobalFunction( "GuiDrawIcon", lguiGuiDrawIcon );
|
assingGlobalFunction( "GuiDrawIcon", lguiGuiDrawIcon );
|
||||||
/* Container/separator controls, useful for controls organization. */
|
/* Container/separator controls, useful for controls organization. */
|
||||||
|
|||||||
43
src/rgui.c
43
src/rgui.c
@@ -2,6 +2,7 @@
|
|||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "rgui.h"
|
#include "rgui.h"
|
||||||
#include "lua_core.h"
|
#include "lua_core.h"
|
||||||
|
#include "rmath.h"
|
||||||
|
|
||||||
#define RAYGUI_IMPLEMENTATION
|
#define RAYGUI_IMPLEMENTATION
|
||||||
#include "raygui.h"
|
#include "raygui.h"
|
||||||
@@ -286,14 +287,48 @@ int lguiGuiSetIconScale( lua_State* L ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
> icons = RL.GuiGetIcons()
|
> iconsBuffer = RL.GuiGetIcons()
|
||||||
|
|
||||||
Get raygui icons data pointer
|
Get raygui icons data in buffer. guiIcons size is by default: 256*(16*16/32) = 2048*4 = 8192 bytes = 8 KB
|
||||||
|
|
||||||
- Success return int
|
- Success return Buffer
|
||||||
*/
|
*/
|
||||||
int lguiGuiGetIcons( lua_State* L ) {
|
int lguiGuiGetIcons( lua_State* L ) {
|
||||||
lua_pushinteger( L, *GuiGetIcons() );
|
const unsigned int dataSize = RAYGUI_ICON_MAX_ICONS * RAYGUI_ICON_DATA_ELEMENTS * sizeof( unsigned int );
|
||||||
|
|
||||||
|
Buffer buffer = {
|
||||||
|
.type = BUFFER_UNSIGNED_INT,
|
||||||
|
.size = dataSize * sizeof( unsigned int ),
|
||||||
|
.data = malloc( dataSize * sizeof( unsigned int ) )
|
||||||
|
};
|
||||||
|
memcpy( buffer.data, GuiGetIcons(), dataSize );
|
||||||
|
|
||||||
|
uluaPushBuffer( L, buffer );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> success = RL.GuiSetIcons( Buffer iconBuffer )
|
||||||
|
|
||||||
|
Set raygui icons data in buffer. guiIcons size is by default: 256*(16*16/32) = 2048*4 = 8192 bytes = 8 KB
|
||||||
|
|
||||||
|
- Failure return false
|
||||||
|
- Success return true
|
||||||
|
*/
|
||||||
|
int lguiGuiSetIcons( lua_State* L ) {
|
||||||
|
Buffer* buffer = uluaGetBuffer( L, 1 );
|
||||||
|
|
||||||
|
if ( buffer->type != BUFFER_UNSIGNED_INT ) {
|
||||||
|
TraceLog( state->logLevelInvalid, "Buffer type must be BUFFER_UNSIGNED_INT" );
|
||||||
|
lua_pushboolean( L, false );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
const unsigned int dataSize = RAYGUI_ICON_MAX_ICONS * RAYGUI_ICON_DATA_ELEMENTS * sizeof( unsigned int );
|
||||||
|
memcpy( GuiGetIcons(), buffer->data, imin( dataSize, buffer->size ) );
|
||||||
|
|
||||||
|
lua_pushboolean( L, true );
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
#include "rmath.h"
|
#include "rmath.h"
|
||||||
#include "lua_core.h"
|
#include "lua_core.h"
|
||||||
|
|
||||||
inline int imin( int a, int b ) {
|
int imin( int a, int b ) {
|
||||||
return a < b ? a : b;
|
return a < b ? a : b;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int imax( int a, int b ) {
|
int imax( int a, int b ) {
|
||||||
return a > b ? a : b;
|
return a > b ? a : b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user