Raymath *Equals functions return bool instead of int.
This commit is contained in:
@@ -2,10 +2,9 @@ package.path = package.path..";"..RL.GetBasePath().."?.lua"
|
||||
package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua"
|
||||
|
||||
Util = require( "utillib" )
|
||||
Rect = require( "rectangle" )
|
||||
Vec2 = require( "vector2" )
|
||||
Vector2 = require( "vector2" )
|
||||
Color = require( "color" )
|
||||
Rect = require( "rectangle" )
|
||||
Rectangle = require( "rectangle" )
|
||||
Raygui = require( "raygui" )
|
||||
|
||||
require( "sprite_button" ):register( Raygui )
|
||||
@@ -16,12 +15,12 @@ require( "tree_item" ):register( Raygui )
|
||||
Gui = Raygui:new()
|
||||
|
||||
local buttonTexture = nil
|
||||
local winSize = Vec2:new( 1024, 720 )
|
||||
local winSize = Vector2:new( 1024, 720 )
|
||||
local cat = {
|
||||
texture = nil,
|
||||
source = Rect:new( 0, 0, 0, 0 ),
|
||||
dest = Rect:new( 0, 0, 0, 0 ),
|
||||
origin = Vec2:new( 0, 0 ),
|
||||
source = Rectangle:new( 0, 0, 0, 0 ),
|
||||
dest = Rectangle:new( 0, 0, 0, 0 ),
|
||||
origin = Vector2:new( 0, 0 ),
|
||||
rotation = 0.0,
|
||||
tint = Color:newT( RL.WHITE ),
|
||||
visible = true,
|
||||
@@ -52,8 +51,8 @@ end
|
||||
local function addSpriteButtons()
|
||||
buttonTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/button.png" )
|
||||
|
||||
local buttonSize = Vec2:new( 216, 32 )
|
||||
local bounds = Rect:new( winSize.x / 2 - buttonSize.x / 2, 200, 216, 32 )
|
||||
local buttonSize = Vector2:new( 216, 32 )
|
||||
local bounds = Rectangle:new( winSize.x / 2 - buttonSize.x / 2, 200, 216, 32 )
|
||||
local gap = buttonSize.y + 2
|
||||
addButton( bounds, "Start New Game", { pressed = function() print( "New Game!" ) end } )
|
||||
bounds.y = bounds.y + gap
|
||||
@@ -72,7 +71,7 @@ end
|
||||
|
||||
local function addPropertyList()
|
||||
PropertyList = Gui:PropertyList(
|
||||
Rect:new( 20, 20, 256, 328 ),
|
||||
Rectangle:new( 20, 20, 256, 328 ),
|
||||
"Property List",
|
||||
{ -- Callbacks.
|
||||
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 )
|
||||
|
||||
PropertyList:addControl( PropertyList.gui:Line(
|
||||
Rect:new( 0, 0, 0, 0 ),
|
||||
Rectangle:new( 0, 0, 0, 0 ),
|
||||
"Cat Texture"
|
||||
) )
|
||||
|
||||
@@ -98,11 +97,11 @@ local function addPropertyList()
|
||||
|
||||
-- Position.
|
||||
PropertyList:addControl( PropertyList.gui:Label(
|
||||
Rect:new( 0, 0, 0, 0 ),
|
||||
Rectangle:new( 0, 0, 0, 0 ),
|
||||
"Position:"
|
||||
), transformGroup )
|
||||
PropertyList:addControl( PropertyList.gui:TextBox(
|
||||
Rect:new( 0, 0, 64, 22 ),
|
||||
Rectangle:new( 0, 0, 64, 22 ),
|
||||
cat.dest.x,
|
||||
32,
|
||||
false,
|
||||
@@ -117,7 +116,7 @@ local function addPropertyList()
|
||||
"Position X"
|
||||
), transformGroup, true )
|
||||
PropertyList:addControl( PropertyList.gui:TextBox(
|
||||
Rect:new( 74, 0, 64, 22 ),
|
||||
Rectangle:new( 74, 0, 64, 22 ),
|
||||
cat.dest.y,
|
||||
32,
|
||||
false,
|
||||
@@ -133,11 +132,11 @@ local function addPropertyList()
|
||||
), transformGroup )
|
||||
-- Origin.
|
||||
PropertyList:addControl( PropertyList.gui:Label(
|
||||
Rect:new( 0, 0, 0, 0 ),
|
||||
Rectangle:new( 0, 0, 0, 0 ),
|
||||
"Origin:"
|
||||
), transformGroup )
|
||||
PropertyList:addControl( PropertyList.gui:TextBox(
|
||||
Rect:new( 0, 0, 64, 22 ),
|
||||
Rectangle:new( 0, 0, 64, 22 ),
|
||||
cat.dest.x,
|
||||
32,
|
||||
false,
|
||||
@@ -152,7 +151,7 @@ local function addPropertyList()
|
||||
"Origin X"
|
||||
), transformGroup, true )
|
||||
PropertyList:addControl( PropertyList.gui:TextBox(
|
||||
Rect:new( 74, 0, 64, 22 ),
|
||||
Rectangle:new( 74, 0, 64, 22 ),
|
||||
cat.dest.y,
|
||||
32,
|
||||
false,
|
||||
@@ -168,7 +167,7 @@ local function addPropertyList()
|
||||
), transformGroup )
|
||||
-- Rotation.
|
||||
PropertyList:addControl( PropertyList.gui:Slider(
|
||||
Rect:new( 60, 0, PropertyList.defaultControlSize.x - 150, 22 ),
|
||||
Rectangle:new( 60, 0, PropertyList.defaultControlSize.x - 150, 22 ),
|
||||
"Rotation",
|
||||
"0",
|
||||
0,
|
||||
@@ -186,7 +185,7 @@ local function addPropertyList()
|
||||
), transformGroup )
|
||||
-- Flipped.
|
||||
PropertyList:addControl( PropertyList.gui:CheckBox(
|
||||
Rect:new( 0, 0, 20, 20 ),
|
||||
Rectangle:new( 0, 0, 20, 20 ),
|
||||
"Flipped",
|
||||
cat.flipped,
|
||||
{ -- Callbacks.
|
||||
@@ -201,7 +200,7 @@ local function addPropertyList()
|
||||
local visibilityGroup = PropertyList:addGroup( "Visibility", false )
|
||||
|
||||
PropertyList:addControl( PropertyList.gui:CheckBox(
|
||||
Rect:new( 0, 0, 20, 20 ),
|
||||
Rectangle:new( 0, 0, 20, 20 ),
|
||||
"Visible",
|
||||
cat.visible,
|
||||
{ -- Callbacks.
|
||||
@@ -217,7 +216,7 @@ local function addPropertyList()
|
||||
local tintGroup = PropertyList:addGroup( "Tint", false, visibilityGroup )
|
||||
|
||||
PropertyList:addControl( PropertyList.gui:ColorPicker(
|
||||
Rect:new( 0, 0, 128, 128 ),
|
||||
Rectangle:new( 0, 0, 128, 128 ),
|
||||
"Color Picker",
|
||||
Color:new( 255, 255, 255, 255 ),
|
||||
{ -- Callbacks.
|
||||
@@ -226,12 +225,12 @@ local function addPropertyList()
|
||||
), tintGroup )
|
||||
|
||||
PropertyList:addControl( PropertyList.gui:Line(
|
||||
Rect:new( 0, 0, 0, 0 ),
|
||||
Rectangle:new( 0, 0, 0, 0 ),
|
||||
"Testing"
|
||||
) )
|
||||
|
||||
PropertyList:addControl( PropertyList.gui:DropdownBox(
|
||||
Rect:new( 0, 0, 0, 0 ),
|
||||
Rectangle:new( 0, 0, 0, 0 ),
|
||||
"Dog\nGiraffe\nLion\nHorse",
|
||||
0,
|
||||
false,
|
||||
@@ -244,7 +243,7 @@ local function addPropertyList()
|
||||
|
||||
for i = 1, 5 do
|
||||
PropertyList:addControl( PropertyList.gui:CheckBox(
|
||||
Rect:new( 128, 0, 20, 20 ),
|
||||
Rectangle:new( 128, 0, 20, 20 ),
|
||||
i.."_Visible",
|
||||
false,
|
||||
{ -- Callbacks.
|
||||
@@ -268,7 +267,7 @@ end
|
||||
|
||||
local function addTreeView()
|
||||
TreeView = Gui:TreeView(
|
||||
Rect:new( 600, 20, 256, 328 ),
|
||||
Rectangle:new( 600, 20, 256, 328 ),
|
||||
"Tree View",
|
||||
{ -- Callbacks.
|
||||
select = function( controls ) selected( controls ) end,
|
||||
@@ -298,8 +297,8 @@ end
|
||||
|
||||
function RL.init()
|
||||
local monitor = 0
|
||||
local mPos = Vec2:newT( RL.GetMonitorPosition( monitor ) )
|
||||
local mSize = Vec2:newT( RL.GetMonitorSize( monitor ) )
|
||||
local mPos = Vector2:newT( RL.GetMonitorPosition( monitor ) )
|
||||
local mSize = Vector2:newT( RL.GetMonitorSize( monitor ) )
|
||||
|
||||
RL.SetWindowState( RL.FLAG_WINDOW_RESIZABLE )
|
||||
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
|
||||
@@ -312,7 +311,7 @@ function RL.init()
|
||||
-- RL.GuiSetStyle( RL.SPINNER, RL.TEXT_PADDING, 2 )
|
||||
|
||||
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.dest = cat.source:clone()
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ function PropertyList:new( bounds, text, callbacks, styles, tooltip )
|
||||
|
||||
object.bounds = bounds:clone()
|
||||
object.text = text
|
||||
object.scroll = Vec2:new( 0, 0 )
|
||||
object.view = Rect:new( 0, 0, 0, 0 )
|
||||
object.scroll = Vector2:new( 0, 0 )
|
||||
object.view = Rectangle:new( 0, 0, 0, 0 )
|
||||
object.callbacks = callbacks -- scroll, grab, drag.
|
||||
object.styles = styles
|
||||
object.tooltip = tooltip
|
||||
@@ -28,9 +28,8 @@ function PropertyList:new( bounds, text, callbacks, styles, tooltip )
|
||||
object.disabled = false
|
||||
object.draggable = true
|
||||
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._posY = 0 -- In control list update.
|
||||
@@ -41,7 +40,7 @@ function PropertyList:new( bounds, text, callbacks, styles, tooltip )
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
local function getControlBounds( control )
|
||||
@@ -65,7 +64,7 @@ function PropertyList:updateControl( control )
|
||||
end
|
||||
|
||||
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 )
|
||||
|
||||
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 },
|
||||
{ 0, 0 },
|
||||
0.0,
|
||||
RL.WHITE
|
||||
RL.WHITE
|
||||
)
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
function PropertyList:setPosition( pos )
|
||||
self.bounds.x = pos.x
|
||||
self.bounds.y = pos.y
|
||||
|
||||
if self.visible then
|
||||
self:draw() -- Update self.view.
|
||||
end
|
||||
self:updateMouseOffset()
|
||||
end
|
||||
|
||||
@@ -228,19 +235,19 @@ function PropertyList:setSize( size )
|
||||
local scrollBarWidth = RL.GuiGetStyle( RL.LISTVIEW, RL.SCROLLBAR_WIDTH )
|
||||
local borderWidth = RL.GuiGetStyle( RL.DEFAULT, RL.BORDER_WIDTH )
|
||||
|
||||
self.content = Rect:new(
|
||||
self.content = Rectangle:new(
|
||||
0,
|
||||
self.gui.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT,
|
||||
self.bounds.width - 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 )
|
||||
self.view = Rect:newT( view )
|
||||
self.view = Rectangle:newT( view )
|
||||
|
||||
self.gui.view = Rect: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.gui.view = Rectangle:new( 0, 0, self.view.width, self.view.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
|
||||
RL.UnloadRenderTexture( self.framebuffer )
|
||||
|
||||
@@ -42,7 +42,7 @@ function TreeItem:setOpenIcon()
|
||||
end
|
||||
|
||||
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 lineCol = RL.GetColor( RL.GuiGetStyle( RL.DEFAULT, RL.LINE_COLOR ) )
|
||||
|
||||
@@ -59,7 +59,7 @@ function TreeItem:draw()
|
||||
}, lineCol )
|
||||
end
|
||||
|
||||
local toggleRect = Rect:new(
|
||||
local toggleRect = Rectangle:new(
|
||||
self.bounds.x + buttonRect.width,
|
||||
self.bounds.y,
|
||||
self.bounds.width - buttonRect.width,
|
||||
|
||||
@@ -20,8 +20,8 @@ function TreeView:new( bounds, text, callbacks, styles, tooltip )
|
||||
|
||||
object.bounds = bounds:clone()
|
||||
object.text = text
|
||||
object.scroll = Vec2:new( 0, 0 )
|
||||
object.view = Rect:new( 0, 0, 0, 0 )
|
||||
object.scroll = Vector2:new( 0, 0 )
|
||||
object.view = Rectangle:new( 0, 0, 0, 0 )
|
||||
object.callbacks = callbacks -- select, grab, drag.
|
||||
object.styles = styles
|
||||
object.tooltip = tooltip
|
||||
@@ -44,7 +44,7 @@ function TreeView:new( bounds, text, callbacks, styles, tooltip )
|
||||
|
||||
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._posY = 0 -- In control list update.
|
||||
@@ -61,7 +61,7 @@ function TreeView:new( bounds, text, callbacks, styles, tooltip )
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
local function getControlBounds( control )
|
||||
@@ -76,7 +76,7 @@ function TreeView:updateControl( control )
|
||||
self._curId = self._curId + 1
|
||||
|
||||
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 )
|
||||
|
||||
bounds.x = bounds.x + self._curDepth * self.indentation
|
||||
@@ -269,7 +269,7 @@ function TreeView:itemSelect( item )
|
||||
end
|
||||
|
||||
function TreeView:update()
|
||||
local mousePos = Vec2:newT( RL.GetMousePosition() )
|
||||
local mousePos = Vector2:newT( RL.GetMousePosition() )
|
||||
local guiMousePos = mousePos + self.gui.mouseOffset
|
||||
local mouseInView = self.view:checkCollisionPoint( mousePos )
|
||||
|
||||
@@ -360,7 +360,7 @@ function TreeView:draw()
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
function TreeView:setPosition( pos )
|
||||
@@ -377,19 +377,19 @@ function TreeView:setSize( size )
|
||||
local scrollBarWidth = RL.GuiGetStyle( RL.LISTVIEW, RL.SCROLLBAR_WIDTH )
|
||||
local borderWidth = RL.GuiGetStyle( RL.DEFAULT, RL.BORDER_WIDTH )
|
||||
|
||||
self.content = Rect:new(
|
||||
self.content = Rectangle:new(
|
||||
0,
|
||||
self.gui.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT,
|
||||
self.bounds.width - 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 )
|
||||
self.view = Rect:newT( view )
|
||||
self.view = Rectangle:newT( view )
|
||||
|
||||
self.gui.view = Rect: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.gui.view = Rectangle:new( 0, 0, self.view.width, self.view.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
|
||||
RL.UnloadRenderTexture( self.framebuffer )
|
||||
|
||||
Reference in New Issue
Block a user