interactive range graph

This commit is contained in:
TheOnly8Z 2023-09-25 14:03:26 -07:00
parent d7133b07f0
commit 561f6137f9

View File

@ -2130,6 +2130,7 @@ function SWEP:CreateCustomize2HUD()
local stk_min, stk_max, stk_count = 1, shot_limit, shot_limit
local stk_num = self:GetBuff("Num")
local dmgt = tostring("DMG")
local rangegraph = vgui.Create("DButton", ArcCW.InvHUD_Menu3)
rangegraph:SetSize(ss * 200, ss * 110)
@ -2500,7 +2501,6 @@ function SWEP:CreateCustomize2HUD()
surface.SetTextPos(x_2, h - rss * 10)
surface.DrawText(hu_2)
local dmgt = tostring("DMG")
local twt = surface.GetTextSize(dmgt)
if wmin < tw then
@ -2529,7 +2529,6 @@ function SWEP:CreateCustomize2HUD()
surface.SetTextPos(w - ss * 2 - w_hu, h - rss * 10)
surface.DrawText(hu_3)
local dmgt = tostring("DMG")
local twt = surface.GetTextSize(dmgt)
surface.SetTextPos(w - ss * 2 - twt, ss * 8)
surface.DrawText(dmgt)
@ -2548,11 +2547,50 @@ function SWEP:CreateCustomize2HUD()
surface.SetTextPos(x_3, h - rss * 10)
surface.DrawText(hu_3)
local dmgt = tostring("DMG")
local twt = surface.GetTextSize(dmgt)
surface.SetTextPos(x_3 - (twt / 2), ss * 8)
surface.DrawText(dmgt)
end
if sran != mran and self2:IsHovered() then
local mouse_x, _ = self2:ScreenToLocal(input.GetCursorPos())
local mouse_frac = math.Clamp((mouse_x - x_2) / (x_3 - x_2), 0, 1)
if mouse_frac > 0 and mouse_frac < 1 then
local mouse_range = mran + mouse_frac * (sran - mran)
local mouse_dmg = math.Round(self:GetDamage(mouse_range))
local y_slope = Lerp(mouse_frac, y_2, y_3)
surface.SetDrawColor(col_vline)
surface.DrawLine(mouse_x, 0, mouse_x, h)
local mouse_text1 = tostring(mouse_dmg)
local mouse_text_w, _ = surface.GetTextSize(mouse_text1)
local nudge = -mouse_text_w * 0.5
local side_margin = ss * 12
local a = 255
if mouse_x - x_2 <= side_margin then
local f = (1 - (mouse_x - x_2) / side_margin)
a = Lerp(f, 255, 0)
elseif x_3 - mouse_x <= side_margin then
local f = (1 - (x_3 - mouse_x) / side_margin)
a = Lerp(f, 255, 25)
end
surface.SetTextColor(255, 255, 255, a)
surface.SetTextPos(mouse_x + nudge, y_slope - ss * 12)
surface.DrawText(mouse_text1)
local m_mouse, hu_mouse = RangeText(mouse_range)
local w_m, _ = surface.GetTextSize(m_mouse)
local w_hu, _ = surface.GetTextSize(hu_mouse)
surface.SetTextPos(mouse_x - w_m * 0.5, y_slope + rss * 5)
surface.DrawText(m_mouse)
surface.SetTextPos(mouse_x - w_hu * 0.5, y_slope + rss * 11)
surface.DrawText(hu_mouse)
end
end
end
if !drawndmg then
@ -2560,9 +2598,9 @@ function SWEP:CreateCustomize2HUD()
surface.SetTextPos(ss * 2, ss * 1)
surface.DrawText(dmg)
local dmgt = tostring("DMG")
surface.SetTextPos(ss * 2, ss * 8)
surface.DrawText(dmgt)
end
end
end