Raygui lib examples file browser.

This commit is contained in:
jussi
2024-03-29 20:51:43 +02:00
parent 523351609a
commit b96960a1f9
13 changed files with 517 additions and 50 deletions

6
API.md
View File

@@ -3990,7 +3990,7 @@ End scissor mode
--- ---
> shader = RL.LoadShader( string vsFileName, string fsFileName ) > shader = RL.LoadShader( string|nil vsFileName, string|nil fsFileName )
Load shader from files and bind default locations. Load shader from files and bind default locations.
NOTE: Set nil if no shader NOTE: Set nil if no shader
@@ -4000,7 +4000,7 @@ NOTE: Set nil if no shader
--- ---
> shader = RL.LoadShaderFromMemory( string vsCode, string fsCode ) > shader = RL.LoadShaderFromMemory( string|nil vsCode, string|nil fsCode )
Load shader from code strings and bind default locations Load shader from code strings and bind default locations
NOTE: Set nil if no shader NOTE: Set nil if no shader
@@ -4444,7 +4444,7 @@ Load directory filepaths
--- ---
> fileNames = RL.LoadDirectoryFilesEx( string basePath, string filter, bool scanSubdirs ) > fileNames = RL.LoadDirectoryFilesEx( string basePath, string|nil filter, bool scanSubdirs )
Load directory filepaths with extension filtering and recursive directory scan Load directory filepaths with extension filtering and recursive directory scan

View File

@@ -1552,8 +1552,8 @@ function RL.EndScissorMode() end
---NOTE: Set nil if no shader ---NOTE: Set nil if no shader
---- Failure return nil ---- Failure return nil
---- Success return Shader ---- Success return Shader
---@param vsFileName string ---@param vsFileName string|nil
---@param fsFileName string ---@param fsFileName string|nil
---@return any shader ---@return any shader
function RL.LoadShader( vsFileName, fsFileName ) end function RL.LoadShader( vsFileName, fsFileName ) end
@@ -1561,8 +1561,8 @@ function RL.LoadShader( vsFileName, fsFileName ) end
---NOTE: Set nil if no shader ---NOTE: Set nil if no shader
---- Failure return nil ---- Failure return nil
---- Success return Shader ---- Success return Shader
---@param vsCode string ---@param vsCode string|nil
---@param fsCode string ---@param fsCode string|nil
---@return any shader ---@return any shader
function RL.LoadShaderFromMemory( vsCode, fsCode ) end function RL.LoadShaderFromMemory( vsCode, fsCode ) end
@@ -1917,7 +1917,7 @@ function RL.LoadDirectoryFiles( dirPath ) end
---Load directory filepaths with extension filtering and recursive directory scan ---Load directory filepaths with extension filtering and recursive directory scan
---- Success return string{} ---- Success return string{}
---@param basePath string ---@param basePath string
---@param filter string ---@param filter string|nil
---@param scanSubdirs boolean ---@param scanSubdirs boolean
---@return any fileNames ---@return any fileNames
function RL.LoadDirectoryFilesEx( basePath, filter, scanSubdirs ) end function RL.LoadDirectoryFilesEx( basePath, filter, scanSubdirs ) end
@@ -1982,7 +1982,7 @@ function RL.DecodeDataBase64( data ) end
---Load automation events list from file, nil for empty list, capacity = MAX_AUTOMATION_EVENTS ---Load automation events list from file, nil for empty list, capacity = MAX_AUTOMATION_EVENTS
---- Success return AutomationEventList ---- Success return AutomationEventList
---@param fileName any ---@param fileName string|nil
---@return any eventList ---@return any eventList
function RL.LoadAutomationEventList( fileName ) end function RL.LoadAutomationEventList( fileName ) end

View File

@@ -36,6 +36,7 @@ DETAILED CHANGES:
- ADDED: Round. - ADDED: Round.
- ADDED: PubSub lib. - ADDED: PubSub lib.
- ADDED: Raygui lib tree view. - ADDED: Raygui lib tree view.
- ADDED: Raygui lib examples file browser.
------------------------------------------------------------------------ ------------------------------------------------------------------------
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

View File

@@ -2,8 +2,6 @@ Current {
} }
Backlog { Backlog {
* Raygui
* File browser.
* Raygui lib * Raygui lib
* Check if could remove flickering from changing draw order by making queue for order * Check if could remove flickering from changing draw order by making queue for order
changing and only change them after everything is drawn. changing and only change them after everything is drawn.

View File

@@ -33,13 +33,28 @@ local function getParamType( param )
elseif param == "int" then return "integer" elseif param == "int" then return "integer"
elseif param == "string" then return "string" elseif param == "string" then return "string"
elseif param == "bool" then return "boolean" elseif param == "bool" then return "boolean"
elseif param == "bool" then return "boolean" elseif param == "nil" then return "nil"
elseif param:sub( #param - 1, #param ) == "{}" then return "table" elseif param:sub( #param - 1, #param ) == "{}" then return "table"
else else
return "any" return "any"
end end
end end
local function getParam( param )
local text = ""
local params = split( param, "|" )
for i, p in ipairs( params ) do
text = text..getParamType( p )
if i < #params then
text = text.."|"
end
end
return text
end
local function parseFunction( line ) local function parseFunction( line )
local splitted = split( line, "(" ) local splitted = split( line, "(" )
local parString = splitted[2]:sub(2) local parString = splitted[2]:sub(2)
@@ -52,7 +67,8 @@ local function parseFunction( line )
local sepPar = split( par, " " ) local sepPar = split( par, " " )
parStr = parStr..sepPar[2] parStr = parStr..sepPar[2]
str = str.."---@param "..sepPar[2].." " str = str.."---@param "..sepPar[2].." "
str = str..getParamType( sepPar[1] ).."\n" -- str = str..getParamType( sepPar[1] ).."\n"
str = str..getParam( sepPar[1] ).."\n"
if i < #parameters then if i < #parameters then
parStr = parStr..", " parStr = parStr..", "

View File

@@ -1,5 +1,3 @@
-- Pong example using Vector2 library.
package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua" package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua"
Vec2 = require "vector2" Vec2 = require "vector2"
@@ -9,8 +7,8 @@ local winSize = Vec2:new( 800, 600 )
local monitor = 0 local monitor = 0
-- Constants. -- Constants.
local PLAYER_SPEED = 300 local PLAYER_SPEED = 300 -- Pixels per second.
local BALL_SPEED = 330 local BALL_SPEED = 330 -- Pixels per second.
-- Game objects. -- Game objects.
local playerLeft = { local playerLeft = {
@@ -42,7 +40,7 @@ local function reset()
-- Short for if math random result 1, set BALL_SPEED otherwise set -BALL_SPEED. -- Short for if math random result 1, set BALL_SPEED otherwise set -BALL_SPEED.
-- Could be replaced by normal if statement for easier readability. -- Could be replaced by normal if statement for easier readability.
ball.vel.x = math.random( 0, 1 ) == 1 and BALL_SPEED or -BALL_SPEED ball.vel.x = math.random( 0, 1 ) == 1 and BALL_SPEED or -BALL_SPEED
-- Start slow. -- Start easy.
ball.vel.y = 0 ball.vel.y = 0
end end

View File

@@ -19,7 +19,7 @@ function Calculator:new( pos )
{ -- Callbacks. { -- Callbacks.
close = function() object:setVisible( false ) end, close = function() object:setVisible( false ) end,
grab = function() object:set2Top() end, grab = function() object:set2Top() end,
drag = function( self ) object:setPosition( Vec2:new( self.bounds.x, self.bounds.y ) ) end drag = function( this ) object:setPosition( Vec2:new( this.bounds.x, this.bounds.y ) ) end
} }
) )
object.display = Gui:Label( object.display = Gui:Label(

View File

@@ -0,0 +1,380 @@
local FileBrowser = {}
FileBrowser.__index = FileBrowser
FileBrowser.MODES = {
OPEN = 1,
SAVE = 2,
}
FileBrowser.FILE_ICONS = {
DIR = 1,
FILE = 10,
[".wav"] = 11,
[".mp3"] = 11,
[".ogg"] = 11,
[".mid"] = 11,
[".png"] = 12,
[".jpg"] = 12,
[".jpeg"] = 12,
[".avi"] = 13,
[".mov"] = 13,
[".mp4"] = 13,
[".exe"] = 142,
}
function FileBrowser:new( pos )
local object = setmetatable( {}, FileBrowser )
object.padding = 4
object.spacing = 4
object.controls = {}
object.callbacks = {} -- open.
local winSize = Vec2:new( 600, 490 )
local iconButtonSize = Vec2:new( 28, 28 )
local textButtonSize = Vec2:new( 72, 28 )
-- Window.
object.window = Gui:WindowBox(
Rect:new( pos.x, pos.y, winSize.x, winSize.y ),
"File Browser",
{ -- callbacks.
close = function() object:setVisible( false ) end,
grab = function() object:set2Top() end,
drag = function( this ) object:setPosition( Vec2:new( this.bounds.x, this.bounds.y ) ) end
}
)
-- Ok button.
object.okButton = Gui:Button(
Rect:new( 0, 0, textButtonSize.x, textButtonSize.y ),
"Open",
{ -- callbacks.
pressed = function() object:ok() end
}
)
object.okButton.position = Vec2:new(
winSize.x - textButtonSize.x - object.padding,
winSize.y - textButtonSize.y - object.padding
)
-- Filter dropdown.
object.filterDropdown = Gui:DropdownBox(
Rect:new( 0, 0, textButtonSize.x, textButtonSize.y ),
"All\n.png\n.lua\n.wav\n.ogg\n.txt",
0, -- active.
false, -- editMode.
{ -- callbacks.
select = function() object:setFilter() end
},
{ -- styles.
properties = {
{ RL.DROPDOWNBOX, RL.TEXT_ALIGNMENT, RL.TEXT_ALIGN_LEFT },
{ RL.DROPDOWNBOX, RL.TEXT_PADDING, 8 },
}
}
)
object.filterDropdown.position = Vec2:new(
winSize.x - textButtonSize.x * 2 - object.padding * 2,
winSize.y - textButtonSize.y - object.padding
)
-- Back button.
object.backButton = Gui:Button(
Rect:new( 0, 0, iconButtonSize.x, iconButtonSize.y ),
RL.GuiIconText( 118, "" ),
{ -- callbacks.
pressed = function() object:back() end
}
)
object.backButton.position = Vec2:new(
winSize.x - iconButtonSize.x - object.padding,
Gui.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT + object.padding
)
-- Search button.
object.searchToggle = Gui:Toggle(
Rect:new( 0, 0, iconButtonSize.x, iconButtonSize.y ),
RL.GuiIconText( 42, "" ),
false, -- active.
{ -- callbacks.
pressed = function( this ) object:searchPressed( this.active ) end
}
)
object.searchToggle.position = Vec2:new(
winSize.x - iconButtonSize.x * 2 - object.padding * 2,
Gui.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT + object.padding
)
-- Path text box.
object.pathBox = Gui:TextBox(
Rect:new( 0, 0, winSize.x - iconButtonSize.x * 2 - object.padding * 4, iconButtonSize.y ),
"",
256,
false,
{ -- callbacks.
-- edit = function() object:editPathCallback() end,
textEdit = function() object:editPathCallback() end
}
)
object.pathBox.position = Vec2:new(
object.padding,
Gui.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT + object.padding
)
-- File text box.
object.fileBox = Gui:TextBox(
Rect:new( 0, 0, winSize.x - textButtonSize.x * 2 - object.padding * 4, iconButtonSize.y ),
"",
256,
false,
{ -- callbacks.
-- edit = function() object:checkPath() end
}
)
object.fileBox.position = Vec2:new(
object.padding,
winSize.y - object.okButton.bounds.height - object.padding
)
-- File List.
object.list = Gui:ListView(
Rect:new( 0, 0,
winSize.x - object.padding * 2,
winSize.y - Gui.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT - textButtonSize.y
- object.pathBox.bounds.height - object.padding * 3 - object.spacing
),
"",
0, -- scrollIndex.
0, -- active.
{ -- callbacks.
select = function() object:select() end
},
{ -- styles
properties = {
{ RL.LISTVIEW, RL.TEXT_ALIGNMENT, RL.TEXT_ALIGN_LEFT }
}
}
)
object.list.position = Vec2:new(
object.padding,
object.pathBox.position.y + object.pathBox.bounds.height + object.padding
)
table.insert( object.controls, object.okButton )
table.insert( object.controls, object.filterDropdown )
table.insert( object.controls, object.backButton )
table.insert( object.controls, object.searchToggle )
table.insert( object.controls, object.list )
table.insert( object.controls, object.pathBox )
table.insert( object.controls, object.fileBox )
object.filter = nil
object.path = ""
object.file = ""
object.searchText = ""
object.files = {}
object.lastActive = 0
object.mode = self.MODES.OPEN
object:setPosition( pos )
object:setVisible( false )
return object
end
function FileBrowser:popup( mode, path, callback )
self:setPath( path )
self.mode = mode
if self.mode == self.MODES.OPEN then
self.okButton.text = "Open"
self.callbacks.ok = callback
end
self:setVisible( true )
end
function FileBrowser:editPathCallback()
if self.searchToggle.active then
self.searchText = self.pathBox.text
self:updateList()
else
self:checkPath()
end
end
function FileBrowser:checkPath()
local path = self.pathBox.text
self.searchToggle.active = false
self.searchText = ""
if RL.FileExists( path ) and not RL.IsPathFile( path ) then
self:setPath( path )
end
end
function FileBrowser:back()
if self.searchToggle.active then
return
end
for i = #self.pathBox.text, 1, -1 do
if self.pathBox.text:sub( i, i ) == "/" and i < #self.pathBox.text then
self.pathBox.text = self.pathBox.text:sub( 1, math.max( 1, i - 1 ) )
self:checkPath()
return
end
end
end
function FileBrowser:setPath( path )
if path:sub( 1, 2 ) == "//" then
path = path:sub( 2 )
end
self.lastActive = 0
self.list.active = -1
self.pathBox.text = path
self.path = path
self:updateList()
end
function FileBrowser:updateList()
self.list.text = ""
self.files = {}
local files = RL.LoadDirectoryFilesEx( self.path, self.filter, false )
table.sort( files, function( a, b ) return a < b end )
for i = #files, 1, -1 do
local filePath = files[i]
-- Don't add unix hidden files.
if RL.GetFileName( filePath ):sub( 1, 1 ) ~= "." then
local record = {
path = filePath,
name = RL.GetFileName( filePath ),
isFile = RL.IsPathFile( filePath ),
sortValue = i
}
if record.isFile then
record.sortValue = record.sortValue + #files
end
-- Search.
if self.searchText == "" or ( 0 < #self.searchText
and self.searchText:lower() == record.name:sub( 1, #self.searchText ):lower() ) then
table.insert( self.files, record )
end
end
end
table.sort( self.files, function( a, b ) return a.sortValue < b.sortValue end )
for i, file in ipairs( self.files ) do
local icon = self.FILE_ICONS.DIR
if file.isFile then
local ext = RL.GetFileExtension( file.name )
if self.FILE_ICONS[ ext ] ~= nil then
icon = self.FILE_ICONS[ ext ]
else
icon = self.FILE_ICONS.FILE
end
end
self.list.text = self.list.text..RL.GuiIconText( icon, file.name )
if i < #self.files then
self.list.text = self.list.text.."\n"
end
end
end
function FileBrowser:select()
local index = self.list.active + 1
local lastFile = self.files[ self.lastActive ]
if 0 < index then
self.file = self.files[ index ].path
self.fileBox.text = self.files[ index ].name
elseif lastFile ~= nil then
-- Trigger if active pressed again, so index would be 0.
if index == 0 then
if RL.IsPathFile( lastFile.path ) then
self:ok()
else
self.pathBox.text = lastFile.path
self:checkPath()
end
end
end
self.lastActive = index
end
function FileBrowser:ok()
if self.mode == self.MODES.OPEN then
if RL.IsPathFile( self.file ) then
if self.callbacks.ok ~= nil then
self.callbacks.ok( self.file )
end
else
self.pathBox.text = self.file
self:checkPath()
end
end
end
function FileBrowser:searchPressed( active )
if active then
self.pathBox.text = self.searchText
self.pathBox.active = true
Gui:editMode( self.pathBox ) -- Would not call edit callback if had one.
self.pathBox.editMode = true
else
self.searchText = ""
self.pathBox.text = self.path
self:checkPath()
end
end
function FileBrowser:setFilter()
if self.filterDropdown.active == 0 then
self.filter = nil
else
self.filter = self.filterDropdown:getItem( self.filterDropdown.active )
end
self:updateList()
print( "self.filter", self.filter )
end
function FileBrowser:setPosition( pos )
for _, control in ipairs( self.controls ) do
control:setPosition( pos + control.position )
end
end
function FileBrowser:set2Top()
Gui:set2Top( self.window )
for _, control in ipairs( self.controls ) do
Gui:set2Top( control )
end
end
function FileBrowser:setVisible( visible )
self.visible = visible
self.window.visible = visible
for _, control in ipairs( self.controls ) do
control.visible = visible
end
end
return FileBrowser

View File

@@ -1,18 +1,28 @@
package.path = package.path..";"..RL.GetBasePath().."?.lua" package.path = package.path..";"..RL.GetBasePath().."?.lua"
package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua" package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua"
Util = require( "utillib" ) Util = require( "utillib" )
Rect = require( "rectangle" ) Rect = require( "rectangle" )
Vec2 = require( "vector2" ) Vec2 = require( "vector2" )
Color = require( "color" ) Color = require( "color" )
Raygui = require( "raygui" ) Raygui = require( "raygui" )
Calculator = require( "calculator" ) Calculator = require( "calculator" )
FileBrowser = require( "file_browser" )
Gui = Raygui:new() Gui = Raygui:new()
local showAllButton = nil
local calculator = nil local calculator = nil
local calculator2 = nil local fileBrowser = nil
local function loadFile( path )
print( "Load file: "..path )
end
local function showAll()
calculator:setVisible( true )
fileBrowser:setVisible( true )
end
function RL.init() function RL.init()
local monitor = 0 local monitor = 0
@@ -29,8 +39,22 @@ function RL.init()
RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SIZE, 20 ) RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SIZE, 20 )
RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SPACING, 4 ) RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SPACING, 4 )
RL.GuiLoadStyle( RL.GetBasePath().."../resources/styles/style_dark.rgs" )
showAllButton = Gui:Button(
Rect:new( 0, 0, 108, 28 ),
"Show All",
{ -- callbacks.
pressed = function() showAll() end
}
)
calculator = Calculator:new( Vec2:new( 32, 32 ) ) calculator = Calculator:new( Vec2:new( 32, 32 ) )
calculator2 = Calculator:new( Vec2:new( 64, 65 ) ) fileBrowser = FileBrowser:new(
Vec2:new( 250, 100 )
)
fileBrowser:popup( fileBrowser.MODES.OPEN, RL.GetBasePath(), loadFile )
end end
function RL.update( delta ) function RL.update( delta )

View File

@@ -27,6 +27,7 @@ function PropertyList:new( bounds, text, callbacks, styles, tooltip )
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.draggable = true object.draggable = true
object.defaultControlHeight = 22
object.mouseScale = 1 -- Set this if drawing in different size to render texture for example. object.mouseScale = 1 -- Set this if drawing in different size to render texture for example.
object:setSize( Vec2:new( object.bounds.width, object.bounds.height ) ) object:setSize( Vec2:new( object.bounds.width, object.bounds.height ) )
@@ -143,7 +144,7 @@ function PropertyList:addGroup( name, active, group )
}, },
{ -- Styles. { -- Styles.
properties = { properties = {
{ RL.TOGGLE, RL.TEXT_ALIGNMENT, RL.TEXT_ALIGN_LEFT } { RL.TOGGLE, RL.TEXT_ALIGNMENT, RL.TEXT_ALIGN_LEFT },
} }
} }
) )
@@ -233,7 +234,7 @@ function PropertyList:setSize( size )
self.bounds.width - scrollBarWidth - self.padding * 2 - borderWidth * 2, self.bounds.width - scrollBarWidth - self.padding * 2 - borderWidth * 2,
self.bounds.height - scrollBarWidth - self.padding * 2 - borderWidth * 2 self.bounds.height - scrollBarWidth - self.padding * 2 - borderWidth * 2
) )
self.defaultControlSize = Vec2:new( self.content.width, 22 ) self.defaultControlSize = Vec2:new( self.content.width, self.defaultControlHeight )
local _, _, view = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll, self.view ) local _, _, view = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll, self.view )
self.view = Rect:new( view ) self.view = Rect:new( view )

View File

@@ -39,8 +39,9 @@ function TreeView:new( bounds, text, callbacks, styles, tooltip )
object.draggable = true object.draggable = true
object.allowMove = true object.allowMove = true
object.allowMultiselect = true object.allowMultiselect = true
object.defaultControlHeight = 22
object.mouseScale = 1 -- Set this if drawing in different size to render texture for example. object.mouseScale = 1 -- Set this if drawing in different size to render texture for example.
object.selectedItems = {} object.selectedItems = {}
object:setSize( Vec2:new( object.bounds.width, object.bounds.height ) ) object:setSize( Vec2:new( object.bounds.width, object.bounds.height ) )
@@ -161,14 +162,12 @@ function TreeView:checkItem( controls, item, mode )
if 0 < #control.controls then if 0 < #control.controls then
self:checkItem( control.controls, item, mode ) self:checkItem( control.controls, item, mode )
end end
if mode == self.RANGE_SELECT then if mode == self.RANGE_SELECT and control.visible
if self._idRange[1] <= control._id and control._id <= self._idRange[2] then and self._idRange[1] <= control._id and control._id <= self._idRange[2] then
control.active = true control.active = true
end end
end
if control.active then if control.active then
table.insert( self.selectedItems, control ) table.insert( self.selectedItems, control )
-- table.insert( self.selectedItems, 1, control )
end end
end end
end end
@@ -384,7 +383,7 @@ function TreeView:setSize( size )
self.bounds.width - scrollBarWidth - self.padding * 2 - borderWidth * 2, self.bounds.width - scrollBarWidth - self.padding * 2 - borderWidth * 2,
self.bounds.height - scrollBarWidth - self.padding * 2 - borderWidth * 2 self.bounds.height - scrollBarWidth - self.padding * 2 - borderWidth * 2
) )
self.defaultControlSize = Vec2:new( self.content.width, 22 ) self.defaultControlSize = Vec2:new( self.content.width, self.defaultControlHeight )
local _, _, view = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll, self.view ) local _, _, view = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll, self.view )
self.view = Rect:new( view ) self.view = Rect:new( view )

View File

@@ -787,7 +787,7 @@ function Spinner:draw()
self._viewBoundsOffset:set( self.viewBounds.x - self.bounds.x, self.viewBounds.y - self.bounds.y ) self._viewBoundsOffset:set( self.viewBounds.x - self.bounds.x, self.viewBounds.y - self.bounds.y )
if result == 1 then if result == 1 then
self._gui:editMode( self.editMode ) self._gui:editMode( self )
self.editMode = not self.editMode self.editMode = not self.editMode
end end
if self.value ~= oldValue then if self.value ~= oldValue then
@@ -858,7 +858,7 @@ function ValueBox:draw()
self._viewBoundsOffset:set( self.viewBounds.x - self.bounds.x, self.viewBounds.y - self.bounds.y ) self._viewBoundsOffset:set( self.viewBounds.x - self.bounds.x, self.viewBounds.y - self.bounds.y )
if result == 1 then if result == 1 then
self._gui:editMode( self.editMode ) self._gui:editMode( self )
self.editMode = not self.editMode self.editMode = not self.editMode
end end
if self.value ~= oldValue and self.callbacks.edit ~= nil then if self.value ~= oldValue and self.callbacks.edit ~= nil then
@@ -915,7 +915,7 @@ function TextBox:draw()
RL.EndScissorMode() RL.EndScissorMode()
end end
if result == 1 then if result == 1 then
self._gui:editMode( self.editMode ) self._gui:editMode( self )
self.editMode = not self.editMode self.editMode = not self.editMode
if not self.editMode and self.callbacks.edit ~= nil then if not self.editMode and self.callbacks.edit ~= nil then
@@ -1721,6 +1721,7 @@ function Raygui:new()
object.grabPos = Vec2:new() object.grabPos = Vec2:new()
object.scrolling = false object.scrolling = false
object.textEdit = false object.textEdit = false
object.textEditControl = nil
object.defaultTexture = RL.GetTextureDefault() object.defaultTexture = RL.GetTextureDefault()
object.defaultRect = Rect:new( 0, 0, 1, 1 ) -- For texture. object.defaultRect = Rect:new( 0, 0, 1, 1 ) -- For texture.
object.defaultFont = RL.GuiGetFont() object.defaultFont = RL.GuiGetFont()
@@ -1874,6 +1875,13 @@ function Raygui:draw()
self.scrolling = false self.scrolling = false
end end
end end
local oldTextEditText = "" -- For checking if text has changed so we can call input callback.
if self.textEdit then
oldTextEditText = self.textEditControl.text
end
-- Set mouse offset if gui is for example embedded to some control. -- Set mouse offset if gui is for example embedded to some control.
RL.SetMouseOffset( self.mouseOffset ) RL.SetMouseOffset( self.mouseOffset )
@@ -1897,6 +1905,9 @@ function Raygui:draw()
and self.tooltip.delay <= self.tooltip.timer then and self.tooltip.delay <= self.tooltip.timer then
self:drawTooltip() self:drawTooltip()
end end
if self.textEdit and oldTextEditText ~= self.textEditControl.text and self.textEditControl.callbacks.textEdit ~= nil then
self.textEditControl.callbacks.textEdit( self.textEditControl )
end
RL.GuiUnlock() RL.GuiUnlock()
RL.GuiEnable() RL.GuiEnable()
@@ -1944,19 +1955,21 @@ function Raygui:remove( control )
end end
end end
function Raygui:editMode( editMode ) function Raygui:editMode( control )
if not editMode then if self.textEditControl ~= nil and not control.editMode then
for _, control in ipairs( self.controls ) do self.textEditControl.editMode = false
if control.editMode then
control.editMode = false
if control.callbacks.edit ~= nil then if self.textEditControl.callbacks.edit ~= nil then
control.callbacks.edit( control ) self.textEditControl.callbacks.edit( self.textEditControl )
end end
end end
self.textEdit = not control.editMode
if self.textEdit then
self.textEditControl = control
else
self.textEditControl = nil
end end
end
self.textEdit = not editMode
end end
function Raygui:drawControl( control ) function Raygui:drawControl( control )
@@ -2016,6 +2029,7 @@ end
---@param text string ---@param text string
---@param callbacks table close, grab, drag. ---@param callbacks table close, grab, drag.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table WindowBox ---@return table WindowBox
function Raygui:WindowBox( bounds, text, callbacks, styles, tooltip ) function Raygui:WindowBox( bounds, text, callbacks, styles, tooltip )
return self:addControl( WindowBox:new( bounds, text, callbacks, styles, tooltip ) ) return self:addControl( WindowBox:new( bounds, text, callbacks, styles, tooltip ) )
@@ -2024,6 +2038,7 @@ end
---@param bounds Rectangle ---@param bounds Rectangle
---@param text string ---@param text string
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table GroupBox ---@return table GroupBox
function Raygui:GroupBox( bounds, text, styles, tooltip ) function Raygui:GroupBox( bounds, text, styles, tooltip )
return self:addControl( GroupBox:new( bounds, text, styles, tooltip ) ) return self:addControl( GroupBox:new( bounds, text, styles, tooltip ) )
@@ -2032,6 +2047,7 @@ end
---@param bounds Rectangle ---@param bounds Rectangle
---@param text string ---@param text string
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table Line ---@return table Line
function Raygui:Line( bounds, text, styles, tooltip ) function Raygui:Line( bounds, text, styles, tooltip )
return self:addControl( Line:new( bounds, text, styles, tooltip ) ) return self:addControl( Line:new( bounds, text, styles, tooltip ) )
@@ -2041,6 +2057,7 @@ end
---@param text string ---@param text string
---@param callbacks table grab, drag. ---@param callbacks table grab, drag.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table Panel ---@return table Panel
function Raygui:Panel( bounds, text, callbacks, styles, tooltip ) function Raygui:Panel( bounds, text, callbacks, styles, tooltip )
return self:addControl( Panel:new( bounds, text, callbacks, styles, tooltip ) ) return self:addControl( Panel:new( bounds, text, callbacks, styles, tooltip ) )
@@ -2051,6 +2068,7 @@ end
---@param active integer ---@param active integer
---@param callbacks table select, close, grab, drag. ---@param callbacks table select, close, grab, drag.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table GuiTabBar ---@return table GuiTabBar
function Raygui:GuiTabBar( bounds, text, active, callbacks, styles, tooltip ) function Raygui:GuiTabBar( bounds, text, active, callbacks, styles, tooltip )
return self:addControl( GuiTabBar:new( bounds, text, active, callbacks, styles, tooltip ) ) return self:addControl( GuiTabBar:new( bounds, text, active, callbacks, styles, tooltip ) )
@@ -2062,6 +2080,7 @@ end
---@param scroll Vector2 ---@param scroll Vector2
---@param callbacks table scroll, grab, drag. ---@param callbacks table scroll, grab, drag.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table ScrollPanel ---@return table ScrollPanel
function Raygui:ScrollPanel( bounds, text, content, scroll, callbacks, styles, tooltip ) function Raygui:ScrollPanel( bounds, text, content, scroll, callbacks, styles, tooltip )
return self:addControl( ScrollPanel:new( bounds, text, content, scroll, callbacks, styles, tooltip ) ) return self:addControl( ScrollPanel:new( bounds, text, content, scroll, callbacks, styles, tooltip ) )
@@ -2070,6 +2089,7 @@ end
---@param bounds Rectangle ---@param bounds Rectangle
---@param text string ---@param text string
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table Label ---@return table Label
function Raygui:Label( bounds, text, styles, tooltip ) function Raygui:Label( bounds, text, styles, tooltip )
return self:addControl( Label:new( bounds, text, styles, tooltip ) ) return self:addControl( Label:new( bounds, text, styles, tooltip ) )
@@ -2079,6 +2099,7 @@ end
---@param text string ---@param text string
---@param callbacks table pressed. ---@param callbacks table pressed.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table Button ---@return table Button
function Raygui:Button( bounds, text, callbacks, styles, tooltip ) function Raygui:Button( bounds, text, callbacks, styles, tooltip )
return self:addControl( Button:new( bounds, text, callbacks, styles, tooltip ) ) return self:addControl( Button:new( bounds, text, callbacks, styles, tooltip ) )
@@ -2088,6 +2109,7 @@ end
---@param text string ---@param text string
---@param callbacks table pressed. ---@param callbacks table pressed.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table LabelButton ---@return table LabelButton
function Raygui:LabelButton( bounds, text, callbacks, styles, tooltip ) function Raygui:LabelButton( bounds, text, callbacks, styles, tooltip )
return self:addControl( LabelButton:new( bounds, text, callbacks, styles, tooltip ) ) return self:addControl( LabelButton:new( bounds, text, callbacks, styles, tooltip ) )
@@ -2098,6 +2120,7 @@ end
---@param active boolean ---@param active boolean
---@param callbacks table pressed. ---@param callbacks table pressed.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table Toggle ---@return table Toggle
function Raygui:Toggle( bounds, text, active, callbacks, styles, tooltip ) function Raygui:Toggle( bounds, text, active, callbacks, styles, tooltip )
return self:addControl( Toggle:new( bounds, text, active, callbacks, styles, tooltip ) ) return self:addControl( Toggle:new( bounds, text, active, callbacks, styles, tooltip ) )
@@ -2108,6 +2131,7 @@ end
---@param active integer ---@param active integer
---@param callbacks table select. ---@param callbacks table select.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table ToggleGroup ---@return table ToggleGroup
function Raygui:ToggleGroup( bounds, text, active, callbacks, styles, tooltip ) function Raygui:ToggleGroup( bounds, text, active, callbacks, styles, tooltip )
return self:addControl( ToggleGroup:new( bounds, text, active, callbacks, styles, tooltip ) ) return self:addControl( ToggleGroup:new( bounds, text, active, callbacks, styles, tooltip ) )
@@ -2118,6 +2142,7 @@ end
---@param checked boolean ---@param checked boolean
---@param callbacks table pressed. ---@param callbacks table pressed.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table CheckBox ---@return table CheckBox
function Raygui:CheckBox( bounds, text, checked, callbacks, styles, tooltip ) function Raygui:CheckBox( bounds, text, checked, callbacks, styles, tooltip )
return self:addControl( CheckBox:new( bounds, text, checked, callbacks, styles, tooltip ) ) return self:addControl( CheckBox:new( bounds, text, checked, callbacks, styles, tooltip ) )
@@ -2128,6 +2153,7 @@ end
---@param active integer ---@param active integer
---@param callbacks table select. ---@param callbacks table select.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table ComboBox ---@return table ComboBox
function Raygui:ComboBox( bounds, text, active, callbacks, styles, tooltip ) function Raygui:ComboBox( bounds, text, active, callbacks, styles, tooltip )
return self:addControl( ComboBox:new( bounds, text, active, callbacks, styles, tooltip ) ) return self:addControl( ComboBox:new( bounds, text, active, callbacks, styles, tooltip ) )
@@ -2139,6 +2165,7 @@ end
---@param editMode boolean ---@param editMode boolean
---@param callbacks table select. ---@param callbacks table select.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table DropdownBox ---@return table DropdownBox
function Raygui:DropdownBox( bounds, text, active, editMode, callbacks, styles, tooltip ) function Raygui:DropdownBox( bounds, text, active, editMode, callbacks, styles, tooltip )
return self:addControl( DropdownBox:new( bounds, text, active, editMode, callbacks, styles, tooltip ) ) return self:addControl( DropdownBox:new( bounds, text, active, editMode, callbacks, styles, tooltip ) )
@@ -2152,6 +2179,7 @@ end
---@param editMode boolean ---@param editMode boolean
---@param callbacks table edit. ---@param callbacks table edit.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table Spinner ---@return table Spinner
function Raygui:Spinner( bounds, text, value, minValue, maxValue, editMode, callbacks, styles, tooltip ) function Raygui:Spinner( bounds, text, value, minValue, maxValue, editMode, callbacks, styles, tooltip )
return self:addControl( Spinner:new( bounds, text, value, minValue, maxValue, editMode, callbacks, styles, tooltip ) ) return self:addControl( Spinner:new( bounds, text, value, minValue, maxValue, editMode, callbacks, styles, tooltip ) )
@@ -2165,6 +2193,7 @@ end
---@param editMode boolean ---@param editMode boolean
---@param callbacks table edit. ---@param callbacks table edit.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table ValueBox ---@return table ValueBox
function Raygui:ValueBox( bounds, text, value, minValue, maxValue, editMode, callbacks, styles, tooltip ) function Raygui:ValueBox( bounds, text, value, minValue, maxValue, editMode, callbacks, styles, tooltip )
return self:addControl( ValueBox:new( bounds, text, value, minValue, maxValue, editMode, callbacks, styles, tooltip ) ) return self:addControl( ValueBox:new( bounds, text, value, minValue, maxValue, editMode, callbacks, styles, tooltip ) )
@@ -2176,6 +2205,7 @@ end
---@param editMode boolean ---@param editMode boolean
---@param callbacks table edit. ---@param callbacks table edit.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table TextBox ---@return table TextBox
function Raygui:TextBox( bounds, text, textSize, editMode, callbacks, styles, tooltip ) function Raygui:TextBox( bounds, text, textSize, editMode, callbacks, styles, tooltip )
return self:addControl( TextBox:new( bounds, text, textSize, editMode, callbacks, styles, tooltip ) ) return self:addControl( TextBox:new( bounds, text, textSize, editMode, callbacks, styles, tooltip ) )
@@ -2189,6 +2219,7 @@ end
---@param maxValue number ---@param maxValue number
---@param callbacks table edit. ---@param callbacks table edit.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table Slider ---@return table Slider
function Raygui:Slider( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) function Raygui:Slider( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip )
return self:addControl( Slider:new( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) ) return self:addControl( Slider:new( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) )
@@ -2202,6 +2233,7 @@ end
---@param maxValue number ---@param maxValue number
---@param callbacks table edit. ---@param callbacks table edit.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table SliderBar ---@return table SliderBar
function Raygui:SliderBar( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) function Raygui:SliderBar( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip )
return self:addControl( SliderBar:new( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) ) return self:addControl( SliderBar:new( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) )
@@ -2215,6 +2247,7 @@ end
---@param maxValue number ---@param maxValue number
---@param callbacks table edit. ---@param callbacks table edit.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table ProgressBar ---@return table ProgressBar
function Raygui:ProgressBar( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) function Raygui:ProgressBar( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip )
return self:addControl( ProgressBar:new( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) ) return self:addControl( ProgressBar:new( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) )
@@ -2223,6 +2256,7 @@ end
---@param bounds Rectangle ---@param bounds Rectangle
---@param text string ---@param text string
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table StatusBar ---@return table StatusBar
function Raygui:StatusBar( bounds, text, styles, tooltip ) function Raygui:StatusBar( bounds, text, styles, tooltip )
return self:addControl( StatusBar:new( bounds, text, styles, tooltip ) ) return self:addControl( StatusBar:new( bounds, text, styles, tooltip ) )
@@ -2231,6 +2265,7 @@ end
---@param bounds Rectangle ---@param bounds Rectangle
---@param text string ---@param text string
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table DummyRec ---@return table DummyRec
function Raygui:DummyRec( bounds, text, styles, tooltip ) function Raygui:DummyRec( bounds, text, styles, tooltip )
return self:addControl( DummyRec:new( bounds, text, styles, tooltip ) ) return self:addControl( DummyRec:new( bounds, text, styles, tooltip ) )
@@ -2242,6 +2277,7 @@ end
---@param subdivs integer ---@param subdivs integer
---@param callbacks table cellChange. ---@param callbacks table cellChange.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table Grid ---@return table Grid
function Raygui:Grid( bounds, text, spacing, subdivs, callbacks, styles, tooltip ) function Raygui:Grid( bounds, text, spacing, subdivs, callbacks, styles, tooltip )
return self:addControl( Grid:new( bounds, text, spacing, subdivs, callbacks, styles, tooltip ) ) return self:addControl( Grid:new( bounds, text, spacing, subdivs, callbacks, styles, tooltip ) )
@@ -2253,6 +2289,7 @@ end
---@param active integer ---@param active integer
---@param callbacks table select. ---@param callbacks table select.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table ListView ---@return table ListView
function Raygui:ListView( bounds, text, scrollIndex, active, callbacks, styles, tooltip ) function Raygui:ListView( bounds, text, scrollIndex, active, callbacks, styles, tooltip )
return self:addControl( ListView:new( bounds, text, scrollIndex, active, callbacks, styles, tooltip ) ) return self:addControl( ListView:new( bounds, text, scrollIndex, active, callbacks, styles, tooltip ) )
@@ -2265,6 +2302,7 @@ end
---@param focus integer ---@param focus integer
---@param callbacks table select. ---@param callbacks table select.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table ListViewEx ---@return table ListViewEx
function Raygui:ListViewEx( bounds, text, scrollIndex, active, focus, callbacks, styles, tooltip ) function Raygui:ListViewEx( bounds, text, scrollIndex, active, focus, callbacks, styles, tooltip )
return self:addControl( ListViewEx:new( bounds, text, scrollIndex, active, focus, callbacks, styles, tooltip ) ) return self:addControl( ListViewEx:new( bounds, text, scrollIndex, active, focus, callbacks, styles, tooltip ) )
@@ -2276,6 +2314,7 @@ end
---@param buttons string ---@param buttons string
---@param callbacks table pressed, grab, drag. ---@param callbacks table pressed, grab, drag.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table MessageBox ---@return table MessageBox
function Raygui:MessageBox( bounds, title, message, buttons, callbacks, styles, tooltip ) function Raygui:MessageBox( bounds, title, message, buttons, callbacks, styles, tooltip )
return self:addControl( MessageBox:new( bounds, title, message, buttons, callbacks, styles, tooltip ) ) return self:addControl( MessageBox:new( bounds, title, message, buttons, callbacks, styles, tooltip ) )
@@ -2290,6 +2329,7 @@ end
---@param secretViewActive boolean ---@param secretViewActive boolean
---@param callbacks table pressed, grab, drag. ---@param callbacks table pressed, grab, drag.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table TextInputBox ---@return table TextInputBox
function Raygui:TextInputBox( bounds, title, message, buttons, text, textMaxSize, secretViewActive, callbacks, styles, tooltip ) function Raygui:TextInputBox( bounds, title, message, buttons, text, textMaxSize, secretViewActive, callbacks, styles, tooltip )
return self:addControl( TextInputBox:new( bounds, title, message, buttons, text, textMaxSize, secretViewActive, callbacks, styles, tooltip ) ) return self:addControl( TextInputBox:new( bounds, title, message, buttons, text, textMaxSize, secretViewActive, callbacks, styles, tooltip ) )
@@ -2300,6 +2340,7 @@ end
---@param color Color ---@param color Color
---@param callbacks table edit. ---@param callbacks table edit.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table ColorPicker ---@return table ColorPicker
function Raygui:ColorPicker( bounds, text, color, callbacks, styles, tooltip ) function Raygui:ColorPicker( bounds, text, color, callbacks, styles, tooltip )
return self:addControl( ColorPicker:new( bounds, text, color, callbacks, styles, tooltip ) ) return self:addControl( ColorPicker:new( bounds, text, color, callbacks, styles, tooltip ) )
@@ -2310,6 +2351,7 @@ end
---@param color Color ---@param color Color
---@param callbacks table edit. ---@param callbacks table edit.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table ColorPanel ---@return table ColorPanel
function Raygui:ColorPanel( bounds, text, color, callbacks, styles, tooltip ) function Raygui:ColorPanel( bounds, text, color, callbacks, styles, tooltip )
return self:addControl( ColorPanel:new( bounds, text, color, callbacks, styles, tooltip ) ) return self:addControl( ColorPanel:new( bounds, text, color, callbacks, styles, tooltip ) )
@@ -2320,6 +2362,7 @@ end
---@param alpha number ---@param alpha number
---@param callbacks table edit. ---@param callbacks table edit.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table ColorBarAlpha ---@return table ColorBarAlpha
function Raygui:ColorBarAlpha( bounds, text, alpha, callbacks, styles, tooltip ) function Raygui:ColorBarAlpha( bounds, text, alpha, callbacks, styles, tooltip )
return self:addControl( ColorBarAlpha:new( bounds, text, alpha, callbacks, styles, tooltip ) ) return self:addControl( ColorBarAlpha:new( bounds, text, alpha, callbacks, styles, tooltip ) )
@@ -2330,6 +2373,7 @@ end
---@param value number ---@param value number
---@param callbacks table edit. ---@param callbacks table edit.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table ColorBarHue ---@return table ColorBarHue
function Raygui:ColorBarHue( bounds, text, value, callbacks, styles, tooltip ) function Raygui:ColorBarHue( bounds, text, value, callbacks, styles, tooltip )
return self:addControl( ColorBarHue:new( bounds, text, value, callbacks, styles, tooltip ) ) return self:addControl( ColorBarHue:new( bounds, text, value, callbacks, styles, tooltip ) )
@@ -2341,6 +2385,7 @@ end
---@param maxValue integer ---@param maxValue integer
---@param callbacks table edit. ---@param callbacks table edit.
---@param styles table|nil ---@param styles table|nil
---@param tooltip string|nil
---@return table ColorBarHue ---@return table ColorBarHue
function Raygui:GuiScrollBar( bounds, value, minValue, maxValue, callbacks, styles, tooltip ) function Raygui:GuiScrollBar( bounds, value, minValue, maxValue, callbacks, styles, tooltip )
return self:addControl( GuiScrollBar:new( bounds, value, minValue, maxValue, callbacks, styles, tooltip ) ) return self:addControl( GuiScrollBar:new( bounds, value, minValue, maxValue, callbacks, styles, tooltip ) )

View File

@@ -843,7 +843,7 @@ int lcoreEndScissorMode( lua_State* L ) {
*/ */
/* /*
> shader = RL.LoadShader( string vsFileName, string fsFileName ) > shader = RL.LoadShader( string|nil vsFileName, string|nil fsFileName )
Load shader from files and bind default locations. Load shader from files and bind default locations.
NOTE: Set nil if no shader NOTE: Set nil if no shader
@@ -867,7 +867,7 @@ int lcoreLoadShader( lua_State* L ) {
} }
/* /*
> shader = RL.LoadShaderFromMemory( string vsCode, string fsCode ) > shader = RL.LoadShaderFromMemory( string|nil vsCode, string|nil fsCode )
Load shader from code strings and bind default locations Load shader from code strings and bind default locations
NOTE: Set nil if no shader NOTE: Set nil if no shader
@@ -1761,7 +1761,7 @@ int lcoreLoadDirectoryFiles( lua_State* L ) {
} }
/* /*
> fileNames = RL.LoadDirectoryFilesEx( string basePath, string filter, bool scanSubdirs ) > fileNames = RL.LoadDirectoryFilesEx( string basePath, string|nil filter, bool scanSubdirs )
Load directory filepaths with extension filtering and recursive directory scan Load directory filepaths with extension filtering and recursive directory scan
@@ -1769,8 +1769,13 @@ Load directory filepaths with extension filtering and recursive directory scan
*/ */
int lcoreLoadDirectoryFilesEx( lua_State* L ) { int lcoreLoadDirectoryFilesEx( lua_State* L ) {
bool scanSubdirs = uluaGetBoolean( L, 3 ); bool scanSubdirs = uluaGetBoolean( L, 3 );
const char* basePath = luaL_checkstring( L, 1 );
char* filter = NULL;
FilePathList files = LoadDirectoryFilesEx( luaL_checkstring( L, 1 ), luaL_checkstring( L, 2 ), scanSubdirs ); if ( lua_isstring( L, 2 ) ) {
filter = (char*)lua_tostring( L, 2 );
}
FilePathList files = LoadDirectoryFilesEx( basePath, filter, scanSubdirs );
lua_createtable( L, files.count, 0 ); lua_createtable( L, files.count, 0 );