From 883acbee6022f5ba311db805584c96d0006a484a Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Thu, 31 Dec 2015 22:49:46 -0500 Subject: Added new scoreboard --- gamemode/hud/draw_scoreboard.lua | 62 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/gamemode/hud/draw_scoreboard.lua b/gamemode/hud/draw_scoreboard.lua index 8062c56..6ad71cb 100644 --- a/gamemode/hud/draw_scoreboard.lua +++ b/gamemode/hud/draw_scoreboard.lua @@ -4,12 +4,68 @@ local SCOREBOARD_OFF = 101 local SCOREBOARD_WIDTH = 700 local SCOREBOARD_X = ScrW() / 2 - SCOREBOARD_WIDTH / 2 +local scoreboard = nil + function GM:ScoreboardShow() - self.ShowSB = true + local NPly = #player.GetAll() + local Tall = SCOREBOARD_OFF + 20 * NPly + local y = ScrH() / 2 - Tall / 2 + local by = y + SCOREBOARD_OFF + + scoreboard = vgui.Create("MBFrame") + if(!scoreboard) then return end + scoreboard:SetPos(SCOREBOARD_X,y) + scoreboard:SetSize(SCOREBOARD_WIDTH,Tall) + scoreboard:SetTitle("Scoreboard") + scoreboard:ShowCloseButton(false) + + for i,v in pairs(player.GetAll()) do + print("Makeing label for " .. v:Nick()) + local ypos = (20*(i-1))+24 + local playerlabel = vgui.Create("MBLabel") + playerlabel:SetParent(scoreboard) + playerlabel:SetPos(2, ypos) + local ptext = v:Nick() + if(v:IsPigeon()) then + ptext = ptext .. " (Dead)" + end + playerlabel:AddText(ptext) + playerlabel:SetupLines() + + local pinglabel = vgui.Create("MBLabel") + pinglabel:SetParent(scoreboard) + pinglabel:SetPos(SCOREBOARD_WIDTH-100,ypos) + pinglabel:AddText(v:Ping()) + pinglabel:SetupLines() + + --if(v == LocalPlayer()) then continue end + + local mutebutton = vgui.Create("MBButton") + mutebutton:SetParent(scoreboard) + mutebutton:SetPos(SCOREBOARD_X,ypos) + if(v:IsMuted()) then + mutebutton.Text = "Mute" + mutebutton.OnClick = function() + v:SetMuted(true) + end + else + mutebutton.Text = "Unmute" + mutebutton.OnClick = function() + v:SetMuted(false) + end + end + + end + + scoreboard:MakePopup() + --self.ShowSB = true end function GM:ScoreboardHide() - self.ShowSB = false + if(scoreboard) then + scoreboard:SetVisible(false) + end + --self.ShowSB = false end function GM:HUDDrawScoreBoard() @@ -29,6 +85,8 @@ function GM:HUDDrawScoreBoard() for k,v in pairs( player.GetAll() ) do local Y = by + 20 * (k-1) + DrawText("") + if (v:IsPigeon()) then DrawText(v:Nick(), "Trebuchet18", SCOREBOARD_X + 2, Y, MAIN_GREYCOLOR) DrawText(v:Ping(), "Trebuchet18", SCOREBOARD_X + SCOREBOARD_WIDTH - 30, Y, MAIN_GREYCOLOR) -- cgit v1.2.3-70-g09d2