Position argument added for GetCodepoint, GetCodepointNext and GetCodepointPrevious.

This commit is contained in:
jussi
2024-04-13 18:44:42 +03:00
parent b96960a1f9
commit 1d66edf4f2
11 changed files with 67 additions and 36 deletions

View File

@@ -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.

View File

@@ -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.

View File

@@ -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 )

View File

@@ -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

View File

@@ -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