Raymath *Equals functions return bool instead of int.

This commit is contained in:
jussi
2024-07-06 01:03:02 +03:00
parent 61c932f260
commit 528f3f3d82
15 changed files with 154 additions and 126 deletions

8
API.md
View File

@@ -8395,7 +8395,7 @@ Wrap input value from min to max
Check whether two given floats are almost equal Check whether two given floats are almost equal
- Success return int - Success return bool
--- ---
@@ -8619,7 +8619,7 @@ Clamp the magnitude of the vector between two min and max values
Check whether two given vectors are almost equal Check whether two given vectors are almost equal
- Success return int - Success return bool
--- ---
@@ -8907,7 +8907,7 @@ Clamp the magnitude of the vector between two values
Check whether two given vectors are almost equal Check whether two given vectors are almost equal
- Success return int - Success return bool
--- ---
@@ -9275,7 +9275,7 @@ Transform a quaternion given a transformation matrix
Check whether two given quaternions are almost equal Check whether two given quaternions are almost equal
- Success return int - Success return bool
--- ---

View File

@@ -5470,7 +5470,7 @@ function RL.Remap( value, inputStart, inputEnd, outputStart, outputEnd ) end
function RL.Wrap( value, min, max ) end function RL.Wrap( value, min, max ) end
---Check whether two given floats are almost equal ---Check whether two given floats are almost equal
---- Success return int ---- Success return bool
---@param x number ---@param x number
---@param y number ---@param y number
---@return any result ---@return any result
@@ -5660,7 +5660,7 @@ function RL.Vector2Clamp( v, min, max ) end
function RL.Vector2ClampValue( v, min, max ) end function RL.Vector2ClampValue( v, min, max ) end
---Check whether two given vectors are almost equal ---Check whether two given vectors are almost equal
---- Success return int ---- Success return bool
---@param v1 table ---@param v1 table
---@param v2 table ---@param v2 table
---@return any result ---@return any result
@@ -5909,7 +5909,7 @@ function RL.Vector3Clamp( v, min, max ) end
function RL.Vector3ClampValue( v, min, max ) end function RL.Vector3ClampValue( v, min, max ) end
---Check whether two given vectors are almost equal ---Check whether two given vectors are almost equal
---- Success return int ---- Success return bool
---@param v1 table ---@param v1 table
---@param v2 table ---@param v2 table
---@return any result ---@return any result
@@ -6224,7 +6224,7 @@ function RL.QuaternionToEuler( q ) end
function RL.QuaternionTransform( q, mat ) end function RL.QuaternionTransform( q, mat ) end
---Check whether two given quaternions are almost equal ---Check whether two given quaternions are almost equal
---- Success return int ---- Success return bool
---@param q1 table ---@param q1 table
---@param q2 table ---@param q2 table
---@return any result ---@return any result

View File

