All global variables and functions are not in global RL table. doc_parser creates also ReiLua_API.lua.

This commit is contained in:
jussi
2023-04-06 12:31:37 +03:00
parent 198a74c0aa
commit 2526c9732e
47 changed files with 8730 additions and 3196 deletions

View File

@@ -20,7 +20,7 @@ function Calculator:new( pos )
padding = 10,
onClicked = function()
object:set2Top()
object.dragPos = Vec2:new( RL_GetMousePosition() ) - Vec2:new( object.handle.bounds.x, object.handle.bounds.y )
object.dragPos = Vec2:new( RL.GetMousePosition() ) - Vec2:new( object.handle.bounds.x, object.handle.bounds.y )
Gui.heldCallback = function() object:drag() end
end,
} )
@@ -30,7 +30,7 @@ function Calculator:new( pos )
texture = bgrTexture,
HAling = Gui.ALING.CENTER,
VAling = Gui.ALING.CENTER,
color = Color:new( LIGHTGRAY ),
color = Color:new( RL.LIGHTGRAY ),
} ) )
object.handle:add( Gui.texture:new( {
@@ -38,8 +38,8 @@ function Calculator:new( pos )
texture = borderTexture,
HAling = Gui.ALING.CENTER,
VAling = Gui.ALING.CENTER,
color = Color:new( LIGHTGRAY ),
nPatchInfo = { source = { 0, 0, 24, 24 }, left = 8, top = 8, right = 8, bottom = 8, layout = NPATCH_NINE_PATCH },
color = Color:new( RL.LIGHTGRAY ),
nPatchInfo = { source = { 0, 0, 24, 24 }, left = 8, top = 8, right = 8, bottom = 8, layout = RL.NPATCH_NINE_PATCH },
} ) )
object.handle:add( Gui.text:new( { text = "Calculator", fontSize = 20, VAling = Gui.ALING.CENTER } ) )
@@ -51,8 +51,8 @@ function Calculator:new( pos )
onClicked = function()
object:setVisible( false )
end,
onMouseOver = function( self ) self.items[1].color = Color:new( WHITE ) end,
notMouseOver = function( self ) self.items[1].color = Color:new( BLACK ) end,
onMouseOver = function( self ) self.items[1].color = Color:new( RL.WHITE ) end,
notMouseOver = function( self ) self.items[1].color = Color:new( RL.BLACK ) end,
} )
object.closeButton:add( Gui.texture:new( {
@@ -73,7 +73,7 @@ function Calculator:new( pos )
texture = bgrTexture,
HAling = Gui.ALING.CENTER,
VAling = Gui.ALING.CENTER,
color = Color:new( GRAY ),
color = Color:new( RL.GRAY ),
} ) )
object.panel:add( Gui.texture:new( {
@@ -81,8 +81,8 @@ function Calculator:new( pos )
texture = borderTexture,
HAling = Gui.ALING.CENTER,
VAling = Gui.ALING.CENTER,
color = Color:new( LIGHTGRAY ),
nPatchInfo = { source = { 0, 0, 24, 24 }, left = 8, top = 8, right = 8, bottom = 8, layout = NPATCH_NINE_PATCH },
color = Color:new( RL.LIGHTGRAY ),
nPatchInfo = { source = { 0, 0, 24, 24 }, left = 8, top = 8, right = 8, bottom = 8, layout = RL.NPATCH_NINE_PATCH },
} ) )
-- Display.
@@ -91,13 +91,13 @@ function Calculator:new( pos )
bounds = Rect:new( 0, 0, object.windowRect.width - 16, object.DISPLAY_HIGHT ),
padding = 10,
drawBounds = true,
color = Color:new( WHITE )
color = Color:new( RL.WHITE )
} )
object.display:add( Gui.text:new( { text = "", fontSize = 30, VAling = Gui.ALING.CENTER, maxTextLen = 8 } ) )
-- Buttons.
local buttonStrings = { "7", "8", "9", "/", "4", "5", "6", "*", "1", "2", "3", "-", "0", "C", "=", "+" }
object.buttons = {}
@@ -108,8 +108,8 @@ function Calculator:new( pos )
table.insert( object.buttons, Gui.element:new( {
bounds = Rect:new( 0, 0, 40, 32 ),
drawBounds = true,
onMouseOver = function( self ) self.color = Color:new( WHITE ) end,
notMouseOver = function( self ) self.color = Color:new( LIGHTGRAY ) end,
onMouseOver = function( self ) self.color = Color:new( RL.WHITE ) end,
notMouseOver = function( self ) self.color = Color:new( RL.LIGHTGRAY ) end,
} ) )
object.buttons[ #object.buttons ].pos = Vec2:new( 8 + x * 46, object.HANDLE_HIGHT + object.DISPLAY_HIGHT + 16 + y * 38 )
@@ -161,7 +161,7 @@ function Calculator:setPosition( pos )
end
function Calculator:drag()
local mousePos = Vec2:new( RL_GetMousePosition() )
local mousePos = Vec2:new( RL.GetMousePosition() )
local winPos = Vec2:new( self.handle.bounds.x, self.handle.bounds.y )
self:setPosition( mousePos - self.dragPos )
@@ -173,13 +173,13 @@ function Calculator:setVisible( visible )
self.closeButton.visible = visible
self.closeButton.disabled = not visible
self.panel.visible = visible
self.panel.disabled = not visible
self.display.visible = visible
self.display.disabled = not visible
for _, button in ipairs( self.buttons ) do
button.visible = visible
button.disabled = not visible
@@ -188,7 +188,7 @@ end
function Calculator:set2Top()
self.panel:set2Top()
for _, button in ipairs( self.buttons ) do
button:set2Top()
end

View File

@@ -20,7 +20,7 @@ function FileExplorer:new( pos )
padding = 10,
onClicked = function()
object:set2Top()
object.dragPos = Vec2:new( RL_GetMousePosition() ) - Vec2:new( object.handle.bounds.x, object.handle.bounds.y )
object.dragPos = Vec2:new( RL.GetMousePosition() ) - Vec2:new( object.handle.bounds.x, object.handle.bounds.y )
Gui.heldCallback = function() object:drag() end
end,
} )
@@ -30,16 +30,16 @@ function FileExplorer:new( pos )
texture = bgrTexture,
HAling = Gui.ALING.CENTER,
VAling = Gui.ALING.CENTER,
color = Color:new( LIGHTGRAY ),
color = Color:new( RL.LIGHTGRAY ),
} ) )
object.handle:add( Gui.texture:new( {
bounds = object.handle.bounds:clone(),
texture = borderTexture,
HAling = Gui.ALING.CENTER,
VAling = Gui.ALING.CENTER,
color = Color:new( LIGHTGRAY ),
nPatchInfo = { source = { 0, 0, 24, 24 }, left = 8, top = 8, right = 8, bottom = 8, layout = NPATCH_NINE_PATCH },
color = Color:new( RL.LIGHTGRAY ),
nPatchInfo = { source = { 0, 0, 24, 24 }, left = 8, top = 8, right = 8, bottom = 8, layout = RL.NPATCH_NINE_PATCH },
} ) )
object.handle:add( Gui.text:new( { text = "File Explorer", fontSize = 20, VAling = Gui.ALING.CENTER } ) )
@@ -51,8 +51,8 @@ function FileExplorer:new( pos )
onClicked = function()
object:setVisible( false )
end,
onMouseOver = function( self ) self.items[1].color = Color:new( WHITE ) end,
notMouseOver = function( self ) self.items[1].color = Color:new( BLACK ) end,
onMouseOver = function( self ) self.items[1].color = Color:new( RL.WHITE ) end,
notMouseOver = function( self ) self.items[1].color = Color:new( RL.BLACK ) end,
} )
object.closeButton:add( Gui.texture:new( {
@@ -73,7 +73,7 @@ function FileExplorer:new( pos )
texture = bgrTexture,
HAling = Gui.ALING.CENTER,
VAling = Gui.ALING.CENTER,
color = Color:new( GRAY ),
color = Color:new( RL.GRAY ),
} ) )
object.panel:add( Gui.texture:new( {
@@ -81,8 +81,8 @@ function FileExplorer:new( pos )
texture = borderTexture,
HAling = Gui.ALING.CENTER,
VAling = Gui.ALING.CENTER,
color = Color:new( LIGHTGRAY ),
nPatchInfo = { source = { 0, 0, 24, 24 }, left = 8, top = 8, right = 8, bottom = 8, layout = NPATCH_NINE_PATCH },
color = Color:new( RL.LIGHTGRAY ),
nPatchInfo = { source = { 0, 0, 24, 24 }, left = 8, top = 8, right = 8, bottom = 8, layout = RL.NPATCH_NINE_PATCH },
} ) )
-- Path.
@@ -90,7 +90,7 @@ function FileExplorer:new( pos )
object.pathBox = Gui.element:new( {
bounds = Rect:new( 0, 0, object.windowRect.width - 16 - 64, object.HANDLE_HIGHT ),
drawBounds = true,
color = Color:new( WHITE ),
color = Color:new( RL.WHITE ),
-- onClicked = function() Gui.setInputFocus( object.pathBox ) end,
-- inputFocus = function() object.pathBox.color = Color:new( BLUE ) end,
-- inputUnfocus = function() object.pathBox.color = Color:new( WHITE ) end,
@@ -103,8 +103,8 @@ function FileExplorer:new( pos )
object.backButton = Gui.element:new( {
bounds = Rect:new( 0, 0, 56, object.HANDLE_HIGHT ),
drawBounds = true,
onMouseOver = function( self ) self.color = Color:new( WHITE ) end,
notMouseOver = function( self ) self.color = Color:new( LIGHTGRAY ) end,
onMouseOver = function( self ) self.color = Color:new( RL.WHITE ) end,
notMouseOver = function( self ) self.color = Color:new( RL.LIGHTGRAY ) end,
onClicked = function() object:backDir() end,
} )
@@ -112,7 +112,7 @@ function FileExplorer:new( pos )
bounds = Rect:new( 0, 0, object.HANDLE_HIGHT, object.HANDLE_HIGHT ),
texture = backTexture,
HAling = Gui.ALING.CENTER,
color = Color:new( BLACK )
color = Color:new( RL.BLACK )
} ) )
-- Files.
@@ -130,7 +130,7 @@ function FileExplorer:new( pos )
object.fileName = Gui.element:new( {
bounds = Rect:new( 0, 0, object.windowRect.width - 16 - 70, object.HANDLE_HIGHT ),
drawBounds = true,
color = Color:new( WHITE ),
color = Color:new( RL.WHITE ),
} )
object.fileName:add( Gui.text:new( { text = "", maxTextLen = 32, allowLineBreak = false, VAling = Gui.ALING.CENTER } ) )
@@ -140,18 +140,18 @@ function FileExplorer:new( pos )
object.openButton = Gui.element:new( {
bounds = Rect:new( 0, 0, 64, object.HANDLE_HIGHT ),
drawBounds = true,
color = Color:new( WHITE ),
color = Color:new( RL.WHITE ),
onClicked = function() object:openFile() end,
onMouseOver = function( self ) self.color = Color:new( WHITE ) end,
notMouseOver = function( self ) self.color = Color:new( LIGHTGRAY ) end,
onMouseOver = function( self ) self.color = Color:new( RL.WHITE ) end,
notMouseOver = function( self ) self.color = Color:new( RL.LIGHTGRAY ) end,
} )
object.openButton:add( Gui.text:new( { text = "Open", VAling = Gui.ALING.CENTER, HAling = Gui.ALING.CENTER } ) )
-- Variables.
object.path = RL_GetBasePath()
object.path = RL.GetBasePath()
-- Take last '/' away.
if util.utf8Sub( object.path, utf8.len( object.path ), utf8.len( object.path ) ) == "/" then
object.path = util.utf8Sub( object.path, 1, utf8.len( object.path ) - 1 )
@@ -189,7 +189,7 @@ function FileExplorer:changeDir( path )
end
function FileExplorer:backDir()
self.path = RL_GetPrevDirectoryPath( self.path )
self.path = RL.GetPrevDirectoryPath( self.path )
self:updatePath()
end
@@ -197,11 +197,11 @@ end
function FileExplorer:fileSelect( file )
self.file = file
self.fileName.items[1]:set( RL_GetFileName( file ) )
self.fileName.items[1]:set( RL.GetFileName( file ) )
end
function FileExplorer:openFile()
print( self.file, RL_GetFileLength( self.file ) )
print( self.file, RL.GetFileLength( self.file ) )
end
function FileExplorer:updateFiles()
@@ -216,8 +216,8 @@ function FileExplorer:updateFiles()
local files = {}
local folders = {}
for _, file in ipairs( RL_LoadDirectoryFiles( self.path ) ) do
if RL_IsPathFile( file ) then
for _, file in ipairs( RL.LoadDirectoryFiles( self.path ) ) do
if RL.IsPathFile( file ) then
table.insert( files, file )
else
table.insert( folders, file )
@@ -232,7 +232,7 @@ function FileExplorer:updateFiles()
end
for _, file in ipairs( files ) do
self:addFileToList( file, filesTexture, WHITE, function() self:fileSelect( file ) end )
self:addFileToList( file, filesTexture, RL.WHITE, function() self:fileSelect( file ) end )
end
end
@@ -247,7 +247,7 @@ function FileExplorer:addFileToList( file, texture, color, func )
element:add( Gui.text:new( {
bounds = Rect:new( 28, 0, 20, 20 ),
text = RL_GetFileName( file ),
text = RL.GetFileName( file ),
fontSize = 20,
HAling = Gui.ALING.NONE,
VAling = Gui.ALING.CENTER,
@@ -264,7 +264,7 @@ function FileExplorer:addFileToList( file, texture, color, func )
end
function FileExplorer:drag()
local mousePos = Vec2:new( RL_GetMousePosition() )
local mousePos = Vec2:new( RL.GetMousePosition() )
local winPos = Vec2:new( self.handle.bounds.x, self.handle.bounds.y )
self:setPosition( mousePos - self.dragPos )

View File

@@ -1,5 +1,5 @@
package.path = package.path..";"..RL_GetBasePath().."?.lua"
package.path = package.path..";"..RL_GetBasePath().."../resources/lib/?.lua"
package.path = package.path..";"..RL.GetBasePath().."?.lua"
package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua"
util = require( "utillib" )
Vec2 = require( "vector2" )
@@ -13,29 +13,29 @@ FileExplorer = require( "file_explorer" )
-- Textures.
-- Note that textures are global.
cancelTexture = RL_LoadTexture( RL_GetBasePath().."../resources/images/cancel.png" )
backTexture = RL_LoadTexture( RL_GetBasePath().."../resources/images/previous-button.png" )
folderTexture = RL_LoadTexture( RL_GetBasePath().."../resources/images/open-folder.png" )
filesTexture = RL_LoadTexture( RL_GetBasePath().."../resources/images/files.png" )
borderTexture = RL_LoadTexture( RL_GetBasePath().."../resources/images/ui_border.png" )
bgrTexture = RL_LoadTexture( RL_GetBasePath().."../resources/images/ui_bgr.png" )
cancelTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/cancel.png" )
backTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/previous-button.png" )
folderTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/open-folder.png" )
filesTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/files.png" )
borderTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/ui_border.png" )
bgrTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/ui_bgr.png" )
RL_GenTextureMipmaps( cancelTexture )
RL_GenTextureMipmaps( backTexture )
RL_GenTextureMipmaps( folderTexture )
RL_GenTextureMipmaps( filesTexture )
RL_GenTextureMipmaps( borderTexture )
RL_GenTextureMipmaps( bgrTexture )
RL.GenTextureMipmaps( cancelTexture )
RL.GenTextureMipmaps( backTexture )
RL.GenTextureMipmaps( folderTexture )
RL.GenTextureMipmaps( filesTexture )
RL.GenTextureMipmaps( borderTexture )
RL.GenTextureMipmaps( bgrTexture )
RL_SetTextureFilter( cancelTexture, TEXTURE_FILTER_TRILINEAR )
RL_SetTextureFilter( backTexture, TEXTURE_FILTER_TRILINEAR )
RL_SetTextureFilter( folderTexture, TEXTURE_FILTER_TRILINEAR )
RL_SetTextureFilter( filesTexture, TEXTURE_FILTER_TRILINEAR )
RL_SetTextureFilter( borderTexture, TEXTURE_FILTER_TRILINEAR )
RL_SetTextureFilter( bgrTexture, TEXTURE_FILTER_TRILINEAR )
RL.SetTextureFilter( cancelTexture, RL.TEXTURE_FILTER_TRILINEAR )
RL.SetTextureFilter( backTexture, RL.TEXTURE_FILTER_TRILINEAR )
RL.SetTextureFilter( folderTexture, RL.TEXTURE_FILTER_TRILINEAR )
RL.SetTextureFilter( filesTexture, RL.TEXTURE_FILTER_TRILINEAR )
RL.SetTextureFilter( borderTexture, RL.TEXTURE_FILTER_TRILINEAR )
RL.SetTextureFilter( bgrTexture, RL.TEXTURE_FILTER_TRILINEAR )
RL_SetTextureWrap( borderTexture, TEXTURE_WRAP_REPEAT )
RL_SetTextureWrap( bgrTexture, TEXTURE_WRAP_REPEAT )
RL.SetTextureWrap( borderTexture, RL.TEXTURE_WRAP_REPEAT )
RL.SetTextureWrap( bgrTexture, RL.TEXTURE_WRAP_REPEAT )
-- End of calculator definition.
@@ -51,8 +51,8 @@ function initGui()
calculator:setVisible( true )
fileExplorer:setVisible( true )
end,
onMouseOver = function( self ) self.color = Color:new( LIGHTGRAY ) end,
notMouseOver = function( self ) self.color = Color:new( GRAY ) end,
onMouseOver = function( self ) self.color = Color:new( RL.LIGHTGRAY ) end,
notMouseOver = function( self ) self.color = Color:new( RL.GRAY ) end,
} )
showButton:add( Gui.text:new( { text = "Show", VAling = Gui.ALING.CENTER, HAling = Gui.ALING.CENTER } ) )
@@ -61,27 +61,27 @@ function initGui()
fileExplorer = FileExplorer:new( Vec2:new( 280, 96 ) )
end
function init()
function RL.init()
local monitor = 0
local mPos = RL_GetMonitorPosition( monitor )
local mSize = RL_GetMonitorSize( monitor )
winSize = RL_GetScreenSize()
local mPos = RL.GetMonitorPosition( monitor )
local mSize = RL.GetMonitorSize( monitor )
winSize = RL.GetScreenSize()
RL_SetWindowTitle( "ReiLuaGui examples" )
RL_SetWindowState( FLAG_WINDOW_RESIZABLE )
RL_SetWindowState( FLAG_VSYNC_HINT )
RL_SetWindowSize( winSize )
RL_SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
RL.SetWindowTitle( "ReiLuaGui examples" )
RL.SetWindowState( RL.FLAG_WINDOW_RESIZABLE )
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
RL.SetWindowSize( winSize )
RL.SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
initGui()
end
function process( delta )
Gui.process( Vec2:new( RL_GetMousePosition() ) )
function RL.process( delta )
Gui.process( Vec2:new( RL.GetMousePosition() ) )
end
function draw()
RL_ClearBackground( RAYWHITE )
function RL.draw()
RL.ClearBackground( RL.RAYWHITE )
Gui.draw()
end