Client Utilities

Utilities Updated: Dec 10, 2025

Client Utilities

Utility functions available on the client.

cLib.Scale

Scale value for current resolution.

local scaled = cLib.Scale(value)
-- Based on 1920x1080
panel:SetSize(cLib.Scale(500), cLib.Scale(400))
panel:DockMargin(cLib.Scale(10), cLib.Scale(10), cLib.Scale(10), cLib.Scale(10))

cLib.DrawPanelBlur

Draw blur effect behind a panel.

cLib.DrawPanelBlur(panel, layers, density)
function PANEL:Paint(w, h)
    cLib.DrawPanelBlur(self, 4, 3)  -- 4 layers, density 3
    draw.RoundedBox(8, 0, 0, w, h, Color(30, 30, 35, 200))
end

cLib.SmartEllipsis

Truncate text with ellipsis to fit width.

local text = cLib.SmartEllipsis(str, maxWidth, font)
local longName = "This is a very long item name that won't fit"
local truncated = cLib.SmartEllipsis(longName, cLib.Scale(150), "cLib.Text")
-- Result: "This is a very lon..."

-- In paint function
function PANEL:Paint(w, h)
    local text = cLib.SmartEllipsis(self.itemName, w - 20, "cLib.Text")
    draw.SimpleText(text, "cLib.Text", 10, h/2, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
end

Notifications

-- cLib notification system
cLib.Notify(message, type, duration)
cLib.Notify("Settings saved!", "success", 3)
cLib.Notify("Failed to connect", "error", 5)
cLib.Notify("New message received", "info", 4)
cLib.Notify("Low health warning!", "warning", 3)

Dialogs

-- Alert dialog
cLib.Alert(title, message, buttonText, callback)

-- Confirm dialog
cLib.Confirm(title, message, onConfirm, onCancel)

-- Prompt dialog
cLib.Prompt(title, message, placeholder, default, onSubmit, onCancel)

Context Menu

cLib.ShowContextMenu(options, x, y)

Tooltips

cLib.SetTooltip(panel, text, delay)