@@ -61,6 +61,8 @@ DETAILED CHANGES:
- FIXED: GuiGetIcons was returning just first int. Now returns a Buffer. - FIXED: GuiGetIcons was returning just first int. Now returns a Buffer.
- ADDED: GuiSetIcons. - ADDED: GuiSetIcons.
- ADDED: GetMouseOffset and GetMouseScale. - ADDED: GetMouseOffset and GetMouseScale.
- CHANGE: Raymath *Equals functions return bool instead of int.
- FIXED: ColorToInt cast to unsigned int.
------------------------------------------------------------------------ ------------------------------------------------------------------------
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,6 +2,8 @@ Current {
} }
Backlog { Backlog {
* Raygui
* ICON_ defines.
* 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

@@ -2,10 +2,9 @@ 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" ) Vector2 = require( "vector2" )
Vec2 = require( "vector2" )
Color = require( "color" ) Color = require( "color" )
Rect = require( "rectangle" ) Rectangle = require( "rectangle" )
Raygui = require( "raygui" ) Raygui = require( "raygui" )
require( "sprite_button" ):register( Raygui ) require( "sprite_button" ):register( Raygui )
@@ -16,12 +15,12 @@ require( "tree_item" ):register( Raygui )
Gui = Raygui:new() Gui = Raygui:new()
local buttonTexture = nil local buttonTexture = nil
local winSize = Vec2:new( 1024, 720 ) local winSize = Vector2:new( 1024, 720 )
local cat = { local cat = {
texture = nil, texture = nil,
source = Rect:new( 0, 0, 0, 0 ), source = Rectangle:new( 0, 0, 0, 0 ),
dest = Rect:new( 0, 0, 0, 0 ), dest = Rectangle:new( 0, 0, 0, 0 ),
origin = Vec2:new( 0, 0 ), origin = Vector2:new( 0, 0 ),
rotation = 0.0, rotation = 0.0,
tint = Color:newT( RL.WHITE ), tint = Color:newT( RL.WHITE ),
visible = true, visible = true,
@@ -52,8 +51,8 @@ end
local function addSpriteButtons() local function addSpriteButtons()
buttonTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/button.png" ) buttonTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/button.png" )
local buttonSize = Vec2:new( 216, 32 ) local buttonSize = Vector2:new( 216, 32 )
local bounds = Rect:new( winSize.x / 2 - buttonSize.x / 2, 200, 216, 32 ) local bounds = Rectangle:new( winSize.x / 2 - buttonSize.x / 2, 200, 216, 32 )
local gap = buttonSize.y + 2 local gap = buttonSize.y + 2
addButton( bounds, "Start New Game", { pressed = function() print( "New Game!" ) end } ) addButton( bounds, "Start New Game", { pressed = function() print( "New Game!" ) end } )
bounds.y = bounds.y + gap bounds.y = bounds.y + gap
@@ -72,7 +71,7 @@ end
local function addPropertyList() local function addPropertyList()
PropertyList = Gui:PropertyList( PropertyList = Gui:PropertyList(
Rect:new( 20, 20, 256, 328 ), Rectangle:new( 20, 20, 256, 328 ),
"Property List", "Property List",
{ -- Callbacks. { -- Callbacks.
grab = function( self ) Gui:setToTop( self ) end, grab = function( self ) Gui:setToTop( self ) end,
@@ -88,7 +87,7 @@ local function addPropertyList()
RL.GuiSetStyle( RL.SPINNER, RL.TEXT_ALIGNMENT, RL.TEXT_ALIGN_LEFT ) RL.GuiSetStyle( RL.SPINNER, RL.TEXT_ALIGNMENT, RL.TEXT_ALIGN_LEFT )
PropertyList:addControl( PropertyList.gui:Line( PropertyList:addControl( PropertyList.gui:Line(
Rect:new( 0, 0, 0, 0 ), Rectangle:new( 0, 0, 0, 0 ),
"Cat Texture" "Cat Texture"
) ) ) )
@@ -98,11 +97,11 @@ local function addPropertyList()
-- Position. -- Position.
PropertyList:addControl( PropertyList.gui:Label( PropertyList:addControl( PropertyList.gui:Label(
Rect:new( 0, 0, 0, 0 ), Rectangle:new( 0, 0, 0, 0 ),
"Position:" "Position:"
), transformGroup ) ), transformGroup )
PropertyList:addControl( PropertyList.gui:TextBox( PropertyList:addControl( PropertyList.gui:TextBox(
Rect:new( 0, 0, 64, 22 ), Rectangle:new( 0, 0, 64, 22 ),
cat.dest.x, cat.dest.x,
32, 32,
false, false,
@@ -117,7 +116,7 @@ local function addPropertyList()
"Position X" "Position X"
), transformGroup, true ) ), transformGroup, true )
PropertyList:addControl( PropertyList.gui:TextBox( PropertyList:addControl( PropertyList.gui:TextBox(
Rect:new( 74, 0, 64, 22 ), Rectangle:new( 74, 0, 64, 22 ),
cat.dest.y, cat.dest.y,
32, 32,
false, false,
@@ -133,11 +132,11 @@ local function addPropertyList()
), transformGroup ) ), transformGroup )
-- Origin. -- Origin.
PropertyList:addControl( PropertyList.gui:Label( PropertyList:addControl( PropertyList.gui:Label(
Rect:new( 0, 0, 0, 0 ), Rectangle:new( 0, 0, 0, 0 ),
"Origin:" "Origin:"
), transformGroup ) ), transformGroup )
PropertyList:addControl( PropertyList.gui:TextBox( PropertyList:addControl( PropertyList.gui:TextBox(
Rect:new( 0, 0, 64, 22 ), Rectangle:new( 0, 0, 64, 22 ),
cat.dest.x, cat.dest.x,
32, 32,
false, false,
@@ -152,7 +151,7 @@ local function addPropertyList()
"Origin X" "Origin X"
), transformGroup, true ) ), transformGroup, true )
PropertyList:addControl( PropertyList.gui:TextBox( PropertyList:addControl( PropertyList.gui:TextBox(
Rect:new( 74, 0, 64, 22 ), Rectangle:new( 74, 0, 64, 22 ),
cat.dest.y, cat.dest.y,
32, 32,
false, false,
@@ -168,7 +167,7 @@ local function addPropertyList()
), transformGroup ) ), transformGroup )
-- Rotation. -- Rotation.
PropertyList:addControl( PropertyList.gui:Slider( PropertyList:addControl( PropertyList.gui:Slider(
Rect:new( 60, 0, PropertyList.defaultControlSize.x - 150, 22 ), Rectangle:new( 60, 0, PropertyList.defaultControlSize.x - 150, 22 ),
"Rotation", "Rotation",
"0", "0",
0, 0,
@@ -186,7 +185,7 @@ local function addPropertyList()
), transformGroup ) ), transformGroup )
-- Flipped. -- Flipped.
PropertyList:addControl( PropertyList.gui:CheckBox( PropertyList:addControl( PropertyList.gui:CheckBox(
Rect:new( 0, 0, 20, 20 ), Rectangle:new( 0, 0, 20, 20 ),
"Flipped", "Flipped",
cat.flipped, cat.flipped,
{ -- Callbacks. { -- Callbacks.
@@ -201,7 +200,7 @@ local function addPropertyList()
local visibilityGroup = PropertyList:addGroup( "Visibility", false ) local visibilityGroup = PropertyList:addGroup( "Visibility", false )
PropertyList:addControl( PropertyList.gui:CheckBox( PropertyList:addControl( PropertyList.gui:CheckBox(
Rect:new( 0, 0, 20, 20 ), Rectangle:new( 0, 0, 20, 20 ),
"Visible", "Visible",
cat.visible, cat.visible,
{ -- Callbacks. { -- Callbacks.
@@ -217,7 +216,7 @@ local function addPropertyList()
local tintGroup = PropertyList:addGroup( "Tint", false, visibilityGroup ) local tintGroup = PropertyList:addGroup( "Tint", false, visibilityGroup )
PropertyList:addControl( PropertyList.gui:ColorPicker( PropertyList:addControl( PropertyList.gui:ColorPicker(
Rect:new( 0, 0, 128, 128 ), Rectangle:new( 0, 0, 128, 128 ),
"Color Picker", "Color Picker",
Color:new( 255, 255, 255, 255 ), Color:new( 255, 255, 255, 255 ),
{ -- Callbacks. { -- Callbacks.
@@ -226,12 +225,12 @@ local function addPropertyList()
), tintGroup ) ), tintGroup )
PropertyList:addControl( PropertyList.gui:Line( PropertyList:addControl( PropertyList.gui:Line(
Rect:new( 0, 0, 0, 0 ), Rectangle:new( 0, 0, 0, 0 ),
"Testing" "Testing"
) ) ) )
PropertyList:addControl( PropertyList.gui:DropdownBox( PropertyList:addControl( PropertyList.gui:DropdownBox(
Rect:new( 0, 0, 0, 0 ), Rectangle:new( 0, 0, 0, 0 ),
"Dog\nGiraffe\nLion\nHorse", "Dog\nGiraffe\nLion\nHorse",
0, 0,
false, false,
@@ -244,7 +243,7 @@ local function addPropertyList()
for i = 1, 5 do for i = 1, 5 do
PropertyList:addControl( PropertyList.gui:CheckBox( PropertyList:addControl( PropertyList.gui:CheckBox(
Rect:new( 128, 0, 20, 20 ), Rectangle:new( 128, 0, 20, 20 ),
i.."_Visible", i.."_Visible",
false, false,
{ -- Callbacks. { -- Callbacks.
@@ -268,7 +267,7 @@ end
local function addTreeView() local function addTreeView()
TreeView = Gui:TreeView( TreeView = Gui:TreeView(
Rect:new( 600, 20, 256, 328 ), Rectangle:new( 600, 20, 256, 328 ),
"Tree View", "Tree View",
{ -- Callbacks. { -- Callbacks.
select = function( controls ) selected( controls ) end, select = function( controls ) selected( controls ) end,
@@ -298,8 +297,8 @@ end
function RL.init() function RL.init()
local monitor = 0 local monitor = 0
local mPos = Vec2:newT( RL.GetMonitorPosition( monitor ) ) local mPos = Vector2:newT( RL.GetMonitorPosition( monitor ) )
local mSize = Vec2:newT( RL.GetMonitorSize( monitor ) ) local mSize = Vector2:newT( RL.GetMonitorSize( monitor ) )
RL.SetWindowState( RL.FLAG_WINDOW_RESIZABLE ) RL.SetWindowState( RL.FLAG_WINDOW_RESIZABLE )
RL.SetWindowState( RL.FLAG_VSYNC_HINT ) RL.SetWindowState( RL.FLAG_VSYNC_HINT )
@@ -312,7 +311,7 @@ function RL.init()
-- RL.GuiSetStyle( RL.SPINNER, RL.TEXT_PADDING, 2 ) -- RL.GuiSetStyle( RL.SPINNER, RL.TEXT_PADDING, 2 )
cat.texture = RL.LoadTexture( RL.GetBasePath().."../resources/images/cat.png" ) cat.texture = RL.LoadTexture( RL.GetBasePath().."../resources/images/cat.png" )
local texSize = Vec2:newT( RL.GetTextureSize( cat.texture ) ) local texSize = Vector2:newT( RL.GetTextureSize( cat.texture ) )
cat.source:set( 0, 0, texSize.x, texSize.y ) cat.source:set( 0, 0, texSize.x, texSize.y )
cat.dest = cat.source:clone() cat.dest = cat.source:clone()

View File

@@ -10,8 +10,8 @@ function PropertyList:new( bounds, text, callbacks, styles, tooltip )
object.bounds = bounds:clone() object.bounds = bounds:clone()
object.text = text object.text = text
object.scroll = Vec2:new( 0, 0 ) object.scroll = Vector2:new( 0, 0 )
object.view = Rect:new( 0, 0, 0, 0 ) object.view = Rectangle:new( 0, 0, 0, 0 )
object.callbacks = callbacks -- scroll, grab, drag. object.callbacks = callbacks -- scroll, grab, drag.
object.styles = styles object.styles = styles
object.tooltip = tooltip object.tooltip = tooltip
@@ -28,9 +28,8 @@ function PropertyList:new( bounds, text, callbacks, styles, tooltip )
object.disabled = false object.disabled = false
object.draggable = true object.draggable = true
object.defaultControlHeight = 22 object.defaultControlHeight = 22
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( Vector2:new( object.bounds.width, object.bounds.height ) )
object._forceCheckScroll = false object._forceCheckScroll = false
object._posY = 0 -- In control list update. object._posY = 0 -- In control list update.
@@ -41,7 +40,7 @@ function PropertyList:new( bounds, text, callbacks, styles, tooltip )
end end
function PropertyList:getDefaultBounds() function PropertyList:getDefaultBounds()
return Rect:new( self.padding, self.padding, self.defaultControlSize.x, self.defaultControlSize.y ) return Rectangle:new( self.padding, self.padding, self.defaultControlSize.x, self.defaultControlSize.y )
end end
local function getControlBounds( control ) local function getControlBounds( control )
@@ -65,7 +64,7 @@ function PropertyList:updateControl( control )
end end
if control.visible then if control.visible then
control:setPosition( Vec2:new( control.bounds.x, self._posY ) ) control:setPosition( Vector2:new( control.bounds.x, self._posY ) )
local bounds = getControlBounds( control ) local bounds = getControlBounds( control )
if not control._noYAdvance then if not control._noYAdvance then
@@ -206,18 +205,26 @@ function PropertyList:draw()
{ math.floor( self.view.x ), math.floor( self.view.y ), self.view.width, self.view.height }, { math.floor( self.view.x ), math.floor( self.view.y ), self.view.width, self.view.height },
{ 0, 0 }, { 0, 0 },
0.0, 0.0,
RL.WHITE RL.WHITE
) )
end end
function PropertyList:updateMouseOffset() function PropertyList:updateMouseOffset()
self.gui.mouseOffset = Vec2:new( -self.view.x - self.scroll.x, -self.view.y - self.scroll.y ):scale( self.mouseScale ) if self._gui then
self.gui.mouseScale = self._gui.mouseScale
local mouseScale = Vector2:temp( 1, 1 ) / self.gui.mouseScale
self.gui.mouseOffset = self._gui.mouseOffset + ( -Vector2:temp( self.view.x, self.view.y ) - self.scroll ) * mouseScale
end
end end
function PropertyList:setPosition( pos ) function PropertyList:setPosition( pos )
self.bounds.x = pos.x self.bounds.x = pos.x
self.bounds.y = pos.y self.bounds.y = pos.y
if self.visible then
self:draw() -- Update self.view.
end
self:updateMouseOffset() self:updateMouseOffset()
end end
@@ -228,19 +235,19 @@ function PropertyList:setSize( size )
local scrollBarWidth = RL.GuiGetStyle( RL.LISTVIEW, RL.SCROLLBAR_WIDTH ) local scrollBarWidth = RL.GuiGetStyle( RL.LISTVIEW, RL.SCROLLBAR_WIDTH )
local borderWidth = RL.GuiGetStyle( RL.DEFAULT, RL.BORDER_WIDTH ) local borderWidth = RL.GuiGetStyle( RL.DEFAULT, RL.BORDER_WIDTH )
self.content = Rect:new( self.content = Rectangle:new(
0, 0,
self.gui.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT, self.gui.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT,
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, self.defaultControlHeight ) self.defaultControlSize = Vector2: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:newT( view ) self.view = Rectangle:newT( view )
self.gui.view = Rect:new( 0, 0, self.view.width, self.view.height ) self.gui.view = Rectangle:new( 0, 0, self.view.width, self.view.height )
self.framebufferSize = Vec2:new( self.bounds.width, self.bounds.height - self.gui.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT ) self.framebufferSize = Vector2:new( self.bounds.width, self.bounds.height - self.gui.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT )
if self.framebuffer ~= nil and not RL.IsGCUnloadEnabled() then if self.framebuffer ~= nil and not RL.IsGCUnloadEnabled() then
RL.UnloadRenderTexture( self.framebuffer ) RL.UnloadRenderTexture( self.framebuffer )

View File

@@ -42,7 +42,7 @@ function TreeItem:setOpenIcon()
end end
function TreeItem:draw() function TreeItem:draw()
local buttonRect = Rect:new( 0, 0, 0, 0 ) local buttonRect = Rectangle:new( 0, 0, 0, 0 )
local hasContainer = 0 < #self.controls local hasContainer = 0 < #self.controls
local lineCol = RL.GetColor( RL.GuiGetStyle( RL.DEFAULT, RL.LINE_COLOR ) ) local lineCol = RL.GetColor( RL.GuiGetStyle( RL.DEFAULT, RL.LINE_COLOR ) )
@@ -59,7 +59,7 @@ function TreeItem:draw()
}, lineCol ) }, lineCol )
end end
local toggleRect = Rect:new( local toggleRect = Rectangle:new(
self.bounds.x + buttonRect.width, self.bounds.x + buttonRect.width,
self.bounds.y, self.bounds.y,
self.bounds.width - buttonRect.width, self.bounds.width - buttonRect.width,

View File

@@ -20,8 +20,8 @@ function TreeView:new( bounds, text, callbacks, styles, tooltip )
object.bounds = bounds:clone() object.bounds = bounds:clone()
object.text = text object.text = text
object.scroll = Vec2:new( 0, 0 ) object.scroll = Vector2:new( 0, 0 )
object.view = Rect:new( 0, 0, 0, 0 ) object.view = Rectangle:new( 0, 0, 0, 0 )
object.callbacks = callbacks -- select, grab, drag. object.callbacks = callbacks -- select, grab, drag.
object.styles = styles object.styles = styles
object.tooltip = tooltip object.tooltip = tooltip
@@ -44,7 +44,7 @@ function TreeView:new( bounds, text, callbacks, styles, tooltip )
object.selectedItems = {} object.selectedItems = {}
object:setSize( Vec2:new( object.bounds.width, object.bounds.height ) ) object:setSize( Vector2:new( object.bounds.width, object.bounds.height ) )
object._forceCheckScroll = false object._forceCheckScroll = false
object._posY = 0 -- In control list update. object._posY = 0 -- In control list update.
@@ -61,7 +61,7 @@ function TreeView:new( bounds, text, callbacks, styles, tooltip )
end end
function TreeView:getDefaultBounds() function TreeView:getDefaultBounds()
return Rect:new( self.padding, self.padding, self.defaultControlSize.x, self.defaultControlSize.y ) return Rectangle:new( self.padding, self.padding, self.defaultControlSize.x, self.defaultControlSize.y )
end end
local function getControlBounds( control ) local function getControlBounds( control )
@@ -76,7 +76,7 @@ function TreeView:updateControl( control )
self._curId = self._curId + 1 self._curId = self._curId + 1
if control.visible then if control.visible then
control:setPosition( Vec2:new( control.bounds.x, self._posY ) ) control:setPosition( Vector2:new( control.bounds.x, self._posY ) )
local bounds = getControlBounds( control ) local bounds = getControlBounds( control )
bounds.x = bounds.x + self._curDepth * self.indentation bounds.x = bounds.x + self._curDepth * self.indentation
@@ -269,7 +269,7 @@ function TreeView:itemSelect( item )
end end
function TreeView:update() function TreeView:update()
local mousePos = Vec2:newT( RL.GetMousePosition() ) local mousePos = Vector2:newT( RL.GetMousePosition() )
local guiMousePos = mousePos + self.gui.mouseOffset local guiMousePos = mousePos + self.gui.mouseOffset
local mouseInView = self.view:checkCollisionPoint( mousePos ) local mouseInView = self.view:checkCollisionPoint( mousePos )
@@ -360,7 +360,7 @@ function TreeView:draw()
end end
function TreeView:updateMouseOffset() function TreeView:updateMouseOffset()
self.gui.mouseOffset = Vec2:new( -self.view.x - self.scroll.x, -self.view.y - self.scroll.y ):scale( self.mouseScale ) self.gui.mouseOffset = Vector2:new( -self.view.x - self.scroll.x, -self.view.y - self.scroll.y ):scale( self.mouseScale )
end end
function TreeView:setPosition( pos ) function TreeView:setPosition( pos )
@@ -377,19 +377,19 @@ function TreeView:setSize( size )
local scrollBarWidth = RL.GuiGetStyle( RL.LISTVIEW, RL.SCROLLBAR_WIDTH ) local scrollBarWidth = RL.GuiGetStyle( RL.LISTVIEW, RL.SCROLLBAR_WIDTH )
local borderWidth = RL.GuiGetStyle( RL.DEFAULT, RL.BORDER_WIDTH ) local borderWidth = RL.GuiGetStyle( RL.DEFAULT, RL.BORDER_WIDTH )
self.content = Rect:new( self.content = Rectangle:new(
0, 0,
self.gui.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT, self.gui.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT,
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, self.defaultControlHeight ) self.defaultControlSize = Vector2: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:newT( view ) self.view = Rectangle:newT( view )
self.gui.view = Rect:new( 0, 0, self.view.width, self.view.height ) self.gui.view = Rectangle:new( 0, 0, self.view.width, self.view.height )
self.framebufferSize = Vec2:new( self.bounds.width, self.bounds.height - self.gui.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT ) self.framebufferSize = Vector2:new( self.bounds.width, self.bounds.height - self.gui.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT )
if self.framebuffer ~= nil and not RL.IsGCUnloadEnabled() then if self.framebuffer ~= nil and not RL.IsGCUnloadEnabled() then
RL.UnloadRenderTexture( self.framebuffer ) RL.UnloadRenderTexture( self.framebuffer )

View File

@@ -33,10 +33,10 @@ local metatable = {
return 4 return 4
end, end,
__eq = function( c1, c2 ) __eq = function( c1, c2 )
return math.floor( c1.r ) == math.floor( c2.r ) return RL.FloatEquals( c1.r, c2.r )
and math.floor( c1.g ) == math.floor( c2.g ) and RL.FloatEquals( c1.g, c2.g )
and math.floor( c1.b ) == math.floor( c2.b ) and RL.FloatEquals( c1.b, c2.b )
and math.floor( c1.a ) == math.floor( c2.a ) and RL.FloatEquals( c1.a, c2.a )
end, end,
__concat = function( a, b ) __concat = function( a, b )
return tostring( a )..tostring( b ) return tostring( a )..tostring( b )
@@ -164,6 +164,15 @@ function Color:lerp( color, amount )
) )
end end
function Color:round()
return Color:new(
RL.Round( self.r ),
RL.Round( self.g ),
RL.Round( self.b ),
RL.Round( self.a )
)
end
-- Temp pre generated objects to avoid "slow" table generation. -- Temp pre generated objects to avoid "slow" table generation.
local TEMP_COUNT = 100 local TEMP_COUNT = 100

View File

@@ -31,7 +31,7 @@ local metatable = {
return 4 return 4
end, end,
__eq = function( q1, q2 ) __eq = function( q1, q2 )
return RL.QuaternionEquals( q1, q2 ) == 1 return RL.QuaternionEquals( q1, q2 )
end, end,
__concat = function( a, b ) __concat = function( a, b )
return tostring( a )..tostring( b ) return tostring( a )..tostring( b )

View File

@@ -59,7 +59,7 @@ function WindowBox:new( bounds, text, callbacks, styles, tooltip )
object.bounds = bounds:clone() object.bounds = bounds:clone()
object.text = text object.text = text
object.callbacks = callbacks -- close, grab, drag. object.callbacks = callbacks -- close, grab, drag.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.draggable = true object.draggable = true
@@ -102,7 +102,7 @@ function GroupBox:new( bounds, text, styles, tooltip )
object.text = text object.text = text
object.styles = styles object.styles = styles
object.tooltip = tooltip object.tooltip = tooltip
object.visible = true object.visible = true
object.disabled = false object.disabled = false
@@ -134,7 +134,7 @@ function Line:new( bounds, text, styles, tooltip )
object.bounds = bounds:clone() object.bounds = bounds:clone()
object.text = text object.text = text
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.styles = styles object.styles = styles
@@ -169,7 +169,7 @@ function Panel:new( bounds, text, callbacks, styles, tooltip )
object.bounds = bounds:clone() object.bounds = bounds:clone()
object.text = text object.text = text
object.callbacks = callbacks -- grab, drag. object.callbacks = callbacks -- grab, drag.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.draggable = true object.draggable = true
@@ -206,7 +206,7 @@ function GuiTabBar:new( bounds, text, active, callbacks, styles, tooltip )
object.text = text object.text = text
object.active = active object.active = active
object.callbacks = callbacks -- select, close, grab, drag. object.callbacks = callbacks -- select, close, grab, drag.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.styles = styles object.styles = styles
@@ -261,7 +261,7 @@ function ScrollPanel:new( bounds, text, content, scroll, callbacks, styles, tool
object.scroll = scroll:clone() object.scroll = scroll:clone()
object.view = Rectangle:new( 0, 0, 0, 0 ) object.view = Rectangle:new( 0, 0, 0, 0 )
object.callbacks = callbacks -- scroll, grab, drag. object.callbacks = callbacks -- scroll, grab, drag.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.draggable = true object.draggable = true
@@ -310,7 +310,7 @@ function Label:new( bounds, text, styles, tooltip )
object.bounds = bounds:clone() object.bounds = bounds:clone()
object.text = text object.text = text
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.styles = styles object.styles = styles
@@ -345,7 +345,7 @@ function Button:new( bounds, text, callbacks, styles, tooltip )
object.bounds = bounds:clone() object.bounds = bounds:clone()
object.text = text object.text = text
object.callbacks = callbacks -- pressed. object.callbacks = callbacks -- pressed.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.styles = styles object.styles = styles
@@ -384,7 +384,7 @@ function LabelButton:new( bounds, text, callbacks, styles, tooltip )
object.bounds = bounds:clone() object.bounds = bounds:clone()
object.text = text object.text = text
object.callbacks = callbacks -- pressed. object.callbacks = callbacks -- pressed.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.styles = styles object.styles = styles
@@ -424,7 +424,7 @@ function Toggle:new( bounds, text, active, callbacks, styles, tooltip )
object.text = text object.text = text
object.active = active object.active = active
object.callbacks = callbacks -- pressed. object.callbacks = callbacks -- pressed.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.styles = styles object.styles = styles
@@ -473,7 +473,7 @@ function ToggleGroup:new( bounds, text, active, callbacks, styles, tooltip )
object.text = text object.text = text
object.active = active object.active = active
object.callbacks = callbacks -- select. object.callbacks = callbacks -- select.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.focusBounds = {} object.focusBounds = {}
@@ -538,7 +538,7 @@ function ToggleGroup:draw()
if self.active ~= oldActive then if self.active ~= oldActive then
local inBounds = false local inBounds = false
for _, bounds in ipairs( self.focusBounds ) do for _, bounds in ipairs( self.focusBounds ) do
if self._gui:clickedInBounds( bounds ) then if self._gui:clickedInBounds( bounds ) then
inBounds = true inBounds = true
@@ -578,12 +578,12 @@ function CheckBox:new( bounds, text, checked, callbacks, styles, tooltip )
object.text = text object.text = text
object.checked = checked object.checked = checked
object.callbacks = callbacks -- pressed. object.callbacks = callbacks -- pressed.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.textBounds = Rectangle:new( 0, 0, 0, 0 ) object.textBounds = Rectangle:new( 0, 0, 0, 0 )
object.focusBounds = bounds:clone() object.focusBounds = bounds:clone()
object._focusBoundsOffset = Vector2:new( 0, 0 ) -- Used in set position. object._focusBoundsOffset = Vector2:new( 0, 0 ) -- Used in set position.
object.styles = styles object.styles = styles
object.tooltip = tooltip object.tooltip = tooltip
@@ -636,7 +636,7 @@ function ComboBox:new( bounds, text, active, callbacks, styles, tooltip )
object.text = text object.text = text
object.active = active object.active = active
object.callbacks = callbacks -- select. object.callbacks = callbacks -- select.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.styles = styles object.styles = styles
@@ -686,7 +686,7 @@ function DropdownBox:new( bounds, text, active, editMode, callbacks, styles, too
object.active = active object.active = active
object.editMode = editMode object.editMode = editMode
object.callbacks = callbacks -- select. object.callbacks = callbacks -- select.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.editModeBounds = bounds:clone() object.editModeBounds = bounds:clone()
@@ -747,7 +747,7 @@ Spinner.__index = Spinner
function Spinner:new( bounds, text, value, minValue, maxValue, editMode, callbacks, styles, tooltip ) function Spinner:new( bounds, text, value, minValue, maxValue, editMode, callbacks, styles, tooltip )
local object = setmetatable( {}, self ) local object = setmetatable( {}, self )
object._gui = nil object._gui = nil
object.bounds = bounds:clone() object.bounds = bounds:clone()
object.text = text object.text = text
object.value = value object.value = value
@@ -755,12 +755,12 @@ function Spinner:new( bounds, text, value, minValue, maxValue, editMode, callbac
object.maxValue = maxValue object.maxValue = maxValue
object.editMode = editMode object.editMode = editMode
object.callbacks = callbacks -- edit. object.callbacks = callbacks -- edit.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.textBounds = Rectangle:new( 0, 0, 0, 0 ) object.textBounds = Rectangle:new( 0, 0, 0, 0 )
object.viewBounds = bounds:clone() object.viewBounds = bounds:clone()
object._viewBoundsOffset = Vector2:new( 0, 0 ) object._viewBoundsOffset = Vector2:new( 0, 0 )
object.styles = styles object.styles = styles
object.tooltip = tooltip object.tooltip = tooltip
@@ -818,7 +818,7 @@ ValueBox.__index = ValueBox
function ValueBox:new( bounds, text, value, minValue, maxValue, editMode, callbacks, styles, tooltip ) function ValueBox:new( bounds, text, value, minValue, maxValue, editMode, callbacks, styles, tooltip )
local object = setmetatable( {}, self ) local object = setmetatable( {}, self )
object._gui = nil object._gui = nil
object.bounds = bounds:clone() object.bounds = bounds:clone()
object.text = text object.text = text
object.value = value object.value = value
@@ -826,12 +826,12 @@ function ValueBox:new( bounds, text, value, minValue, maxValue, editMode, callba
object.maxValue = maxValue object.maxValue = maxValue
object.editMode = editMode object.editMode = editMode
object.callbacks = callbacks -- edit. object.callbacks = callbacks -- edit.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.textBounds = Rectangle:new( 0, 0, 0, 0 ) object.textBounds = Rectangle:new( 0, 0, 0, 0 )
object.viewBounds = bounds:clone() object.viewBounds = bounds:clone()
object._viewBoundsOffset = Vector2:new( 0, 0 ) object._viewBoundsOffset = Vector2:new( 0, 0 )
object.styles = styles object.styles = styles
object.tooltip = tooltip object.tooltip = tooltip
@@ -938,7 +938,7 @@ Slider.__index = Slider
function Slider:new( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) function Slider:new( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip )
local object = setmetatable( {}, self ) local object = setmetatable( {}, self )
object._gui = nil object._gui = nil
object.bounds = bounds:clone() object.bounds = bounds:clone()
object.textLeft = textLeft object.textLeft = textLeft
object.textRight = textRight object.textRight = textRight
@@ -952,7 +952,7 @@ function Slider:new( bounds, textLeft, textRight, value, minValue, maxValue, cal
object.textLeftBounds = Rectangle:new( 0, 0, 0, 0 ) object.textLeftBounds = Rectangle:new( 0, 0, 0, 0 )
object.textRightBounds = Rectangle:new( 0, 0, 0, 0 ) object.textRightBounds = Rectangle:new( 0, 0, 0, 0 )
object.viewBounds = bounds:clone() object.viewBounds = bounds:clone()
object._viewBoundsOffset = Vector2:new( 0, 0 ) object._viewBoundsOffset = Vector2:new( 0, 0 )
object.styles = styles object.styles = styles
object.tooltip = tooltip object.tooltip = tooltip
@@ -1010,13 +1010,13 @@ function SliderBar:new( bounds, textLeft, textRight, value, minValue, maxValue,
object.minValue = minValue object.minValue = minValue
object.maxValue = maxValue object.maxValue = maxValue
object.callbacks = callbacks -- edit. object.callbacks = callbacks -- edit.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.textLeftBounds = Rectangle:new( 0, 0, 0, 0 ) object.textLeftBounds = Rectangle:new( 0, 0, 0, 0 )
object.textRightBounds = Rectangle:new( 0, 0, 0, 0 ) object.textRightBounds = Rectangle:new( 0, 0, 0, 0 )
object.viewBounds = bounds:clone() object.viewBounds = bounds:clone()
object._viewBoundsOffset = Vector2:new( 0, 0 ) object._viewBoundsOffset = Vector2:new( 0, 0 )
object.styles = styles object.styles = styles
object.tooltip = tooltip object.tooltip = tooltip
@@ -1074,13 +1074,13 @@ function ProgressBar:new( bounds, textLeft, textRight, value, minValue, maxValue
object.minValue = minValue object.minValue = minValue
object.maxValue = maxValue object.maxValue = maxValue
object.callbacks = callbacks -- edit. object.callbacks = callbacks -- edit.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.textLeftBounds = Rectangle:new( 0, 0, 0, 0 ) object.textLeftBounds = Rectangle:new( 0, 0, 0, 0 )
object.textRightBounds = Rectangle:new( 0, 0, 0, 0 ) object.textRightBounds = Rectangle:new( 0, 0, 0, 0 )
object.viewBounds = bounds:clone() object.viewBounds = bounds:clone()
object._viewBoundsOffset = Vector2:new( 0, 0 ) object._viewBoundsOffset = Vector2:new( 0, 0 )
object.styles = styles object.styles = styles
object.tooltip = tooltip object.tooltip = tooltip
@@ -1100,7 +1100,7 @@ function ProgressBar:draw()
self.textRightBounds:setT( textRightBounds ) self.textRightBounds:setT( textRightBounds )
self.viewBounds = self.bounds:fit( self.textLeftBounds ):fit( self.textRightBounds ) self.viewBounds = self.bounds:fit( self.textLeftBounds ):fit( self.textRightBounds )
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 self.value ~= oldValue then if self.value ~= oldValue then
if not self._gui:clickedInBounds( self.bounds ) then if not self._gui:clickedInBounds( self.bounds ) then
self.value = oldValue self.value = oldValue
@@ -1132,7 +1132,7 @@ function StatusBar:new( bounds, text, styles, tooltip )
object.bounds = bounds:clone() object.bounds = bounds:clone()
object.text = text object.text = text
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.styles = styles object.styles = styles
@@ -1166,7 +1166,7 @@ function DummyRec:new( bounds, text, styles, tooltip )
object.bounds = bounds:clone() object.bounds = bounds:clone()
object.text = text object.text = text
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.styles = styles object.styles = styles
@@ -1203,7 +1203,7 @@ function Grid:new( bounds, text, spacing, subdivs, callbacks, styles, tooltip )
object.spacing = spacing object.spacing = spacing
object.subdivs = subdivs object.subdivs = subdivs
object.callbacks = callbacks -- cellChange. object.callbacks = callbacks -- cellChange.
object.mouseCell = Vector2:new( 0, 0 ) object.mouseCell = Vector2:new( 0, 0 )
object.visible = true object.visible = true
object.disabled = false object.disabled = false
@@ -1253,7 +1253,7 @@ function ListView:new( bounds, text, scrollIndex, active, callbacks, styles, too
object.scrollIndex = scrollIndex object.scrollIndex = scrollIndex
object.active = active object.active = active
object.callbacks = callbacks -- select. object.callbacks = callbacks -- select.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.styles = styles object.styles = styles
@@ -1305,7 +1305,7 @@ function ListViewEx:new( bounds, text, scrollIndex, active, focus, callbacks, st
object.active = active object.active = active
object.focus = focus object.focus = focus
object.callbacks = callbacks -- select. object.callbacks = callbacks -- select.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.styles = styles object.styles = styles
@@ -1356,7 +1356,7 @@ function MessageBox:new( bounds, title, message, buttons, callbacks, styles, too
object.message = message object.message = message
object.buttons = buttons object.buttons = buttons
object.callbacks = callbacks -- pressed, grab, drag. object.callbacks = callbacks -- pressed, grab, drag.
object.buttonIndex = -1 object.buttonIndex = -1
object.visible = true object.visible = true
object.disabled = false object.disabled = false
@@ -1406,7 +1406,7 @@ function TextInputBox:new( bounds, title, message, buttons, text, textMaxSize, s
object.textMaxSize = textMaxSize object.textMaxSize = textMaxSize
object.secretViewActive = secretViewActive object.secretViewActive = secretViewActive
object.callbacks = callbacks -- pressed, grab, drag. object.callbacks = callbacks -- pressed, grab, drag.
object.buttonIndex = -1 object.buttonIndex = -1
object.visible = true object.visible = true
object.disabled = false object.disabled = false
@@ -1452,13 +1452,13 @@ function ColorPicker:new( bounds, text, color, callbacks, styles, tooltip )
object.text = text object.text = text
object.color = color object.color = color
object.callbacks = callbacks -- edit. object.callbacks = callbacks -- edit.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.focusBounds = Rectangle:new( 0, 0, 0, 0 ) object.focusBounds = Rectangle:new( 0, 0, 0, 0 )
object.styles = styles object.styles = styles
object.tooltip = tooltip object.tooltip = tooltip
object:updateFocusBounds() object:updateFocusBounds()
return object return object
@@ -1518,7 +1518,7 @@ function ColorPanel:new( bounds, text, color, callbacks, styles, tooltip )
object.text = text object.text = text
object.color = color object.color = color
object.callbacks = callbacks -- edit. object.callbacks = callbacks -- edit.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.styles = styles object.styles = styles
@@ -1568,7 +1568,7 @@ function ColorBarAlpha:new( bounds, text, alpha, callbacks, styles, tooltip )
object.text = text object.text = text
object.alpha = alpha object.alpha = alpha
object.callbacks = callbacks -- edit. object.callbacks = callbacks -- edit.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.styles = styles object.styles = styles
@@ -1617,7 +1617,7 @@ function ColorBarHue:new( bounds, text, value, callbacks, styles, tooltip )
object.text = text object.text = text
object.value = value object.value = value
object.callbacks = callbacks -- edit. object.callbacks = callbacks -- edit.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.styles = styles object.styles = styles
@@ -1667,7 +1667,7 @@ function GuiScrollBar:new( bounds, value, minValue, maxValue, callbacks, styles,
object.minValue = minValue object.minValue = minValue
object.maxValue = maxValue object.maxValue = maxValue
object.callbacks = callbacks -- edit. object.callbacks = callbacks -- edit.
object.visible = true object.visible = true
object.disabled = false object.disabled = false
object.styles = styles object.styles = styles
@@ -1726,6 +1726,7 @@ function Raygui:new()
object.defaultRect = Rectangle:new( 0, 0, 1, 1 ) -- For texture. object.defaultRect = Rectangle:new( 0, 0, 1, 1 ) -- For texture.
object.defaultFont = RL.GuiGetFont() object.defaultFont = RL.GuiGetFont()
object.mouseOffset = Vector2:new( 0, 0 ) object.mouseOffset = Vector2:new( 0, 0 )
object.mouseScale = Vector2:new( 1, 1 )
object.view = Rectangle:new( 0, 0, 0, 0 ) -- Active if larger than 0. Then only controls in view will be updated and drawn. object.view = Rectangle:new( 0, 0, 0, 0 ) -- Active if larger than 0. Then only controls in view will be updated and drawn.
object.tooltip = { object.tooltip = {
text = nil, text = nil,
@@ -1756,7 +1757,10 @@ function Raygui:update()
return return
end 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.
local mouseOffset = RL.GetMouseOffset()
local mouseScale = RL.GetMouseScale()
RL.SetMouseOffset( self.mouseOffset ) RL.SetMouseOffset( self.mouseOffset )
RL.SetMouseScale( self.mouseScale )
if RL.IsMouseButtonPressed( RL.MOUSE_BUTTON_LEFT ) then if RL.IsMouseButtonPressed( RL.MOUSE_BUTTON_LEFT ) then
self._mousePressPos:setT( RL.GetMousePosition() ) self._mousePressPos:setT( RL.GetMousePosition() )
@@ -1771,15 +1775,15 @@ function Raygui:update()
if control.visible and control.update ~= nil and self:inView( control ) then if control.visible and control.update ~= nil and self:inView( control ) then
if control:update() then if control:update() then
self.focused = i self.focused = i
if i ~= self.tooltip.focused then if i ~= self.tooltip.focused then
self.tooltip.focused = -1 -- Note that we don't want it to be 0, same as self.focus. self.tooltip.focused = -1 -- Note that we don't want it to be 0, same as self.focus.
self.tooltip.timer = 0.0 self.tooltip.timer = 0.0
end end
if control.tooltip ~= nil then if control.tooltip ~= nil then
self.tooltip.focused = i self.tooltip.focused = i
if self.tooltip.timer < self.tooltip.delay then if self.tooltip.timer < self.tooltip.delay then
self.tooltip.timer = self.tooltip.timer + RL.GetFrameTime() self.tooltip.timer = self.tooltip.timer + RL.GetFrameTime()
else else
@@ -1798,7 +1802,8 @@ function Raygui:update()
self.tooltip.timer = 0.0 self.tooltip.timer = 0.0
end end
RL.SetMouseOffset( { 0, 0 } ) RL.SetMouseOffset( mouseOffset )
RL.SetMouseScale( mouseScale )
end end
function Raygui:drag( control ) function Raygui:drag( control )
@@ -1883,7 +1888,10 @@ function Raygui:draw()
end 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.
local mouseOffset = RL.GetMouseOffset()
local mouseScale = RL.GetMouseScale()
RL.SetMouseOffset( self.mouseOffset ) RL.SetMouseOffset( self.mouseOffset )
RL.SetMouseScale( self.mouseScale )
for i, control in ipairs( self.controls ) do for i, control in ipairs( self.controls ) do
if not self.locked and not self.disabled and i == self.focused then if not self.locked and not self.disabled and i == self.focused then
@@ -1911,7 +1919,8 @@ function Raygui:draw()
RL.GuiUnlock() RL.GuiUnlock()
RL.GuiEnable() RL.GuiEnable()
RL.SetMouseOffset( { 0, 0 } ) RL.SetMouseOffset( mouseOffset )
RL.SetMouseScale( mouseScale )
end end
function Raygui:checkScrolling() function Raygui:checkScrolling()

View File

@@ -34,7 +34,7 @@ local metatable = {
return 2 return 2
end, end,
__eq = function( v1, v2 ) __eq = function( v1, v2 )
return RL.Vector2Equals( v1, v2 ) == 1 return RL.Vector2Equals( v1, v2 )
end, end,
__concat = function( a, b ) __concat = function( a, b )
return tostring( a )..tostring( b ) return tostring( a )..tostring( b )

View File

@@ -36,7 +36,7 @@ local metatable = {
return 3 return 3
end, end,
__eq = function( v1, v2 ) __eq = function( v1, v2 )
return RL.Vector3Equals( v1, v2 ) == 1 return RL.Vector3Equals( v1, v2 )
end, end,
__concat = function( a, b ) __concat = function( a, b )
return tostring( a )..tostring( b ) return tostring( a )..tostring( b )

View File

@@ -137,13 +137,13 @@ int lmathWrap( lua_State* L ) {
Check whether two given floats are almost equal Check whether two given floats are almost equal
- Success return int - Success return bool
*/ */
int lmathFloatEquals( lua_State* L ) { int lmathFloatEquals( lua_State* L ) {
float x = luaL_checknumber( L, 1 ); float x = luaL_checknumber( L, 1 );
float y = luaL_checknumber( L, 2 ); float y = luaL_checknumber( L, 2 );
lua_pushinteger( L, FloatEquals( x, y ) ); lua_pushboolean( L, FloatEquals( x, y ) == 1 );
return 1; return 1;
} }
@@ -570,13 +570,13 @@ int lmathVector2ClampValue( lua_State* L ) {
Check whether two given vectors are almost equal Check whether two given vectors are almost equal
- Success return int - Success return bool
*/ */
int lmathVector2Equals( lua_State* L ) { int lmathVector2Equals( lua_State* L ) {
Vector2 v1 = uluaGetVector2( L, 1 ); Vector2 v1 = uluaGetVector2( L, 1 );
Vector2 v2 = uluaGetVector2( L, 2 ); Vector2 v2 = uluaGetVector2( L, 2 );
lua_pushinteger( L, Vector2Equals( v1, v2 ) ); lua_pushboolean( L, Vector2Equals( v1, v2 ) == 1 );
return 1; return 1;
} }
@@ -1136,13 +1136,13 @@ int lmathVector3ClampValue( lua_State* L ) {
Check whether two given vectors are almost equal Check whether two given vectors are almost equal
- Success return int - Success return bool
*/ */
int lmathVector3Equals( lua_State* L ) { int lmathVector3Equals( lua_State* L ) {
Vector3 v1 = uluaGetVector3( L, 1 ); Vector3 v1 = uluaGetVector3( L, 1 );
Vector3 v2 = uluaGetVector3( L, 2 ); Vector3 v2 = uluaGetVector3( L, 2 );
lua_pushinteger( L, Vector3Equals( v1, v2 ) ); lua_pushboolean( L, Vector3Equals( v1, v2 ) == 1 );
return 1; return 1;
} }
@@ -1853,13 +1853,13 @@ int lmathQuaternionTransform( lua_State* L ) {
Check whether two given quaternions are almost equal Check whether two given quaternions are almost equal
- Success return int - Success return bool
*/ */
int lmathQuaternionEquals( lua_State* L ) { int lmathQuaternionEquals( lua_State* L ) {
Quaternion q1 = uluaGetQuaternion( L, 1 ); Quaternion q1 = uluaGetQuaternion( L, 1 );
Quaternion q2 = uluaGetQuaternion( L, 2 ); Quaternion q2 = uluaGetQuaternion( L, 2 );
lua_pushinteger( L, QuaternionEquals( q1, q2 ) ); lua_pushboolean( L, QuaternionEquals( q1, q2 ) == 1 );
return 1; return 1;
} }

View File

@@ -1897,7 +1897,7 @@ Returns hexadecimal value for a Color
int ltexturesColorToInt( lua_State* L ) { int ltexturesColorToInt( lua_State* L ) {
Color color = uluaGetColor( L, 1 ); Color color = uluaGetColor( L, 1 );
lua_pushinteger( L, ColorToInt( color ) ); lua_pushinteger( L, (unsigned int)ColorToInt( color ) );
return 1; return 1;
} }