Object libraries like Vector2 optimizations.

This commit is contained in:
jussi
2024-04-17 00:35:58 +03:00
parent 41b6739824
commit 70b40f6782
31 changed files with 527 additions and 370 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:newT( 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( RL.LIGHTGRAY ),
color = Color:newT( RL.LIGHTGRAY ),
} ) )
object.handle:add( Gui.texture:new( {
@@ -38,7 +38,7 @@ function Calculator:new( pos )
texture = BorderTexture,
HAling = Gui.ALING.CENTER,
VAling = Gui.ALING.CENTER,
color = Color:new( RL.LIGHTGRAY ),
color = Color:newT( RL.LIGHTGRAY ),
nPatchInfo = { source = { 0, 0, 24, 24 }, left = 8, top = 8, right = 8, bottom = 8, layout = RL.NPATCH_NINE_PATCH },
} ) )
@@ -51,8 +51,8 @@ function Calculator:new( pos )
onClicked = function()
object:setVisible( false )
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,
onMouseOver = function( this ) this.items[1].color = Color:newT( RL.WHITE ) end,
notMouseOver = function( this ) this.items[1].color = Color:newT( 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( RL.GRAY ),
color = Color:newT( RL.GRAY ),
} ) )
object.panel:add( Gui.texture:new( {
@@ -81,7 +81,7 @@ function Calculator:new( pos )
texture = BorderTexture,
HAling = Gui.ALING.CENTER,
VAling = Gui.ALING.CENTER,
color = Color:new( RL.LIGHTGRAY ),
color = Color:newT( RL.LIGHTGRAY ),
nPatchInfo = { source = { 0, 0, 24, 24 }, left = 8, top = 8, right = 8, bottom = 8, layout = RL.NPATCH_NINE_PATCH },
} ) )
@@ -91,7 +91,7 @@ function Calculator:new( pos )
bounds = Rect:new( 0, 0, object.windowRect.width - 16, object.DISPLAY_HIGHT ),
padding = 10,
drawBounds = true,
color = Color:new( RL.WHITE )
color = Color:newT( RL.WHITE )
} )
object.display:add( Gui.text:new( { text = "", fontSize = 30, VAling = Gui.ALING.CENTER, maxTextLen = 8 } ) )
@@ -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( RL.WHITE ) end,
notMouseOver = function( self ) self.color = Color:new( RL.LIGHTGRAY ) end,
onMouseOver = function( self ) self.color = Color:newT( RL.WHITE ) end,
notMouseOver = function( self ) self.color = Color:newT( 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:newT( RL.GetMousePosition() )
local winPos = Vec2:new( self.handle.bounds.x, self.handle.bounds.y )
self:setPosition( mousePos - self.dragPos )