--by exechack.cc Toxicbadkazuin surface.CreateFont( "Sony_VolumeEditor_TitleFont", { font = "Raleway", size = 25, weight = 200, antialias = true, extended = true, } ) surface.CreateFont( "Sony_VolumeEditor_Font_20", { font = "Roboto", size = 20, weight = 20, antialias = true, extended = true, } ) surface.CreateFont( "Sony_VolumeEditor_Font_15", { font = "Roboto", size = 15, weight = 20, antialias = true, extended = true, } ) // Draw our volume slider panel: function DrawVolumeSliderPanel(parent, playerentity) local Main = vgui.Create("DPanel", parent) Main:Dock(TOP) Main:DockMargin(0, 5, 4, 0) Main:SetTall(50) Main.Paint = function( s, w, h ) draw.RoundedBox(3, 0, 0, w, h, Color(0, 0, 0, 255)) draw.RoundedBox(3, 1, 1, w-2, h-2, Color(60, 60, 60, 255)) draw.RoundedBox(3, 9, 9, 34, 34, Color(10, 10, 10, 255)) end local Avatar = vgui.Create( "AvatarImage", Main ) Avatar:SetSize( 32, 32 ) Avatar:SetPos( 10, 10 ) Avatar:SetPlayer( playerentity, 64 ) local Slider = vgui.Create( "DNumSlider", Main ) Slider:DockMargin(45, 0, 0, 0) Slider:Dock(FILL) Slider:SetText( playerentity:Nick() ) Slider:SetMin( 0 ) Slider:SetMax( 100 ) Slider:SetDecimals( 0 ) Slider:SetValue( playerentity:GetVoiceVolumeScale()*100 ) Slider.AssignedPlayer = playerentity Slider.TextArea:SetFont("Sony_VolumeEditor_Font_20") Slider.TextArea:SetTextColor(Color(255,255,255,255)) Slider.Label:SetFont("Sony_VolumeEditor_Font_20") Slider.Label:SetTextColor(Color(255,255,255,255)) Slider.Label:DockMargin(12, 0, 0, 0) Slider.Slider.Knob:SetSize(14, 14) Slider.Slider.Knob.Paint = function( self, w, h ) if self:IsHovered() then draw.RoundedBox(11, w / 2 - (22) / 2, h / 2 - (22) / 2 + (1), 22, 22, Color(255, 255, 255, 20)) end // Make the slider handle red if the person is muted entirely. if Slider:GetValue() == 0 then draw.RoundedBox(7, w / 2 - (14) / 2, h / 2 - (14) / 2 + (1), w, h, Color(255, 100, 100)) Slider.Label:SetTextColor(Color(255,100,100,255)) else draw.RoundedBox(7, w / 2 - (14) / 2, h / 2 - (14) / 2 + (1), w, h, Color(0, 136, 209)) Slider.Label:SetTextColor(Color(255,255,255,255)) end end Slider.Slider.Paint = function(self, w, h) draw.RoundedBox(0, 8, h / 2, select(1, Slider.Slider.Knob:GetPos()), 2, Color(0, 136, 209)) draw.RoundedBox(0, select(1, Slider.Slider.Knob:GetPos()), h / 2, w - 13 - select(1, Slider.Slider.Knob:GetPos()), 2, Color(160, 160, 160)) end Slider.OnValueChanged = function( self, value ) Slider.AssignedPlayer:SetVoiceVolumeScale( value/100 ) end end local function Volume_OpenSettings() local BasePanel = vgui.Create("DFrame"); BasePanel:SetDraggable(true) BasePanel:SetSizable(false) BasePanel:ShowCloseButton(false) BasePanel:MakePopup() BasePanel:SetSize(320, 345) BasePanel:Center() BasePanel:SetTitle("") BasePanel.OnClose = function() surface.PlaySound( "buttons/button15.wav" ) end // If there's noone on the server but you then display a message so users don't think the UI is broken or something. local AnyoneThere = false for _, ply in ipairs(player.GetAll()) do if IsValid(ply) then if ply != LocalPlayer() then AnyoneThere = true break end end end BasePanel.Paint = function(self, w, h) draw.RoundedBox(4, 0, 0, w, h, Color(1, 1, 1, 255)) -- Black Background, used to provide outline around edge of main window. draw.RoundedBox(4, 1, 1, w-2, h-2, Color(50, 50, 50, 200)) -- Background draw.RoundedBoxEx(4, 1, 1, w-2, 41, Color( 52, 52, 57, 255 ), true, true, false, false) -- Top bar with rounded corners. draw.RoundedBox(0, 0, 41, w, 1, Color(0, 0, 0, 255)) -- Top Spacer draw.RoundedBoxEx(4, 1, h-21, w-2, 20, Color( 52, 52, 57, 255 ), false, false, true, true) -- Footer with rounded bottom corners. draw.RoundedBox(0, 0, h-21, w, 1, Color(0, 0, 0, 255)) -- Footer spacer on top. draw.SimpleText("Adjust voice volume:", "Sony_VolumeEditor_TitleFont", 10, 20, Color(255,255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) if AnyoneThere == true then draw.SimpleText("Drag the slider to adjust voice volume.", "Sony_VolumeEditor_Font_15", 10, h-11, Color(200,200,200,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) else draw.SimpleText("There's nobody online but you.", "Sony_VolumeEditor_Font_15", 10, h-11, Color(200,200,200,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) draw.SimpleText("You're on your own!", "Sony_VolumeEditor_TitleFont", w/2, h/2-10, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) draw.SimpleText("Other player's volume sliders will appear here.", "Sony_VolumeEditor_Font_15", w/2, h/2+10, Color(200,200,200,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) end end local w, h = BasePanel:GetSize() -- The close button local CloseButton = vgui.Create("DButton", BasePanel) CloseButton:SetText("") CloseButton:SetPos(w-32, 9) CloseButton:SetSize(24, 24) CloseButton:SetTextColor(Color(255, 255, 255)) CloseButton.Paint = function(self, w, h) draw.RoundedBox(0, 0, 0, w, h, Color(255, 100, 100, 0)) end function CloseButton:DoClick() LocalPlayer():EmitSound("buttons/button15.wav", 500, 100) BasePanel:Close() end -- The close button icon. local icon = vgui.Create( "DImage", BasePanel ) icon:SetPos(w-32, 9) icon:SetSize( 24, 24 ) icon:SetImage( "materials/gui/cancel.png" ) // Scrollpanel we can add our settings and sliders to. local ScrollPanel = vgui.Create("DScrollPanel", BasePanel) ScrollPanel:Dock(FILL) ScrollPanel:DockMargin(0, 15, 0, 22) local ScrollPanelBar = ScrollPanel:GetVBar() ScrollPanelBar:SetWidth(8) function ScrollPanelBar:Paint(w, h) draw.RoundedBox(0, 0, 0, w, h, Color(44, 44, 44, 100)) end function ScrollPanelBar.btnUp:Paint(w, h) draw.RoundedBox(0, 0, 0, w, h, Color(44, 44, 44, 255)) end function ScrollPanelBar.btnDown:Paint(w, h) draw.RoundedBox(0, 0, 0, w, h, Color(44, 44, 44, 255)) end function ScrollPanelBar.btnGrip:Paint(w, h) draw.RoundedBox(0, 0, 0, w, h, Color( 52, 52, 57, 255 )) end // For debugging where the panel actually is. Uncomment this to make it visible. -- ScrollPanel.Paint = function(self, w, h) -- draw.RoundedBox(1, 1, 1, w-2, h-2, Color(80, 80, 80, 255)) -- end // Header for individual player's voice volume: -- local MenuButton = vgui.Create("DButton", ScrollPanel) -- MenuButton:SetText("") -- MenuButton:Dock(TOP) -- MenuButton:DockMargin(0, 5, 4, 0) -- MenuButton:SetHeight(25) -- MenuButton.Paint = function(self, w, h) -- draw.RoundedBox(3, 0, 0, w, h, Color(0, 0, 0, 255)) -- draw.RoundedBox(3, 1, 1, w - 2, h - 2, Color(90, 90, 90, 255)) -- draw.SimpleText("Adjust individual voice volume:", "Sony_VolumeEditor_Font_20", w/2, 12, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) -- end // Add a slider for every player, but filter out bots. for _, ply in ipairs(player.GetAll()) do if IsValid(ply) then if ply != LocalPlayer() then DrawVolumeSliderPanel(ScrollPanel, ply) end end end end concommand.Add("voice_volume_settings", function() Volume_OpenSettings() end)