summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorjussi2024-04-13 18:44:42 +0300
committerjussi2024-04-13 18:44:42 +0300
commit1d66edf4f2390c25485ef4205b20c184de1c2f5d (patch)
tree7a3cd79e26d7b93a2fb4a3764171fbe90d22a9d4 /examples
parentb96960a1f97f815a6872fedc422ea950ed477cda (diff)
downloadreilua-enhanced-1d66edf4f2390c25485ef4205b20c184de1c2f5d.tar.gz
reilua-enhanced-1d66edf4f2390c25485ef4205b20c184de1c2f5d.tar.bz2
reilua-enhanced-1d66edf4f2390c25485ef4205b20c184de1c2f5d.zip
Position argument added for GetCodepoint, GetCodepointNext and GetCodepointPrevious.
Diffstat (limited to 'examples')
-rw-r--r--examples/2D_lights/main.lua8
-rw-r--r--examples/raygui_examples/calculator.lua4
-rw-r--r--examples/raygui_examples/file_browser.lua13
-rw-r--r--examples/resources/lib/pubsub.lua24
-rw-r--r--examples/resources/lib/utillib.lua3
5 files changed, 35 insertions, 17 deletions
diff --git a/examples/2D_lights/main.lua b/examples/2D_lights/main.lua
index 847f5b2..34bf8bc 100644
--- a/examples/2D_lights/main.lua
+++ b/examples/2D_lights/main.lua
@@ -12,6 +12,8 @@ local LIGHTRENDER_SIZE = 1024 -- Maxinum light size.
local SHADOW_FOV = 45 -- Camera fov for shadow rendering.
local WALL_MESH_HEIGHT = math.tan( RL.DEG2RAD * ( 90 - SHADOW_FOV / 2 ) ) * LIGHTRENDER_SIZE / TILE_SIZE_PX / 2
+print( "WALL_MESH_HEIGHT", WALL_MESH_HEIGHT )
+
local monitor = 0
local monitorPos = Vector2:new( RL.GetMonitorPosition( monitor ) )
local monitorSize = Vector2:new( RL.GetMonitorSize( monitor ) )
@@ -24,7 +26,7 @@ local lightTexSize = Vector2:new()
local framebuffer = nil
local lightMap = nil -- Final image of all lights.
local lightRender = nil -- RenderTexture for individual light and shadow rendering.
-local ambientLight = Color:new( 40, 40, 40, 255 )
+local ambientLight = Color:new( 40, 40, 40 )
local wallSegs = {}
local shadowMesh = nil
local lights = {}
@@ -131,10 +133,10 @@ function RL.init()
RL.rlDisableBackfaceCulling()
end
--- Process.
+-- Update.
function RL.update( delta )
- lights[1].pos = Vector2:new( RL.GetMousePosition() )
+ lights[1].pos:set( RL.GetMousePosition() )
end
-- Drawing.
diff --git a/examples/raygui_examples/calculator.lua b/examples/raygui_examples/calculator.lua
index 78253c0..6274a0b 100644
--- a/examples/raygui_examples/calculator.lua
+++ b/examples/raygui_examples/calculator.lua
@@ -11,9 +11,9 @@ Calculator.OPERATIONS = {
}
function Calculator:new( pos )
- local object = setmetatable( {}, Calculator )
+ local object = setmetatable( {}, Calculator )
- object.window = Gui:WindowBox(
+ object.window = Gui:WindowBox(
Rect:new( pos.x, pos.y, 188, 216 ),
"Calculator",
{ -- Callbacks.
diff --git a/examples/raygui_examples/file_browser.lua b/examples/raygui_examples/file_browser.lua
index cdecfb0..df6f244 100644
--- a/examples/raygui_examples/file_browser.lua
+++ b/examples/raygui_examples/file_browser.lua
@@ -22,7 +22,7 @@ FileBrowser.FILE_ICONS = {
}
function FileBrowser:new( pos )
- local object = setmetatable( {}, FileBrowser )
+ local object = setmetatable( {}, FileBrowser )
object.padding = 4
object.spacing = 4
@@ -34,7 +34,7 @@ function FileBrowser:new( pos )
local textButtonSize = Vec2:new( 72, 28 )
-- Window.
- object.window = Gui:WindowBox(
+ object.window = Gui:WindowBox(
Rect:new( pos.x, pos.y, winSize.x, winSize.y ),
"File Browser",
{ -- callbacks.
@@ -182,7 +182,7 @@ function FileBrowser:new( pos )
return object
end
-function FileBrowser:popup( mode, path, callback )
+function FileBrowser:popup( mode, path, callback, filters )
self:setPath( path )
self.mode = mode
@@ -191,6 +191,10 @@ function FileBrowser:popup( mode, path, callback )
self.callbacks.ok = callback
end
+ if filters ~= nil then
+ self.filterDropdown.text = "All\n"..filters
+ end
+
self:setVisible( true )
end
@@ -266,7 +270,7 @@ function FileBrowser:updateList()
-- Search.
if self.searchText == "" or ( 0 < #self.searchText
- and self.searchText:lower() == record.name:sub( 1, #self.searchText ):lower() ) then
+ and -1 < RL.TextFindIndex( record.name:lower(), self.searchText:lower() ) ) then
table.insert( self.files, record )
end
end
@@ -351,7 +355,6 @@ function FileBrowser:setFilter()
end
self:updateList()
- print( "self.filter", self.filter )
end
function FileBrowser:setPosition( pos )
diff --git a/examples/resources/lib/pubsub.lua b/examples/resources/lib/pubsub.lua
index 2847d92..47d9a63 100644
--- a/examples/resources/lib/pubsub.lua
+++ b/examples/resources/lib/pubsub.lua
@@ -13,21 +13,33 @@ function PubSub:add( name )
self.signals[ name ] = {}
end
+function PubSub:remove( name )
+ if self.signals[ name ] ~= nil then
+ table.remove( self.signals, name )
+ end
+end
+
function PubSub:subscribe( name, func )
- table.insert( self.signals[ name ], func )
+ if self.signals[ name ] ~= nil then
+ table.insert( self.signals[ name ], func )
+ end
end
function PubSub:unSubscribe( name, uFunc )
- for i, func in ipairs( self.signals[ name ] ) do
- if func == uFunc then
- table.remove( self.signals[ name ], i )
+ if self.signals[ name ] ~= nil then
+ for i, func in ipairs( self.signals[ name ] ) do
+ if func == uFunc then
+ table.remove( self.signals[ name ], i )
+ end
end
end
end
function PubSub:publish( name, ... )
- for _, func in ipairs( self.signals[ name ] ) do
- func( ... )
+ if self.signals[ name ] ~= nil then
+ for _, func in ipairs( self.signals[ name ] ) do
+ func( ... )
+ end
end
end
diff --git a/examples/resources/lib/utillib.lua b/examples/resources/lib/utillib.lua
index 73bb11c..a661f60 100644
--- a/examples/resources/lib/utillib.lua
+++ b/examples/resources/lib/utillib.lua
@@ -7,7 +7,8 @@ end
local utillib = {}
-function utillib.tableClone( org )
+-- Does not work with dictionaries.
+function utillib.arrayClone( org )
return { table.unpack( org ) }
end