-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.lua
More file actions
40 lines (36 loc) · 1.52 KB
/
util.lua
File metadata and controls
40 lines (36 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
local screen = {guiGetScreenSize()}
function isMouseInPosition(x, y, width, height, ...)
if not isCursorShowing() then
return false
end
local cx, cy = getCursorPosition()
local cursorX, cursorY = cx * screen[1], cy * screen[2]
local targetX, targetY = x, y
local targetWidth, targetHeight = width, height
if cursorX >= targetX and cursorX <= targetX + targetWidth and cursorY >= targetY and cursorY <= targetY + targetHeight then
return true
else
return false
end
end
function dxDrawTextOnRectangle(texto, posX, posY, width, height, fuente, alignX, alignY, color, posGui)
dxDrawRectangle( posX, posY, width, height, color, posGui or false )
dxDrawText(texto, posX, posY, width+posX, height+posY, tocolor(255,255,255,255), 1, fuente or "arial", alignX or "center", alignY or "center", false, true, posGui or false, false, false)
end
function isMouseOnGuiElement(guiElement, guiElementParent)
if isCursorShowing() and isElement(guiElement) then
local sx, sy = guiGetScreenSize()
local x, y = getCursorPosition()
local wx, wy = 0, 0
x, y = x * sx, y * sy
if guiElementParent and isElement(guiElementParent) then
wx, wy = guiGetPosition(guiElementParent, false)
end
local bx, by = guiGetPosition(guiElement, false)
local ex, ey = guiGetSize(guiElement, false)
if x >= wx + bx and x <= wx + bx + ex and y >= wy + by and y <= wy + by + ey then
return true
end
return false
end
end