summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lua_core.c8
-rw-r--r--src/rgui.c162
2 files changed, 166 insertions, 4 deletions
diff --git a/src/lua_core.c b/src/lua_core.c
index d6ef706..aeeec9c 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -811,6 +811,8 @@ void luaRegister() {
/* Style. */
lua_register( L, "RL_GuiSetStyle", lguiGuiSetStyle );
lua_register( L, "RL_GuiGetStyle", lguiGuiGetStyle );
+ lua_register( L, "RL_GuiLoadStyle", lguiGuiLoadStyle );
+ lua_register( L, "RL_GuiLoadStyleDefault", lguiGuiLoadStyleDefault );
/* Container. */
lua_register( L, "RL_GuiWindowBox", lguiGuiWindowBox );
lua_register( L, "RL_GuiGroupBox", lguiGuiGroupBox );
@@ -840,6 +842,12 @@ void luaRegister() {
lua_register( L, "RL_GuiColorPanel", lguiGuiColorPanel );
lua_register( L, "RL_GuiColorBarAlpha", lguiGuiColorBarAlpha );
lua_register( L, "RL_GuiColorBarHue", lguiGuiColorBarHue );
+ /* Icons. */
+ lua_register( L, "RL_GuiDrawIcon", lguiGuiDrawIcon );
+ lua_register( L, "RL_GuiSetIconScale", lguiGuiSetIconScale );
+ lua_register( L, "RL_GuiSetIconPixel", lguiGuiSetIconPixel );
+ lua_register( L, "RL_GuiClearIconPixel", lguiGuiClearIconPixel );
+ lua_register( L, "RL_GuiCheckIconPixel", lguiGuiCheckIconPixel );
}
/* Lua util functions. */
diff --git a/src/rgui.c b/src/rgui.c
index dabf18f..8d2ea37 100644
--- a/src/rgui.c
+++ b/src/rgui.c
@@ -18,7 +18,7 @@ Enable gui controls ( Global state )
int lguiGuiEnable( lua_State *L ) {
GuiEnable();
- return 1;
+ return 0;
}
/*
@@ -29,7 +29,7 @@ Disable gui controls ( Global state )
int lguiGuiDisable( lua_State *L ) {
GuiDisable();
- return 1;
+ return 0;
}
/*
@@ -40,7 +40,7 @@ Lock gui controls ( Global state )
int lguiGuiLock( lua_State *L ) {
GuiLock();
- return 1;
+ return 0;
}
/*
@@ -51,7 +51,7 @@ Unlock gui controls ( Global state )
int lguiGuiUnlock( lua_State *L ) {
GuiUnlock();
- return 1;
+ return 0;
}
/*
@@ -122,6 +122,37 @@ int lguiGuiGetStyle( lua_State *L ) {
}
/*
+> success = RL_GuiLoadStyle( int control, int property )
+
+Load style file over global style variable ( .rgs )
+
+- Failure return false
+- Success return true
+*/
+int lguiGuiLoadStyle( lua_State *L ) {
+ if ( !lua_isstring( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiLoadStyle( string fileName )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ GuiLoadStyle( lua_tostring( L, -1 ) );
+ lua_pushboolean( L, true );
+
+ return 1;
+}
+
+/*
+> RL_GuiLoadStyleDefault()
+
+Load style default over global style
+*/
+int lguiGuiLoadStyleDefault( lua_State *L ) {
+ GuiLoadStyleDefault();
+
+ return 0;
+}
+
+/*
## Gui - Container
*/
@@ -873,3 +904,126 @@ int lguiGuiColorBarHue( lua_State *L ) {
return 1;
}
+
+/*
+## Gui - Icons
+*/
+
+/*
+> success = RL_GuiDrawIcon( int iconId, Vector2 pos, int pixelSize, Color color )
+
+Draw icon
+
+- Failure return false
+- Success return true
+*/
+int lguiGuiDrawIcon( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiDrawIcon( int iconId, Vector2 pos, int pixelSize, Color color )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ Color color = uluaGetColor( L );
+ lua_pop( L, 1 );
+ int pixelSize = lua_tointeger( L, -1 );
+ lua_pop( L, 1 );
+ Vector2 pos = uluaGetVector2( L );
+ lua_pop( L, 1 );
+ int iconId = lua_tointeger( L, -1 );
+
+ GuiDrawIcon( iconId, pos.x, pos.y, pixelSize, color );
+ lua_pushboolean( L, true );
+
+ return 1;
+}
+
+/*
+> success = RL_GuiSetIconScale( int scale )
+
+Set icon scale ( 1 by default )
+
+- Failure return false
+- Success return true
+*/
+int lguiGuiSetIconScale( lua_State *L ) {
+ if ( !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiSetIconScale( int scale )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ GuiSetIconScale( (unsigned int)lua_tointeger( L, -1 ) );
+ lua_pushboolean( L, true );
+
+ return 1;
+}
+
+/*
+> success = RL_GuiSetIconPixel( int iconId, Vector2 pos )
+
+Set icon pixel value
+
+- Failure return false
+- Success return true
+*/
+int lguiGuiSetIconPixel( lua_State *L ) {
+ if ( !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiSetIconPixel( int iconId, Vector2 pos )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ Vector2 pos = uluaGetVector2( L );
+ lua_pop( L, 1 );
+ int iconId = lua_tointeger( L, -1 );
+
+ GuiSetIconPixel( iconId, pos.x, pos.y );
+ lua_pushboolean( L, true );
+
+ return 1;
+}
+
+/*
+> success = RL_GuiClearIconPixel( int iconId, Vector2 pos )
+
+Clear icon pixel value
+
+- Failure return false
+- Success return true
+*/
+int lguiGuiClearIconPixel( lua_State *L ) {
+ if ( !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiClearIconPixel( int iconId, Vector2 pos )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ Vector2 pos = uluaGetVector2( L );
+ lua_pop( L, 1 );
+ int iconId = lua_tointeger( L, -1 );
+
+ GuiClearIconPixel( iconId, pos.x, pos.y );
+ lua_pushboolean( L, true );
+
+ return 1;
+}
+
+/*
+> value = RL_GuiCheckIconPixel( int iconId, Vector2 pos )
+
+Check icon pixel value
+
+- Failure return nil
+- Success return bool
+*/
+int lguiGuiCheckIconPixel( lua_State *L ) {
+ if ( !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiCheckIconPixel( int iconId, Vector2 pos )" );
+ lua_pushnil( L );
+ return 1;
+ }
+ Vector2 pos = uluaGetVector2( L );
+ lua_pop( L, 1 );
+ int iconId = lua_tointeger( L, -1 );
+
+ lua_pushboolean( L, GuiCheckIconPixel( iconId, pos.x, pos.y ) );
+
+ return 1;
+}