Advertisement
GMODOWNER

THIS IS WHERE IT SAYS THE ERROR IS COMING FROM

Jan 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 30.30 KB | None | 0 0
  1. local matList = Material("shenesis/f4menu/list.png", "noclamp smooth")
  2. local matUser = Material("shenesis/f4menu/user.png", "noclamp smooth")
  3. local matPrevious = Material("shenesis/f4menu/previous.png", "noclamp smooth")
  4. local matClose = Material("shenesis/f4menu/close.png", "noclamp smooth")
  5.  
  6. local font = LOUNGE_TAB.Font
  7. local font_bold = LOUNGE_TAB.FontBold
  8. local font_italic = LOUNGE_TAB.FontItalic
  9.  
  10. --
  11. local function GetUserGroup(ply)
  12.     if (LOUNGE_TAB.UsergroupMode == 1) then
  13.         return serverguard.player:GetRank(ply)
  14.     else
  15.         return ply:GetUserGroup()
  16.     end
  17. end
  18.  
  19. function LT_QuickLabel(t, f, c, p)
  20.     local l = vgui.Create("DLabel", p)
  21.     l:SetText(t)
  22.     l:SetFont(f)
  23.     l:SetColor(c)
  24.     l:SizeToContents()
  25.  
  26.     return l
  27. end
  28.  
  29. function LT_PaintScroll(panel)
  30.     local styl = LOUNGE_TAB.Style
  31.  
  32.     local scr = panel:GetVBar()
  33.     scr.Paint = function(_, w, h)
  34.         draw.RoundedBox(4, 0, 0, w, h, styl.bg)
  35.     end
  36.  
  37.     scr.btnUp.Paint = function(_, w, h)
  38.         draw.RoundedBox(4, 2, 0, w - 4, h - 2, styl.inbg)
  39.     end
  40.     scr.btnDown.Paint = function(_, w, h)
  41.         draw.RoundedBox(4, 2, 2, w - 4, h - 2, styl.inbg)
  42.     end
  43.  
  44.     scr.btnGrip.Paint = function(me, w, h)
  45.         draw.RoundedBox(4, 2, 0, w - 4, h, styl.inbg)
  46.  
  47.         if (me.Hovered) then
  48.             draw.RoundedBox(4, 2, 0, w - 4, h, styl.hover2)
  49.         end
  50.  
  51.         if (me.Depressed) then
  52.             draw.RoundedBox(4, 2, 0, w - 4, h, styl.hover2)
  53.         end
  54.     end
  55. end
  56.  
  57. function LT_Menu()
  58.     local styl = LOUNGE_TAB.Style
  59.  
  60.     if (IsValid(_LOUNGE_TAB_MENU)) then
  61.         _LOUNGE_TAB_MENU:Remove()
  62.     end
  63.  
  64.     local th = 48 * _LOUNGE_TAB_SCALE
  65.     local m = th * 0.25
  66.  
  67.     local cancel = vgui.Create("DPanel")
  68.     cancel:SetDrawBackground(false)
  69.     cancel:StretchToParent(0, 0, 0, 0)
  70.     cancel:MoveToFront()
  71.     cancel:MakePopup()
  72.  
  73.     local pnl = vgui.Create("DPanel")
  74.     pnl:SetDrawBackground(false)
  75.     pnl:SetSize(20, 1)
  76.     pnl.AddOption = function(me, text, callback)
  77.         surface.SetFont("TAB_LOUNGE_MediumB")
  78.         local wi, he = surface.GetTextSize(text)
  79.         wi = wi + m * 2
  80.         he = he + m
  81.  
  82.         me:SetWide(math.max(wi, me:GetWide()))
  83.         me:SetTall(pnl:GetTall() + he)
  84.  
  85.         local btn = vgui.Create("DButton", me)
  86.         btn:SetText(text)
  87.         btn:SetFont("TAB_LOUNGE_MediumB")
  88.         btn:SetColor(styl.text)
  89.         btn:Dock(TOP)
  90.         btn:SetSize(wi, he)
  91.         btn.Paint = function(me, w, h)
  92.             surface.SetDrawColor(styl.menu)
  93.             surface.DrawRect(0, 0, w, h)
  94.  
  95.             if (me.Hovered) then
  96.                 surface.SetDrawColor(styl.hover)
  97.                 surface.DrawRect(0, 0, w, h)
  98.             end
  99.  
  100.             if (me:IsDown()) then
  101.                 surface.SetDrawColor(styl.hover)
  102.                 surface.DrawRect(0, 0, w, h)
  103.             end
  104.         end
  105.         btn.DoClick = function(me)
  106.             callback()
  107.             pnl:Close()
  108.         end
  109.     end
  110.     pnl.Open = function(me)
  111.         _LOUNGE_TAB:KillFocus()
  112.         _LOUNGE_TAB:SetMouseInputEnabled(false)
  113.         _LOUNGE_TAB:SetKeyboardInputEnabled(false)
  114.    
  115.         me:SetPos(gui.MouseX(), gui.MouseY())
  116.         me:SetDrawOnTop(true)
  117.         me:MakePopup()
  118.         me:MoveToFront()
  119.     end
  120.     pnl.Close = function(me)
  121.         if (me.m_bClosing) then
  122.             return end
  123.  
  124.         me.m_bClosing = true
  125.         me:AlphaTo(0, 0.1, 0, function()
  126.             me:Remove()
  127.         end)
  128.  
  129.         if (IsValid(_LOUNGE_TAB)) then
  130.             _LOUNGE_TAB:MakePopup()
  131.             _LOUNGE_TAB:SetMouseInputEnabled(true)
  132.             _LOUNGE_TAB:SetKeyboardInputEnabled(true)
  133.         end
  134.     end
  135.     _LOUNGE_TAB_MENU = pnl
  136.  
  137.     cancel.OnMouseReleased = function(me, mc)
  138.         pnl:Close()
  139.     end
  140.     cancel.Think = function(me)
  141.         if (!IsValid(pnl)) then
  142.             me:Remove()
  143.         end
  144.     end
  145.  
  146.     return pnl
  147. end
  148.  
  149. function LT_StringRequest(title, text, callback, def)
  150.     local styl = LOUNGE_TAB.Style
  151.  
  152.     if (IsValid(_LOUNGE_TAB_STRREQ)) then
  153.         _LOUNGE_TAB_STRREQ:Remove()
  154.     end
  155.  
  156.     local scale = _LOUNGE_TAB_SCALE
  157.     local wi, he = 600 * scale, 160 * scale
  158.  
  159.     local cancel = vgui.Create("DPanel")
  160.     cancel:SetDrawBackground(false)
  161.     cancel:StretchToParent(0, 0, 0, 0)
  162.     cancel:MoveToFront()
  163.     cancel:MakePopup()
  164.  
  165.     local pnl = vgui.Create("EditablePanel")
  166.     pnl:SetSize(wi, he)
  167.     pnl:Center()
  168.     pnl:MakePopup()
  169.     pnl.m_fCreateTime = SysTime()
  170.     pnl.Paint = function(me, w, h)
  171.         Derma_DrawBackgroundBlur(me, me.m_fCreateTime)
  172.         draw.RoundedBox(4, 0, 0, w, h, styl.bg)
  173.     end
  174.     pnl.Close = function(me)
  175.         if (me.m_bClosing) then
  176.             return end
  177.  
  178.         me.m_bClosing = true
  179.         me:AlphaTo(0, 0.1, 0, function()
  180.             me:Remove()
  181.         end)
  182.     end
  183.     _LOUNGE_F4_STRREQ = pnl
  184.  
  185.     cancel.OnMouseReleased = function(me, mc)
  186.         if (mc == MOUSE_LEFT) then
  187.             pnl:Close()
  188.         end
  189.     end
  190.     cancel.Think = function(me)
  191.         if (!IsValid(pnl)) then
  192.             me:Remove()
  193.         end
  194.     end
  195.  
  196.         local th = 48 * scale
  197.         local m = th * 0.25
  198.  
  199.         local header = vgui.Create("DPanel", pnl)
  200.         header:SetTall(th)
  201.         header:Dock(TOP)
  202.         header.Paint = function(me, w, h)
  203.             draw.RoundedBoxEx(4, 0, 0, w, h, styl.header, true, true, false, false)
  204.         end
  205.  
  206.             local titlelbl = LT_QuickLabel(title, "TAB_LOUNGE_Larger", styl.text, header)
  207.             titlelbl:Dock(LEFT)
  208.             titlelbl:DockMargin(m, 0, 0, 0)
  209.  
  210.             local close = vgui.Create("DButton", header)
  211.             close:SetText("")
  212.             close:SetWide(th)
  213.             close:Dock(RIGHT)
  214.             close.Paint = function(me, w, h)
  215.                 if (me.Hovered) then
  216.                     draw.RoundedBoxEx(4, 0, 0, w, h, styl.close_hover, false, true, false, false)
  217.                 end
  218.  
  219.                 if (me:IsDown()) then
  220.                     draw.RoundedBoxEx(4, 0, 0, w, h, styl.hover, false, true, false, false)
  221.                 end
  222.  
  223.                 surface.SetDrawColor(me:IsDown() and styl.text_down or styl.text)
  224.                 surface.SetMaterial(matClose)
  225.                 surface.DrawTexturedRectRotated(w * 0.5, h * 0.5, 16 * scale, 16 * scale, 0)
  226.             end
  227.             close.DoClick = function(me)
  228.                 pnl:Close()
  229.             end
  230.  
  231.         local body = vgui.Create("DPanel", pnl)
  232.         body:SetDrawBackground(false)
  233.         body:Dock(FILL)
  234.         body:DockPadding(m, m, m, m)
  235.  
  236.             local tx = LT_QuickLabel(text, "TAB_LOUNGE_Large", styl.text, body)
  237.             tx:SetContentAlignment(5)
  238.             tx:SetWrap(tx:GetWide() > wi - m * 2)
  239.             tx:Dock(FILL)
  240.  
  241.             local apply = vgui.Create("DButton", body)
  242.             apply:SetText("OK")
  243.             apply:SetColor(styl.text)
  244.             apply:SetFont("TAB_LOUNGE_Medium")
  245.             apply:Dock(BOTTOM)
  246.             apply.Paint = function(me, w, h)
  247.                 draw.RoundedBox(4, 0, 0, w, h, styl.inbg)
  248.  
  249.                 if (me.Hovered) then
  250.                     surface.SetDrawColor(styl.hover)
  251.                     surface.DrawRect(0, 0, w, h)
  252.                 end
  253.  
  254.                 if (me:IsDown()) then
  255.                     surface.SetDrawColor(styl.hover)
  256.                     surface.DrawRect(0, 0, w, h)
  257.                 end
  258.             end
  259.  
  260.             local entry = vgui.Create("DTextEntry", body)
  261.             entry:SetText(def or "")
  262.             entry:RequestFocus()
  263.             entry:SetFont("TAB_LOUNGE_Medium")
  264.             entry:SetDrawLanguageID(false)
  265.             entry:Dock(BOTTOM)
  266.             entry:DockMargin(0, m, 0, m)
  267.             entry.Paint = function(me, w, h)
  268.                 draw.RoundedBox(4, 0, 0, w, h, styl.textentry)
  269.                 me:DrawTextEntryText(me:GetTextColor(), me:GetHighlightColor(), me:GetCursorColor())
  270.             end
  271.             entry.OnEnter = function()
  272.                 apply:DoClick()
  273.             end
  274.  
  275.             apply.DoClick = function()
  276.                 pnl:Close()
  277.                 callback(entry:GetValue())
  278.             end
  279.  
  280.     pnl.OnFocusChanged = function(me, gained)
  281.         if (!gained) then
  282.             timer.Simple(0, function()
  283.                 if (!IsValid(me) or vgui.GetKeyboardFocus() == entry) then
  284.                     return end
  285.  
  286.                 me:Close()
  287.             end)
  288.         end
  289.     end
  290.  
  291.     pnl:SetWide(math.max(tx:GetWide() + m * 2, pnl:GetWide()))
  292.     pnl:CenterHorizontal()
  293.  
  294.     pnl:SetAlpha(0)
  295.     pnl:AlphaTo(255, 0.1)
  296. end
  297.  
  298. function LT_FormatTime(time)
  299.     local t = {}
  300.  
  301.     local w = math.floor(time / (86400 * 7))
  302.     if (w > 0) then
  303.         table.insert(t, w .. "w")
  304.         time = time - w * (86400 * 7)
  305.     end
  306.  
  307.     local d = math.floor(time / 86400)
  308.     if (d > 0) then
  309.         table.insert(t, d .. "d")
  310.         time = time - d * 86400
  311.     end
  312.  
  313.     local h = math.floor(time / 3600)
  314.     if (h > 0) then
  315.         table.insert(t, h .. "h")
  316.         time = time - h * 3600
  317.     end
  318.  
  319.     local m = math.floor(time / 60)
  320.     if (m > 0) then
  321.         table.insert(t, m .. "m")
  322.         time = time - m * 60
  323.     end
  324.  
  325.     local s = math.floor(time)
  326.     if (s > 0) then
  327.         table.insert(t, s .. "s")
  328.     end
  329.  
  330.     return table.concat(t, " ")
  331. end
  332.  
  333. local function rainbowThink(me)
  334.     me.m_iHue = (me.m_iHue + FrameTime() * math.min(150, me.m_iRate)) % 360
  335.     me:SetFGColor(HSVToColor(me.m_iHue, 1, 1))
  336. end
  337.  
  338. function LOUNGE_TAB:Show()
  339.     if (IsValid(_LOUNGE_TAB)) then
  340.         _LOUNGE_TAB:Remove()
  341.     end
  342.  
  343.     local curpage
  344.  
  345.     local scale = math.Clamp(ScrH() / 1080, 0.7, 1)
  346.     _LOUNGE_TAB_SCALE = scale
  347.  
  348.     surface.CreateFont("TAB_LOUNGE_Small", {font = font, size = 14 * scale})
  349.     surface.CreateFont("TAB_LOUNGE_Medium", {font = font, size = 16 * scale})
  350.     surface.CreateFont("TAB_LOUNGE_Large", {font = font, size = 20 * scale})
  351.     surface.CreateFont("TAB_LOUNGE_Larger", {font = font, size = 24 * scale})
  352.     surface.CreateFont("TAB_LOUNGE_SmallB", {font = font_bold, size = 14 * scale})
  353.     surface.CreateFont("TAB_LOUNGE_MediumB", {font = font_bold, size = 16 * scale})
  354.     surface.CreateFont("TAB_LOUNGE_LargeB", {font = font_bold, size = 20 * scale})
  355.     surface.CreateFont("TAB_LOUNGE_LargerB", {font = font_bold, size = 24 * scale})
  356.     surface.CreateFont("TAB_LOUNGE_MediumI", {font = font_italic, size = 16 * scale})
  357.     surface.CreateFont("TAB_LOUNGE_LargeI", {font = font_italic, size = 20 * scale})
  358.     surface.CreateFont("TAB_LOUNGE_LargerI", {font = font_italic, size = 24 * scale})
  359.  
  360.     local wi, he = (900 * self.WidthScale) * scale, (700 * self.HeightScale) * scale
  361.  
  362.     local pnl = vgui.Create("EditablePanel")
  363.     pnl:SetSize(wi, he)
  364.     pnl:Center()
  365.     pnl.m_fCreateTime = SysTime()
  366.     pnl:MoveToFront()
  367.     pnl:SetZPos(99)
  368.     pnl.Paint = function(me, w, h)
  369.         if (self.DrawBackgroundBlur) then
  370.             Derma_DrawBackgroundBlur(me, me.m_fCreateTime - 0.1)
  371.         end
  372.  
  373.         draw.RoundedBox(4, 0, 0, w, h, self.Style.bg)
  374.         me:MoveToFront()
  375.         me:RequestFocus()
  376.     end
  377.     pnl.Close = function(me)
  378.         if (me.m_bClosing) then
  379.             return end
  380.  
  381.         me.m_bClosing = true
  382.         me:AlphaTo(0, 0.1, 0, function()
  383.             me:Remove()
  384.             _TAB_LOUNGE_RESIZING = false
  385.         end)
  386.     end
  387.     _LOUNGE_TAB = pnl
  388.  
  389.         local th = 48 * scale
  390.         local m = th * 0.25
  391.         local m5 = m * 0.5
  392.  
  393.         local header = vgui.Create("DPanel", pnl)
  394.         header:SetTall(th)
  395.         header:Dock(TOP)
  396.         header.Paint = function(me, w, h)
  397.             draw.RoundedBoxEx(4, 0, 0, w, h, self.Style.header, true, true, false, false)
  398.         end
  399.  
  400.             local titlelbl = LT_QuickLabel(self.Title ~= "" and self.Title or GetHostName(), "TAB_LOUNGE_Larger", self.Style.text, header)
  401.             titlelbl:Dock(FILL)
  402.             titlelbl:DockMargin(m, 0, 0, 0)
  403.  
  404.             local lbl_playercount
  405.             if (self.DisplayPlayerCount) then
  406.                 local pnl = vgui.Create("DPanel", header)
  407.                 pnl:Dock(RIGHT)
  408.                 pnl:DockMargin(0, m, m, m)
  409.  
  410.                     local tx = LT_QuickLabel("0", "TAB_LOUNGE_LargerB", self.Style.text, pnl)
  411.                     tx:Dock(RIGHT)
  412.                     tx.Update = function(me)
  413.                         local cnt, max = #player.GetAll(), game.MaxPlayers()
  414.  
  415.                         me:SetText(cnt .. "/" .. max)
  416.                         me:SetTextColor(cnt >= max and self.Style.full or self.Style.text)
  417.                         me:SizeToContents()
  418.  
  419.                         pnl:SetWide(24 * scale + tx:GetWide() + m5)
  420.                     end
  421.                     lbl_playercount = tx
  422.  
  423.                     tx:Update()
  424.  
  425.                 pnl.Paint = function(me, w, h)
  426.                     surface.SetDrawColor(tx:GetTextColor())
  427.                     surface.SetMaterial(matUser)
  428.                     surface.DrawTexturedRectRotated(h * 0.5, h * 0.5, h, h, 0)
  429.                 end
  430.             end
  431.  
  432.         local body = vgui.Create("DPanel", pnl)
  433.         body:SetDrawBackground(false)
  434.         body:Dock(FILL)
  435.  
  436.             local contents = vgui.Create("DScrollPanel", body)
  437.             LT_PaintScroll(contents)
  438.             contents:SetWide(wi - th)
  439.             contents:Dock(FILL)
  440.             contents:GetCanvas():DockPadding(m5, m5, m5, m5)
  441.  
  442.             local toggled = cookie.GetNumber("LoungeTab_ToggleOff", 1) == 1
  443.  
  444.             local navbar = vgui.Create("DPanel", body)
  445.             navbar:SetWide(toggled and th or th * 3)
  446.             navbar:Dock(LEFT)
  447.             navbar:DockPadding(0, th, 0, 0)
  448.             navbar.Paint = function(me, w, h)
  449.                 draw.RoundedBoxEx(4, 0, 0, w, h, self.Style.inbg, false, false, true, false)
  450.             end
  451.  
  452.                 local togglenavbar = vgui.Create("DButton", navbar)
  453.                 togglenavbar:SetText("")
  454.                 togglenavbar:SetToolTip(LOUNGE_TAB.Language.toggle)
  455.                 togglenavbar:SetSize(th, th)
  456.                 togglenavbar.Paint = function(me, w, h)
  457.                     surface.SetDrawColor(self.Style.text)
  458.                     surface.SetMaterial(matList)
  459.                     surface.DrawTexturedRectRotated(w * 0.5, h * 0.5, 24 * scale, 24 * scale, 0)
  460.                 end
  461.                 togglenavbar.DoClick = function()
  462.                     toggled = !toggled
  463.                     cookie.Set("LoungeTab_ToggleOff", toggled and 1 or 0)
  464.  
  465.                     _TAB_LOUNGE_RESIZING = true
  466.                     navbar:Stop()
  467.                     navbar:SizeTo(toggled and th or th * 3, -1, 0.1, 0, 0.2, function()
  468.                         _TAB_LOUNGE_RESIZING = false
  469.                     end)
  470.                 end
  471.  
  472.                 for _, page in ipairs (LOUNGE_TAB.Buttons) do
  473.                     if (page.display and !page.display()) then
  474.                         continue end
  475.  
  476.                     local tx = LOUNGE_TAB.Language[page.text] or page.text
  477.  
  478.                     local btn = vgui.Create("DButton", navbar)
  479.                     btn:SetText("")
  480.                     btn:SetToolTip(tx)
  481.                     btn:SetTall(th)
  482.                     btn:Dock(TOP)
  483.                     btn.Paint = function(me, w, h)
  484.                         if (me.Hovered) then
  485.                             surface.SetDrawColor(self.Style.hover)
  486.                             surface.DrawRect(0, 0, w, h)
  487.                         end
  488.  
  489.                         if (me:IsDown()) then
  490.                             surface.SetDrawColor(self.Style.hover)
  491.                             surface.DrawRect(0, 0, w, h)
  492.                         end
  493.  
  494.                         surface.SetDrawColor(self.Style.text)
  495.                         surface.SetMaterial(page.icon)
  496.                         surface.DrawTexturedRectRotated(24 * scale, 24 * scale, 24 * scale, 24 * scale, 0)
  497.                     end
  498.                     btn.DoClick = function()
  499.                         page.callback()
  500.                     end
  501.  
  502.                         local lbl = LT_QuickLabel(tx, "TAB_LOUNGE_Medium", self.Style.text, btn)
  503.                         lbl:Dock(LEFT)
  504.                         lbl:DockMargin(th, 0, 0, 0)
  505.                 end
  506.  
  507.             local paint_line = function(me, w, h)
  508.                 if (me.m_Player ~= nil and !IsValid(me.m_Player)) then
  509.                     me:Close()
  510.                 end
  511.  
  512.                 draw.RoundedBox(4, 0, 0, w, h, self.Style.inbg)
  513.  
  514.                 if (me.Hovered) then
  515.                     surface.SetDrawColor(self.Style.hover2)
  516.                     surface.DrawRect(0, 0, w, h)
  517.                 end
  518.  
  519.                 if (me:IsDown()) then
  520.                     surface.SetDrawColor(self.Style.hover2)
  521.                     surface.DrawRect(0, 0, w, h)
  522.                 end
  523.             end
  524.  
  525.             local function PopulatePlayerList(ilist, filter)
  526.                 local players = {}
  527.                 for _, v in ipairs (player.GetAll()) do
  528.                     if (filter and !filter(v)) then
  529.                         continue end
  530.  
  531.                     table.insert(players, v)
  532.                 end
  533.  
  534.                 local colSort = self.PlayerColumns[self.PlayerSortBy]
  535.                 table.sort(players, function(a, b)
  536.                     if (self.SortAsc) then
  537.                         return colSort.func(a) < colSort.func(b)
  538.                     else
  539.                         return colSort.func(a) > colSort.func(b)
  540.                     end
  541.                 end)
  542.  
  543.                 for _, v in ipairs (players) do
  544.                     if (self.DisplayFlag) and ((!self.OnlyAdminsSeeFlags or LocalPlayer():IsAdmin()) or v == LocalPlayer()) then
  545.                         if (!v.m_CountryCode) and (!v.m_fNextFlagRequest or CurTime() >= v.m_fNextFlagRequest) then
  546.                             v.m_fNextFlagRequest = CurTime() + 30
  547.  
  548.                             net.Start("TAB_LOUNGE_CountryFlag")
  549.                                 net.WriteEntity(v)
  550.                             net.SendToServer()
  551.                         end
  552.                     end
  553.  
  554.                     local link, steamid = "http://steamcommunity.com/profiles/" .. (v:SteamID64() or "0"), v:SteamID()
  555.  
  556.                     local line = vgui.Create("DButton", ilist)
  557.                     line:SetText("")
  558.                     line:SetTall((32 + m5 * 2) * scale)
  559.                     line:Dock(TOP)
  560.                     line:DockMargin(0, 0, 0, m5)
  561.                     line:DockPadding(m5, m5, m5, m5)
  562.                     line.m_Player = v
  563.                     line.Paint = paint_line
  564.                     line.Close = function(me)
  565.                         if (me.m_bClosing) then
  566.                             return end
  567.  
  568.                         me.m_bClosing = true
  569.                         me:AlphaTo(0, 0.2, 0, function()
  570.                             me:SizeTo(-1, 0, 0.1, nil, nil, function()
  571.                                 ilist:InvalidateLayout(true)
  572.                                 me:Remove()
  573.  
  574.                                 if (IsValid(lbl_playercount)) then
  575.                                     lbl_playercount:Update()
  576.                                 end
  577.                             end)
  578.                         end)
  579.                     end
  580.                     line.DoClick = function(me)
  581.                         if (me.m_bClosing) then
  582.                             return end
  583.  
  584.                         if (self.UsePlayerAdminMenu > 0) then
  585.                             local pnl = vgui.Create("DPanel", body)
  586.                             pnl:StretchToParent(navbar:GetWide(), 0, 0, 0)
  587.                             pnl:AlignLeft(navbar:GetWide() - pnl:GetWide())
  588.                             pnl:DockPadding(m5, m5, m5, m5)
  589.                             pnl:MoveToBefore(navbar)
  590.                             pnl.Paint = function(me, w, h)
  591.                                 surface.SetDrawColor(self.Style.bg)
  592.                                 surface.DrawRect(0, 0, w, h)
  593.                             end
  594.  
  595.                                 local top = vgui.Create("DPanel", pnl)
  596.                                 top:SetDrawBackground(false)
  597.                                 top:SetTall(32 * scale)
  598.                                 top:Dock(TOP)
  599.  
  600.                                     local bak = vgui.Create("DButton", top)
  601.                                     bak:SetText("")
  602.                                     bak:SetWide(top:GetTall())
  603.                                     bak:Dock(LEFT)
  604.                                     bak.Paint = function(me, w, h)
  605.                                         surface.SetDrawColor(color_white)
  606.                                         surface.SetMaterial(matPrevious)
  607.                                         surface.DrawTexturedRect(-m5, 0, w, h)
  608.                                     end
  609.                                     bak.DoClick = function()
  610.                                         if (pnl.m_bClosing) then
  611.                                             return end
  612.  
  613.                                         pnl.m_bClosing = true
  614.                                         pnl:Stop()
  615.                                         pnl.Think = function() end
  616.                                         pnl:MoveTo(-pnl:GetWide(), -1, 0.3, nil, nil, function()
  617.                                             pnl:Remove()
  618.                                         end)
  619.                                     end
  620.  
  621.                                 local pinfo = vgui.Create("DPanel", pnl)
  622.                                 pinfo:SetTall(64 * scale + m5 * 2)
  623.                                 pinfo:Dock(TOP)
  624.                                 pinfo:DockMargin(0, m5, 0, 0)
  625.                                 pinfo:DockPadding(m5, m5, m5, m5)
  626.                                 pinfo.Paint = function(me, w, h)
  627.                                     draw.RoundedBox(4, 0, 0, w, h, self.Style.inbg)
  628.                                 end
  629.  
  630.                                     local av = vgui.Create("AvatarImage", pinfo)
  631.                                     av:SetWide(64 * scale)
  632.                                     av:SetPlayer(v, 64)
  633.                                     av:Dock(LEFT)
  634.  
  635.                                     local info = vgui.Create("DIconLayout", pinfo)
  636.                                     info:SetSpaceX(m5)
  637.                                     info:SetLayoutDir(LEFT)
  638.                                     info:Dock(FILL)
  639.                                     info:DockMargin(m5, 0, 0, 0)
  640.  
  641.                                     if (self.UsePlayerAdminMenu == 1 and FAdmin) then
  642.                                         for _, inf in pairs (FAdmin.ScoreBoard.Player.Information) do
  643.                                             local val = inf.func(v)
  644.                                             if (val) then
  645.                                                 LT_QuickLabel(inf.name .. ": " .. val, "TAB_LOUNGE_Medium", self.Style.text, info)
  646.                                             end
  647.                                         end
  648.                                     elseif (self.UsePlayerAdminMenu == 2) then
  649.                                         LT_QuickLabel(v:Nick(), "TAB_LOUNGE_Medium", self.Style.text, info)
  650.                                         LT_QuickLabel(v:SteamID(), "TAB_LOUNGE_Medium", self.Style.text, info)
  651.                                     end
  652.  
  653.                                 local acts = vgui.Create("DIconLayout", pnl)
  654.                                 acts:SetSpaceX(m5)
  655.                                 acts:SetSpaceY(m5)
  656.                                 acts:Dock(FILL)
  657.                                 acts:DockMargin(0, m5, 0, 0)
  658.  
  659.                                     local function CreateButton(tx, cb)
  660.                                         local btn = vgui.Create("DButton", acts)
  661.                                         btn:SetText(tx)
  662.                                         btn:SetFont("TAB_LOUNGE_Medium")
  663.                                         btn:SetColor(color_transparent)
  664.                                         btn:SizeToContents()
  665.                                         btn:SetWide(btn:GetWide() + m5 * 2)
  666.                                         btn.Paint = function(me, w, h)
  667.                                             paint_line(me, w, h)
  668.  
  669.                                             if (me.m_Image1) then
  670.                                                 surface.SetMaterial(me.m_Image1)
  671.                                                 surface.SetDrawColor(color_white)
  672.                                                 surface.DrawTexturedRect(m5, m5, 16, 16)
  673.                                             end
  674.  
  675.                                             if (me.m_Image2) then
  676.                                                 surface.SetMaterial(me.m_Image2)
  677.                                                 surface.SetDrawColor(color_white)
  678.                                                 surface.DrawTexturedRect(m5, m5, 16, 16)
  679.                                             end
  680.  
  681.                                             if (me.m_Image1 or me.m_Image2) then
  682.                                                 draw.SimpleText(me:GetText(), me:GetFont(), w - m5, h * 0.5, self.Style.text, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
  683.                                             else
  684.                                                 draw.SimpleText(me:GetText(), me:GetFont(), w * 0.5, h * 0.5, self.Style.text, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  685.                                             end
  686.                                         end
  687.                                         btn.DoClick = function(s)
  688.                                             local im = 0
  689.                                             if (s.m_Image1 or s.m_Image2) then
  690.                                                 im = m5 + 18
  691.                                             end
  692.  
  693.                                             cb(v, s)
  694.                                             s:SizeToContentsX()
  695.                                             s:SetWide(s:GetWide() + m5 * 2 + im)
  696.  
  697.                                             acts:Layout()
  698.                                         end
  699.  
  700.                                         return btn
  701.                                     end
  702.  
  703.                                     if (self.UsePlayerAdminMenu == 1 and FAdmin) then
  704.                                         for _, inf in pairs (FAdmin.ScoreBoard.Player.ActionButtons) do
  705.                                             if not (inf.Visible == true or (type(inf.Visible) == "function" and inf.Visible(v) == true)) then
  706.                                                 continue end
  707.  
  708.                                             local name = inf.Name
  709.                                             if (isfunction(name)) then name = name(v) end
  710.  
  711.                                             local btn = CreateButton(DarkRP.deLocalise(name), function(v, s)
  712.                                                 inf.Action(v, s)
  713.                                             end)
  714.                                             btn.SetImage = function(me, im)
  715.                                                 me.m_Image1 = Material(im)
  716.                                             end
  717.                                             btn.SetImage2 = function(me, im)
  718.                                                 me.m_Image2 = Material(im)
  719.                                             end
  720.  
  721.                                             if (inf.Image and LOUNGE_TAB.ShowFAdminIcons) then
  722.                                                 if (isstring(inf.Image)) then
  723.                                                     btn:SetImage(inf.Image)
  724.                                                 elseif (istable(inf.Image)) then
  725.                                                     btn:SetImage(inf.Image[1])
  726.                                                     if (inf.Image[2]) then
  727.                                                         btn:SetImage2(inf.Image[2])
  728.                                                     end
  729.                                                 elseif (isfunction(inf.Image)) then
  730.                                                     local img1, img2 = inf.Image(v)
  731.                                                     btn:SetImage(img1)
  732.                                                     if (img2) then btn:SetImage2(img2) end
  733.                                                 end
  734.  
  735.                                                 btn:SetWide(btn:GetWide() + 16)
  736.                                                 btn:SetTall(math.max(btn:GetTall(), 16 + m5 * 2))
  737.                                             end
  738.  
  739.                                             if (inf.OnButtonCreated) then
  740.                                                 inf.OnButtonCreated(v, btn)
  741.                                             end
  742.                                         end
  743.                                     elseif (self.UsePlayerAdminMenu == 2 and ULib) then
  744.                                         for cmd, data in pairs (ULib.cmds.translatedCmds) do
  745.                                             -- local opposite = data.opposite
  746.                                             if (opposite ~= cmd and (LocalPlayer():query(data.cmd) or (opposite and LocalPlayer():query(opposite)))) then
  747.                                                 local say = cmd
  748.                                                 local dat = ULib.cmds.translatedCmds[say]
  749.                                                 if not (dat.args[2] and (dat.args[2].type == ULib.cmds.PlayersArg or dat.args[2].type == ULib.cmds.PlayerArg)) then
  750.                                                     continue end
  751.  
  752.                                                 local btn = CreateButton(string.gsub(cmd, "ulx ", ""), function(v, s)
  753.                                                     local torun = string.Explode(" ", cmd)
  754.                                                     table.insert(torun, "$" .. ULib.getUniqueIDForPlayer(v))
  755.  
  756.                                                     if (dat.args[3]) and (dat.args[3].type == ULib.cmds.StringArg or dat.args[3].type == ULib.cmds.NumArg) then
  757.                                                         LT_StringRequest(cmd .. " -> " .. v:Nick(), dat.args[3].hint or cmd, function(tx)
  758.                                                             table.insert(torun, tx)
  759.                                                             RunConsoleCommand(unpack(torun))
  760.                                                         end, dat.args[3].default)
  761.                                                     else
  762.                                                         RunConsoleCommand(unpack(torun))
  763.                                                     end
  764.                                                 end)
  765.                                             end
  766.                                         end
  767.                                     end
  768.  
  769.                             pnl:MoveTo(navbar:GetWide(), -1, 0.3, nil, nil, function()
  770.                                 pnl.Think = function(s)
  771.                                     if (!IsValid(v)) then
  772.                                         bak:DoClick()
  773.                                     end
  774.  
  775.                                     s:StretchToParent(navbar:GetWide(), 0, 0, 0)
  776.                                 end
  777.                             end)
  778.                         else
  779.                             me:DoRightClick()
  780.                         end
  781.                     end
  782.                     line.DoRightClick = function()
  783.                         local m = LT_Menu()
  784.  
  785.                             m:AddOption(self.Language.view_steam_profile, function()
  786.                                 gui.OpenURL(link)
  787.                             end)
  788.                             m:AddOption(self.Language.copy_steamid, function()
  789.                                 SetClipboardText(steamid)
  790.                             end)
  791.  
  792.                             if (v ~= LocalPlayer()) then
  793.                                 m:AddOption(v:IsMuted() and self.Language.unmute or self.Language.mute, function()
  794.                                     v:SetMuted(!v:IsMuted())
  795.                                 end)
  796.                             end
  797.  
  798.                         m:Open()
  799.                     end
  800.  
  801.                         --
  802.                         local av = vgui.Create("AvatarImage", line)
  803.                         av:SetPlayer(v)
  804.                         av:SetWide(32 * scale)
  805.                         av:Dock(LEFT)
  806.                         av:DockMargin(0, 0, m5, 0)
  807.  
  808.                             local btn = vgui.Create("DButton", av)
  809.                             btn:SetText("")
  810.                             btn:Dock(FILL)
  811.                             btn.Paint = function() end
  812.                             btn.DoClick = function()
  813.                                 v:ShowProfile()
  814.                             end
  815.  
  816.                         --
  817.                         local cc = self.PlayerFlags[v:SteamID()] or self.PlayerFlags[v:SteamID64()] or self.PlayerFlags[GetUserGroup(v)]
  818.                         if (!cc) and ((!self.OnlyAdminsSeeFlags or LocalPlayer():IsAdmin()) or v == LocalPlayer()) then
  819.                             cc = v.m_CountryCode
  820.                         end
  821.                         if (self.DisplayFlag and cc and file.Exists("materials/flags16/" .. cc .. ".png", "GAME")) then
  822.                             local mat = Material("flags16/" .. cc .. ".png", "noclamp")
  823.  
  824.                             local img = vgui.Create("DPanel", line)
  825.                             img:SetMouseInputEnabled(false)
  826.                             img:SetWide(16)
  827.                             img:Dock(LEFT)
  828.                             img:DockMargin(0, 0, m5, 0)
  829.                             img.Paint = function(me, w, h)
  830.                                 surface.SetDrawColor(color_white)
  831.                                 surface.SetMaterial(mat)
  832.                                 surface.DrawTexturedRectRotated(w * 0.5, h * 0.5, 16, 11, 0)
  833.                             end
  834.                         end
  835.  
  836.                         --
  837.                         local usergroup = GetUserGroup(v)
  838.                         if (usergroup ~= "user" or self.DisplayUserLabel) then
  839.                             local rainbow = false
  840.                             local col = self.UsergroupColors[usergroup] or self.Style.text
  841.                             if (col == "rainbow") then
  842.                                 col = self.Style.text
  843.                                 rainbow = true
  844.                             end
  845.  
  846.                             local ug = LT_QuickLabel(self.CleanUsergroups[usergroup] or usergroup, self.ItalicUsergroup and "TAB_LOUNGE_LargeI" or "TAB_LOUNGE_Large", col, line)
  847.                             ug:Dock(LEFT)
  848.                             if (ug:GetText() == "") then
  849.                                 ug:DockMargin(0, 0, 0, 0)
  850.                             else
  851.                                 ug:DockMargin(0, 0, m5, 0)
  852.                             end
  853.                             if (rainbow) then
  854.                                 ug.m_iHue = 0
  855.                                 ug.m_iRate = 360
  856.                                 ug.Think = rainbowThink
  857.                             end
  858.                         end
  859.  
  860.                         --
  861.                         local rainbow = false
  862.                         local col = self.PlayerColors[v:SteamID()] or self.PlayerColors[v:SteamID64()] or self.PlayerColors[GetUserGroup(v)] or self.Style.text
  863.                         if (col == "rainbow") then
  864.                             col = self.Style.text
  865.                             rainbow = true
  866.                         end
  867.  
  868.                         local nick = LT_QuickLabel(v:Nick(), "TAB_LOUNGE_LargeB", col, line)
  869.                         nick:Dock(FILL)
  870.                         if (rainbow) then
  871.                             nick.m_iHue = 0
  872.                             nick.m_iRate = 360
  873.                             nick.Think = rainbowThink
  874.                         end
  875.  
  876.                         --
  877.                         local wi = 80
  878.  
  879.                         local function addColumn(tx, func, width, font)
  880.                             local col = vgui.Create("DPanel", line)
  881.                             col:SetMouseInputEnabled(false)
  882.                             col:SetDrawBackground(false)
  883.                             col:SetWide(width * scale)
  884.                             col:Dock(RIGHT)
  885.  
  886.                                 local lbl = LT_QuickLabel(self.Language[tx] or tx or "", "TAB_LOUNGE_Small", self.Style.subtext, col)
  887.                                 lbl:SetContentAlignment(5)
  888.                                 lbl:Dock(BOTTOM)
  889.  
  890.                                 if (lbl:GetText() == "") then
  891.                                     lbl:Remove()
  892.                                 end
  893.  
  894.                                 local val = LT_QuickLabel("", font or "TAB_LOUNGE_LargeB", self.Style.text, col)
  895.                                 val:SetContentAlignment(5)
  896.                                 val:Dock(FILL)
  897.  
  898.                             col.m_fNextUpdate = CurTime() + 3
  899.                             col.Think = function(me)
  900.                                 if (CurTime() >= me.m_fNextUpdate) then
  901.                                     me:Update()
  902.                                     me.m_fNextUpdate = CurTime() + 3
  903.                                 end
  904.                             end
  905.                             col.Update = function(me)
  906.                                 if (!IsValid(v)) then
  907.                                     return end
  908.  
  909.                                 local va, co = func(v)
  910.                                 co = co or self.Style.text
  911.                                 val:SetTextColor(co)
  912.                                 val:SetText(string.Comma(va))
  913.                             end
  914.                             col:Update()
  915.                         end
  916.  
  917.                         for _, col in SortedPairs (self.PlayerColumns, true) do
  918.                             if (col.darkrp and !DarkRP) then
  919.                                 continue end
  920.  
  921.                             if (col.ttt and !DetectiveMode) then
  922.                                 continue end
  923.  
  924.                             if (col.candisplay and !col.candisplay()) then
  925.                                 continue end
  926.  
  927.                             addColumn(col.text or "", col.func, col.wi or wi, col.font)
  928.                         end
  929.                 end
  930.  
  931.                 return #players > 0
  932.             end
  933.  
  934.             local function AddGroup(tx, fil)
  935.                 local lbl = LT_QuickLabel(tx, "TAB_LOUNGE_Larger", self.Style.text, contents)
  936.                 lbl:Dock(TOP)
  937.  
  938.                 local plist = vgui.Create("DScrollPanel", contents)
  939.                 plist:Dock(TOP)
  940.  
  941.                 local added = PopulatePlayerList(plist, fil)
  942.                 plist:GetCanvas():InvalidateLayout(true)
  943.                 plist:SetTall(plist:GetCanvas():GetTall())
  944.  
  945.                 if (!added) then
  946.                     lbl:Remove()
  947.                     plist:Remove()
  948.                 end
  949.  
  950.                 return plist
  951.             end
  952.  
  953.             if (self.DisplayStyle == 0) then -- all in same list
  954.                 PopulatePlayerList(contents)
  955.             elseif (self.DisplayStyle == 1) then -- separate by team
  956.                 local teamz = {}
  957.                 for _, v in pairs (player.GetAll()) do
  958.                     if (!teamz[v:Team()]) then
  959.                         teamz[v:Team()] = true
  960.                     end
  961.                 end
  962.  
  963.                 for t in SortedPairs (teamz) do
  964.                     AddGroup(team.GetName(t), function(ply)
  965.                         return ply:Team() == t
  966.                     end)
  967.                 end
  968.             elseif (self.DisplayStyle == 2) then -- separate by usergroup
  969.                 local ugz = {}
  970.                 for _, v in pairs (player.GetAll()) do
  971.                     if (!ugz[GetUserGroup(v)]) then
  972.                         ugz[GetUserGroup(v)] = true
  973.                     end
  974.                 end
  975.  
  976.                 for u in SortedPairs (ugz) do
  977.                     AddGroup(self.CleanUsergroups[u] or u, function(ply)
  978.                         return GetUserGroup(ply) == u
  979.                     end)
  980.                 end
  981.             elseif (self.DisplayStyle == 3) then -- separate by alive/dead
  982.                 AddGroup(self.Language.alive, function(ply)
  983.                     return ply:Alive()
  984.                 end)
  985.  
  986.                 AddGroup(self.Language.dead, function(ply)
  987.                     return !ply:Alive()
  988.                 end)
  989.             elseif (self.DisplayStyle == 4) then -- separate by alive/dead
  990.                 AddGroup(self.Language.free, function(ply)
  991.                     return !ply:isArrested()
  992.                 end)
  993.  
  994.                 AddGroup(self.Language.arrested, function(ply)
  995.                     return ply:isArrested()
  996.                 end)
  997.             elseif (self.DisplayStyle == 5) then -- TTT separation
  998.                 local groups = {}
  999.  
  1000.                 groups[GROUP_TERROR] = AddGroup(self.Language.terrorists, function(ply)
  1001.                     return ScoreGroup(ply) == GROUP_TERROR
  1002.                 end)
  1003.  
  1004.                 groups[GROUP_SPEC] = AddGroup(self.Language.spectators, function(ply)
  1005.                     return ScoreGroup(ply) == GROUP_SPEC
  1006.                 end)
  1007.  
  1008.                 if (DetectiveMode and DetectiveMode()) then
  1009.                     groups[GROUP_NOTFOUND] = AddGroup(self.Language.mia, function(ply)
  1010.                         return ScoreGroup(ply) == GROUP_NOTFOUND
  1011.                     end)
  1012.  
  1013.                     groups[GROUP_FOUND] = AddGroup(self.Language.confirmed, function(ply)
  1014.                         return ScoreGroup(ply) == GROUP_FOUND
  1015.                     end)
  1016.                 end
  1017.             end
  1018.  
  1019.     pnl:SetAlpha(0)
  1020.     pnl:AlphaTo(255, 0.1)
  1021.  
  1022.     _LOUNGE_TAB:MakePopup()
  1023.     _LOUNGE_TAB:KillFocus()
  1024.     _LOUNGE_TAB:SetMouseInputEnabled(false)
  1025.     _LOUNGE_TAB:SetKeyboardInputEnabled(false)
  1026.     gui.EnableScreenClicker(false)
  1027. end
  1028.  
  1029. hook.Add("ScoreboardShow", "LOUNGE_TAB_ScoreboardShow", function()
  1030.     LOUNGE_TAB:Show()
  1031.  
  1032.     if (LOUNGE_TAB.CursorOnOpen) then
  1033.         gui.EnableScreenClicker(true)
  1034.         _LOUNGE_TAB:SetMouseInputEnabled(true)
  1035.         LOUNGE_TAB.ScoreboardCursor = true
  1036.     end
  1037.  
  1038.     return false
  1039. end)
  1040.  
  1041. hook.Add("ScoreboardHide", "LOUNGE_TAB_ScoreboardHide", function()
  1042.     if (IsValid(_LOUNGE_TAB)) then
  1043.         _LOUNGE_TAB:Close()
  1044.     end
  1045.     if (IsValid(_LOUNGE_TAB_STRREQ)) then
  1046.         _LOUNGE_TAB_STRREQ:Close()
  1047.     end
  1048.  
  1049.     if (LOUNGE_TAB.ScoreboardCursor) then
  1050.         gui.EnableScreenClicker(false)
  1051.     end
  1052. end)
  1053.  
  1054. hook.Add("KeyRelease", "Scoreboard.DoCursorOnRMB", function(ply, key)
  1055.     if (key == IN_ATTACK2 and IsValid(_LOUNGE_TAB)) then
  1056.         gui.EnableScreenClicker(true)
  1057.         _LOUNGE_TAB:SetMouseInputEnabled(true)
  1058.         LOUNGE_TAB.ScoreboardCursor = true
  1059.     end
  1060. end)
  1061.  
  1062. hook.Add("InitPostEntity", "LOUNGE_TAB_InitPostEntity", function()
  1063.     hook.Remove("ScoreboardShow", "FAdmin_scoreboard")
  1064.     hook.Remove("ScoreboardHide", "FAdmin_scoreboard")
  1065. end)
  1066.  
  1067. net.Receive("TAB_LOUNGE_CountryFlag", function()
  1068.     local ent = net.ReadEntity()
  1069.     local cc = net.ReadString()
  1070.     if (IsValid(ent)) then
  1071.         ent.m_CountryCode = cc
  1072.     end
  1073. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement