Advertisement
Friks12829

jobs_panel_new

Aug 21st, 2024 (edited)
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 16.93 KB | None | 0 0
  1. local net=net local pairs=pairs local util=util local table=table local http=http local vgui=vgui local file=file local Material=Material local surface=surface local draw=draw local Color=Color local gui=gui local os=os local istable=istable local isstring=isstring local isnumber=isnumber local isfunction=isfunction local IsValid=IsValid local RunConsoleCommand=RunConsoleCommand local string=string local player=player local hook=hook local type=type local tonumber=tonumber local tostring=tostring local TEXT_ALIGN_CENTER=TEXT_ALIGN_CENTER local duplicator=duplicator local Sound=Sound local math=math local CurTime=CurTime local SysTime=SysTime local LocalPlayer=LocalPlayer local debugoverlay=debugoverlay local color_white=color_white local IsEntity=IsEntity local ScrW=ScrW local ScrH=ScrH local render=render local function a(y)function y:PerformLayout()local z,A=self:GetSize()self.pnlCanvas:SetTall(A)local B=0 for C,D in pairs(self.Panels)do if not IsValid(D)then goto h end if not D:IsVisible()then goto h end D:SetPos(B,0)D:SetTall(A)if D.ApplySchemeSettings then D:ApplySchemeSettings()end B=B+D:GetWide()-self.m_iOverlap::h::end self.pnlCanvas:SetWide(B+self.m_iOverlap)if z<self.pnlCanvas:GetWide()then self.OffsetX=math.Clamp(self.OffsetX,0,self.pnlCanvas:GetWide()-self:GetWide())else self.OffsetX=0 end self.pnlCanvas.x=self.OffsetX*-1 self.btnLeft:AlignLeft(4)self.btnLeft:AlignBottom(5)self.btnRight:AlignRight(4)self.btnRight:AlignBottom(5)self.btnLeft:SetVisible(self.pnlCanvas.x<0)self.btnRight:SetVisible(self.pnlCanvas.x+self.pnlCanvas:GetWide()>self:GetWide())end end local function b(y)y.btnLeft:TDLib():ClearPaint():Background(Color(50,50,50,150)):Text("<","DC_Normal_Bold",color_white):FadeHover(Color(200,200,200,100))y.btnLeft:Dock(LEFT)y.btnLeft:SetWide(50)y.btnLeft:DockMargin(5,5,5,5)y.btnRight:TDLib():ClearPaint():Background(Color(50,50,50,150)):Text(">","DC_Normal_Bold",color_white):FadeHover(Color(200,200,200,100))y.btnRight:Dock(RIGHT)y.btnRight:SetWide(50)y.btnRight:DockMargin(5,5,5,5)end local c=Material("console/background06")local d=Color(255,255,255,254)local e=Color(30,30,30,130)local f=Color(209,209,209)local g=Color(238,238,238)local h=Color(50,50,50,150)local i=Color(50,50,90,200)local function j(y)local z=y:GetVBar()y:TDLib():Background(e)z:TDLib():ClearPaint():Background(e)z.btnUp:TDLib():ClearPaint():Background(Color(10,10,10,100))z.btnDown:TDLib():ClearPaint():Background(Color(10,10,10,100))z.btnGrip:TDLib():ClearPaint():Background(Color(40,40,40,150))end local k=surface.CreateFont local function l(y)k("CloudGaming.Title",{font="Montserrat Medium",extended=true,size=y*0.05})k("CloudGaming.TitleSmall",{font="Montserrat Medium",extended=true,size=y*0.04})k("CloudGaming.TitleBold",{font="Montserrat Bold",extended=true,size=y*0.055})k("CloudGaming.Micro",{font="Montserrat Regular",extended=true,size=y*0.0175})k("CloudGaming.Tooltip",{font="Montserrat Medium",extended=true,size=y*0.0175})k("CloudGaming.Small",{font="Montserrat Medium",extended=true,size=y*0.02})k("CloudGaming.Default",{font="Montserrat Medium",extended=true,size=y*0.025})k("CloudGaming.DefaultBold",{font="Montserrat Bold",extended=true,size=y*0.025})k("CloudGaming.Medium",{font="Montserrat Medium",extended=true,size=y*0.0265})k("CloudGaming.Big",{font="Montserrat Medium",extended=true,size=y*0.03})k("CloudGaming.BigBold",{font="Montserrat Bold",extended=true,size=y*0.035})k("CloudGaming.Huge",{font="Montserrat Medium",extended=true,size=y*0.0385})k("CloudGaming.HugeBold",{font="Montserrat Bold",extended=true,size=y*0.045})end local m={}local n={}local o={}timer.Simple(1,function()n=DarkRP.getCategories().jobs end)local p=Material("../data/vipIcon.png")if p:IsError()then http.Fetch("https://i.imgur.com/fvaUN5H.png",function(y)file.Write("vipIcon.png",y)end)timer.Simple(10,function()p=Material("../data/vipIcon.png")end)end local q=Color(120,10,10,200)local r=c local s={}local t=surface.SetDrawColor local u=surface.SetMaterial local v=surface.DrawTexturedRect local w=Vector(104.844879,-81.280373,50)local x=Angle(4.057,141.358,10.000)function m:Init()self:DockMargin(0,0,0,0)self:DockPadding(5,5,5,5)self.initt=CurTime()+0.5 self:TDLib():ClearPaint():On("Paint",function(P,Q,R)t(d)u(r)v(0,0,Q,R)end):Blur(3)l(ScrW()*.6)local y=vgui.Create("DHorizontalScroller",self)y:Dock(TOP)y:SetTall(80)y:DockMargin(0,10,0,0)y:TDLib():ClearPaint():Background(e,2)a(y)b(y)local z=vgui.Create("DHorizontalScroller",self)z:Dock(TOP)z:SetTall(60)z:DockMargin(0,5,0,0)z:TDLib():ClearPaint():Background(e,2)a(z)b(z)local A=vgui.Create("DScrollPanel",self)A:Dock(LEFT)A:SetWide(ScrW()*.25)A:DockMargin(0,5,0,0)A:TDLib():ClearPaint():Background(e,2)j(A)local B=vgui.Create("Panel",self)B:Dock(LEFT)B:DockMargin(8,3,3,3)B:SetWide(ScrW()*.205)local C=vgui.Create("Panel",self)C:Dock(RIGHT)C:DockMargin(3,3,3,3)C:SetWide(ScrW()*.13)local D=C:Add("DScrollPanel")D:Dock(FILL)j(D)D:ClearPaint()local E=vgui.Create("DModelPanel",self)E:SetCursor("arrow")E:Dock(FILL)E:DockMargin(3,3,3,3)E:SetModel(LocalPlayer():GetModel())E:SetFOV(55)E.xVelocity=0 E.xOffset=0 E.yVelocity=0 E.ZoomingVector=Vector(0,0,0)E.LayoutEntity=function(P,Q)end E.OnMousePressed=function(P,Q)if IsValid(E)then if Q==MOUSE_LEFT then E._MousePosition={input.GetCursorPos()}E.Pressed=true end end end E.OnMouseWheeled=function(P,Q)E.xVelocity=E.xVelocity+Q end self.OnMouseWheeled=E.OnMouseWheeled E.Think=function(P)if not input.IsMouseDown(MOUSE_LEFT)then P.Pressed=false end P.xVelocity=P.xVelocity*0.9 P.yVelocity=P.yVelocity*0.9 if P.Pressed then local Q,R={input.GetCursorPos()},P._MousePosition local S,T=Q[1]-R[1],Q[2]-R[2]P.yVelocity=P.yVelocity+S*0.03 end P._MousePosition={input.GetCursorPos()}P.Entity:SetAngles(P.Entity:GetAngles()+Angle(0,P.yVelocity,0))P.xOffset=math.Clamp(P.xOffset+P.xVelocity,-32,64)P.Entity:SetPos(P.ZoomingVector*P.xOffset)end self.OnMousePressed=E.OnMousePressed local F=100 local function G(P,Q)D:Clear()print(#P.weapons)if P.weapons and#P.weapons>0 then local eb=B:Add("Panel")eb:Dock(TOP)eb:SetTall(60)eb:DockMargin(0,0,0,1)eb:TDLib():ClearPaint():Background(PIXEL.Colors.Background,2)eb:On("Paint",function(gb,hb,ib)PIXEL.DrawSimpleText("ОРУЖИЯ","DC_Normal",hb/2,ib/2,PIXEL.Colors.Primary,1,1)end)local fb=B:Add("DScrollPanel")fb:Dock(TOP)fb:SetTall(200)j(fb)for gb,hb in ipairs(P.weapons)do local ib=weapons.Get(hb)if not ib then goto a0 end local jb=fb:Add("DPanel")jb:Dock(TOP)jb:SetTall(30)jb:DockMargin(1,2,1,1)jb:TDLib():ClearPaint():Background(e,2)local kb=vgui.Create("DPanel",jb)kb:Dock(LEFT)kb:SetWide(200)kb:DockMargin(5,1,1,1)kb:TDLib():ClearPaint():Text(ib.PrintName~=nil and ib.PrintName or ib.Name~=nil and ib.Name or hb,"DC_Small",f,TEXT_ALIGN_LEFT)local lb=vgui.Create("DPanel",jb)lb:Dock(FILL)lb:DockMargin(1,1,1,1)lb:TDLib():ClearPaint():On("Paint",function(mb,nb,ob)draw.RoundedBox(1,2,2,nb*(ib.Primary~=nil and ib.Primary.ClipSize~=nil and ib.Primary.ClipSize~=-1 and ib.Primary.Damage~=nil and ib.Primary.Damage/F or 0),25,q)PIXEL.DrawSimpleText(ib.Primary~=nil and ib.Primary.ClipSize~=nil and ib.Primary.ClipSize~=-1 and ib.Primary.Damage~=nil and"Урон: "..ib.Primary.Damage or"-","DC_Small",5,ob/2,color_white,TEXT_ALIGN_LEFT,1)end)::a0::end end if P.stats then local eb=B:Add("Panel")eb:Dock(TOP)eb:SetTall(60)eb:DockMargin(0,5,0,1)eb:TDLib():ClearPaint():Background(PIXEL.Colors.Background,2)eb:On("Paint",function(gb,hb,ib)PIXEL.DrawSimpleText("СТАТИСТИКА","DC_Normal",hb/2,ib/2,PIXEL.Colors.Primary,1,1)end)local fb=B:Add("DScrollPanel")fb:Dock(TOP)fb:SetTall(200)j(fb)for gb,hb in pairs(P.stats)do if not DC_CORE.Config.JobStatInfo[gb]then continue end local ib=DC_CORE and DC_CORE.GetPhrase and DC_CORE:GetPhrase(gb)or gb local jb=fb:Add("DPanel")jb:Dock(TOP)jb:SetTall(30)jb:DockMargin(1,2,1,1)jb:TDLib():ClearPaint():Background(e,2)local kb=vgui.Create("DPanel",jb)kb:Dock(LEFT)kb:SetWide(200)kb:DockMargin(5,1,1,1)kb:TDLib():ClearPaint():Text(ib,"DC_Small",f,TEXT_ALIGN_LEFT)local lb=vgui.Create("DPanel",jb)lb:Dock(FILL)lb:DockMargin(1,1,1,1)lb:TDLib():ClearPaint():On("Paint",function(mb,nb,ob)draw.RoundedBox(1,2,2,nb*hb,1000,q)PIXEL.DrawSimpleText(hb,"DC_Small",5,ob/2,color_white,TEXT_ALIGN_LEFT,1)end)::a0::end end local R=B:Add("Panel")R:Dock(TOP)R:SetTall(60)R:DockMargin(0,5,0,1)R:TDLib():ClearPaint():Background(PIXEL.Colors.Background,2)R:On("Paint",function(eb,fb,gb)PIXEL.DrawSimpleText("ОПИСАНИЕ","DC_Normal",fb/2,gb/2,PIXEL.Colors.Primary,1,1)end)local S=B:Add("DScrollPanel")S:Dock(FILL)S:DockMargin(0,8,0,3)j(S)local T=S:Add("PIXEL.Label")T:SetAutoWrap(true)T:SetContentAlignment(5)T:Dock(FILL)T:SetWrap(true)T:SetMultiline(true)T:SetAutoHeight(true)T:SetFont("DC_Normal")T:SetTextColor(f)T:SetText(P.description)E:SetModel(istable(P.model)and P.model[1]or P.model)if GetGlobalString("d_serverid","none")=="stalker"then E.Entity:SetSequence(8)end local U=table.Copy(e)U.a=200 local V={}local W={}local function X()for eb,fb in pairs(V)do if IsValid(fb)then fb:Remove()end end W={}for eb,fb in pairs(E.Entity:GetBodyGroups())do if fb.num<=1 then goto aa end W[fb.id]=0 local gb=D:Add("DPanel")gb:Dock(TOP)gb:SetTall(50)gb:DockMargin(1,2,1,0)gb:TDLib():ClearPaint():Background(e,1):Text(fb.name.." ("..fb.num..")","CloudGaming.Small",f,1)local hb=vgui.Create("DButton",gb)hb:Dock(LEFT)hb:DockMargin(2,2,2,2)hb:SetWide(35)hb:TDLib():ClearPaint():Background(e,2):FadeHover(U):Text("<","CloudGaming.Small",f,1):On("DoClick",function()W[fb.id]=math.Clamp(W[fb.id]-1,0,fb.num-1)E.Entity:SetBodygroup(fb.id,W[fb.id])end)local ib=vgui.Create("DButton",gb)ib:Dock(RIGHT)ib:DockMargin(2,2,2,2)ib:SetWide(35)ib:TDLib():ClearPaint():Background(e,2):FadeHover(U):Text(">","CloudGaming.Small",f,1):On("DoClick",function()W[fb.id]=math.Clamp(W[fb.id]+1,0,fb.num-1)E.Entity:SetBodygroup(fb.id,W[fb.id])end)table.insert(V,gb)::aa::end end local Y=1 if istable(P.model)and#P.model>1 then local eb=D:Add("DPanel")eb:Dock(TOP)eb:SetTall(50)eb:DockMargin(1,2,1,0)eb:TDLib():ClearPaint():Background(e,1):Text("Модель"..(istable(P.model)and" ("..#P.model..")"or""),"CloudGaming.Small",f,1)local fb=vgui.Create("DButton",eb)fb:Dock(LEFT)fb:DockMargin(2,2,2,2)fb:SetWide(35)fb:TDLib():ClearPaint():Background(e,2):FadeHover(U):Text("<","CloudGaming.Small",f,1):On("DoClick",function()if not istable(P.model)then return end Y=math.Clamp(Y-1,1,#P.model)E:SetModel(P.model[Y])X() E.Entity:SetSequence(8) end)local gb=vgui.Create("DButton",eb)gb:Dock(RIGHT)gb:DockMargin(2,2,2,2)gb:SetWide(35)gb:TDLib():ClearPaint():Background(e,2):FadeHover(U):Text(">","CloudGaming.Small",f,1):On("DoClick",function()if not istable(P.model)then return end Y=math.Clamp(Y+1,1,#P.model)E:SetModel(P.model[Y])X() E.Entity:SetSequence(8)end)end local Z=0 if E.Entity:SkinCount()>1 then local eb=D:Add("DPanel")eb:Dock(TOP)eb:SetTall(50)eb:DockMargin(1,2,1,0)eb:TDLib():ClearPaint():Background(e,1):Text("Скины ("..E.Entity:SkinCount()..")","CloudGaming.Small",f,1)local fb=vgui.Create("DButton",eb)fb:Dock(LEFT)fb:DockMargin(2,2,2,2)fb:SetWide(35)fb:TDLib():ClearPaint():Background(e,2):FadeHover(U):Text("<","CloudGaming.Small",f,1):On("DoClick",function()Z=math.Clamp(Z-1,0,E.Entity:SkinCount()-1)E.Entity:SetSkin(Z)end)local gb=vgui.Create("DButton",eb)gb:Dock(RIGHT)gb:DockMargin(2,2,2,2)gb:SetWide(35)gb:TDLib():ClearPaint():Background(e,2):FadeHover(U):Text(">","CloudGaming.Small",f,1):On("DoClick",function()Z=math.Clamp(Z+1,0,E.Entity:SkinCount()-1)E.Entity:SetSkin(Z)end)end if IsValid(C.takeBtn)then C.takeBtn:Remove()end C.takeBtn=self:Add("DButton")C.takeBtn:Dock(BOTTOM)C.takeBtn:SetTall(50)C.takeBtn:DockMargin(1,2,1,6)local ab=P.playtime and P.playtime>LocalPlayer():GetUTimeTotalTime()and(not table.HasValue(DC_JobSystem.IgnoreRanks,LocalPlayer():GetUserGroup()or(P.legendary~=nil)))local bb=not DC_JobSystem.IsTeamUnlocked(LocalPlayer(),Q)and P.jobcost~=nil local cb=LocalPlayer():canAfford(P.jobcost)C.takeBtn:SetText("")C.takeBtn:TDLib():ClearPaint():Background(P.vip~=nil and P.vip==true and not LocalPlayer():CheckGroup("vip")and Color(100,10,10,200)or e,3):FadeHover(Color(10,100,10,150))local db=os.date("%A")if(P.isblock~=nil)and(P.isblock==true)and(curDay~="Saturday")and(curDay~="Sunday")then C.takeBtn:Text(bb and P.jobcost>0 and"ДОСТУПНО ПО ВЫХОДНЫМ ("..DarkRP.formatMoney(P.jobcost)..") "or"ДОСТУПНО ПО ВЫХОДНЫМ ","CloudGaming.Small",f,1)elseif ab then C.takeBtn:On("Paint",function(eb,fb,gb)PIXEL.DrawSimpleText("ОСТАЛОСЬ: "..DC_JobSystem.FormatTime(P.playtime-LocalPlayer():GetUTimeTotalTime()),"DC_Normal",fb/2,gb/2,g,1,1)end)elseif bb then C.takeBtn:Text("РАЗБЛОКИРОВАТЬ ЗА "..DarkRP.formatMoney(P.jobcost),"CloudGaming.Small",f,1)if cb then C.takeBtn:Text("РАЗБЛОКИРОВАТЬ ЗА "..DarkRP.formatMoney(P.jobcost),"CloudGaming.Small",f,1)else C.takeBtn:Text("НЕДОСТАТОЧНО ДЕНЕГ ["..DarkRP.formatMoney(P.jobcost).."]","CloudGaming.Small",g,1)end else C.takeBtn:Text(P.vip~=nil and P.vip==true and not table.HasValue(DC_JobSystem.VipRanks,LocalPlayer():GetUserGroup())and"ВЫ НЕ VIP"or LocalPlayer():Team()==P.team and"СМЕНИТЬ ОДЕЖДУ"or P.max~=0 and#team.GetPlayers(P.team)>=P.max and"НЕТ МЕСТ"or"ВЗЯТЬ РАБОТУ","CloudGaming.Small",f,1)end C.takeBtn:On("DoClick",function()if ab then return end if bb and cb then Derma_Query("Вы уверены что хотите разблокировать '"..P.name.."' за "..DarkRP.formatMoney(P.jobcost).."?","Подтверждение","Да",function()LocalPlayer():ConCommand("DC_JobSystem.UnlockJob "..P.team)if not IsValid(self)then return end timer.Simple(0.6,function()if not IsValid(self)then return end G(P,P.team)end)end,"Нет")return elseif bb then return end if LocalPlayer():Team()~=P.team then self:GetParent():Remove()gui.EnableScreenClicker(false)RunConsoleCommand("DC_JobSystem.ChangeJob",P.team)end timer.Simple(0.25,function()netstream.Start("DC_JobSystem.BodygroupData",Z,Y,W)end)end)X()end local H=nil local I=nil local J=nil local function K(P,Q)B:Clear()J=P G(Q,P)end local L=Color(200,200,200,100)local function M(P,Q,R)J=nil I=Q A:Clear()for S,T in pairs(R)do if T.ishide==true then goto at end if J==nil then K(T.team,T)end surface.SetFont("CloudGaming.Default")local U=T.name..(T.max~=0 and" ["..#team.GetPlayers(T.team).."/"..T.max.."]"or"")local V,W=surface.GetTextSize(U)local X=Color(30,30,30,200)local Y=A:Add("DButton")Y:Dock(TOP)Y:SetTall(60)Y:DockMargin(1,1,1,1)local Z=T.vip~=nil and T.vip==true Y:SetWide(Z and V+85 or V+30)local ab=T.playtime and T.playtime>LocalPlayer():GetUTimeTotalTime()and not table.HasValue(DC_JobSystem.IgnoreRanks,LocalPlayer():GetUserGroup())Y:TDLib():ClearPaint():On("Paint",function(bb,cb,db)draw.RoundedBox(3,0,0,cb,db,J==T.team and X or h)if T.vip~=nil and T.vip==true then surface.SetDrawColor(color_white)surface.SetMaterial(p)surface.DrawTexturedRect(5,db/2-15,30,30)end if ab then local eb,fb=PIXEL.DrawSimpleText(U,"DC_Normal",T.vip~=nil and T.vip==true and 38 or 5,db/2,g,TEXT_ALIGN_LEFT,1)local gb,hb=PIXEL.DrawSimpleText(DC_JobSystem.FormatTime(T.playtime-LocalPlayer():GetUTimeTotalTime()),"DC_Normal",cb-5,db/2,g,TEXT_ALIGN_RIGHT,1)bb:SetWide(eb+gb+30)else PIXEL.DrawSimpleText(U,"DC_Normal",T.vip~=nil and T.vip==true and 38 or 5,db/2,f,TEXT_ALIGN_LEFT,1)end end):FadeHover(X):Text("","DC_Normal",f,0):On("OnCursorEntered",function()surface.PlaySound("UI/buttonrollover.wav")end):On("DoClick",function(bb)K(T.team,T)end)::at::end end local function N(P,Q)I=nil H=P z:Clear()A:Clear()o={}if DC_JobSystem.UIBackgrounds[Q.name]then s[Q.name]=s[Q.name]or Material(DC_JobSystem.UIBackgrounds[Q.name].BackgroundPath)r=s[Q.name]if r:IsError()then r=c end else r=c end for R,S in ipairs(Q.members)do if S.sCategory~=nil then o[S.sCategory]=o[S.sCategory]or{}table.insert(o[S.sCategory],S)end end if table.Count(o)>0 then z:SetVisible(true)for R,S in pairs(o)do if I==nil then M(P,R,S)end surface.SetFont("DC_Normal")local T,U=surface.GetTextSize(R)local V=Color(30,30,30,200)local W=z:Add("DButton")W:Dock(LEFT)W:DockMargin(1,1,1,1)W:SetWide(T+30)W:TDLib():ClearPaint():On("Paint",function(X,Y,Z)draw.RoundedBox(3,0,0,Y,Z,I==R and V or h)end):FadeHover(V):Text(R,"DC_Normal",f,1):On("OnCursorEntered",function()surface.PlaySound("UI/buttonrollover.wav")end):On("DoClick",function(X)M(W,R,S)end)z:AddPanel(W)end else z:SetVisible(false)M(P,nil,Q.members)end end local O=LocalPlayer():GetUserGroup()=="user"or LocalPlayer():GetUserGroup()=="vip"for P,Q in ipairs(n)do if#Q.members<=0 then goto aF end if Q.name=="Лобби"then goto aF end if Q.name=="Администрация"and O then goto aF end if H==nil then N(P,Q)end surface.SetFont("DC_Normal")local R=string.upper(Q.name)local S,T=surface.GetTextSize(R)local U=Color(30,30,30,200)local V=y:Add("DButton")V:Dock(LEFT)V:DockMargin(1,1,1,1)V:SetWide(S+30)V:TDLib():ClearPaint():On("Paint",function(W,X,Y)draw.RoundedBox(3,0,0,X,Y,H==P and U or h)end):FadeHover(U):Text(R,"DC_Normal",f,1):On("OnCursorEntered",function()surface.PlaySound("UI/buttonrollover.wav")end):On("DoClick",function(W)N(P,Q)end)y:AddPanel(V)::aF::end end function m:Think()if not self.initt or self.initt>CurTime()then return end if input.IsKeyDown(KEY_F4)then self:Remove()end end timer.Simple(2,function()vgui.Register("jobs_panel",m,"DPanel")end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement