summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lua_core.c10
-rw-r--r--src/rgui.c235
2 files changed, 241 insertions, 4 deletions
diff --git a/src/lua_core.c b/src/lua_core.c
index 6006474..95f4055 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -824,6 +824,10 @@ void luaRegister() {
lua_register( L, "RL_GuiDisable", lguiGuiDisable );
lua_register( L, "RL_GuiLock", lguiGuiLock );
lua_register( L, "RL_GuiUnlock", lguiGuiUnlock );
+ lua_register( L, "RL_GuiIsLocked", lguiGuiIsLocked );
+ lua_register( L, "RL_GuiFade", lguiGuiFade );
+ lua_register( L, "RL_GuiSetState", lguiGuiSetState );
+ lua_register( L, "RL_GuiGetState", lguiGuiGetState );
/* Font. */
lua_register( L, "RL_GuiSetFont", lguiGuiSetFont );
/* Style. */
@@ -840,9 +844,11 @@ void luaRegister() {
/* Basic. */
lua_register( L, "RL_GuiLabel", lguiGuiLabel );
lua_register( L, "RL_GuiButton", lguiGuiButton );
+ lua_register( L, "RL_GuiLabelButton", lguiGuiLabelButton );
lua_register( L, "RL_GuiToggle", lguiGuiToggle );
lua_register( L, "RL_GuiToggleGroup", lguiGuiToggleGroup );
lua_register( L, "RL_GuiCheckBox", lguiGuiCheckBox );
+ lua_register( L, "RL_GuiComboBox", lguiGuiComboBox );
lua_register( L, "RL_GuiTextBox", lguiGuiTextBox );
lua_register( L, "RL_GuiTextBoxMulti", lguiGuiTextBoxMulti );
lua_register( L, "RL_GuiSpinner", lguiGuiSpinner );
@@ -852,8 +858,12 @@ void luaRegister() {
lua_register( L, "RL_GuiProgressBar", lguiGuiProgressBar );
lua_register( L, "RL_GuiScrollBar", lguiGuiScrollBar );
lua_register( L, "RL_GuiDropdownBox", lguiGuiDropdownBox );
+ lua_register( L, "RL_GuiStatusBar", lguiGuiStatusBar );
+ lua_register( L, "RL_GuiDummyRec", lguiGuiDummyRec );
+ lua_register( L, "RL_GuiGrid", lguiGuiGrid );
/* Advanced. */
lua_register( L, "RL_GuiListView", lguiGuiListView );
+ lua_register( L, "RL_GuiListViewEx", lguiGuiListViewEx );
lua_register( L, "RL_GuiMessageBox", lguiGuiMessageBox );
lua_register( L, "RL_GuiTextInputBox", lguiGuiTextInputBox );
lua_register( L, "RL_GuiColorPicker", lguiGuiColorPicker );
diff --git a/src/rgui.c b/src/rgui.c
index 8d2ea37..894c470 100644
--- a/src/rgui.c
+++ b/src/rgui.c
@@ -13,7 +13,7 @@
/*
> RL_GuiEnable()
-Enable gui controls ( Global state )
+Enable gui controls ( global state )
*/
int lguiGuiEnable( lua_State *L ) {
GuiEnable();
@@ -24,7 +24,7 @@ int lguiGuiEnable( lua_State *L ) {
/*
> RL_GuiDisable()
-Disable gui controls ( Global state )
+Disable gui controls ( global state )
*/
int lguiGuiDisable( lua_State *L ) {
GuiDisable();
@@ -35,7 +35,7 @@ int lguiGuiDisable( lua_State *L ) {
/*
> RL_GuiLock()
-Lock gui controls ( Global state )
+Lock gui controls ( global state )
*/
int lguiGuiLock( lua_State *L ) {
GuiLock();
@@ -46,7 +46,7 @@ int lguiGuiLock( lua_State *L ) {
/*
> RL_GuiUnlock()
-Unlock gui controls ( Global state )
+Unlock gui controls ( global state )
*/
int lguiGuiUnlock( lua_State *L ) {
GuiUnlock();
@@ -55,6 +55,72 @@ int lguiGuiUnlock( lua_State *L ) {
}
/*
+> locked = RL_GuiIsLocked()
+
+Check if gui is locked ( global state )
+
+- Success return bool
+*/
+int lguiGuiIsLocked( lua_State *L ) {
+ lua_pushboolean( L, GuiIsLocked() );
+
+ return 0;
+}
+
+/*
+> success = RL_GuiFade( float alpha )
+
+Set gui controls alpha ( global state ), alpha goes from 0.0f to 1.0f
+
+- Failure return false
+- Success return true
+*/
+int lguiGuiFade( lua_State *L ) {
+ if ( !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiFade( float alpha )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ GuiFade( lua_tonumber( L, -1 ) );
+ lua_pushboolean( L, true );
+
+ return 1;
+}
+
+/*
+> success = RL_GuiSetState( int state )
+
+Set gui state ( global state )
+
+- Failure return false
+- Success return true
+*/
+int lguiGuiSetState( lua_State *L ) {
+ if ( !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiSetState( int state )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ GuiSetState( lua_tointeger( L, -1 ) );
+ lua_pushboolean( L, true );
+
+ return 1;
+}
+
+/*
+> state = RL_GuiGetState()
+
+Get gui state ( global state )
+
+- Success return int
+*/
+int lguiGuiGetState( lua_State *L ) {
+ lua_pushinteger( L, GuiGetState() );
+
+ return 1;
+}
+
+/*
## Gui - Font
*/
@@ -338,6 +404,30 @@ int lguiGuiButton( lua_State *L ) {
}
/*
+> clicked = RL_GuiLabelButton( Rectangle bounds, string text )
+
+Label button control, show true when clicked
+
+- Failure return nil
+- Success return boolean
+*/
+int lguiGuiLabelButton( lua_State *L ) {
+ if ( !lua_istable( L, -2 ) || !lua_isstring( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiLabelButton( Rectangle bounds, string text )" );
+ lua_pushnil( L );
+ return 1;
+ }
+ char text[ STRING_LEN ] = { '\0' };
+ strcpy( text, lua_tostring( L, -1 ) );
+ lua_pop( L, 1 );
+ Rectangle bounds = uluaGetRectangle( L );
+
+ lua_pushboolean( L, GuiLabelButton( bounds, text ) );
+
+ return 1;
+}
+
+/*
> active = RL_GuiToggle( Rectangle bounds, string text, bool active )
Toggle Button control, returns true when active
@@ -416,6 +506,32 @@ int lguiGuiCheckBox( lua_State *L ) {
}
/*
+> active = RL_GuiComboBox( Rectangle bounds, string text, int active )
+
+Combo Box control, returns selected item index
+
+- Failure return nil
+- Success return int
+*/
+int lguiGuiComboBox( lua_State *L ) {
+ if ( !lua_istable( L, -3 ) || !lua_isstring( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiComboBox( Rectangle bounds, string text, int active )" );
+ lua_pushnil( L );
+ return 1;
+ }
+ int active = lua_tointeger( L, -1 );
+ lua_pop( L, 1 );
+ char text[ STRING_LEN ] = { '\0' };
+ strcpy( text, lua_tostring( L, -1 ) );
+ lua_pop( L, 1 );
+ Rectangle bounds = uluaGetRectangle( L );
+
+ lua_pushinteger( L, GuiComboBox( bounds, text, active ) );
+
+ return 1;
+}
+
+/*
> pressed, text = RL_GuiTextBox( Rectangle bounds, string text, int textSize, bool editMode )
Text Box control, updates input text
@@ -700,6 +816,84 @@ int lguiGuiDropdownBox( lua_State *L ) {
}
/*
+> success = RL_GuiStatusBar( Rectangle bounds, string text )
+
+Status Bar control, shows info text
+
+- Failure return false
+- Success return true
+*/
+int lguiGuiStatusBar( lua_State *L ) {
+ if ( !lua_istable( L, -2 ) || !lua_isstring( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiStatusBar( Rectangle bounds, string text )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ char text[ STRING_LEN ] = { '\0' };
+ strcpy( text, lua_tostring( L, -1 ) );
+ lua_pop( L, 1 );
+ Rectangle bounds = uluaGetRectangle( L );
+
+ GuiStatusBar( bounds, text );
+ lua_pushboolean( L, true );
+
+ return 1;
+}
+
+/*
+> success = RL_GuiDummyRec( Rectangle bounds, string text )
+
+Dummy control for placeholders
+
+- Failure return false
+- Success return true
+*/
+int lguiGuiDummyRec( lua_State *L ) {
+ if ( !lua_istable( L, -2 ) || !lua_isstring( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiDummyRec( Rectangle bounds, string text )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ char text[ STRING_LEN ] = { '\0' };
+ strcpy( text, lua_tostring( L, -1 ) );
+ lua_pop( L, 1 );
+ Rectangle bounds = uluaGetRectangle( L );
+
+ GuiDummyRec( bounds, text );
+ lua_pushboolean( L, true );
+
+ return 1;
+}
+
+/*
+> cell = RL_GuiGrid( Rectangle bounds, string text, float spacing, int subdivs )
+
+Grid control, returns mouse cell position
+
+- Failure return false
+- Success return Vector2
+*/
+int lguiGuiGrid( lua_State *L ) {
+ if ( !lua_istable( L, -4 ) || !lua_isstring( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiGrid( Rectangle bounds, string text, float spacing, int subdivs )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ int subdivs = lua_tointeger( L, -1 );
+ lua_pop( L, 1 );
+ float spacing = lua_tonumber( L, -1 );
+ lua_pop( L, 1 );
+ char text[ STRING_LEN ] = { '\0' };
+ strcpy( text, lua_tostring( L, -1 ) );
+ lua_pop( L, 1 );
+ Rectangle bounds = uluaGetRectangle( L );
+
+ uluaPushVector2( L, GuiGrid( bounds, text, spacing, subdivs ) );
+
+ return 1;
+}
+
+/*
## Gui - Advanced
*/
@@ -733,6 +927,39 @@ int lguiGuiListView( lua_State *L ) {
}
/*
+> itemIndex, scrollIndex, focus = RL_GuiListViewEx( Rectangle bounds, string text, int focus, int scrollIndex, int active )
+
+List View with extended parameters, returns selected list item index, scroll index and focus
+
+- Failure return nil
+- Success return int, int, int
+*/
+int lguiGuiListViewEx( lua_State *L ) {
+ if ( !lua_istable( L, -5 ) || !lua_isstring( L, -4 ) || !lua_isnumber( L, -3 )
+ || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiListViewEx( Rectangle bounds, string text, int focus, int scrollIndex, int active )" );
+ lua_pushnil( L );
+ return 1;
+ }
+ int active = lua_tointeger( L, -1 );
+ lua_pop( L, 1 );
+ int scrollIndex = lua_tointeger( L, -1 );
+ lua_pop( L, 1 );
+ int focus = lua_tointeger( L, -1 );
+ lua_pop( L, 1 );
+ int count = 0;
+ const char **text = GuiTextSplit( lua_tostring( L, -1 ), &count, NULL );
+ lua_pop( L, 1 );
+ Rectangle bounds = uluaGetRectangle( L );
+
+ lua_pushinteger( L, GuiListViewEx( bounds, text, count, &focus, &scrollIndex, active ) );
+ lua_pushinteger( L, scrollIndex );
+ lua_pushinteger( L, focus );
+
+ return 3;
+}
+
+/*
> buttonIndex = RL_GuiMessageBox( Rectangle bounds, string title, string message, string buttons )
Message Box control, displays a message, returns button index ( 0 is x button )