-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathDT-Bar.lua
63 lines (49 loc) · 1.82 KB
/
DT-Bar.lua
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
--[[
Doubletap Bar for Lmaobox
Author: LNX (github.com/lnx00)
]]
local options = {
X = 0.5,
Y = 0.6,
Size = 5,
Colors = {
Background = { 45, 50, 55, 100 },
Recharge = { 75, 120, 235, 255 },
Ready = { 70, 190, 50, 255 },
Outline = { 15, 15, 15, 255 }
}
}
local MAX_TICKS = 23
local function DT_Enabled()
local dtMode = gui.GetValue("double tap (beta)")
local dashKey = gui.GetValue("dash move key")
return dtMode ~= "off" or dashKey ~= 0
end
local function OnDraw()
if not DT_Enabled() then return end
local pLocal = entities.GetLocalPlayer()
if not pLocal or engine.IsGameUIVisible() then return end
local pWeapon = pLocal:GetPropEntity("m_hActiveWeapon")
if not pWeapon then return end
local ratio = warp.GetChargedTicks() / MAX_TICKS
local boxWidth = 24 * options.Size
local boxHeight = math.floor(4 * options.Size)
local barWidth = math.floor(boxWidth * ratio)
local sWidth, sHeight = draw.GetScreenSize()
local xPos = math.floor(sWidth * options.X - boxWidth * 0.5)
local yPos = math.floor(sHeight * options.Y - boxHeight * 0.5)
draw.Color(table.unpack(options.Colors.Background))
draw.FilledRect(xPos, yPos, xPos + boxWidth, yPos + boxHeight)
if warp.IsWarping() or warp.GetChargedTicks() < MAX_TICKS then
draw.Color(table.unpack(options.Colors.Recharge))
elseif warp.CanDoubleTap(pWeapon) then
draw.Color(table.unpack(options.Colors.Ready))
else
draw.Color(205, 95, 50, 255)
end
draw.FilledRect(xPos, yPos, xPos + barWidth, yPos + boxHeight)
draw.Color(table.unpack(options.Colors.Outline))
draw.OutlinedRect(xPos, yPos, xPos + boxWidth, yPos + boxHeight)
end
callbacks.Unregister("Draw", "lnx_DT-Bar_Draw")
callbacks.Register("Draw", "lnx_DT-Bar_Draw", OnDraw)