Advertisement
ChanServ

Nicolas

Nov 23rd, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.22 KB | None | 0 0
  1. -- This code is pretty ugly but hopefully it will be useful to you.
  2. local width, height = ScrW(), ScrH()
  3. local aspect = 9/16
  4. local showoutline = true
  5. local function ScrW()
  6.     return width
  7. end
  8. local function ScrH()
  9.     return height
  10. end
  11. local window, slider = vgui.Create("DFrame")
  12. window:SetSize(200, 150)
  13. window:Center()
  14. window:MakePopup()
  15. window:SetScreenLock(true)
  16. window:SetTitle("Nicolas")
  17. function window:OnClose()
  18.     hook.Remove("HUDPaint", "nicolas")
  19. end
  20. local combo, aspectcombo = vgui.Create("DComboBox", window)
  21. combo:DockMargin(0, 4, 0, 0)
  22. combo:Dock(BOTTOM)
  23. combo:AddChoice("640 x 480 (4:3)", {640, 480, 1})
  24. combo:AddChoice("1280 x 1024 (5:4)", {640, 480, 2})
  25. combo:AddChoice("1280 x 720 (16:9)", {1280, 720, 3})
  26. combo:AddChoice("1920 x 1080 (16:9)", {1920, 1080, 3})
  27. combo:AddChoice("1680 x 1050 (16:10)", {1920, 1080, 4})
  28. function combo:OnSelect(i, v, d)
  29.     aspectcombo:ChooseOptionID(d[3])
  30.     slider:SetValue(d[1])
  31. end
  32. aspectcombo = vgui.Create("DComboBox", window)
  33. aspectcombo:DockMargin(0, 4, 0, 0)
  34. aspectcombo:Dock(BOTTOM)
  35. aspectcombo:AddChoice("4:3", 3/4)
  36. aspectcombo:AddChoice("5:4", 4/5)
  37. aspectcombo:AddChoice("16:9", 9/16)
  38. aspectcombo:AddChoice("16:10", 10/16)
  39. function aspectcombo:OnSelect(i, v, d)
  40.     aspect = tonumber(d)
  41.     slider:OnValueChanged(width)
  42. end
  43. slider = vgui.Create("DNumSlider", window)
  44. slider:Dock(FILL)
  45. slider:SetMin(0)
  46. slider:SetMax(width)
  47. slider:SetDecimals(0)
  48. function slider:OnValueChanged(v)
  49.     width = v
  50.     height = aspect*v
  51.     self:SetText(string.format("%u x %u", ScrW(), ScrH()))
  52. end
  53. aspectcombo:ChooseOptionID(3)
  54. combo:ChooseOptionID(3)
  55.  
  56. local check = vgui.Create("DCheckBoxLabel", window)
  57. check:DockMargin(0, 4, 0, 0)
  58. check:Dock(BOTTOM)
  59. check:SetText("Show outline")
  60. check:SetChecked(showoutline)
  61. function check:OnChange(v)
  62.     showoutline = v
  63. end
  64.  
  65. -- Your code here
  66. hook.Add("HUDPaint", "nicolas", function()
  67.     surface.SetDrawColor(31, 0, 0, 95)
  68.     surface.DrawRect(0, 0, width, height)
  69.     if showoutline then
  70.         surface.SetDrawColor(0, 0, 0, 255)
  71.         surface.DrawOutlinedRect(1, 1, width-2, height-2)
  72.         surface.DrawOutlinedRect(-1, -1, width+2, height+2)
  73.         surface.SetDrawColor(255, 255, 255, 255)
  74.         surface.DrawOutlinedRect(0, 0, width, height)
  75.     end
  76.    
  77.     -- Your code here
  78. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement