This commit is contained in:
lifestorm
2024-08-05 18:40:29 +03:00
parent c4d91bf369
commit 324f19217d
8040 changed files with 1853423 additions and 21 deletions

View File

@@ -0,0 +1,48 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local Lerp = Lerp
local FrameTime = FrameTime
local SUI, NAME = CURRENT_SUI, CURRENT_SUI.name
local TDLib = sui.TDLib
local Panel = {}
sui.scaling_functions(Panel)
function Panel:Init()
self:ScaleInit()
local rounded_box = {}
local switch_circle = {}
function self:Paint(w, h)
local is_checked = self:GetChecked()
local _h = SUI.Scale(14)
TDLib.RoundedBox(rounded_box, _h, 0, h / 2 - _h / 2, w, _h, is_checked and SUI.GetColor("toggle_button_active") or SUI.GetColor("toggle_button"))
local size = h - 2
do
local pos = is_checked and (w - (size / 2)) or (h / 2 - 1)
if self.pos then
self.pos = Lerp(FrameTime() * 12, self.pos, pos)
else
self.pos = pos
end
end
TDLib.DrawCircle(switch_circle, self.pos, h / 2, size / 2, is_checked and SUI.GetColor("toggle_button_switch_active") or SUI.GetColor("toggle_button_switch"))
end
self:SetSize(34, 20)
end
sui.register("ToggleButton", Panel, "DCheckBox")