diff options
| author | jussi | 2023-11-21 23:34:47 +0200 |
|---|---|---|
| committer | jussi | 2023-11-21 23:34:47 +0200 |
| commit | 85a48cf09302a2a14aeeb2d6cf3b8fcc1607e222 (patch) | |
| tree | d8b49bac0c6e9d339cf663d483270d08072b1e8d /src | |
| parent | 01883035b03b3d42818a7890fe6e845b0623f022 (diff) | |
| download | reilua-enhanced-85a48cf09302a2a14aeeb2d6cf3b8fcc1607e222.tar.gz reilua-enhanced-85a48cf09302a2a14aeeb2d6cf3b8fcc1607e222.tar.bz2 reilua-enhanced-85a48cf09302a2a14aeeb2d6cf3b8fcc1607e222.zip | |
Raygui updated to version 4.0.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lua_core.c | 66 | ||||
| -rw-r--r-- | src/rgui.c | 682 |
2 files changed, 432 insertions, 316 deletions
diff --git a/src/lua_core.c b/src/lua_core.c index c85d541..e289967 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -677,10 +677,18 @@ static void defineGlobals() { assignGlobalInt( STATE_FOCUSED, "STATE_FOCUSED" ); assignGlobalInt( STATE_PRESSED, "STATE_PRESSED" ); assignGlobalInt( STATE_DISABLED, "STATE_DISABLED" ); - /* GuiTextAlignment */ + /* GuiControlTextAlignment */ assignGlobalInt( TEXT_ALIGN_LEFT, "TEXT_ALIGN_LEFT" ); assignGlobalInt( TEXT_ALIGN_CENTER, "TEXT_ALIGN_CENTER" ); assignGlobalInt( TEXT_ALIGN_RIGHT, "TEXT_ALIGN_RIGHT" ); + /* GuiControlTextAlignmentVertical */ + assignGlobalInt( TEXT_ALIGN_TOP, "TEXT_ALIGN_TOP" ); + assignGlobalInt( TEXT_ALIGN_MIDDLE, "TEXT_ALIGN_MIDDLE" ); + assignGlobalInt( TEXT_ALIGN_BOTTOM, "TEXT_ALIGN_BOTTOM" ); + /* GuiControlTextWrapMode */ + assignGlobalInt( TEXT_WRAP_NONE, "TEXT_WRAP_NONE" ); + assignGlobalInt( TEXT_WRAP_CHAR, "TEXT_WRAP_CHAR" ); + assignGlobalInt( TEXT_WRAP_WORD, "TEXT_WRAP_WORD" ); /* GuiControl */ assignGlobalInt( DEFAULT, "DEFAULT" ); assignGlobalInt( LABEL, "LABEL" ); // Used also for: LABELBUTTON @@ -714,12 +722,14 @@ static void defineGlobals() { assignGlobalInt( BORDER_WIDTH, "BORDER_WIDTH" ); assignGlobalInt( TEXT_PADDING, "TEXT_PADDING" ); assignGlobalInt( TEXT_ALIGNMENT, "TEXT_ALIGNMENT" ); - assignGlobalInt( RESERVED, "RESERVED" ); /* GuiDefaultProperty */ assignGlobalInt( TEXT_SIZE, "TEXT_SIZE" ); // Text size (glyphs max height) assignGlobalInt( TEXT_SPACING, "TEXT_SPACING" ); // Text spacing between glyphs assignGlobalInt( LINE_COLOR, "LINE_COLOR" ); // Line control color assignGlobalInt( BACKGROUND_COLOR, "BACKGROUND_COLOR" ); // Background color + assignGlobalInt( TEXT_LINE_SPACING, "TEXT_LINE_SPACING" ); // Text spacing between lines + assignGlobalInt( TEXT_ALIGNMENT_VERTICAL, "TEXT_ALIGNMENT_VERTICAL" ); // Text vertical alignment inside text bounds (after border and padding) + assignGlobalInt( TEXT_WRAP_MODE, "TEXT_WRAP_MODE" ); // Text wrap-mode inside text bounds /* GuiToggleProperty */ assignGlobalInt( GROUP_PADDING, "GROUP_PADDING" ); // ToggleGroup separation between toggles /* GuiSliderProperty */ @@ -742,9 +752,8 @@ static void defineGlobals() { /* GuiDropdownBoxProperty */ assignGlobalInt( ARROW_PADDING, "ARROW_PADDING" ); // DropdownBox arrow separation from border and items assignGlobalInt( DROPDOWN_ITEMS_SPACING, "DROPDOWN_ITEMS_SPACING" ); // DropdownBox items separation - /* GuiTextBoxProperty */ - assignGlobalInt( TEXT_INNER_PADDING, "TEXT_INNER_PADDING" ); // TextBox/TextBoxMulti/ValueBox/Spinner inner text padding - assignGlobalInt( TEXT_LINES_SPACING, "TEXT_LINES_SPACING" ); // TextBoxMulti lines separation + /* TextBox/TextBoxMulti/ValueBox/Spinner */ + assignGlobalInt( TEXT_READONLY, "TEXT_READONLY" ); // TextBox in read-only mode: 0-text editable, 1-text no-editable /* GuiSpinnerProperty */ assignGlobalInt( SPIN_BUTTON_WIDTH, "SPIN_BUTTON_WIDTH" ); // Spinner left/right buttons width assignGlobalInt( SPIN_BUTTON_SPACING, "SPIN_BUTTON_SPACING" ); // Spinner buttons separation @@ -2204,48 +2213,61 @@ void luaRegister() { assingGlobalFunction( "QuaternionEquals", lmathQuaternionEquals ); /* Gui. */ - /* Global. */ + /* Global gui state control functions. */ assingGlobalFunction( "GuiEnable", lguiGuiEnable ); assingGlobalFunction( "GuiDisable", lguiGuiDisable ); assingGlobalFunction( "GuiLock", lguiGuiLock ); assingGlobalFunction( "GuiUnlock", lguiGuiUnlock ); assingGlobalFunction( "GuiIsLocked", lguiGuiIsLocked ); - assingGlobalFunction( "GuiFade", lguiGuiFade ); + assingGlobalFunction( "GuiSetAlpha", lguiGuiSetAlpha ); assingGlobalFunction( "GuiSetState", lguiGuiSetState ); assingGlobalFunction( "GuiGetState", lguiGuiGetState ); - /* Font. */ + /* Font set/get functions. */ assingGlobalFunction( "GuiSetFont", lguiGuiSetFont ); assingGlobalFunction( "GuiGetFont", lguiGuiGetFont ); - /* Style. */ + /* Style set/get functions. */ assingGlobalFunction( "GuiSetStyle", lguiGuiSetStyle ); assingGlobalFunction( "GuiGetStyle", lguiGuiGetStyle ); - /* Container. */ + /* Styles loading functions */ + assingGlobalFunction( "GuiLoadStyle", lguiGuiLoadStyle ); + assingGlobalFunction( "GuiLoadStyleDefault", lguiGuiLoadStyleDefault ); + /* Tooltips management functions. */ + assingGlobalFunction( "GuiEnableTooltip", lguiGuiEnableTooltip ); + assingGlobalFunction( "GuiDisableTooltip", lguiGuiDisableTooltip ); + assingGlobalFunction( "GuiSetTooltip", lguiGuiSetTooltip ); + /* Icons functionality. */ + assingGlobalFunction( "GuiIconText", lguiGuiIconText ); + assingGlobalFunction( "GuiSetIconScale", lguiGuiSetIconScale ); + assingGlobalFunction( "GuiGetIcons", lguiGuiGetIcons ); + assingGlobalFunction( "GuiLoadIcons", lguiGuiLoadIcons ); + assingGlobalFunction( "GuiDrawIcon", lguiGuiDrawIcon ); + /* Container/separator controls, useful for controls organization. */ assingGlobalFunction( "GuiWindowBox", lguiGuiWindowBox ); assingGlobalFunction( "GuiGroupBox", lguiGuiGroupBox ); assingGlobalFunction( "GuiLine", lguiGuiLine ); assingGlobalFunction( "GuiPanel", lguiGuiPanel ); + assingGlobalFunction( "GuiTabBar", lguiGuiTabBar ); assingGlobalFunction( "GuiScrollPanel", lguiGuiScrollPanel ); - /* Basic. */ + /* Basic controls set. */ assingGlobalFunction( "GuiLabel", lguiGuiLabel ); assingGlobalFunction( "GuiButton", lguiGuiButton ); assingGlobalFunction( "GuiLabelButton", lguiGuiLabelButton ); assingGlobalFunction( "GuiToggle", lguiGuiToggle ); assingGlobalFunction( "GuiToggleGroup", lguiGuiToggleGroup ); + assingGlobalFunction( "GuiToggleSlider", lguiGuiToggleSlider ); assingGlobalFunction( "GuiCheckBox", lguiGuiCheckBox ); assingGlobalFunction( "GuiComboBox", lguiGuiComboBox ); - assingGlobalFunction( "GuiTextBox", lguiGuiTextBox ); - assingGlobalFunction( "GuiTextBoxMulti", lguiGuiTextBoxMulti ); + assingGlobalFunction( "GuiDropdownBox", lguiGuiDropdownBox ); assingGlobalFunction( "GuiSpinner", lguiGuiSpinner ); assingGlobalFunction( "GuiValueBox", lguiGuiValueBox ); + assingGlobalFunction( "GuiTextBox", lguiGuiTextBox ); assingGlobalFunction( "GuiSlider", lguiGuiSlider ); assingGlobalFunction( "GuiSliderBar", lguiGuiSliderBar ); assingGlobalFunction( "GuiProgressBar", lguiGuiProgressBar ); - assingGlobalFunction( "GuiScrollBar", lguiGuiScrollBar ); - assingGlobalFunction( "GuiDropdownBox", lguiGuiDropdownBox ); assingGlobalFunction( "GuiStatusBar", lguiGuiStatusBar ); assingGlobalFunction( "GuiDummyRec", lguiGuiDummyRec ); assingGlobalFunction( "GuiGrid", lguiGuiGrid ); - /* Advanced. */ + /* Advance controls set. */ assingGlobalFunction( "GuiListView", lguiGuiListView ); assingGlobalFunction( "GuiListViewEx", lguiGuiListViewEx ); assingGlobalFunction( "GuiMessageBox", lguiGuiMessageBox ); @@ -2254,16 +2276,8 @@ void luaRegister() { assingGlobalFunction( "GuiColorPanel", lguiGuiColorPanel ); assingGlobalFunction( "GuiColorBarAlpha", lguiGuiColorBarAlpha ); assingGlobalFunction( "GuiColorBarHue", lguiGuiColorBarHue ); - /* Styles loading functions */ - assingGlobalFunction( "GuiLoadStyle", lguiGuiLoadStyle ); - assingGlobalFunction( "GuiLoadStyleDefault", lguiGuiLoadStyleDefault ); - /* Icons. */ - assingGlobalFunction( "GuiIconText", lguiGuiIconText ); - assingGlobalFunction( "GuiDrawIcon", lguiGuiDrawIcon ); - assingGlobalFunction( "GuiSetIconScale", lguiGuiSetIconScale ); - assingGlobalFunction( "GuiSetIconPixel", lguiGuiSetIconPixel ); - assingGlobalFunction( "GuiClearIconPixel", lguiGuiClearIconPixel ); - assingGlobalFunction( "GuiCheckIconPixel", lguiGuiCheckIconPixel ); + assingGlobalFunction( "GuiColorPickerHSV", lguiGuiColorPickerHSV ); + assingGlobalFunction( "GuiColorPanelHSV", lguiGuiColorPanelHSV ); /* Lights */ /* Light management functions. */ @@ -64,18 +64,18 @@ Check if gui is locked (global state) int lguiGuiIsLocked( lua_State *L ) { lua_pushboolean( L, GuiIsLocked() ); - return 0; + return 1; } /* -> RL.GuiFade( float alpha ) +> RL.GuiSetAlpha( float alpha ) Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f */ -int lguiGuiFade( lua_State *L ) { +int lguiGuiSetAlpha( lua_State *L ) { float alpha = luaL_checknumber( L, 1 ); - GuiFade( alpha ); + GuiSetAlpha( alpha ); return 0; } @@ -172,79 +172,278 @@ int lguiGuiGetStyle( lua_State *L ) { } /* +## Gui - Styles loading functions +*/ + +/* +> success = RL.GuiLoadStyle( string fileName ) + +Load style file over global style variable (.rgs) + +- Failure return nil +- Success return true +*/ +int lguiGuiLoadStyle( lua_State *L ) { + if ( FileExists( luaL_checkstring( L, 1 ) ) ) { + GuiLoadStyle( lua_tostring( L, 1 ) ); + lua_pushboolean( L, true ); + + return 1; + } + TraceLog( state->logLevelInvalid, "Invalid file '%s'", lua_tostring( L, 1 ) ); + lua_pushnil( L ); + + return 1; +} + +/* +> RL.GuiLoadStyleDefault() + +Load style default over global style +*/ +int lguiGuiLoadStyleDefault( lua_State *L ) { + GuiLoadStyleDefault(); + + return 0; +} + +/* +## Gui - Tooltips management functions +*/ + +/* +> RL.GuiEnableTooltip() + +Enable gui tooltips (global state) +*/ +int lguiGuiEnableTooltip( lua_State *L ) { + GuiEnableTooltip(); + + return 0; +} + +/* +> RL.GuiDisableTooltip() + +Disable gui tooltips (global state) +*/ +int lguiGuiDisableTooltip( lua_State *L ) { + GuiDisableTooltip(); + + return 0; +} + +/* +> RL.GuiSetTooltip( string tooltip ) + +Set tooltip string +*/ +int lguiGuiSetTooltip( lua_State *L ) { + GuiSetTooltip( luaL_checkstring( L, 1 ) ); + + return 0; +} + +/* +## Gui - Icons functionality +*/ + +/* +> text = RL.GuiIconText( int iconId, string text ) + +Get text with icon id prepended (if supported) + +- Success return string +*/ +int lguiGuiIconText( lua_State *L ) { + int iconId = luaL_checkinteger( L, 1 ); + + if ( TextIsEqual( luaL_checkstring( L, 2 ), "" ) ) { + lua_pushstring( L, GuiIconText( iconId, NULL ) ); + } + else { + lua_pushstring( L, GuiIconText( iconId, luaL_checkstring( L, 2 ) ) ); + } + + return 1; +} + +/* +> RL.GuiSetIconScale( int scale ) + +Set icon scale (1 by default) +*/ +int lguiGuiSetIconScale( lua_State *L ) { + unsigned int scale = luaL_checkinteger( L, 1 ); + + GuiSetIconScale( scale ); + + return 0; +} + +/* +> icons = RL.GuiGetIcons() + +Get raygui icons data pointer + +- Success return int +*/ +int lguiGuiGetIcons( lua_State *L ) { + lua_pushinteger( L, *GuiGetIcons() ); + + return 1; +} + +/* +> iconNames = RL.GuiLoadIcons( string fileName, bool loadIconsName ) + +Load raygui icons file (.rgi) into internal icons data + +- Failure return nil +- Success return strings{} +*/ +int lguiGuiLoadIcons( lua_State *L ) { + const char *fileName = luaL_checkstring( L, 1 ); + bool loadIconsName = uluaGetBoolean( L, 2 ); + + if ( FileExists( fileName ) ) { + char **iconNames = GuiLoadIcons( fileName, loadIconsName ); + + lua_createtable( L, 255, 0 ); + + for ( int i = 0; i < 255; i++ ) { + lua_pushstring( L, iconNames[i] ); + lua_rawseti( L, -2, i + 1 ); + free( iconNames[i] ); + } + free( iconNames ); + + return 1; + } + TraceLog( state->logLevelInvalid, "Invalid file '%s'", lua_tostring( L, 1 ) ); + lua_pushnil( L ); + + return 1; +} + +/* +> RL.GuiDrawIcon( int iconId, Vector2 pos, int pixelSize, Color color ) + +Draw icon +*/ +int lguiGuiDrawIcon( lua_State *L ) { + int iconId = luaL_checkinteger( L, 1 ); + Vector2 pos = uluaGetVector2( L, 2 ); + int pixelSize = luaL_checkinteger( L, 3 ); + Color color = uluaGetColor( L, 4 ); + + GuiDrawIcon( iconId, pos.x, pos.y, pixelSize, color ); + + return 0; +} + +/* ## Gui - Container/separator controls, useful for controls organization */ /* -> state = RL.GuiWindowBox( Rectangle bounds, string title ) +> result = RL.GuiWindowBox( Rectangle bounds, string title ) Window Box control, shows a window that can be closed -- Success return bool +- Success return int */ int lguiGuiWindowBox( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); - lua_pushboolean( L, GuiWindowBox( bounds, luaL_checkstring( L, 2 ) ) ); + lua_pushinteger( L, GuiWindowBox( bounds, luaL_checkstring( L, 2 ) ) ); return 1; } /* -> RL.GuiGroupBox( Rectangle bounds, string text ) +> result = RL.GuiGroupBox( Rectangle bounds, string text ) Group Box control with text name + +- Success return int */ int lguiGuiGroupBox( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); - GuiGroupBox( bounds, luaL_checkstring( L, 2 ) ); + lua_pushinteger( L, GuiGroupBox( bounds, luaL_checkstring( L, 2 ) ) ); - return 0; + return 1; } /* -> RL.GuiLine( Rectangle bounds, string text ) +> result = RL.GuiLine( Rectangle bounds, string text ) Line separator control, could contain text + +- Success return int */ int lguiGuiLine( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); - GuiLine( bounds, luaL_checkstring( L, 2 ) ); + lua_pushinteger( L, GuiLine( bounds, luaL_checkstring( L, 2 ) ) ); - return 0; + return 1; } /* -> RL.GuiPanel( Rectangle bounds, string text ) +> result = RL.GuiPanel( Rectangle bounds, string text ) Panel control, useful to group controls + +- Success return int */ int lguiGuiPanel( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); - GuiPanel( bounds, luaL_checkstring( L, 2 ) ); + lua_pushinteger( L, GuiPanel( bounds, luaL_checkstring( L, 2 ) ) ); - return 0; + return 1; } /* -> view, scroll = RL.GuiScrollPanel( Rectangle bounds, string text, Rectangle content, Vector2 scroll ) +> result, active = RL.GuiTabBar( Rectangle bounds, string text, int active ) + +Tab Bar control, returns TAB to be closed or -1 + +- Success return int, int +*/ +int lguiGuiTabBar( lua_State *L ) { + Rectangle bounds = uluaGetRectangle( L, 1 ); + int active = luaL_checkinteger( L, 3 ); + + int count = 0; + const char **text = TextSplit( luaL_checkstring( L, 2 ), ';', &count ); + + lua_pushinteger( L, GuiTabBar( bounds, text, count, &active ) ); + lua_pushinteger( L, active ); + + return 2; +} + +/* +> result, scroll, view = RL.GuiScrollPanel( Rectangle bounds, string text, Rectangle content, Vector2 scroll, Rectangle view ) Scroll Panel control -- Success return Rectangle, Vector2 +- Success return int, Vector2, Rectangle */ int lguiGuiScrollPanel( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); Rectangle content = uluaGetRectangle( L, 3 ); Vector2 scroll = uluaGetVector2( L, 4 ); + Rectangle view = uluaGetRectangle( L, 5 ); - uluaPushRectangle( L, GuiScrollPanel( bounds, luaL_checkstring( L, 2 ), content, &scroll ) ); + lua_pushinteger( L, GuiScrollPanel( bounds, luaL_checkstring( L, 2 ), content, &scroll, &view ) ); uluaPushVector2( L, scroll ); + uluaPushRectangle( L, view ); - return 2; + return 3; } /* @@ -252,160 +451,159 @@ int lguiGuiScrollPanel( lua_State *L ) { */ /* -> RL.GuiLabel( Rectangle bounds, string text ) +> result = RL.GuiLabel( Rectangle bounds, string text ) Label control, shows text + +- Success return int */ int lguiGuiLabel( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); - GuiLabel( bounds, luaL_checkstring( L, 2 ) ); + lua_pushinteger( L, GuiLabel( bounds, luaL_checkstring( L, 2 ) ) ); - return 0; + return 1; } /* -> clicked = RL.GuiButton( Rectangle bounds, string text ) +> result = RL.GuiButton( Rectangle bounds, string text ) Button control, returns true when clicked -- Success return boolean +- Success return int */ int lguiGuiButton( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); - lua_pushboolean( L, GuiButton( bounds, luaL_checkstring( L, 2 ) ) ); + lua_pushinteger( L, GuiButton( bounds, luaL_checkstring( L, 2 ) ) ); return 1; } /* -> clicked = RL.GuiLabelButton( Rectangle bounds, string text ) +> result = RL.GuiLabelButton( Rectangle bounds, string text ) Label button control, show true when clicked -- Success return boolean +- Success return int */ int lguiGuiLabelButton( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); - lua_pushboolean( L, GuiLabelButton( bounds, luaL_checkstring( L, 2 ) ) ); + lua_pushinteger( L, GuiLabelButton( bounds, luaL_checkstring( L, 2 ) ) ); return 1; } /* -> active = RL.GuiToggle( Rectangle bounds, string text, bool active ) +> result, active = RL.GuiToggle( Rectangle bounds, string text, bool active ) Toggle Button control, returns true when active -- Success return boolean +- Success return int, bool */ int lguiGuiToggle( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); - bool checked = uluaGetBoolean( L, 3 ); + bool active = uluaGetBoolean( L, 3 ); - lua_pushboolean( L, GuiToggle( bounds, luaL_checkstring( L, 2 ), checked ) ); + lua_pushinteger( L, GuiToggle( bounds, luaL_checkstring( L, 2 ), &active ) ); + lua_pushboolean( L, active ); - return 1; + return 2; } /* -> index = RL.GuiToggleGroup( Rectangle bounds, string text, int active ) +> result, active = RL.GuiToggleGroup( Rectangle bounds, string text, int active ) Toggle Group control, returns active toggle index -- Success return int +- Success return int, int */ int lguiGuiToggleGroup( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); int active = luaL_checkinteger( L, 3 ); - lua_pushinteger( L, GuiToggleGroup( bounds, luaL_checkstring( L, 2 ), active ) ); + lua_pushinteger( L, GuiToggleGroup( bounds, luaL_checkstring( L, 2 ), &active ) ); + lua_pushinteger( L, active ); - return 1; + return 2; } /* -> active = RL.GuiCheckBox( Rectangle bounds, string text, bool checked ) +> result, active = RL.GuiToggleSlider( Rectangle bounds, string text, int active ) -Check Box control, returns true when active +Toggle Slider control, returns true when clicked -- Success return boolean +- Success return int, int */ -int lguiGuiCheckBox( lua_State *L ) { +int lguiGuiToggleSlider( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); - bool checked = uluaGetBoolean( L, 3 ); + int active = luaL_checkinteger( L, 3 ); - lua_pushboolean( L, GuiCheckBox( bounds, luaL_checkstring( L, 2 ), checked ) ); + lua_pushinteger( L, GuiToggleSlider( bounds, luaL_checkstring( L, 2 ), &active ) ); + lua_pushinteger( L, active ); - return 1; + return 2; } /* -> active = RL.GuiComboBox( Rectangle bounds, string text, int active ) +> result, checked = RL.GuiCheckBox( Rectangle bounds, string text, bool checked ) -Combo Box control, returns selected item index +Check Box control, returns true when active -- Success return int +- Success return bool */ -int lguiGuiComboBox( lua_State *L ) { +int lguiGuiCheckBox( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); - int active = luaL_checkinteger( L, 3 ); + bool checked = uluaGetBoolean( L, 3 ); - lua_pushinteger( L, GuiComboBox( bounds, luaL_checkstring( L, 2 ), active ) ); + lua_pushinteger( L, GuiCheckBox( bounds, luaL_checkstring( L, 2 ), &checked ) ); + lua_pushboolean( L, checked ); - return 1; + return 2; } /* -> pressed, text = RL.GuiTextBox( Rectangle bounds, string text, int textSize, bool editMode ) +> result, active = RL.GuiComboBox( Rectangle bounds, string text, int active ) -Text Box control, updates input text +Combo Box control, returns selected item index -- Success return boolean, string +- Success return int, int */ -int lguiGuiTextBox( lua_State *L ) { +int lguiGuiComboBox( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); - int textSize = luaL_checkinteger( L, 3 ); - // char text[ STRING_LEN ] = { '\0' }; - char text[ textSize + 1 ]; - strcpy( text, luaL_checkstring( L, 2 ) ); - bool editMode = uluaGetBoolean( L, 4 ); + int active = luaL_checkinteger( L, 3 ); - lua_pushboolean( L, GuiTextBox( bounds, text, textSize, editMode ) ); - lua_pushstring( L, text ); + lua_pushinteger( L, GuiComboBox( bounds, luaL_checkstring( L, 2 ), &active ) ); + lua_pushinteger( L, active ); return 2; } /* -> pressed, text = RL.GuiTextBoxMulti( Rectangle bounds, string text, int textSize, bool editMode ) +> result, active = RL.GuiDropdownBox( Rectangle bounds, string text, int active, bool editMode ) -Text Box control with multiple lines +Dropdown Box control, returns selected item -- Success return boolean, string +- Success return int, int */ -int lguiGuiTextBoxMulti( lua_State *L ) { +int lguiGuiDropdownBox( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); - int textSize = luaL_checkinteger( L, 3 ); - // char text[ STRING_LEN ] = { '\0' }; - char text[ textSize + 1 ]; - strcpy( text, luaL_checkstring( L, 2 ) ); + int active = luaL_checkinteger( L, 3 ); bool editMode = uluaGetBoolean( L, 4 ); - lua_pushboolean( L, GuiTextBoxMulti( bounds, text, textSize, editMode ) ); - lua_pushstring( L, text ); + lua_pushinteger( L, GuiDropdownBox( bounds, luaL_checkstring( L, 2 ), &active, editMode ) ); + lua_pushinteger( L, active ); return 2; } /* -> pressed, value = RL.GuiSpinner( Rectangle bounds, string text, int value, int minValue, int maxValue, bool editMode ) +> result, value = RL.GuiSpinner( Rectangle bounds, string text, int value, int minValue, int maxValue, bool editMode ) Spinner control, returns selected value -- Success return boolean, int +- Success return int, int */ int lguiGuiSpinner( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); @@ -414,18 +612,18 @@ int lguiGuiSpinner( lua_State *L ) { int maxValue = luaL_checkinteger( L, 5 ); bool editMode = uluaGetBoolean( L, 6 ); - lua_pushboolean( L, GuiSpinner( bounds, luaL_checkstring( L, 2 ), &value, minValue, maxValue, editMode ) ); + lua_pushinteger( L, GuiSpinner( bounds, luaL_checkstring( L, 2 ), &value, minValue, maxValue, editMode ) ); lua_pushinteger( L, value ); return 2; } /* -> pressed, value = RL.GuiValueBox( Rectangle bounds, string text, int value, int minValue, int maxValue, bool editMode ) +> result, value = RL.GuiValueBox( Rectangle bounds, string text, int value, int minValue, int maxValue, bool editMode ) Value Box control, updates input text with numbers -- Success return boolean, int +- Success return int, int */ int lguiGuiValueBox( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); @@ -434,143 +632,136 @@ int lguiGuiValueBox( lua_State *L ) { int maxValue = luaL_checkinteger( L, 5 ); bool editMode = uluaGetBoolean( L, 6 ); - lua_pushboolean( L, GuiValueBox( bounds, luaL_checkstring( L, 2 ), &value, minValue, maxValue, editMode ) ); + lua_pushinteger( L, GuiValueBox( bounds, luaL_checkstring( L, 2 ), &value, minValue, maxValue, editMode ) ); lua_pushinteger( L, value ); return 2; } /* -> value = RL.GuiSlider( Rectangle bounds, string textLeft, string textRight, float value, float minValue, float maxValue ) +> result, text = RL.GuiTextBox( Rectangle bounds, string text, int textSize, bool editMode ) -Slider control, returns selected value +Text Box control, updates input text -- Success return float +- Success return int, string */ -int lguiGuiSlider( lua_State *L ) { +int lguiGuiTextBox( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); - float value = luaL_checknumber( L, 4 ); - float minValue = luaL_checknumber( L, 5 ); - float maxValue = luaL_checknumber( L, 6 ); + int textSize = luaL_checkinteger( L, 3 ); + char text[ textSize + 1 ]; + strcpy( text, luaL_checkstring( L, 2 ) ); + bool editMode = uluaGetBoolean( L, 4 ); - lua_pushnumber( L, GuiSlider( bounds, luaL_checkstring( L, 2 ), luaL_checkstring( L, 3 ), value, minValue, maxValue ) ); + lua_pushinteger( L, GuiTextBox( bounds, text, textSize, editMode ) ); + lua_pushstring( L, text ); - return 1; + return 2; } /* -> value = RL.GuiSliderBar( Rectangle bounds, string textLeft, string textRight, float value, float minValue, float maxValue ) +> result, value = RL.GuiSlider( Rectangle bounds, string textLeft, string textRight, float value, float minValue, float maxValue ) -Slider Bar control, returns selected value +Slider control, returns selected value -- Success return float +- Success return int, float */ -int lguiGuiSliderBar( lua_State *L ) { +int lguiGuiSlider( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); float value = luaL_checknumber( L, 4 ); float minValue = luaL_checknumber( L, 5 ); float maxValue = luaL_checknumber( L, 6 ); - lua_pushnumber( L, GuiSliderBar( bounds, luaL_checkstring( L, 2 ), luaL_checkstring( L, 3 ), value, minValue, maxValue ) ); + lua_pushinteger( L, GuiSlider( bounds, luaL_checkstring( L, 2 ), luaL_checkstring( L, 3 ), &value, minValue, maxValue ) ); + lua_pushnumber( L, value ); - return 1; + return 2; } /* -> value = RL.GuiProgressBar( Rectangle bounds, string textLeft, string textRight, float value, float minValue, float maxValue ) +> result, value = RL.GuiSliderBar( Rectangle bounds, string textLeft, string textRight, float value, float minValue, float maxValue ) -Progress Bar control, shows current progress value +Slider Bar control, returns selected value -- Success return float +- Success return int, float */ -int lguiGuiProgressBar( lua_State *L ) { +int lguiGuiSliderBar( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); float value = luaL_checknumber( L, 4 ); float minValue = luaL_checknumber( L, 5 ); float maxValue = luaL_checknumber( L, 6 ); - lua_pushnumber( L, GuiProgressBar( bounds, luaL_checkstring( L, 2 ), luaL_checkstring( L, 3 ), value, minValue, maxValue ) ); - - return 1; -} - -/* -> value = RL.GuiScrollBar( Rectangle bounds, int value, int minValue, int maxValue ) - -Scroll Bar control - -- Success return int -*/ -int lguiGuiScrollBar( lua_State *L ) { - Rectangle bounds = uluaGetRectangle( L, 1 ); - int value = luaL_checkinteger( L, 2 ); - int minValue = luaL_checkinteger( L, 3 ); - int maxValue = luaL_checkinteger( L, 4 ); - - lua_pushinteger( L, GuiScrollBar( bounds, value, minValue, maxValue ) ); + lua_pushinteger( L, GuiSliderBar( bounds, luaL_checkstring( L, 2 ), luaL_checkstring( L, 3 ), &value, minValue, maxValue ) ); + lua_pushnumber( L, value ); - return 1; + return 2; } /* -> pressed, item = RL.GuiDropdownBox( Rectangle bounds, string text, int active, bool editMode ) +> result, value = RL.GuiProgressBar( Rectangle bounds, string textLeft, string textRight, float value, float minValue, float maxValue ) -Dropdown Box control, returns selected item +Progress Bar control, shows current progress value -- Success return bool, int +- Success return int, float */ -int lguiGuiDropdownBox( lua_State *L ) { +int lguiGuiProgressBar( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); - int active = luaL_checkinteger( L, 3 ); - bool editMode = uluaGetBoolean( L, 4 ); + float value = luaL_checknumber( L, 4 ); + float minValue = luaL_checknumber( L, 5 ); + float maxValue = luaL_checknumber( L, 6 ); - lua_pushboolean( L, GuiDropdownBox( bounds, luaL_checkstring( L, 2 ), &active, editMode ) ); - lua_pushinteger( L, active ); + lua_pushinteger( L, GuiProgressBar( bounds, luaL_checkstring( L, 2 ), luaL_checkstring( L, 3 ), &value, minValue, maxValue ) ); + lua_pushnumber( L, value ); return 2; } /* -> RL.GuiStatusBar( Rectangle bounds, string text ) +> result = RL.GuiStatusBar( Rectangle bounds, string text ) Status Bar control, shows info text + +- Success return int */ int lguiGuiStatusBar( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); - GuiStatusBar( bounds, luaL_checkstring( L, 2 ) ); + lua_pushinteger( L, GuiStatusBar( bounds, luaL_checkstring( L, 2 ) ) ); - return 0; + return 1; } /* -> RL.GuiDummyRec( Rectangle bounds, string text ) +> result = RL.GuiDummyRec( Rectangle bounds, string text ) Dummy control for placeholders + +- Success return int */ int lguiGuiDummyRec( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); - GuiDummyRec( bounds, luaL_checkstring( L, 2 ) ); + lua_pushinteger( L, GuiDummyRec( bounds, luaL_checkstring( L, 2 ) ) ); - return 0; + return 1; } /* -> cell = RL.GuiGrid( Rectangle bounds, string text, float spacing, int subdivs ) +> result, mouseCell = RL.GuiGrid( Rectangle bounds, string text, float spacing, int subdivs, Vector2 mouseCell ) Grid control, returns mouse cell position -- Success return Vector2 +- Success return int, Vector2 */ int lguiGuiGrid( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); float spacing = luaL_checknumber( L, 3 ); int subdivs = luaL_checkinteger( L, 4 ); + Vector2 mouseCell = uluaGetVector2( L, 5 ); - uluaPushVector2( L, GuiGrid( bounds, luaL_checkstring( L, 2 ), spacing, subdivs ) ); + lua_pushinteger( L, GuiGrid( bounds, luaL_checkstring( L, 2 ), spacing, subdivs, &mouseCell ) ); + uluaPushVector2( L, mouseCell ); - return 1; + return 2; } /* @@ -578,49 +769,52 @@ int lguiGuiGrid( lua_State *L ) { */ /* -> itemIndex, scrollIndex = RL.GuiListView( Rectangle bounds, string text, int scrollIndex, int active ) +> result, scrollIndex, active = RL.GuiListView( Rectangle bounds, string text, int scrollIndex, int active ) -List View control, returns selected list item index and scroll index +List View control, returns selected list item index -- Success return int, int +- Success return int, int, int */ int lguiGuiListView( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); int scrollIndex = luaL_checkinteger( L, 3 ); int active = luaL_checkinteger( L, 4 ); - lua_pushinteger( L, GuiListView( bounds, luaL_checkstring( L, 2 ), &scrollIndex, active ) ); + lua_pushinteger( L, GuiListView( bounds, luaL_checkstring( L, 2 ), &scrollIndex, &active ) ); lua_pushinteger( L, scrollIndex ); + lua_pushinteger( L, active ); - return 2; + return 3; } /* -> itemIndex, scrollIndex, focus = RL.GuiListViewEx( Rectangle bounds, string text, int focus, int scrollIndex, int active ) +> result, scrollIndex, active, focus = RL.GuiListViewEx( Rectangle bounds, string text, int scrollIndex, int active, int focus ) -List View with extended parameters, returns selected list item index, scroll index and focus +List View with extended parameters -- Success return int, int, int +- Success return int, int, int, int */ int lguiGuiListViewEx( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); - int focus = luaL_checkinteger( L, 3 ); - int scrollIndex = luaL_checkinteger( L, 4 ); - int active = luaL_checkinteger( L, 5 ); + int scrollIndex = luaL_checkinteger( L, 3 ); + int active = luaL_checkinteger( L, 4 ); + int focus = luaL_checkinteger( L, 5 ); + int count = 0; - const char **text = GuiTextSplit( luaL_checkstring( L, 2 ), &count, NULL ); + const char **text = TextSplit( luaL_checkstring( L, 2 ), ';', &count ); - lua_pushinteger( L, GuiListViewEx( bounds, text, count, &focus, &scrollIndex, active ) ); + lua_pushinteger( L, GuiListViewEx( bounds, text, count, &scrollIndex, &active, &focus ) ); lua_pushinteger( L, scrollIndex ); + lua_pushinteger( L, active ); lua_pushinteger( L, focus ); - return 3; + return 4; } /* -> buttonIndex = RL.GuiMessageBox( Rectangle bounds, string title, string message, string buttons ) +> result = RL.GuiMessageBox( Rectangle bounds, string title, string message, string buttons ) -Message Box control, displays a message, returns button index (0 is x button) +Message Box control, displays a message - Success return int */ @@ -633,219 +827,127 @@ int lguiGuiMessageBox( lua_State *L ) { } /* -> buttonIndex, text, secretViewActive = RL.GuiTextInputBox( Rectangle bounds, string title, string message, string buttons, string text, int textMaxSize, int secretViewActive ) +> result, text, secretViewActive = RL.GuiTextInputBox( Rectangle bounds, string title, string message, string buttons, string text, int textMaxSize, bool secretViewActive ) Text Input Box control, ask for text, supports secret -- Success return int, string, int +- Success return int, string, bool */ int lguiGuiTextInputBox( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); + const char *title = luaL_checkstring( L, 2 ); + const char *message = luaL_checkstring( L, 3 ); + const char *buttons = luaL_checkstring( L, 4 ); int textMaxSize = luaL_checkinteger( L, 6 ); - int secretViewActive = luaL_checkinteger( L, 7 ); + bool secretViewActive = uluaGetBoolean( L, 7 ); char text[ textMaxSize + 1 ]; strcpy( text, luaL_checkstring( L, 5 ) ); - lua_pushinteger( L, GuiTextInputBox( bounds, luaL_checkstring( L, 2 ), luaL_checkstring( L, 3 ), luaL_checkstring( L, 4 ), text, textMaxSize, &secretViewActive ) ); + lua_pushinteger( L, GuiTextInputBox( bounds, title, message, buttons, text, textMaxSize, &secretViewActive ) ); lua_pushstring( L, text ); - lua_pushinteger( L, secretViewActive ); + lua_pushboolean( L, secretViewActive ); return 3; } /* -> color = RL.GuiColorPicker( Rectangle bounds, string text, Color color ) +> result, color = RL.GuiColorPicker( Rectangle bounds, string text, Color color ) Color Picker control (multiple color controls) -- Success return Color +- Success return int, Color */ int lguiGuiColorPicker( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); Color color = uluaGetColor( L, 3 ); - uluaPushColor( L, GuiColorPicker( bounds, luaL_checkstring( L, 2 ), color ) ); + lua_pushinteger( L, GuiColorPicker( bounds, luaL_checkstring( L, 2 ), &color ) ); + uluaPushColor( L, color ); - return 1; + return 2; } /* -> color = RL.GuiColorPanel( Rectangle bounds, string text, Color color ) +> result, color = RL.GuiColorPanel( Rectangle bounds, string text, Color color ) Color Panel control -- Success return Color +- Success return int, Color */ int lguiGuiColorPanel( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); Color color = uluaGetColor( L, 3 ); - uluaPushColor( L, GuiColorPanel( bounds, luaL_checkstring( L, 2 ), color ) ); + lua_pushinteger( L, GuiColorPanel( bounds, luaL_checkstring( L, 2 ), &color ) ); + uluaPushColor( L, color ); - return 1; + return 2; } /* -> alpha = RL.GuiColorBarAlpha( Rectangle bounds, string text, float alpha ) +> result, alpha = RL.GuiColorBarAlpha( Rectangle bounds, string text, float alpha ) Color Bar Alpha control -- Success return float +- Success return int, float */ int lguiGuiColorBarAlpha( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); float alpha = luaL_checknumber( L, 3 ); - lua_pushnumber( L, GuiColorBarAlpha( bounds, luaL_checkstring( L, 2 ), alpha ) ); + lua_pushinteger( L, GuiColorBarAlpha( bounds, luaL_checkstring( L, 2 ), &alpha ) ); + lua_pushnumber( L, alpha ); - return 1; + return 2; } /* -> hue = RL.GuiColorBarHue( Rectangle bounds, string text, float value ) +> result, value = RL.GuiColorBarHue( Rectangle bounds, string text, float value ) Color Bar Hue control -- Success return float +- Success return int, float */ int lguiGuiColorBarHue( lua_State *L ) { Rectangle bounds = uluaGetRectangle( L, 1 ); float value = luaL_checknumber( L, 3 ); - lua_pushnumber( L, GuiColorBarHue( bounds, luaL_checkstring( L, 2 ), value ) ); - - return 1; -} - -/* -## Gui - Styles loading functions -*/ + lua_pushinteger( L, GuiColorBarHue( bounds, luaL_checkstring( L, 2 ), &value ) ); + lua_pushnumber( L, value ); -/* -> success = RL.GuiLoadStyle( string fileName ) - -Load style file over global style variable (.rgs) - -- Failure return false -- Success return true -*/ -int lguiGuiLoadStyle( lua_State *L ) { - if ( FileExists( luaL_checkstring( L, 1 ) ) ) { - GuiLoadStyle( lua_tostring( L, 1 ) ); - lua_pushboolean( L, true ); - - return 1; - } - TraceLog( state->logLevelInvalid, "Invalid file '%s'", lua_tostring( L, 1 ) ); - lua_pushboolean( L, false ); - - return 1; -} - -/* -> RL.GuiLoadStyleDefault() - -Load style default over global style -*/ -int lguiGuiLoadStyleDefault( lua_State *L ) { - GuiLoadStyleDefault(); - - return 0; -} - -/* -## Gui - Icons functionality -*/ - -/* -> text = RL.GuiIconText( int iconId, string text ) - -Get text with icon id prepended (if supported) - -- Success return string -*/ -int lguiGuiIconText( lua_State *L ) { - int iconId = luaL_checkinteger( L, 1 ); - - if ( TextIsEqual( luaL_checkstring( L, 2 ), "" ) ) { - lua_pushstring( L, GuiIconText( iconId, NULL ) ); - } - else { - lua_pushstring( L, GuiIconText( iconId, luaL_checkstring( L, 2 ) ) ); - } - - return 1; -} - -/* -> RL.GuiDrawIcon( int iconId, Vector2 pos, int pixelSize, Color color ) - -Draw icon -*/ -int lguiGuiDrawIcon( lua_State *L ) { - int iconId = luaL_checkinteger( L, 1 ); - Vector2 pos = uluaGetVector2( L, 2 ); - int pixelSize = luaL_checkinteger( L, 3 ); - Color color = uluaGetColor( L, 4 ); - - GuiDrawIcon( iconId, pos.x, pos.y, pixelSize, color ); - - return 0; -} - -/* -> RL.GuiSetIconScale( int scale ) - -Set icon scale (1 by default) -*/ -int lguiGuiSetIconScale( lua_State *L ) { - unsigned int scale = luaL_checkinteger( L, 1 ); - - GuiSetIconScale( scale ); - - return 0; + return 2; } /* -> RL.GuiSetIconPixel( int iconId, Vector2 pos ) +> result, colorHsv = RL.GuiColorPickerHSV( Rectangle bounds, string text, Vector3 colorHsv ) -Set icon pixel value -*/ -int lguiGuiSetIconPixel( lua_State *L ) { - int iconId = luaL_checkinteger( L, 1 ); - Vector2 pos = uluaGetVector2( L, 2 ); - - GuiSetIconPixel( iconId, pos.x, pos.y ); - - return 0; -} +Color Picker control that avoids conversion to RGB on each call (multiple color controls) -/* -> RL.GuiClearIconPixel( int iconId, Vector2 pos ) - -Clear icon pixel value +- Success return int, Vector3 */ -int lguiGuiClearIconPixel( lua_State *L ) { - int iconId = luaL_checkinteger( L, 1 ); - Vector2 pos = uluaGetVector2( L, 2 ); +int lguiGuiColorPickerHSV( lua_State *L ) { + Rectangle bounds = uluaGetRectangle( L, 1 ); + Vector3 colorHsv = uluaGetVector3( L, 3 ); - GuiClearIconPixel( iconId, pos.x, pos.y ); + lua_pushinteger( L, GuiColorPickerHSV( bounds, luaL_checkstring( L, 2 ), &colorHsv ) ); + uluaPushVector3( L, colorHsv ); - return 0; + return 2; } /* -> value = RL.GuiCheckIconPixel( int iconId, Vector2 pos ) +> result, colorHsv = RL.GuiColorPanelHSV( Rectangle bounds, string text, Vector3 colorHsv ) -Check icon pixel value +Color Panel control that returns HSV color value, used by GuiColorPickerHSV() -- Success return bool +- Success return int, Vector3 */ -int lguiGuiCheckIconPixel( lua_State *L ) { - int iconId = luaL_checkinteger( L, 1 ); - Vector2 pos = uluaGetVector2( L, 2 ); +int lguiGuiColorPanelHSV( lua_State *L ) { + Rectangle bounds = uluaGetRectangle( L, 1 ); + Vector3 colorHsv = uluaGetVector3( L, 3 ); - lua_pushboolean( L, GuiCheckIconPixel( iconId, pos.x, pos.y ) ); + lua_pushinteger( L, GuiColorPanelHSV( bounds, luaL_checkstring( L, 2 ), &colorHsv ) ); + uluaPushVector3( L, colorHsv ); - return 1; + return 2; } |
