Initial commit
This commit is contained in:
156
addons/_libnyx/lua/autorun/libnyx.lua
Normal file
156
addons/_libnyx/lua/autorun/libnyx.lua
Normal file
@@ -0,0 +1,156 @@
|
||||
-- libNyx by MaryBlackfild
|
||||
-- JOIN DISCORD: https://discord.gg/rUEEz4mfXw
|
||||
|
||||
-- lua/autorun/libnyx_loader.lua
|
||||
libNyx = libNyx or {}
|
||||
|
||||
local function read_local_version()
|
||||
local p1,p2 = "VERSION","libnyx/VERSION"
|
||||
local v = file.Exists(p1,"GAME") and file.Read(p1,"GAME") or file.Exists(p1,"LUA") and file.Read(p1,"LUA") or file.Exists(p2,"LUA") and file.Read(p2,"LUA") or file.Exists(p2,"GAME") and file.Read(p2,"GAME") or ""
|
||||
v = tostring(v or ""):gsub("[\r\n]","")
|
||||
if v == "" then v = "0.0.0" end
|
||||
return v
|
||||
end
|
||||
|
||||
libNyx.Version = libNyx.Version or read_local_version()
|
||||
|
||||
local RAW_VERSION_URL = "https://raw.githubusercontent.com/maryblackfild/libnyx/main/VERSION"
|
||||
local RAW_LOADER_URL = "https://raw.githubusercontent.com/maryblackfild/libnyx/main/lua/autorun/libnyx_loader.lua"
|
||||
local HOMEPAGE = "https://github.com/maryblackfild/libnyx"
|
||||
|
||||
local function norm(v) v = tostring(v or "") return (v:sub(1,1)=="v") and v:sub(2) or v end
|
||||
local function say(kind,msg)
|
||||
local h = Color(120,200,255)
|
||||
local c = kind=="ok" and Color(120,220,120) or kind=="warn" and Color(255,220,120) or kind=="err" and Color(255,120,120) or Color(200,200,210)
|
||||
MsgC(h,"[libNyx] ",c,msg,"\n")
|
||||
end
|
||||
|
||||
local function do_update_check()
|
||||
say("info","Checking for updates…")
|
||||
http.Fetch(RAW_VERSION_URL, function(body)
|
||||
local remote = tostring(body or ""):gsub("[\r\n]","")
|
||||
if remote=="" then return say("err","Update check failed.") end
|
||||
local a,b = norm(libNyx.Version), norm(remote)
|
||||
if a==b then
|
||||
say("ok",("Up-to-date ✓ (latest: %s)"):format(remote))
|
||||
else
|
||||
say("warn",("Update available ✱ installed %s → latest %s"):format(libNyx.Version, remote))
|
||||
say("info","Get it: "..HOMEPAGE)
|
||||
end
|
||||
end, function()
|
||||
http.Fetch(RAW_LOADER_URL, function(body)
|
||||
local remote = tostring(body or ""):match('libNyx%.Version%s*=%s*["\']([%w%._%-]+)["\']')
|
||||
if not remote or remote=="" then return say("err","Update check failed.") end
|
||||
local a,b = norm(libNyx.Version), norm(remote)
|
||||
if a==b then
|
||||
say("ok",("Up-to-date ✓ (latest: %s)"):format(remote))
|
||||
else
|
||||
say("warn",("Update available ✱ installed %s → latest %s"):format(libNyx.Version, remote))
|
||||
say("info","Get it: "..HOMEPAGE)
|
||||
end
|
||||
end, function() say("err","Update check failed.") end)
|
||||
end)
|
||||
end
|
||||
|
||||
if SERVER then
|
||||
AddCSLuaFile("libnyx/lib/rndx.lua")
|
||||
AddCSLuaFile("libnyx/lib/libnyx_components.lua")
|
||||
AddCSLuaFile("libnyx/lib/libnyx_liquidglass.lua")
|
||||
AddCSLuaFile("libnyx/lib/libnyx_maindemo.lua")
|
||||
timer.Simple(0, function() say("info",("Loaded v%s (server)"):format(libNyx.Version)) do_update_check() end)
|
||||
return
|
||||
end
|
||||
|
||||
local function hasFont(f)
|
||||
local n="__nyx_font_test"
|
||||
surface.CreateFont(n,{font=f,size=16,weight=500,extended=true})
|
||||
surface.SetFont(n)
|
||||
local w,h=surface.GetTextSize("Aa")
|
||||
return (w or 0)>0 and (h or 0)>0
|
||||
end
|
||||
|
||||
local function precreate_alias_fonts()
|
||||
local base = hasFont("Manrope") and "Manrope" or "Tahoma"
|
||||
for sz=10,200 do
|
||||
local name=("libNyx.%s.%d"):format(base, sz)
|
||||
surface.CreateFont(name,{font=base,size=sz,weight=(sz>=28) and 500 or 400,extended=true})
|
||||
end
|
||||
for sz=10,60 do
|
||||
local name=("libNyx.UI.%d"):format(sz)
|
||||
surface.CreateFont(name,{font=base,size=sz,weight=(sz>=28) and 500 or 400,extended=true})
|
||||
end
|
||||
end
|
||||
|
||||
local boot = {}
|
||||
local function include_all_once()
|
||||
if not boot.rndx then
|
||||
libNyx.rndx = include("libnyx/lib/rndx.lua")
|
||||
_G.RNDX = _G.RNDX or libNyx.rndx
|
||||
boot.rndx = true
|
||||
end
|
||||
if not boot.components then
|
||||
include("libnyx/lib/libnyx_components.lua")
|
||||
boot.components = true
|
||||
end
|
||||
if not boot.demo then
|
||||
include("libnyx/lib/libnyx_maindemo.lua")
|
||||
boot.demo = true
|
||||
end
|
||||
if not boot.liquid then
|
||||
include("libnyx/lib/libnyx_liquidglass.lua")
|
||||
boot.liquid = true
|
||||
end
|
||||
end
|
||||
|
||||
local function ready_gate_try()
|
||||
local UI = _G.libNyx and _G.libNyx.UI
|
||||
local ok = UI and UI.Draw and UI.Components and UI.Components.CreateSlider and RNDX
|
||||
if not ok then return false end
|
||||
return true
|
||||
end
|
||||
|
||||
local function run_after_include()
|
||||
precreate_alias_fonts()
|
||||
if _G.libNyx and _G.libNyx.UI and _G.libNyx.UI.InstallGlobalMenuSkin then _G.libNyx.UI.InstallGlobalMenuSkin() end
|
||||
if _G.libNyx and _G.libNyx.UI and _G.libNyx.UI.InstallGlobalNotificationSkin then _G.libNyx.UI.InstallGlobalNotificationSkin() end
|
||||
end
|
||||
|
||||
local trying=0
|
||||
local function wait_until_ready()
|
||||
trying = trying + 1
|
||||
if ready_gate_try() then
|
||||
libNyx.Ready = true
|
||||
return
|
||||
end
|
||||
if trying < 240 then timer.Simple(0, wait_until_ready) else say("warn","Init gate timed out; some UI may be unavailable.") end
|
||||
end
|
||||
|
||||
local function client_bootstrap()
|
||||
include_all_once()
|
||||
run_after_include()
|
||||
wait_until_ready()
|
||||
end
|
||||
|
||||
local function gamemode_init_bridge()
|
||||
if libNyx.__booted then return end
|
||||
libNyx.__booted = true
|
||||
client_bootstrap()
|
||||
end
|
||||
|
||||
hook.Add("OnGamemodeLoaded","libNyx.Loader.GMInit",gamemode_init_bridge)
|
||||
hook.Add("Initialize","libNyx.Loader.Init",gamemode_init_bridge)
|
||||
hook.Add("InitPostEntity","libNyx.Loader.InitPostEntity",function() if not libNyx.Ready then client_bootstrap() end end)
|
||||
hook.Add("OnReloaded","libNyx.Loader.Reload",function()
|
||||
boot = {}
|
||||
libNyx.Ready = false
|
||||
client_bootstrap()
|
||||
end)
|
||||
|
||||
timer.Simple(0, function()
|
||||
if not libNyx.__booted then gamemode_init_bridge() end
|
||||
say("info",("Loaded v%s (client)"):format(libNyx.Version))
|
||||
do_update_check()
|
||||
end)
|
||||
|
||||
-- libNyx by MaryBlackfild
|
||||
-- JOIN DISCORD: https://discord.gg/rUEEz4mfXw
|
||||
1
addons/_libnyx/lua/libnyx/VERSION
Normal file
1
addons/_libnyx/lua/libnyx/VERSION
Normal file
@@ -0,0 +1 @@
|
||||
0.8.0
|
||||
3205
addons/_libnyx/lua/libnyx/lib/libnyx_components.lua
Normal file
3205
addons/_libnyx/lua/libnyx/lib/libnyx_components.lua
Normal file
File diff suppressed because it is too large
Load Diff
410
addons/_libnyx/lua/libnyx/lib/libnyx_liquidglass.lua
Normal file
410
addons/_libnyx/lua/libnyx/lib/libnyx_liquidglass.lua
Normal file
@@ -0,0 +1,410 @@
|
||||
-- libNyx and LiquidGlass shader by MaryBlackfild
|
||||
-- JOIN DISCORD: https://discord.gg/rUEEz4mfXw
|
||||
|
||||
if SERVER then AddCSLuaFile() return end
|
||||
|
||||
local RNDX = include("libnyx/lib/rndx.lua")
|
||||
|
||||
surface.CreateFont("libNyx.Manrope.Liquid",{font="Manrope",size=30,weight=800,antialias=true,extended=true})
|
||||
--surface.CreateFont("libNyx.UI.18",{font="Manrope",size=18,weight=700,antialias=true,extended=true})
|
||||
--surface.CreateFont("libNyx.UI.16",{font="Manrope",size=16,weight=600,antialias=true,extended=true})
|
||||
--surface.CreateFont("libNyx.UI.14",{font="Manrope",size=14,weight=600,antialias=true,extended=true})
|
||||
|
||||
CreateClientConVar("libnyx_liquid_size","300",true,false)
|
||||
|
||||
local Nyx = libNyx and libNyx.UI
|
||||
local Style = Nyx and Nyx.Style
|
||||
local function s(n) return (Nyx and Nyx.Scale and Nyx.Scale(n)) or n end
|
||||
local function f(sz) return (Nyx and Nyx.Font and Nyx.Font(s(sz))) or "DermaDefault" end
|
||||
|
||||
local function clp(x,a,b) if x<a then return a elseif x>b then return b else return x end end
|
||||
local function rstep(x,st) if not st or st<=0 then return x end return math.Round(x/st)*st end
|
||||
local function sdec(st) local q=tostring(st or "") local p=q:find("%.") return p and (#q-p) or 0 end
|
||||
local function dup(t) local r={} for k,v in pairs(t) do r[k]=v end return r end
|
||||
|
||||
local function fmt(v)
|
||||
if type(v)~="number" then return tostring(v or 0) end
|
||||
local out = string.format("%.6f", v):gsub("0+$",""):gsub("%.$","")
|
||||
return (out == "" and "0") or out
|
||||
end
|
||||
|
||||
local DEF = {
|
||||
size = tonumber(GetConVar("libnyx_liquid_size"):GetString()) or 300,
|
||||
rad = 32,
|
||||
strength = 0.012,
|
||||
speed = 0,
|
||||
sat = 1.06,
|
||||
tr = 255, tg = 255, tb = 255,
|
||||
tints = 0.06,
|
||||
blur_all = 0.10,
|
||||
blur_rad = 0,
|
||||
edge = 2.0,
|
||||
shimmer = 25.2,
|
||||
grain = 0.01,
|
||||
alpha = 0.95,
|
||||
shape = RNDX.SHAPE_IOS,
|
||||
shadow_enabled = true,
|
||||
shadow_spread = 40,
|
||||
shadow_intensity = 56
|
||||
}
|
||||
|
||||
local function mk() return dup(DEF) end
|
||||
|
||||
local function open()
|
||||
if not Nyx then return end
|
||||
if IsValid(libNyx.LiquidGlassUI) then libNyx.LiquidGlassUI:Remove() return end
|
||||
|
||||
local st = mk()
|
||||
local ui = { sliders = {} }
|
||||
|
||||
local rt = vgui.Create("EditablePanel")
|
||||
rt:SetSize(ScrW(),ScrH())
|
||||
rt:MakePopup()
|
||||
gui.EnableScreenClicker(true)
|
||||
libNyx.LiquidGlassUI = rt
|
||||
Nyx.AutoNoBG(rt)
|
||||
Nyx.InstallGlobalScroll(rt,{step=s(90),speed=18,fadeHold=0.9,width=s(12)})
|
||||
|
||||
function rt:OnRemove() gui.EnableScreenClicker(false) end
|
||||
function rt:OnKeyCodePressed(k) if k==KEY_ESCAPE then self:Remove() end end
|
||||
|
||||
local pad = s(24)
|
||||
local lw = math.min(s(380), math.max(s(300), math.floor(ScrW()*0.26)))
|
||||
|
||||
local nav = vgui.Create("DPanel", rt)
|
||||
nav:SetPos(pad, pad)
|
||||
nav:SetSize(lw, ScrH() - pad*2)
|
||||
Nyx.AutoNoBG(nav)
|
||||
nav.Paint = function(p,w,h)
|
||||
Nyx.Draw.Glass(0,0,w,h,{
|
||||
radius=s(18),
|
||||
fill=Style and Style.bgColor or Color(10,10,14,150),
|
||||
stroke=true,
|
||||
strokeColor=Style and Style.glassStroke or Color(255,255,255,22),
|
||||
blurIntensity=1.1
|
||||
})
|
||||
draw.SimpleText("libNyx · Liquid Glass", f(22), s(18), s(16), Style and Style.textColor or color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
|
||||
end
|
||||
|
||||
local bd = vgui.Create("DScrollPanel", nav)
|
||||
bd:Dock(FILL)
|
||||
bd:DockMargin(s(12), s(50), s(12), s(12))
|
||||
Nyx.AutoNoBG(bd)
|
||||
Nyx.SmoothScroll.ApplyToScrollPanel(bd,{step=s(90),speed=18,fadeHold=0.9,width=s(12)})
|
||||
local vb = bd:GetVBar()
|
||||
vb:SetWide(0)
|
||||
vb.Paint = function() end
|
||||
if vb.btnUp then vb.btnUp:SetVisible(false) end
|
||||
if vb.btnDown then vb.btnDown:SetVisible(false) end
|
||||
if vb.btnGrip then vb.btnGrip:SetVisible(false) end
|
||||
|
||||
local function title(t)
|
||||
local pnl = vgui.Create("DPanel", bd)
|
||||
pnl:Dock(TOP)
|
||||
pnl:DockMargin(0, s(10), 0, s(6))
|
||||
pnl:SetTall(s(30))
|
||||
Nyx.AutoNoBG(pnl)
|
||||
pnl.Paint = function(_,w,h)
|
||||
draw.SimpleText(t, f(18), 0, h/2, Style and Style.textColor or color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
|
||||
end
|
||||
end
|
||||
|
||||
local function row(h)
|
||||
local r = vgui.Create("DPanel", bd)
|
||||
r:Dock(TOP)
|
||||
r:DockMargin(0, s(6), 0, 0)
|
||||
r:SetTall(h or s(44))
|
||||
Nyx.AutoNoBG(r)
|
||||
r.Paint = function(_,w,h)
|
||||
Nyx.Draw.Panel(0,0,w,h,{radius=s(12),color=Style and Style.panelColor or Color(20,22,30,130),glass=true,stroke=true})
|
||||
end
|
||||
return r
|
||||
end
|
||||
|
||||
local clampBox = function() end
|
||||
|
||||
local function slider(lbl,key,min,max,step,tint)
|
||||
local r = row(s(48))
|
||||
local L = vgui.Create("DLabel", r)
|
||||
L:SetFont(f(18))
|
||||
L:SetTextColor(Style and Style.textColor or color_white)
|
||||
L:SetText(lbl)
|
||||
L:SizeToContents()
|
||||
L:SetPos(s(12), s(12))
|
||||
local sl = Nyx.Components.CreateSlider(r,{min=min,max=max,decimals=sdec(step),value=st[key],tint=tint or (Style and Style.accentColor)})
|
||||
sl:Dock(FILL)
|
||||
sl:DockMargin(s(140), 0, s(12), 0)
|
||||
function sl:OnValueChanged(v)
|
||||
local val = clp(rstep(v,step),min,max)
|
||||
st[key] = val
|
||||
if key=="size" then
|
||||
RunConsoleCommand("libnyx_liquid_size", tostring(math.floor(val)))
|
||||
clampBox()
|
||||
end
|
||||
end
|
||||
ui.sliders[key] = sl
|
||||
return sl
|
||||
end
|
||||
|
||||
local function drop(lbl,choices,onPick)
|
||||
local r = row(s(48))
|
||||
local L = vgui.Create("DLabel", r)
|
||||
L:SetFont(f(18))
|
||||
L:SetTextColor(Style and Style.textColor or color_white)
|
||||
L:SetText(lbl)
|
||||
L:SizeToContents()
|
||||
L:SetPos(s(12), s(12))
|
||||
local dd = Nyx.Components.CreateDropdown(r,{choices=choices,placeholder="",onSelect=onPick})
|
||||
dd:Dock(RIGHT)
|
||||
dd:SetWide(s(150))
|
||||
dd:DockMargin(0, s(6), s(8), s(6))
|
||||
return dd
|
||||
end
|
||||
|
||||
local function toggle(lbl,init,onChange)
|
||||
local r = row(s(44))
|
||||
local sw = Nyx.Components.CreateCheckbox(r,{variant="switch",checked=init,label=lbl})
|
||||
sw:Dock(LEFT)
|
||||
sw:DockMargin(s(10), s(6), 0, s(6))
|
||||
sw:SetOnChange(function(v) if onChange then onChange(v) end end)
|
||||
return sw
|
||||
end
|
||||
|
||||
title("Layout")
|
||||
slider("Size","size",220,520,1)
|
||||
ui.sliders.rad = slider("Corner","rad",0,64,1)
|
||||
local shapeDD = drop("Shape",{
|
||||
{label="iOS"},
|
||||
{label="Figma"},
|
||||
{label="Circle"},
|
||||
},function(lbl)
|
||||
if lbl=="iOS" then st.shape=RNDX.SHAPE_IOS
|
||||
elseif lbl=="Figma" then st.shape=RNDX.SHAPE_FIGMA
|
||||
else st.shape=RNDX.SHAPE_CIRCLE end
|
||||
clampBox()
|
||||
end)
|
||||
|
||||
title("Visuals")
|
||||
slider("Strength","strength",0,0.06,0.001)
|
||||
slider("Speed","speed",0,4,0.1)
|
||||
slider("Saturation","sat",0.5,1.6,0.01)
|
||||
slider("Tint R","tr",0,255,1,Color(255,110,110))
|
||||
slider("Tint G","tg",0,255,1,Color(110,255,110))
|
||||
slider("Tint B","tb",0,255,1,Color(110,110,255))
|
||||
slider("Tint Amt","tints",0,0.35,0.005)
|
||||
|
||||
title("Blur & Edge")
|
||||
slider("Glass Blur","blur_all",0,0.5,0.01)
|
||||
slider("Blur Rad","blur_rad",0,4,0.1)
|
||||
slider("Edge Px","edge",0,6,0.1)
|
||||
|
||||
title("FX")
|
||||
slider("Shimmer","shimmer",0,50,0.1)
|
||||
slider("Grain","grain",0,0.08,0.001)
|
||||
slider("Alpha","alpha",0.2,1.0,0.01)
|
||||
|
||||
title("Shadow")
|
||||
local swShadow = toggle("Enable Shadow",st.shadow_enabled,function(v) st.shadow_enabled=v end)
|
||||
slider("Spread","shadow_spread",0,120,1)
|
||||
slider("Intensity","shadow_intensity",0,180,1)
|
||||
|
||||
local bar = vgui.Create("DPanel", nav)
|
||||
bar:Dock(BOTTOM)
|
||||
bar:SetTall(s(52))
|
||||
Nyx.AutoNoBG(bar)
|
||||
bar.Paint = function(_,w,h)
|
||||
Nyx.Draw.Panel(0,0,w,h,{radius=s(12),color=Style and Style.cardColor or Color(16,18,24,120),glass=true,stroke=true})
|
||||
end
|
||||
|
||||
local btnW = (lw - s(8*4)) / 3
|
||||
|
||||
local function shapeLbl()
|
||||
if st.shape==RNDX.SHAPE_FIGMA then return "Figma"
|
||||
elseif st.shape==RNDX.SHAPE_CIRCLE then return "Circle"
|
||||
else return "iOS" end
|
||||
end
|
||||
|
||||
local btnRst = Nyx.Components.CreateButton(bar,"Reset",{variant="ghost"})
|
||||
btnRst:Dock(LEFT)
|
||||
btnRst:DockMargin(s(8), s(6), s(6), s(6))
|
||||
btnRst:SetWide(btnW)
|
||||
btnRst._onClick = function()
|
||||
st = mk()
|
||||
RunConsoleCommand("libnyx_liquid_size", tostring(st.size))
|
||||
for k,ctrl in pairs(ui.sliders) do if IsValid(ctrl) then ctrl:SetValue(st[k] or 0) end end
|
||||
if IsValid(swShadow) then swShadow:SetChecked(st.shadow_enabled and true or false) end
|
||||
if IsValid(shapeDD) and shapeDD.SetSelectedLabel then shapeDD:SetSelectedLabel(shapeLbl()) end
|
||||
clampBox()
|
||||
if notification and notification.AddLegacy then notification.AddLegacy("libNyx: settings reset.", NOTIFY_HINT, 2) end
|
||||
if chat and chat.AddText then chat.AddText(Color(140,180,255), "[libNyx] ", color_white, "Liquid Glass settings reset.") end
|
||||
end
|
||||
|
||||
local function shapeConst()
|
||||
if st.shape==RNDX.SHAPE_FIGMA then return "RNDX.SHAPE_FIGMA"
|
||||
elseif st.shape==RNDX.SHAPE_CIRCLE then return "RNDX.SHAPE_CIRCLE"
|
||||
else return "RNDX.SHAPE_IOS" end
|
||||
end
|
||||
|
||||
local function ensurePos()
|
||||
local sw,sh = rt:GetWide(), rt:GetTall()
|
||||
local bw,bh = st.size, st.size
|
||||
local leftBound = pad + lw + s(12)
|
||||
local minX = math.max(leftBound, pad)
|
||||
local maxX = sw - pad - bw
|
||||
local minY = pad
|
||||
local maxY = sh - pad - bh
|
||||
if not st.posX then st.posX = sw - bw - pad end
|
||||
if not st.posY then st.posY = pad + s(20) end
|
||||
st.posX = clp(st.posX, minX, math.max(minX, maxX))
|
||||
st.posY = clp(st.posY, minY, math.max(minY, maxY))
|
||||
end
|
||||
|
||||
local btnCP = Nyx.Components.CreateButton(bar,"Copy",{variant="ghost"})
|
||||
btnCP:Dock(LEFT)
|
||||
btnCP:DockMargin(s(6), s(6), s(6), s(6))
|
||||
btnCP:SetWide(btnW)
|
||||
btnCP._onClick = function()
|
||||
ensurePos()
|
||||
local rr = (st.shape==RNDX.SHAPE_CIRCLE) and math.floor((st.size or 0)*0.5) or (st.rad or 0)
|
||||
local lines = {
|
||||
"RNDX().Liquid(bx,by,bw,bh)",
|
||||
" :Rad("..fmt(rr)..")",
|
||||
" :Color(255,255,255,255)",
|
||||
" :Tint("..math.floor(st.tr or 0)..","..math.floor(st.tg or 0)..","..math.floor(st.tb or 0)..")",
|
||||
" :TintStrength("..fmt(st.tints or 0)..")",
|
||||
" :Saturation("..fmt(st.sat or 1)..")",
|
||||
" :GlassBlur("..fmt(st.blur_all or 0)..","..fmt(st.blur_rad or 0)..")",
|
||||
" :EdgeSmooth("..fmt(st.edge or 0)..")",
|
||||
" :Strength("..fmt(st.strength or 0)..")",
|
||||
" :Speed("..fmt(st.speed or 0)..")",
|
||||
" :Shimmer("..fmt(st.shimmer or 0)..")",
|
||||
" :Grain("..fmt(st.grain or 0)..")",
|
||||
" :Alpha("..fmt(st.alpha or 1)..")",
|
||||
" :Flags("..shapeConst()..")"
|
||||
}
|
||||
if st.shadow_enabled and ((st.shadow_spread or 0)>0 or (st.shadow_intensity or 0)>0) then
|
||||
table.insert(lines, #lines, " :Shadow("..fmt(st.shadow_spread or 0)..","..fmt(st.shadow_intensity or 0)..")")
|
||||
end
|
||||
local code = table.concat(lines, "\n")
|
||||
SetClipboardText(code)
|
||||
if notification and notification.AddLegacy then notification.AddLegacy("libNyx: code copied to clipboard.", NOTIFY_GENERIC, 3) end
|
||||
if chat and chat.AddText then chat.AddText(Color(140,180,255), "[libNyx] ", color_white, "Liquid Glass builder copied.") end
|
||||
end
|
||||
|
||||
local btnX = Nyx.Components.CreateButton(bar,"Close",{variant="ghost"})
|
||||
btnX:Dock(FILL)
|
||||
btnX:DockMargin(s(6), s(6), s(8), s(6))
|
||||
btnX._onClick = function() if IsValid(rt) then rt:Remove() end end
|
||||
|
||||
if IsValid(shapeDD) and shapeDD.SetSelectedLabel then shapeDD:SetSelectedLabel(shapeLbl()) end
|
||||
|
||||
local drag = {on=false,dx=0,dy=0}
|
||||
rt._hoverA = 0
|
||||
|
||||
local function clampReal()
|
||||
local sw,sh = rt:GetWide(), rt:GetTall()
|
||||
local bw,bh = st.size, st.size
|
||||
local leftBound = pad + lw + s(12)
|
||||
local minX = math.max(leftBound, pad)
|
||||
local maxX = sw - pad - bw
|
||||
local minY = pad
|
||||
local maxY = sh - pad - bh
|
||||
if not st.posX then st.posX = sw - bw - pad end
|
||||
if not st.posY then st.posY = pad + s(20) end
|
||||
st.posX = clp(st.posX, minX, math.max(minX, maxX))
|
||||
st.posY = clp(st.posY, minY, math.max(minY, maxY))
|
||||
end
|
||||
clampBox = clampReal
|
||||
clampReal()
|
||||
|
||||
hook.Add("OnScreenSizeChanged","libNyx.LiquidGlass.Relayout",function()
|
||||
if not IsValid(rt) or not IsValid(nav) or not IsValid(bd) or not IsValid(bar) then return end
|
||||
rt:SetSize(ScrW(),ScrH())
|
||||
lw = math.min(s(380), math.max(s(300), math.floor(ScrW()*0.26)))
|
||||
nav:SetPos(pad, pad)
|
||||
nav:SetSize(lw, ScrH() - pad*2)
|
||||
clampReal()
|
||||
end)
|
||||
|
||||
function rt:OnMousePressed(mc)
|
||||
if mc ~= MOUSE_LEFT then return end
|
||||
local mx,my = self:LocalCursorPos()
|
||||
local bw,bh = st.size,st.size
|
||||
if mx>=st.posX and mx<=st.posX+bw and my>=st.posY and my<=st.posY+bh then
|
||||
drag.on = true
|
||||
drag.dx = mx - st.posX
|
||||
drag.dy = my - st.posY
|
||||
self:MouseCapture(true)
|
||||
end
|
||||
end
|
||||
|
||||
function rt:OnMouseReleased(mc)
|
||||
if mc ~= MOUSE_LEFT then return end
|
||||
if drag.on then
|
||||
drag.on = false
|
||||
self:MouseCapture(false)
|
||||
end
|
||||
end
|
||||
|
||||
function rt:OnCursorMoved(x,y)
|
||||
if not drag.on then return end
|
||||
st.posX = x - drag.dx
|
||||
st.posY = y - drag.dy
|
||||
clampReal()
|
||||
end
|
||||
|
||||
function rt:Think()
|
||||
local mx,my = self:LocalCursorPos()
|
||||
local bw,bh = st.size,st.size
|
||||
local inside = mx>=st.posX and mx<=st.posX+bw and my>=st.posY and my<=st.posY+bh
|
||||
local tgt = (inside or drag.on) and 1 or 0
|
||||
self._hoverA = Lerp(FrameTime()*10, self._hoverA, tgt)
|
||||
if inside or drag.on then self:SetCursor("sizeall") else self:SetCursor("arrow") end
|
||||
end
|
||||
|
||||
local function curRad(w,h)
|
||||
if st.shape == RNDX.SHAPE_CIRCLE then
|
||||
return math.floor(math.min(w,h) * 0.5)
|
||||
end
|
||||
return st.rad
|
||||
end
|
||||
|
||||
function rt:Paint(sw,sh)
|
||||
clampReal()
|
||||
local bx,by = st.posX, st.posY
|
||||
local bw,bh = st.size, st.size
|
||||
local rr = curRad(bw,bh)
|
||||
|
||||
RNDX().Rect(bx,by,bw,bh):Rad(rr):Flags(st.shape):Blur(1):Draw()
|
||||
|
||||
local liq = RNDX().Liquid(bx,by,bw,bh)
|
||||
:Rad(rr)
|
||||
:Color(255,255,255,255)
|
||||
:Tint(st.tr,st.tg,st.tb)
|
||||
:TintStrength(st.tints)
|
||||
:Saturation(st.sat)
|
||||
:GlassBlur(st.blur_all,st.blur_rad)
|
||||
:EdgeSmooth(st.edge)
|
||||
:Strength(st.strength)
|
||||
:Speed(st.speed)
|
||||
:Shimmer(st.shimmer)
|
||||
:Grain(st.grain)
|
||||
:Alpha(st.alpha)
|
||||
:Flags(st.shape)
|
||||
|
||||
if st.shadow_enabled and (st.shadow_spread>0 or st.shadow_intensity>0) then liq:Shadow(st.shadow_spread,st.shadow_intensity) end
|
||||
liq:Draw()
|
||||
|
||||
local a = self._hoverA
|
||||
local c1 = Color(255,255,255, math.floor(235 * (1-a)))
|
||||
local c2 = Color(255,255,255, math.floor(235 * a))
|
||||
draw.SimpleText("Liquid Glass", "libNyx.Manrope.Liquid", bx + bw/2, by + bh/2, c1, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
|
||||
draw.SimpleText("Hold to drag", "libNyx.Manrope.Liquid", bx + bw/2, by + bh/2, c2, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
|
||||
end
|
||||
end
|
||||
|
||||
concommand.Add("libnyx_liquid", open)
|
||||
|
||||
|
||||
-- libNyx and LiquidGlass shader by MaryBlackfild
|
||||
-- JOIN DISCORD: https://discord.gg/rUEEz4mfXw
|
||||
415
addons/_libnyx/lua/libnyx/lib/libnyx_maindemo.lua
Normal file
415
addons/_libnyx/lua/libnyx/lib/libnyx_maindemo.lua
Normal file
@@ -0,0 +1,415 @@
|
||||
-- libNyx by MaryBlackfild
|
||||
-- JOIN DISCORD: https://discord.gg/rUEEz4mfXw
|
||||
|
||||
if SERVER then
|
||||
AddCSLuaFile()
|
||||
return
|
||||
end
|
||||
|
||||
local libNyx = libNyx or {}
|
||||
libNyx.UI = libNyx.UI or {}
|
||||
_G.libNyx = libNyx
|
||||
|
||||
local RNDX = include("libnyx/lib/rndx.lua")
|
||||
if not (libNyx.UI and libNyx.UI.Draw and libNyx.UI.Components) then
|
||||
include("libnyx/lib/libnyx_components.lua")
|
||||
end
|
||||
|
||||
local Style = libNyx.UI.Style
|
||||
local Components = libNyx.UI.Components
|
||||
|
||||
local GRAD_PALETTE = {
|
||||
Color( 90,160,255),
|
||||
Color(255,125,155),
|
||||
Color(120,220,160),
|
||||
Color(255,200,120),
|
||||
Color(170,120,255),
|
||||
Color(120,200,255),
|
||||
}
|
||||
local function PalettePick(key)
|
||||
key = tostring(key or "")
|
||||
local sum = 0
|
||||
for i = 1, #key do sum = sum + key:byte(i) end
|
||||
local idx = (sum % #GRAD_PALETTE) + 1
|
||||
return GRAD_PALETTE[idx]
|
||||
end
|
||||
|
||||
local showcase
|
||||
function libNyx.UI.OpenShowcase()
|
||||
if IsValid(showcase) then showcase:Close() end
|
||||
local W = math.min(ScrW() - libNyx.UI.Scale(80), 1200)
|
||||
local H = math.min(ScrH() - libNyx.UI.Scale(80), 780)
|
||||
showcase = libNyx.UI.CreateFrame({w = W, h = H, title = "Демонстрация libNyx UI"})
|
||||
|
||||
local pages = vgui.Create("DPanel", showcase)
|
||||
pages:Dock(FILL)
|
||||
pages:DockMargin(Style.padding, Style.padding, Style.padding, Style.padding)
|
||||
pages.Paint = nil
|
||||
|
||||
local page1, page2
|
||||
local function showPage(which)
|
||||
if IsValid(page1) then page1:SetVisible(which == 1) end
|
||||
if IsValid(page2) then page2:SetVisible(which == 2) end
|
||||
end
|
||||
|
||||
local nav = Components.CreateTabs(showcase, {
|
||||
items = {
|
||||
{id="p1", label="демка 1", icon=Material("icon16/page_white.png","noclamp smooth")},
|
||||
{id="p2", label="демка 2", icon=Material("icon16/page_white_text.png","noclamp smooth")},
|
||||
},
|
||||
default = "p1",
|
||||
onChange = function(id) showPage(id == "p1" and 1 or 2) end
|
||||
})
|
||||
nav:Dock(TOP)
|
||||
nav:SetTall(libNyx.UI.Scale(52))
|
||||
nav:DockMargin(Style.headerIndentX, Style.headerIndentY + libNyx.UI.Scale(8), Style.headerIndentX, libNyx.UI.Scale(6))
|
||||
|
||||
|
||||
page1 = vgui.Create("DPanel", pages)
|
||||
page1:Dock(FILL)
|
||||
page1.Paint = nil
|
||||
|
||||
do
|
||||
|
||||
local left = vgui.Create("DPanel", page1)
|
||||
left:Dock(LEFT)
|
||||
left:SetWide(math.floor(W * 0.40))
|
||||
left.Paint = function(s,w,h)
|
||||
libNyx.UI.Draw.Panel(0,0,w,h,{radius=Style.radius, color=Style.panelColor, glass=true})
|
||||
end
|
||||
left:DockMargin(0, 0, Style.padding, 0)
|
||||
|
||||
local leftStack = vgui.Create("DPanel", left)
|
||||
leftStack:Dock(FILL)
|
||||
leftStack:DockPadding(Style.padding, Style.padding, Style.padding, Style.padding)
|
||||
leftStack.Paint = nil
|
||||
|
||||
local checksRow = vgui.Create("DPanel", leftStack)
|
||||
checksRow:Dock(TOP)
|
||||
checksRow:SetTall(libNyx.UI.Scale(32))
|
||||
checksRow:DockMargin(0, 0, 0, libNyx.UI.Scale(16))
|
||||
checksRow.Paint = nil
|
||||
|
||||
local function addChk(var, text, startOn)
|
||||
local c = Components.CreateCheckbox(checksRow, {
|
||||
variant = var,
|
||||
label = text,
|
||||
checked = startOn,
|
||||
tint = Style.accentColor,
|
||||
onChange = function(v)
|
||||
chat.AddText(Color(0,255,0), "[libNyx] ", Color(255,255,0), text, Color(200,200,200), " = ", v and "ON" or "OFF")
|
||||
end
|
||||
})
|
||||
c:Dock(LEFT)
|
||||
c:DockMargin(0, 0, libNyx.UI.Scale(16), 0)
|
||||
return c
|
||||
end
|
||||
|
||||
addChk("switch", "Switch", true)
|
||||
addChk("knob", "Knob", true)
|
||||
addChk("radio", "Radio", true)
|
||||
|
||||
-- buttons
|
||||
local b1 = Components.CreateButton(leftStack, "Основная", {variant="primary", align="left"})
|
||||
b1:Dock(TOP) b1:DockMargin(0, 0, 0, libNyx.UI.Scale(10))
|
||||
|
||||
local b2 = Components.CreateButton(leftStack, "Мягкая", {variant="soft", align="left"})
|
||||
b2:Dock(TOP) b2:DockMargin(0, 0, 0, libNyx.UI.Scale(10))
|
||||
|
||||
local b3 = Components.CreateButton(leftStack, "Прозрачная", {variant="ghost", align="left"})
|
||||
b3:Dock(TOP) b3:DockMargin(0, 0, 0, libNyx.UI.Scale(10))
|
||||
|
||||
local b4 = Components.CreateButton(leftStack, "Градиентная",{variant="gradient", align="left", tint = PalettePick("btn")})
|
||||
b4:Dock(TOP) b4:DockMargin(0, 0, 0, libNyx.UI.Scale(16))
|
||||
|
||||
local b5 = Components.CreateButton(leftStack, "солид", {variant="primary_center"})
|
||||
b5:Dock(TOP) b5:DockMargin(0, 0, 0, libNyx.UI.Scale(10))
|
||||
|
||||
local b6 = Components.CreateButton(leftStack, "Центр-гр", {variant="center_duo", tint = Color(97,17,191), centerTint = Color(136,49,238)})
|
||||
b6:Dock(TOP)
|
||||
b6:DockMargin(0, 0, 0, libNyx.UI.Scale(16))
|
||||
|
||||
local sld = Components.CreateSlider(leftStack, {min=1, max=100, value=42, decimals=0, tint=Style.accentColor})
|
||||
sld:Dock(TOP) sld:DockMargin(0, 0, 0, libNyx.UI.Scale(16))
|
||||
sld:SetTall(libNyx.UI.Scale(30))
|
||||
|
||||
local dd = Components.CreateDropdown(leftStack, {
|
||||
placeholder = "Выберите категорию",
|
||||
choices = {"Недвижимость", "Бизнес", "Промо", "VIP"},
|
||||
onSelect = function(val) chat.AddText(Color(0,255,0), "[libNyx] Вы выбрали: ", Color(255,255,0), val) end,
|
||||
tint = PalettePick("dropdown")
|
||||
})
|
||||
dd:Dock(TOP) dd:DockMargin(0, 0, 0, libNyx.UI.Scale(8))
|
||||
dd:SetTall(libNyx.UI.Scale(36))
|
||||
|
||||
-- bullets
|
||||
local feats = {"The libNyx 1.0","Nyx Team топ","бээ-бээ барашек"}
|
||||
for _, t in ipairs(feats) do
|
||||
local row = vgui.Create("DPanel", leftStack)
|
||||
row:Dock(TOP)
|
||||
row:DockMargin(0, 0, 0, libNyx.UI.Scale(8))
|
||||
row:SetTall(libNyx.UI.Scale(30))
|
||||
row.Paint = function(s,w,h)
|
||||
libNyx.UI.Draw.Panel(0,0,w,h,{radius=libNyx.UI.Scale(8), color=Style.cardColor, glass=true})
|
||||
draw.SimpleText("• "..t, libNyx.UI.Font(libNyx.UI.Scale(18)), libNyx.UI.Scale(8), h/2, Style.textColor, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
|
||||
end
|
||||
end
|
||||
|
||||
-- right pane
|
||||
local right = vgui.Create("DPanel", page1)
|
||||
right:Dock(FILL)
|
||||
right.Paint = function(s,w,h)
|
||||
libNyx.UI.Draw.Panel(0,0,w,h,{radius=Style.radius, color=Style.panelColor, glass=true})
|
||||
end
|
||||
|
||||
-- bottom boxes strip
|
||||
local strip = vgui.Create("DPanel", right)
|
||||
strip:Dock(BOTTOM)
|
||||
strip:SetTall(libNyx.UI.Scale(220))
|
||||
strip:DockMargin(Style.padding, 0, Style.padding, Style.padding)
|
||||
strip.Paint = nil
|
||||
|
||||
local bx1 = Components.CreateVBox(strip, {variant = "center_gradient", title = "Бокс1", icon = Material("icon16/heart.png"), tint = Color(140,120,255)})
|
||||
bx1:Dock(LEFT); bx1:DockMargin(0,0,Style.padding,0)
|
||||
|
||||
local bx2 = Components.CreateVBox(strip, {variant = "sunburst", title = "Бокс2", icon = Material("icon16/star.png"), tint = Color(255,180,90)})
|
||||
bx2:Dock(LEFT); bx2:DockMargin(0,0,Style.padding,0)
|
||||
|
||||
local bx3 = Components.CreateVBox(strip, {variant = "model", title = "Бокс3", model = "models/props_c17/oildrum001.mdl", tint = Color(120,200,255)})
|
||||
bx3:Dock(LEFT); bx3:DockMargin(0,0,Style.padding,0)
|
||||
|
||||
local bx4 = Components.CreateVBox(strip, {variant = "vertical_gradient", title = "Бокс4", icon = Material("icon16/flag_yellow.png"), tint = Color(120,180,255)})
|
||||
bx4:Dock(LEFT)
|
||||
|
||||
-- list
|
||||
local list = Components.CreateList(right, {rowHeight = Style.rowHeight, vbarWidth = libNyx.UI.Scale(12)})
|
||||
list:Dock(FILL)
|
||||
list:DockMargin(Style.padding, Style.padding, Style.padding, Style.padding)
|
||||
|
||||
local iconShop = Material("icon16/cart.png")
|
||||
local iconHome = Material("icon16/house.png")
|
||||
|
||||
list:AddRow({
|
||||
title = "Строка с иконкой и метками",
|
||||
icon = iconShop,
|
||||
labels = {
|
||||
{text="Премиум", color=Color(255,215,0)},
|
||||
{text="Новинка", color=Color(90,160,255)},
|
||||
{text="Рекомендуем", color=Color(120,220,160)},
|
||||
},
|
||||
rightText = "12 000 kr",
|
||||
onClick = function() chat.AddText(Color(0,255,0),"[libNyx] Нажата строка 1") end
|
||||
})
|
||||
|
||||
list:AddRow({
|
||||
title = "Строка без иконки",
|
||||
labels = { {text="Скоро", color=Color(170,120,255)} },
|
||||
rightText = "Бесплатно",
|
||||
gradient = false,
|
||||
onClick = function() chat.AddText(Color(0,255,0),"[libNyx] Нажата строка 2 (plain)") end
|
||||
})
|
||||
|
||||
list:AddRow({
|
||||
title = "Строка с множеством меток",
|
||||
icon = iconHome,
|
||||
labels = {
|
||||
{text="Скидка", color=Color(120,220,160)},
|
||||
{text="Ограничено", color=Color(255,125,155)},
|
||||
{text="-15%", color=Color(255,200,120)},
|
||||
{text="Сегодня", color=Color(120,200,255)},
|
||||
{text="Дополнительно", color=Color(90,160,255)},
|
||||
},
|
||||
rightText = "8 500 kr",
|
||||
})
|
||||
|
||||
|
||||
local inv = vgui.Create("DPanel", right)
|
||||
inv:Dock(TOP)
|
||||
inv:SetTall(libNyx.UI.Scale(110))
|
||||
inv:DockMargin(Style.padding, Style.padding, Style.padding, 0)
|
||||
inv.Paint = nil
|
||||
|
||||
local invCellA = Components.CreateInteractiveCell(inv, {size=libNyx.UI.Scale(88), tint=Color(140,120,255)})
|
||||
invCellA:Dock(LEFT)
|
||||
invCellA:DockMargin(0,0,Style.padding,0)
|
||||
|
||||
local invCellB = Components.CreateInteractiveCell(inv, {size=libNyx.UI.Scale(88), tint=Color(120,200,255)})
|
||||
invCellB:Dock(LEFT)
|
||||
|
||||
invCellA:SetItemIcon(
|
||||
Material("materials_umbrellyx/moreicons/doughnut-1.png", "noclamp smooth"),
|
||||
libNyx.UI.Scale(40),
|
||||
{
|
||||
title = "Пончик «Глазурь»",
|
||||
desc = "Сладкий круглый десерт с сахарной глазурью. Даёт +25 к настроению и немного утоляет голод.",
|
||||
tags = {
|
||||
{text="Еда", color=Color(255,180,90)},
|
||||
{text="Сладкое", color=Color(255,125,155)},
|
||||
{text="Эпик", color=Color(170,120,255)}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
-- (optional) leave empty to demo drag-drop target
|
||||
-- if u want a second example, uncomment:
|
||||
-- invCellB:SetItemIcon(Material("icon16/box.png","noclamp smooth"), libNyx.UI.Scale(36), {
|
||||
-- title = "Пустая коробка",
|
||||
-- desc = "Прочная тара для переноски мелких предметов.",
|
||||
-- tags = {"Контейнер", {text="Обычный", color=Color(120,200,255)}}
|
||||
-- })
|
||||
|
||||
end
|
||||
|
||||
page2 = vgui.Create("DPanel", pages)
|
||||
page2:Dock(FILL)
|
||||
page2:SetVisible(false)
|
||||
page2.Paint = function(s,w,h)
|
||||
libNyx.UI.Draw.Panel(0,0,w,h,{radius=Style.radius, color=Style.panelColor, glass=true})
|
||||
end
|
||||
|
||||
do
|
||||
local subnav = Components.CreateTabs(page2, {
|
||||
items = {
|
||||
{ id = "stylish", label = "Стильно", icon = Material("icon16/page_white_text.png","noclamp smooth") },
|
||||
{ id = "pretty", label = "Красиво", icon = Material("icon16/newspaper.png","noclamp smooth") },
|
||||
{ id = "modern", label = "Современно", icon = Material("icon16/fire.png","noclamp smooth") },
|
||||
{ id = "nyxnyx", label = "никс-никс-никс", icon = Material("icon16/heart.png","noclamp smooth") },
|
||||
{ id = "woohoo", label = "Делаем вуху?", icon = Material("icon16/user.png","noclamp smooth") },
|
||||
{ id = "r34", label = "r34", icon = Material("icon16/star.png","noclamp smooth") },
|
||||
},
|
||||
default = "pretty",
|
||||
onChange = function()
|
||||
page2:InvalidateLayout(true)
|
||||
end
|
||||
})
|
||||
subnav:Dock(TOP)
|
||||
subnav:SetTall(libNyx.UI.Scale(52))
|
||||
subnav:DockMargin(Style.padding, Style.padding, Style.padding, libNyx.UI.Scale(12))
|
||||
|
||||
local content = vgui.Create("DPanel", page2)
|
||||
content:Dock(FILL)
|
||||
content:DockMargin(Style.padding, 0, Style.padding, Style.padding)
|
||||
content.Paint = function(s,w,h)
|
||||
libNyx.UI.Draw.Panel(0,0,w,h,{radius=Style.radius, color=Color(12,14,20,110), glass=true})
|
||||
end
|
||||
|
||||
local toolbar = vgui.Create("DPanel", page2)
|
||||
toolbar:Dock(TOP)
|
||||
toolbar:SetTall(libNyx.UI.Scale(48))
|
||||
toolbar:DockMargin(Style.padding, Style.padding, Style.padding, 0)
|
||||
toolbar.Paint = nil
|
||||
|
||||
local flow = vgui.Create("DIconLayout", content)
|
||||
flow:Dock(FILL)
|
||||
flow:DockMargin(Style.padding, Style.padding, Style.padding, Style.padding)
|
||||
flow:SetSpaceX(Style.padding)
|
||||
flow:SetSpaceY(Style.padding)
|
||||
|
||||
local function cardWidth()
|
||||
local w = content:GetWide()
|
||||
return math.max(libNyx.UI.Scale(220), math.floor((w - Style.padding*3) / 2))
|
||||
end
|
||||
|
||||
local data = {
|
||||
{variant="vibrant", title="Nyx Team", desc="Делаем не только красиво.", from=Color(129,82,255), to=Color(40,192,255), icon="werewolf/0x00000000!0x8aaf8d0ab771a3b9.0x00b2d882.png"},
|
||||
{variant="vibrant", title="Nyx Team", desc="Делаем не только красиво.", from=Color(255,94,176), to=Color(255,142,220), icon="werewolf/0x00000000!0xfce5734b8472e83f.0x00b2d882.png"},
|
||||
{variant="glass", title="Nyx Team", desc="Делаем не только красиво.", from=Color(58,160,255), to=Color(40,120,255), icon="werewolf/0x00000000!0xfc708fa9e974b2cb.0x00b2d882.png"},
|
||||
{variant="glass", title="Nyx Team", desc="Делаем не только красиво.", from=Color(72,210,150), to=Color(28,190,140), icon="werewolf/0x00000000!0xf4e5b382cf4f862d.0x00b2d882.png"},
|
||||
}
|
||||
|
||||
local function clearFlow()
|
||||
for _, ch in ipairs(flow:GetChildren()) do if IsValid(ch) then ch:Remove() end end
|
||||
end
|
||||
|
||||
local function renderCards(query)
|
||||
query = string.Trim(string.lower(query or ""))
|
||||
clearFlow()
|
||||
for _, t in ipairs(data) do
|
||||
local hay = string.lower((t.title or "") .. " " .. (t.desc or ""))
|
||||
if query == "" or string.find(hay, query, 1, true) then
|
||||
local c = Components.CreateCategoryCard(flow, t)
|
||||
c:SetSize(cardWidth(), libNyx.UI.Scale(120))
|
||||
end
|
||||
end
|
||||
flow:InvalidateLayout(true)
|
||||
end
|
||||
|
||||
local search = Components.CreateSearchBox(toolbar, {
|
||||
placeholder = "Поиск…",
|
||||
tint = Style.accentColor,
|
||||
onChange = function(q) renderCards(q) end,
|
||||
onSubmit = function(q) renderCards(q) end,
|
||||
onClear = function() renderCards("") end
|
||||
})
|
||||
search:Dock(FILL)
|
||||
|
||||
content.OnSizeChanged = function()
|
||||
local cw = cardWidth()
|
||||
for _, ch in ipairs(flow:GetChildren()) do
|
||||
ch:SetSize(cw, libNyx.UI.Scale(120))
|
||||
end
|
||||
flow:InvalidateLayout(true)
|
||||
end
|
||||
|
||||
renderCards("")
|
||||
end
|
||||
|
||||
showPage(1)
|
||||
end
|
||||
|
||||
concommand.Add("libnyx_ui_showcase", function() -- comm to open
|
||||
libNyx.UI.OpenShowcase()
|
||||
end)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- libNyx by MaryBlackfild
|
||||
-- JOIN DISCORD: https://discord.gg/rUEEz4mfXw
|
||||
756
addons/_libnyx/lua/libnyx/lib/rndx.lua
Normal file
756
addons/_libnyx/lua/libnyx/lib/rndx.lua
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user