GuiIconText.
This commit is contained in:
9
API.md
9
API.md
@@ -3882,6 +3882,15 @@ Color Bar Hue control
|
||||
|
||||
---
|
||||
|
||||
> text = RL_GuiIconText( int iconId, string text )
|
||||
|
||||
Get text with icon id prepended ( if supported )
|
||||
|
||||
- Failure return false
|
||||
- Success return string
|
||||
|
||||
---
|
||||
|
||||
> success = RL_GuiDrawIcon( int iconId, Vector2 pos, int pixelSize, Color color )
|
||||
|
||||
Draw icon
|
||||
|
||||
@@ -37,7 +37,8 @@ end
|
||||
function draw()
|
||||
RL_ClearBackground( { 50, 20, 75 } )
|
||||
|
||||
if RL_GuiButton( { 112, 16, 96, 32 }, "Exit" ) then
|
||||
-- if RL_GuiButton( { 112, 16, 96, 32 }, "Exit" ) then
|
||||
if RL_GuiButton( { 112, 16, 96, 32 }, RL_GuiIconText( 113, "Exit" ) ) then
|
||||
RL_CloseWindow()
|
||||
end
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ int lguiGuiColorPanel( lua_State *L );
|
||||
int lguiGuiColorBarAlpha( lua_State *L );
|
||||
int lguiGuiColorBarHue( lua_State *L );
|
||||
/* Icons. */
|
||||
int lguiGuiIconText( lua_State *L );
|
||||
int lguiGuiDrawIcon( lua_State *L );
|
||||
int lguiGuiSetIconScale( lua_State *L );
|
||||
int lguiGuiSetIconPixel( lua_State *L );
|
||||
|
||||
@@ -871,6 +871,7 @@ void luaRegister() {
|
||||
lua_register( L, "RL_GuiColorBarAlpha", lguiGuiColorBarAlpha );
|
||||
lua_register( L, "RL_GuiColorBarHue", lguiGuiColorBarHue );
|
||||
/* Icons. */
|
||||
lua_register( L, "RL_GuiIconText", lguiGuiIconText );
|
||||
lua_register( L, "RL_GuiDrawIcon", lguiGuiDrawIcon );
|
||||
lua_register( L, "RL_GuiSetIconScale", lguiGuiSetIconScale );
|
||||
lua_register( L, "RL_GuiSetIconPixel", lguiGuiSetIconPixel );
|
||||
|
||||
29
src/rgui.c
29
src/rgui.c
@@ -1136,6 +1136,35 @@ int lguiGuiColorBarHue( lua_State *L ) {
|
||||
## Gui - Icons
|
||||
*/
|
||||
|
||||
/*
|
||||
> text = RL_GuiIconText( int iconId, string text )
|
||||
|
||||
Get text with icon id prepended ( if supported )
|
||||
|
||||
- Failure return false
|
||||
- Success return string
|
||||
*/
|
||||
int lguiGuiIconText( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, -2 ) || !lua_isstring( L, -1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiIconText( int iconId, string text )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
char text[ STRING_LEN ] = { '\0' };
|
||||
strcpy( text, lua_tostring( L, -1 ) );
|
||||
lua_pop( L, 1 );
|
||||
int iconId = lua_tointeger( L, -1 );
|
||||
|
||||
if ( TextIsEqual( text, "" ) ) {
|
||||
lua_pushstring( L, GuiIconText( iconId, NULL ) );
|
||||
}
|
||||
else {
|
||||
lua_pushstring( L, GuiIconText( iconId, text ) );
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> success = RL_GuiDrawIcon( int iconId, Vector2 pos, int pixelSize, Color color )
|
||||
|
||||
|
||||
@@ -1353,7 +1353,7 @@ Get Color structure from hexadecimal value
|
||||
- Success return Color
|
||||
*/
|
||||
int ltexturesGetColor( lua_State *L ) {
|
||||
if ( !lua_istable( L, -1 ) ) {
|
||||
if ( !lua_isnumber( L, -1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GetColor( unsigned int hexValue )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
@@ -1394,10 +1394,6 @@ int ltexturesGetPixelColor( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Color GetPixelColor(void *srcPtr, int format);
|
||||
|
||||
/*
|
||||
> size = RL_GetPixelDataSize( int width, int height, int format )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user