MeepDarknessMeep

~OLD~ HUDPaint menu

Aug 23rd, 2013
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.05 KB | None | 0 0
  1. S = {}
  2.  
  3. surface.CreateFont("Font222", {font = "BudgetLabel", size = 30, weight = 500, antialias = false, underline = false, shadow = true, outline = true})
  4. surface.CreateFont("Font333", {font = "BudgetLabel", size = 22, weight = 500, antialias = false, underline = false, shadow = true, outline = true})
  5.  
  6. S.y = 1
  7. S.x = 1
  8. S.enter = false
  9. S.table = {}
  10. S.LastTime = CurTime()
  11. S.fadeouttime = 5
  12. local indentx = 4
  13. local indenty = 2
  14.  
  15. function S.insert(name)
  16.     if not S.table or S.table[name] then return false end
  17.     if not type(name) == "string" then return false end
  18.     local i = #S.table + 1
  19.     S.table[i] = {}
  20.     S.table[i].name = name
  21.     S.table[i].options = {}
  22.     return true
  23. end
  24.  
  25. function S.exists(name)
  26.     for i, v in pairs(S.table) do
  27.         if v.name == name then return i end
  28.     end
  29.     return false
  30. end
  31.  
  32. function S.insert2(name, name2, func)
  33.     if not type(name) == "string" or not type(name2) == "string" then return false end
  34.     if not S.table then return false end
  35.     for i = 1, #S.table do
  36.         if S.table[i].name == name then
  37.             local k = #S.table[i].options + 1
  38.             S.table[i].options[k] = {}
  39.             S.table[i].options[k].name = name2
  40.             S.table[i].options[k].func = func
  41.         end
  42.     end
  43. end
  44.  
  45. function S.exists2(name, name2)
  46.     local i = S.exists(name)
  47.     if not i then return false end
  48.     for k = 1, #S.table[i].options do
  49.         if S.table[i].options[k].name == name2 then
  50.             return true, k
  51.         end
  52.     end
  53.     return false
  54. end
  55.  
  56. concommand.Add("left", function()
  57.     if S.x > 1 then
  58.     else
  59.         S.y = S.y - 1
  60.         if S.y < 1 then S.y = #S.table end
  61.     end
  62.     S.LastTime = CurTime()
  63. end)
  64.  
  65. concommand.Add("right", function()
  66.     if S.x > 1 then
  67.     else
  68.         S.y = S.y + 1
  69.         if S.y > #S.table then S.y = 1 end
  70.     end
  71.     S.LastTime = CurTime()
  72. end)
  73.  
  74. concommand.Add("down", function()
  75.     S.x = S.x + 1
  76.     S.LastTime = CurTime()
  77. end)
  78.  
  79. concommand.Add("up", function()
  80.     S.x = S.x - 1
  81.     if S.x < 1 then S.x = 1 end
  82.     S.LastTime = CurTime()
  83. end)
  84.  
  85. concommand.Add("enter", function()
  86.     if S.x > 1 then
  87.         S.enter = true
  88.     end
  89.     S.LastTime = CurTime()
  90. end)
  91.    
  92.  
  93. hook.Add("HUDPaint", "Paintstuff", function()
  94.     surface.SetFont("Font222")
  95.     local fcurtime = S.LastTime + 5
  96.     local acurtime = CurTime()
  97.     local alpha = 255
  98.    
  99.     if acurtime > fcurtime then
  100.         local dif = acurtime - fcurtime
  101.         local numdif = dif / S.fadeouttime
  102.         alpha = (1 - numdif) * 255
  103.         if alpha < 40 then alpha = 40 end
  104.     end
  105.    
  106.     local x = ScrW()
  107.     local y = ScrH()
  108.     local xsides = 0
  109.     local yheight = y / 19
  110.    
  111.     surface.SetDrawColor(15,15,15,alpha)
  112.     surface.DrawRect(0, 0, x, yheight)
  113.     local tbl = S.table
  114.     local tabx = (x - xsides * 2) / #tbl
  115.     local num = 0
  116.     for k,v in pairs(S.table) do
  117.         local color = Color(75,75,75,alpha)
  118.         if k == S.y then
  119.             surface.SetDrawColor(0,0,51,alpha)
  120.             color = Color(0,0,151,alpha)
  121.         else
  122.             surface.SetDrawColor(20,20,20,alpha)
  123.         end
  124.         local x2 = xsides + tabx * num + indentx
  125.         surface.DrawRect(x2, indenty, tabx - indentx, yheight - indenty * 2)
  126.         local w, h = surface.GetTextSize(v.name or "ERROR")
  127.         local y2 = (yheight - indenty * 2) - h
  128.         draw.DrawText(v.name or "ERROR", "Font222", xsides + tabx * num + indentx + tabx / 2, y2, color, TEXT_ALIGN_CENTER)
  129.         surface.SetDrawColor(50,50,50,alpha)
  130.         if k == S.y and S.x > 1 then
  131.             if #v.options < S.x - 1 then
  132.                 S.x = #v.options + 1
  133.             end
  134.             if #v.options > 0 then
  135.                 local opty = yheight * #v.options
  136.                 surface.DrawRect(x2, indenty * 3 + yheight, tabx - indentx, opty)
  137.                 local num2 = 0
  138.                
  139.                 local indentx = indenty
  140.                
  141.                 for i = 1, #v.options do
  142.                     surface.SetDrawColor(20,20,20,alpha)
  143.                     local color = Color(75,75,75,alpha)
  144.                     if S.x - 1 == i then
  145.                         surface.SetDrawColor(0,0,51,alpha)
  146.                         if S.enter then
  147.                             S.enter = false
  148.                             v.options[i].func()
  149.                         end
  150.                     end
  151.                     if S.x - 1 == i then
  152.                         color = Color(0,0,151,alpha)
  153.                     end
  154.                     surface.DrawRect(x2 + indentx, indenty * 4 + yheight * num2 + yheight, tabx - indentx * 4, yheight - indenty * 2)
  155.                     draw.DrawText(v.options[i].name or "ERROR", "Font222", xsides + tabx * num + indentx * 2 + tabx / 2, yheight * num2 + y2 + indenty * 3 + yheight, color, TEXT_ALIGN_CENTER)
  156.                    -- v.options[i].name
  157.                    num2 = num2 + 1
  158.                 end
  159.             end
  160.         end
  161.         num = num + 1
  162.     end
  163.    
  164. end)
  165.  
  166. local a = {["d"] = false, ["u"] = false, ["l"] = false, ["e"] = false, ["r"] = false}
  167.  
  168. hook.Add("Think", "ButtonsMenu", function()
  169.     if not LocalPlayer() then return end
  170.     if input.IsKeyDown(KEY_DOWN) then
  171.         if not a.d then
  172.             a.d = true
  173.             RunConsoleCommand("down")
  174.         end
  175.     else
  176.         a.d = false
  177.     end
  178.    
  179.     if input.IsKeyDown(KEY_UP) then
  180.         if not a.u then
  181.             a.u = true
  182.             RunConsoleCommand("up")
  183.         end
  184.     else
  185.         a.u = false
  186.     end
  187.    
  188.     if input.IsKeyDown(KEY_LEFT) then
  189.         if not a.l then
  190.             a.l = true
  191.             RunConsoleCommand("left")
  192.         end
  193.     else
  194.         a.l = false
  195.     end
  196.    
  197.     if input.IsKeyDown(KEY_RIGHT) then
  198.         if not a.r then
  199.             a.r = true
  200.             RunConsoleCommand("right")
  201.         end
  202.     else
  203.         a.r = false
  204.     end
  205.    
  206.     if input.IsKeyDown(KEY_ENTER) then
  207.         if not a.e then
  208.             a.e = true
  209.             RunConsoleCommand("enter")
  210.         end
  211.     else
  212.         a.e = false
  213.     end
  214. end)
Advertisement
Add Comment
Please, Sign In to add comment