Advertisement
Guest User

Untitled

a guest
May 29th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.38 KB | None | 0 0
  1. -- Menu Handling System
  2.  
  3. surface.CreateFont("tahoma", 20, 700, true, false, "D3AMenu-Title")
  4. surface.CreateFont("tahoma", 18, 600, true, false, "D3AMenu-Button")
  5.  
  6. D3A.Menus = {}
  7. D3A.Menus.Ignore = false
  8. D3A.Menus.Dir = "D3A/Menus/"
  9. D3A.Menus.CurTab = 1
  10. D3A.Menus.OpenTab = {}
  11.  
  12. local function ParseHome()
  13. -- EXAMPLE HOME FILE
  14. -- TITLE:Home Page
  15. -- OBJECTS:
  16. -- 1:Button:Test:RunConsoleCommand("say", "Hi.")
  17.  
  18. if (file.Exists(D3A.Menus.Dir .. "HomePage.txt")) then
  19. local inf = file.Read(D3A.Menus.Dir .. "HomePage.txt")
  20. inf = string.Explode("\n", inf)
  21.  
  22. D3A.Menus.Home = {}
  23. D3A.Menus.Home.UID = "HOMEPAGE"
  24. D3A.Menus.Home.Home = true
  25. D3A.Menus.Home.Selected = true
  26. D3A.Menus.Home.Objects = {}
  27.  
  28. local cnt = #inf
  29.  
  30. for i=1, cnt do
  31. local v = inf[i]
  32. if (string.find(v, "TITLE:")) then
  33. D3A.Menus.Home.Name = string.sub(v, 7)
  34. else
  35. local id = tonumber(string.sub(v, 1, 1))-- 1
  36. v = string.sub(v, string.find(v, ":") + 1)
  37. local type = string.sub(v, 1, string.find(v, ":") - 1)
  38. v = string.sub(v, string.find(v, ":") + 1)
  39. if (type == "CSwatch") then
  40.  
  41. local csw = {}
  42. csw.Modifier = v
  43. csw.R = 0
  44. csw.G = 0
  45. csw.B = 0
  46.  
  47. D3A.Menus.Home.Objects[id] = csw
  48. elseif (type == "Value") then
  49. local text = string.sub(v, 1, string.find(v, ":") - 1)
  50. v = string.sub(v, string.find(v, ":") + 1)
  51. local min = string.sub(v, 1, string.find(v, ":") - 1)
  52. v = string.sub(v, string.find(v, ":") + 1)
  53. local max = v
  54.  
  55. local val = {}
  56. val.Type = "Value"
  57. val.Text = text
  58. val.Min = min
  59. val.Max = max
  60. val.Val = min
  61.  
  62. D3A.Menus.Home.Objects[id] = val
  63. else
  64. local text = string.sub(v, 1, string.find(v, ":") - 1)
  65. v = string.sub(v, string.find(v, ":") + 1)
  66. local func = v
  67.  
  68. local obj = {}
  69. obj.Text = text
  70. obj.Function = function() RunString(func) end
  71. obj.Type = type
  72.  
  73. D3A.Menus.Home.Objects[id] = obj
  74. end
  75. end
  76. end
  77. else
  78. file.Write(D3A.Menus.Dir .. "HomePage.txt", "TITLE:Home Page\n1:Button:Customize home page:D3A.Menus.CustomizeHomepage()")
  79. ParseHome()
  80. end
  81. end
  82. ParseHome()
  83.  
  84. if (file.Exists(D3A.Menus.Dir .. "FGColor.txt")) then
  85. RunString(file.Read(D3A.Menus.Dir .. "FGColor.txt"))
  86. else
  87. file.Write(D3A.Menus.Dir .. "FGColor.txt", "D3A.Menus.FG = Color(40, 90, 40, 180)")
  88. D3A.Menus.FG = Color(40, 90, 40, 180)
  89. end
  90.  
  91. if (file.Exists(D3A.Menus.Dir .. "BGColor.txt")) then
  92. RunString(file.Read(D3A.Menus.Dir .. "BGColor.txt"))
  93. else
  94. file.Write(D3A.Menus.Dir .. "BGColor.txt", "D3A.Menus.BG = Color(255, 255, 255, 30)")
  95. D3A.Menus.BG = Color(255, 255, 255, 30)
  96. end
  97.  
  98. if (file.Exists(D3A.Menus.Dir .. "TextColor.txt")) then
  99. RunString(file.Read(D3A.Menus.Dir .. "TextColor.txt"))
  100. else
  101. file.Write(D3A.Menus.Dir .. "TextColor.txt", "D3A.Menus.Text = Color(255, 255, 255, 255)")
  102. D3A.Menus.Text = Color(255, 255, 255, 255)
  103. end
  104.  
  105. if (file.Exists(D3A.Menus.Dir .. "BorderColor.txt")) then
  106. RunString(file.Read(D3A.Menus.Dir .. "BorderColor.txt"))
  107. else
  108. file.Write(D3A.Menus.Dir .. "BorderColor.txt", "D3A.Menus.Border = Color(180, 180, 180, 50)")
  109. D3A.Menus.Border = Color(180, 180, 180, 50)
  110. end
  111.  
  112. if (file.Exists(D3A.Menus.Dir .. "SelectedColor.txt")) then
  113. RunString(file.Read(D3A.Menus.Dir .. "SelectedColor.txt"))
  114. else
  115. file.Write(D3A.Menus.Dir .. "SelectedColor.txt", "D3A.Menus.Selected = Color(20, 200, 20, 60)")
  116. D3A.Menus.Selected = Color(20, 200, 20, 60)
  117. end
  118.  
  119. if (file.Exists(D3A.Menus.Dir .. "ClickedColor.txt")) then
  120. RunString(file.Read(D3A.Menus.Dir .. "ClickedColor.txt"))
  121. else
  122. file.Write(D3A.Menus.Dir .. "ClickedColor.txt", "D3A.Menus.Clicked = Color(200, 255, 200, 60)")
  123. D3A.Menus.Clicked = Color(200, 255, 200, 60)
  124. end
  125.  
  126. D3A.Window = {}
  127. -- Start settings
  128. D3A.Window.Minimized = false
  129.  
  130. D3A.Window.X = 75
  131. D3A.Window.Y = 45
  132. D3A.Window.Width = ScrW() - 150
  133. D3A.Window.Height = ScrH() - 102
  134.  
  135. D3A.Window.Center = D3A.Window.X + (D3A.Window.Width / 2)
  136. D3A.Window.Tabs = {}
  137. D3A.Window.Tabs[1] = D3A.Menus.Home
  138. /* D3A.Window.Tabs[1] = {}
  139. D3A.Window.Tabs[1].Name = "MOTD"
  140. D3A.Window.Tabs[1].Selected = false
  141. D3A.Window.Tabs[1].Objects = {}
  142. D3A.Window.Tabs[1].Objects[1] = {}
  143. D3A.Window.Tabs[1].Objects[1].Type = "Button"
  144. D3A.Window.Tabs[1].Objects[1].Text = "Test me for wincest."
  145. D3A.Window.Tabs[1].Objects[1].Function = function()
  146. print("God hates you soooo much.")
  147. end
  148.  
  149. D3A.Window.Tabs[2] = {}
  150. D3A.Window.Tabs[2].Name = "MOTD 2"
  151. D3A.Window.Tabs[2].Selected = false
  152. D3A.Window.Tabs[2].Objects = {}
  153. D3A.Window.Tabs[2].Objects[1] = {}
  154. D3A.Window.Tabs[2].Objects[1].Type = "Button"
  155. D3A.Window.Tabs[2].Objects[1].Text = "Test me for wincest."
  156. D3A.Window.Tabs[2].Objects[1].Function = function()
  157. print("God hates you soooo much.")
  158. end*/
  159. -- End settings
  160.  
  161. -- Non-Menu Variables
  162. local First = true
  163. local Timers = {}
  164. local Notifications = {}
  165. local NotificationsY = ScrH() - 45
  166. local NotificationGone = false
  167. local vcEn = LocalPlayer():GetNetworkedBool("voicechatenable", true)
  168.  
  169. -- Menu Variables not worthy of publicity
  170. local TabButtons = {}
  171. local TabPointers = {}
  172.  
  173. function D3A.Menus.MakeNotification(Message)
  174. surface.PlaySound("buttons/combine_button1.wav")
  175.  
  176. local Msg = Message:ReadString()
  177.  
  178. local Note = {}
  179. Note.String = Msg
  180. Note.Y = (ScrH() / 2) + 20
  181. Note.EndY = NotificationsY
  182. Note.Alpha = 255
  183. Note.MoveAmt = 7.5
  184. Note.Lived = 0
  185.  
  186. NotificationsY = NotificationsY - 45
  187.  
  188. Notifications[#Notifications+1] = Note
  189. end
  190. usermessage.Hook("D3A.Menus.MakeNotification", D3A.Menus.MakeNotification)
  191.  
  192. function D3A.Menus.SetActiveTab(tab)
  193. local min = {}
  194. min.Type = "Button"
  195. min.Text = "Minimize"
  196. min.Function = function() D3A.Window.Minimized = true end
  197. min.X1 = 0
  198. min.X2 = 0
  199. min.Y1 = 0
  200. min.Y2 = 0
  201.  
  202. local min2 = {}
  203. min2.Type = "Button"
  204. min2.Text = "Close tabs"
  205. min2.Function = function()
  206. for k, v in ipairs(D3A.Window.Tabs) do
  207. if !(v.UID == "HOMEPAGE") then
  208. D3A.Window.Tabs[k] = nil
  209. TabPointers[v.UID] = nil
  210. end
  211. end
  212. D3A.Menus.SetActiveTab(1)
  213. D3A.Window.Minimized = true
  214. end
  215. min2.X1 = 0
  216. min2.X2 = 0
  217. min2.Y1 = 0
  218. min2.Y2 = 0
  219.  
  220. if (D3A.Window.Tabs[tab]) then
  221. D3A.Menus.OpenTab = D3A.Window.Tabs[tab].Objects
  222. D3A.Menus.OpenTabName = D3A.Window.Tabs[tab].Name
  223. D3A.Menus.OpenTab[-1] = min
  224. D3A.Menus.OpenTab[-2] = min2
  225. for k, v in ipairs(D3A.Window.Tabs) do
  226. D3A.Window.Tabs[k].Selected = false
  227. end
  228. D3A.Window.Tabs[tab].Selected = true
  229. else
  230. D3A.Menus.OpenTab = {}
  231. D3A.Menus.OpenTabName = "None"
  232. D3A.Menus.OpenTab[-1] = min
  233. D3A.Menus.OpenTab[-2] = min2
  234. end
  235. end
  236. D3A.Menus.SetActiveTab(1)
  237.  
  238. function D3A.Menus.New(Message)
  239. D3A.Window.Minimized = false
  240.  
  241. local uid = Message:ReadString()
  242. local title = Message:ReadString()
  243.  
  244. if (!TabPointers[uid]) then
  245. local cnt = #D3A.Window.Tabs
  246. TabPointers[uid] = cnt + 1
  247.  
  248. local tab = {}
  249. tab.UID = uid
  250. tab.Name = title
  251. tab.Selected = false
  252. tab.Objects = {}
  253.  
  254. table.insert(D3A.Window.Tabs, tab)
  255. else
  256. D3A.Window.Tabs[TabPointers[uid]].Name = title
  257. D3A.Window.Tabs[TabPointers[uid]].Objects = {}
  258. end
  259.  
  260. D3A.Menus.SetActiveTab(TabPointers[uid])
  261. print("New tab: " .. title .. ". UID: " .. uid .. ". Pointer: " .. TabPointers[uid])
  262. end
  263. usermessage.Hook("D3A.Menus.New", D3A.Menus.New)
  264.  
  265. function D3A.Menus.MOTD()
  266. D3A.Window.Minimized = false
  267.  
  268. local uid = "MOTD"
  269. local title = "Message of the Day"
  270.  
  271. if (!TabPointers[uid]) then
  272. local cnt = #D3A.Window.Tabs
  273. TabPointers[uid] = cnt + 1
  274.  
  275. local tab = {}
  276. tab.UID = uid
  277. tab.Name = title
  278. tab.Selected = false
  279. tab.Objects = {}
  280.  
  281. table.insert(D3A.Window.Tabs, tab)
  282. else
  283. D3A.Window.Tabs[TabPointers[uid]].Objects = {}
  284. end
  285.  
  286. D3A.Menus.SetActiveTab(TabPointers[uid])
  287. print("New tab: " .. title .. ". UID: " .. uid .. ". Pointer: " .. TabPointers[uid])
  288. end
  289. usermessage.Hook("D3A.Menus.MOTD", D3A.Menus.MOTD)
  290.  
  291. --function D3A.Menus.Close(Message)
  292. -- end
  293. usermessage.Hook("D3A.Menus.Close", function() end)
  294.  
  295. function D3A.Menus.AddButton(Message)
  296. local uid = Message:ReadString()
  297. local txt = Message:ReadString()
  298. local func = Message:ReadString()
  299.  
  300. if (!TabPointers[uid]) then return end
  301. if (!D3A.Window.Tabs[TabPointers[uid]]) then return end
  302.  
  303. local bt = {}
  304. bt.Type = "Button"
  305. bt.Text = txt
  306. bt.Function = function() RunString(func) end
  307.  
  308. table.insert(D3A.Window.Tabs[TabPointers[uid]].Objects, bt)
  309. print("New button: " .. txt .. ". UID: " .. uid .. ". Pointer: " .. TabPointers[uid] .. ". Function: " .. func)
  310. end
  311. usermessage.Hook("D3A.Menus.AddButton", D3A.Menus.AddButton)
  312.  
  313. function D3A.Menus.AddValue(Message)
  314. local uid = Message:ReadString()
  315. local txt = Message:ReadString()
  316. local min = Message:ReadInt()
  317. local max = Message:ReadInt()
  318.  
  319. if (!TabPointers[uid]) then return end
  320. if (!D3A.Window.Tabs[TabPointers[uid]]) then return end
  321.  
  322. local val = {}
  323. va.Type = "Value"
  324. va.Text = txt
  325. va.Min = min
  326. va.Max = max
  327. va.Val = min
  328.  
  329. table.insert(D3A.Window.Tabs[TabPointers[uid]].Objects, val)
  330. print("New value modifier: " .. txt .. ". UID: " .. uid .. ". Pointer: " .. TabPointers[uid] .. ". Minimum: " .. min .. ". Maximum: " .. max)
  331. end
  332. usermessage.Hook("D3A.Menus.AddValue", D3A.Menus.AddValue)
  333.  
  334. function D3A.Menus.AddText(Message)
  335. local uid = Message:ReadString()
  336. local txt = Message:ReadString()
  337.  
  338. if (!TabPointers[uid]) then return end
  339.  
  340. local text = {}
  341. text.Type = "String"
  342. text.Text = txt
  343.  
  344. table.insert(D3A.Window.Tabs[TabPointers[uid]].Objects, text)
  345. print("New text: " .. txt .. ". UID: " .. uid .. ". Pointer: " .. TabPointers[uid])
  346. end
  347. usermessage.Hook("D3A.Menus.AddText", D3A.Menus.AddText)
  348.  
  349. function D3A.Menus.Close(UID)
  350. Saved[UID] = nil
  351. end
  352.  
  353. function D3A.Menus.HUDShouldDraw(E)
  354. if (E == "CHudCrosshair") then
  355. return false
  356. end
  357. end
  358.  
  359. function D3A.Menus.RenderScreenspaceEffects()
  360. local CModify = {}
  361.  
  362. CModify["$pp_colour_contrast"] = 0.4
  363. CModify["$pp_colour_colour"] = 0.5
  364. CModify["$pp_colour_mulg"] = 4
  365.  
  366. DrawColorModify(CModify)
  367. end
  368.  
  369. function D3A.Menus.HUDPaint()
  370. if !(D3A.Window.Minimized) then
  371. draw.RoundedBox(6, D3A.Window.X-3, D3A.Window.Y-3, D3A.Window.Width+6, D3A.Window.Height+6, D3A.Menus.Border)
  372. draw.RoundedBox(6, D3A.Window.X, D3A.Window.Y, D3A.Window.Width, D3A.Window.Height, D3A.Menus.BG)
  373. draw.RoundedBox(4, D3A.Window.X+3, D3A.Window.Y+3, D3A.Window.Width-6, D3A.Window.Height-6, D3A.Menus.FG)
  374.  
  375. surface.SetFont("D3AMenu-Title")
  376. local w = surface.GetTextSize("The D3vine Admin Mod") / 2
  377. draw.RoundedBox(4, D3A.Window.Center-w-4, D3A.Window.Y+6, w*2+8, 26, D3A.Menus.BG)
  378. draw.SimpleText("The D3vine Admin Mod", "D3AMenu-Title", D3A.Window.Center-w, D3A.Window.Y+8, D3A.Menus.Text)
  379.  
  380. -- Below title, Y = 35
  381.  
  382. draw.RoundedBox(4, D3A.Window.X+8, D3A.Window.Y+36, D3A.Window.Width-16, 20, D3A.Menus.BG)
  383.  
  384. surface.SetFont("D3AMenu-Button")
  385. local pX = D3A.Window.X+11
  386. local pY = D3A.Window.Y+38
  387.  
  388. TabButtons = {}
  389.  
  390. for k, v in ipairs(D3A.Window.Tabs) do
  391. local w = surface.GetTextSize(v.Name)
  392. if (v.Selected) then
  393. draw.RoundedBox(4, pX, pY, w+8, 16, D3A.Menus.Selected)
  394. end
  395.  
  396. TabButtons[k] = {}
  397. TabButtons[k].X1 = pX
  398. TabButtons[k].Y1 = pY
  399. TabButtons[k].X2 = pX + w + 8
  400. TabButtons[k].Y2 = pY + 16
  401.  
  402. draw.RoundedBox(4, pX, pY, w+8, 16, D3A.Menus.BG)
  403.  
  404. draw.SimpleText(v.Name, "D3AMenu-Button", pX+4, pY-1, D3A.Menus.Text)
  405. pX = pX + w + 12
  406. end
  407.  
  408. if (!D3A.Window.Tabs[1]) then
  409. draw.SimpleText("No tabs open", "D3AMenu-Button", pX, pY-1, D3A.Menus.Text)
  410. end
  411.  
  412. draw.RoundedBox(4, D3A.Window.X+8, D3A.Window.Y+60, D3A.Window.Width-16, D3A.Window.Height-68, D3A.Menus.BG)
  413.  
  414. local b2 = D3A.Menus.OpenTab[-1]
  415. local b1 = D3A.Menus.OpenTab[-2]
  416.  
  417. local w1 = D3A.Window.X + D3A.Window.Width
  418. local tW1 = surface.GetTextSize(b1.Text) + 4
  419. w1 = w1 - tW1
  420. w1 = w1 - 10
  421.  
  422. -- Close button settings
  423. b1.X1 = w1
  424. b1.X2 = tW1 + 4 + w1
  425. b1.Y1 = D3A.Window.Y + 6
  426. b1.Y2 = b1.Y1 + 26
  427. if (b1.Selected) then
  428. draw.RoundedBox(4, w1 - 1, D3A.Window.Y + 5, tW1 + 6, 28, D3A.Menus.Selected)
  429. end
  430. if (b1.Clicked) then
  431. draw.RoundedBox(4, w1 - 1, D3A.Window.Y + 5, tW1 + 6, 28, D3A.Menus.Clicked)
  432. end
  433. draw.RoundedBox(4, w1, D3A.Window.Y + 6, tW1 + 4, 26, D3A.Menus.BG)
  434. draw.SimpleText(b1.Text, "D3AMenu-Button", w1 + 4, D3A.Window.Y + 10, D3A.Menus.Text)
  435.  
  436. -- Minimize button settings
  437. local tW2 = surface.GetTextSize(b2.Text) + 4
  438. local w2 = w1 - tW2 - 9
  439.  
  440. b2.X1 = w2
  441. b2.X2 = tW2 + 4 + w2
  442. b2.Y1 = D3A.Window.Y + 6
  443. b2.Y2 = b2.Y1 + 26
  444. if (b2.Selected) then
  445. draw.RoundedBox(4, w2 - 1, D3A.Window.Y + 5, tW2 + 6, 28, D3A.Menus.Selected)
  446. end
  447. if (b2.Clicked) then
  448. draw.RoundedBox(4, w2 - 1, D3A.Window.Y + 5, tW2 + 6, 28, D3A.Menus.Clicked)
  449. end
  450. draw.RoundedBox(4, w2, D3A.Window.Y + 6, tW2 + 4, 26, D3A.Menus.BG)
  451.  
  452. draw.SimpleText(b2.Text, "D3AMenu-Button", w2 + 4, D3A.Window.Y + 10, D3A.Menus.Text)
  453.  
  454. local pY = D3A.Window.Y + 65
  455. local pX = D3A.Window.X + 13
  456. local maxY = D3A.Window.Y + D3A.Window.Height - 30
  457. local buttonWidth = 4
  458. surface.SetFont("D3AMenu-Button")
  459.  
  460. for k, v in pairs(D3A.Menus.OpenTab) do
  461. if (tonumber(k) > 0) then
  462. if (v.Type == "Value") then
  463. buttonWidth = 200
  464. break
  465. end
  466.  
  467. if (v.Type == "Button") then
  468. local w = surface.GetTextSize(v.Text) + 4
  469. if (w > buttonWidth) then
  470. buttonWidth = w
  471. end
  472. end
  473. end
  474. end
  475.  
  476. local tabCount = 0
  477. for k, v in pairs(D3A.Menus.OpenTab) do
  478. if (tonumber(k) > 0) then tabCount = tabCount + 1 end
  479. end
  480.  
  481. if (tabCount > 0) then
  482. for i=1, tabCount do
  483. local v = D3A.Menus.OpenTab[i]
  484. if (v.Type == "Button") then
  485. if (pY > maxY) then
  486. pY = D3A.Window.Y + 65
  487. pX = pX + buttonWidth + 11
  488. end
  489. draw.RoundedBox(4, pX, pY, buttonWidth + 2, 26, D3A.Menus.FG)
  490. draw.SimpleText(v.Text, "D3AMenu-Button", pX + 3, pY + 4, D3A.Menus.Text)
  491. if (v.Selected) then
  492. draw.RoundedBox(4, pX-1, pY-1, buttonWidth + 4, 28, D3A.Menus.Selected)
  493. end
  494. if (v.Clicked) then
  495. draw.RoundedBox(4, pX-1, pY-1, buttonWidth + 4, 28, D3A.Menus.Clicked)
  496. end
  497. v.X1 = pX
  498. v.Y1 = pY
  499. v.X2 = pX + buttonWidth + 2
  500. v.Y2 = pY + 26
  501. pY = pY + 33
  502. end
  503. if (v.Type == "String") then
  504. draw.SimpleText(v.Text, "D3AMenu-Button", pX + 3, pY, D3A.Menus.Text)
  505. pY = pY + 29
  506. end
  507. if (v.Type == "Value") then
  508. surface.SetFont("D3AMenu-Button")
  509. local text = v.Text .. ": " .. v.Val
  510.  
  511. local w = surface.GetTextSize(text)
  512. draw.SimpleText(text, "D3AMenu-Button", pX + 100 - (w/2), pY, D3A.Menus.Text)
  513. draw.RoundedBox(4, pX + 6, pY + 18, buttonWidth, 8, D3A.Menus.FG)
  514. local x
  515. if (v.X1) then
  516. x = v.X1
  517. else
  518. x = pX - 1 + (v.Val - v.Min) / (v.Max - v.Min) * 200
  519. end
  520. draw.RoundedBox(4, x, pY + 15, 14, 14, D3A.Menus.FG)
  521. if (v.Selected) then
  522. draw.RoundedBox(4, x, pY + 15, 14, 14, D3A.Menus.Selected)
  523. end
  524. if (v.Clicked) then
  525. draw.RoundedBox(4, x, pY + 15, 14, 14, D3A.Menus.Clicked)
  526. end
  527.  
  528. v.X1 = x
  529. v.X2 = x + 14
  530. v.Y1 = pY + 15
  531. v.Y2 = pY + 29
  532.  
  533. draw.SimpleText("X1: " .. v.X1, "D3AMenu-Button", 400, 50, D3A.Menus.Text)
  534. draw.SimpleText("X2: " .. v.X2, "D3AMenu-Button", 400, 100, D3A.Menus.Text)
  535. draw.SimpleText("Y1: " .. v.Y1, "D3AMenu-Button", 400, 150, D3A.Menus.Text)
  536. draw.SimpleText("Y2: " .. v.Y2, "D3AMenu-Button", 400, 200, D3A.Menus.Text)
  537. draw.SimpleText("mX: " .. gui.MouseX(), "D3AMenu-Button", 400, 250, D3A.Menus.Text)
  538. draw.SimpleText("mY: " .. gui.MouseY(), "D3AMenu-Button", 400, 300, D3A.Menus.Text)
  539. pY = pY + 35
  540. end
  541. end
  542. end
  543. end
  544.  
  545. local timerY = 45
  546. for k, v in pairs(Timers) do
  547. surface.SetFont("D3AMenu-Button")
  548. local width = surface.GetTextSize(v.Text .. " - " .. v.Time) + 5
  549.  
  550. draw.RoundedBox(6, ScrW() - width - 7, timerY - 3, width + 6, 31, D3A.Menus.BG)
  551.  
  552. local perc = v.Time / v.OrigTime
  553. local perc = math.Round(perc * width)
  554.  
  555. draw.RoundedBox(4, ScrW() - width - 4, timerY, perc, 25, D3A.Menus.FG)
  556.  
  557. draw.SimpleText(v.Text .. " - " .. v.Time, "D3AMenu-Button", ScrW() - width, timerY + 3, D3A.Menus.Text)
  558.  
  559. timerY = timerY + 50
  560. end
  561.  
  562. for k, v in pairs(Notifications) do
  563. surface.SetFont("D3AMenu-Button")
  564. local width = surface.GetTextSize(v.String) + 10
  565.  
  566. draw.RoundedBox(6, (ScrW() / 2) - (width / 2), v.Y, width, 28, Color(255, 255, 255, 30 * v.Alpha/255))
  567. draw.RoundedBox(4, (ScrW() / 2) - (width / 2) + 3, v.Y + 3, width - 6, 22, Color(40, 90, 40, v.Alpha))
  568. draw.SimpleText(v.String, "D3AMenu-Button", (ScrW() / 2) - (width / 2) + 5, v.Y + 5, Color(255, 255, 255, v.Alpha))
  569. end
  570.  
  571. if (!vcEn) and (D3A.Window.Minimized) then
  572. surface.SetFont("D3AMenu-Button")
  573. local w = surface.GetTextSize("Voicechat is disabled") + 8
  574. draw.RoundedBox(6, ScrW() / 2 - (w*0.5) - 3, 44, w + 6, 31, D3A.Menus.BG)
  575. draw.RoundedBox(4, ScrW() / 2 - (w*0.5), 47, w, 25, D3A.Menus.FG)
  576. draw.SimpleText("Voicechat is disabled", "D3AMenu-Button", ScrW() / 2 - (w*0.5) + 4, 50, D3A.Menus.Text)
  577. end
  578. end
  579.  
  580. function D3A.Menus.Think()
  581. gui.EnableScreenClicker(true)
  582.  
  583. if (#D3A.Window.Tabs == 0) then
  584. D3A.Window.Tabs[1] = D3A.Menus.Home
  585. D3A.Menus.SetActiveTab(1)
  586. end
  587.  
  588. local mX = gui.MouseX()
  589. local mY = gui.MouseY()
  590.  
  591. for k, v in pairs(D3A.Menus.OpenTab) do
  592. --if (v.Type == "Button") then
  593. if (v.Y2) then
  594. if (mX > v.X1) and (mX < v.X2) and (mY > v.Y1) and (mY < v.Y2) then
  595. v.Selected = true
  596. D3A.Menus.SelectedObj = v
  597. else
  598. v.Selected = false
  599. end
  600. end
  601. --end
  602. end
  603.  
  604. if (D3A.Menus.ClickedOn) then
  605. if (D3A.Menus.ClickedOn.Type == "Value") then
  606. local diff = mX - D3A.Menus.ClickedOn.X1
  607. D3A.Menus.ClickedOn.X1 = mX - diff
  608. D3A.Menus.ClickedOn.X2 = mX - diff + 14
  609. end
  610. end
  611. end
  612.  
  613. function PRINTTAB()
  614. PrintTable(TabButtons)
  615. PrintTable(D3A.Menus.OpenTab)
  616. end
  617.  
  618. function D3A.Menus.MousePressed(Button)
  619. local mX = gui.MouseX()
  620. local mY = gui.MouseY()
  621.  
  622. for k, v in pairs(TabButtons) do
  623. if (mX >= v.X1) and (mX <= v.X2) and (mY >= v.Y1) and (mY <= v.Y2) then
  624. if (Button == 107) then
  625. D3A.Menus.SetActiveTab(k)
  626. elseif (Button == 108) or (Button == 109) then
  627. if (D3A.Window.Tabs[k].Home) then return end
  628. local cnt = #D3A.Window.Tabs
  629. for pt=k, cnt do
  630. print(pt .. " - " .. k)
  631. local curTab = D3A.Window.Tabs[pt]
  632. if (pt == k) then
  633. D3A.Window.Tabs[pt] = nil
  634. PrintTable(TabPointers)
  635. print(curTab.UID)
  636. TabPointers[curTab.UID] = nil
  637. if (D3A.Menus.OpenTabName == curTab.Name) then
  638. D3A.Menus.SetActiveTab(pt-1)
  639. end
  640. elseif (pt > k) then
  641. D3A.Window.Tabs[pt-1] = curTab
  642. D3A.Window.Tabs[pt] = nil
  643. TabPointers[curTab.UID] = pt-1
  644. end
  645. end
  646. end
  647. return
  648. end
  649. end
  650.  
  651. for k, v in pairs(D3A.Menus.OpenTab) do
  652. if (v.Selected) then
  653. v.Clicked = true
  654. D3A.Menus.ClickedOn = v
  655. else
  656. v.Clicked = false
  657. end
  658. end
  659.  
  660. end
  661.  
  662. function D3A.Menus.MouseReleased(Button)
  663. local mX = gui.MouseX()
  664. local mY = gui.MouseY()
  665.  
  666. if (!D3A.Menus.ClickedOn) then return end
  667. local v = D3A.Menus.ClickedOn
  668.  
  669. v.Clicked = nil
  670. D3A.Menus.ClickedOn = nil
  671.  
  672. if (!v.Selected) then
  673. return
  674. end
  675.  
  676. if (Button == 109) then
  677. // Middle Mouse
  678. elseif (Button == 107) then
  679. if (v.Function) then
  680. v.Function()
  681. end
  682. elseif (Button == 108) then
  683. // Right Click
  684. end
  685. end
  686.  
  687. function D3A.Menus.KeyPress(pl, Key)
  688. if (D3A.Menus.Ignore) then return end
  689.  
  690. if (First) then
  691. First = nil
  692. RunConsoleCommand("SetMyTeam_" .. LocalPlayer():UserID())
  693. for k, v in pairs(ents.FindByClass("prop_physics")) do
  694. if (v:GetNetworkedBool("voicechatter")) then
  695. vcEnt = v
  696. vcEn = v:GetNetworkedBool("voicechatenable", false)
  697. end
  698. end
  699. end
  700.  
  701. if (Key == 262144) then
  702. if (D3A.Menus.OpenShft) then
  703. D3A.Menus.Ignore = true
  704. timer.Simple(0.2, function() D3A.Menus.Ignore = false end)
  705.  
  706. D3A.Window.Minimized = !D3A.Window.Minimized
  707. else
  708. D3A.Menus.OpenCtrl = true
  709. end
  710. end
  711.  
  712. if (Key == 131072) then
  713. if (D3A.Menus.OpenCtrl) then
  714. D3A.Menus.Ignore = true
  715. timer.Simple(0.2, function() D3A.Menus.Ignore = false end)
  716.  
  717. D3A.Window.Minimized = !D3A.Window.Minimized
  718. else
  719. D3A.Menus.OpenShft = true
  720. end
  721. end
  722. end
  723.  
  724. function D3A.Menus.KeyRelease(pl, Key)
  725. if (Key == 262144) then
  726. D3A.Menus.OpenCtrl = false
  727. end
  728. if (Key == 131072) then
  729. D3A.Menus.OpenShft = false
  730. end
  731. end
  732.  
  733. hook.Add("Think", "D3AWindowHandler", function()
  734. if (!D3A.Window.Minimized) and (!D3A.Menus.Opened) then
  735. D3A.Menus.Start()
  736. elseif (D3A.Window.Minimized) and (D3A.Menus.Opened) then
  737. D3A.Menus.Stop()
  738. end
  739. end)
  740.  
  741. -- Hooks
  742. hook.Add("HUDPaint", "D3A.Menus.HUDPaint", D3A.Menus.HUDPaint)
  743. hook.Add("KeyPress", "D3A.Menus.KeyPress", D3A.Menus.KeyPress)
  744. hook.Add("KeyRelease", "D3A.Menus.KeyRelease", D3A.Menus.KeyRelease)
  745.  
  746. function D3A.Menus.AddTimer(Message)
  747. local ID = Message:ReadString()
  748. local Text = Message:ReadString()
  749. local Time = Message:ReadLong()
  750.  
  751. Timers[ID] = {}
  752. Timers[ID].Text = Text
  753. Timers[ID].Time = Time
  754. Timers[ID].OrigTime = Time
  755. end
  756. usermessage.Hook("D3A.Menus.AddTimer", D3A.Menus.AddTimer)
  757.  
  758. function D3A.Menus.CheckTimers()
  759. vcEn = LocalPlayer():GetNetworkedBool("voicechatenable", true)
  760.  
  761. for k, v in pairs(Timers) do
  762. v.Time = v.Time - 1
  763. if (v.Time == 0) then
  764. Timers[k] = nil
  765. end
  766. end
  767. end
  768. timer.Create("D3A.Menus.Timers", 1, 0, D3A.Menus.CheckTimers)
  769.  
  770. function D3A.Menus.CheckNotifications()
  771. for k, v in pairs(Notifications) do
  772. if (NotificationGone) then
  773. v.EndY = v.EndY + 45
  774. end
  775. v.Lived = v.Lived + .01
  776. v.Alpha = 255 - ((v.Lived / 3.5) * 255)
  777. if (v.Y < v.EndY) then
  778. v.Y = v.Y + v.MoveAmt
  779. end
  780. if (v.Alpha <= 15) then
  781. Notifications[k] = nil
  782. NotificationsY = NotificationsY + 45
  783. for i, l in pairs(Notifications) do
  784. l.EndY = l.EndY + 45
  785. end
  786. end
  787. end
  788. NotificationGone = false
  789. end
  790. timer.Create("D3A.Menus.Notifications", 0.01, 0, D3A.Menus.CheckNotifications)
  791.  
  792. function D3A.Menus.Start()
  793. D3A.Menus.Opened = true
  794.  
  795. hook.Add("Think", "D3A.Menus.Think", D3A.Menus.Think)
  796. hook.Add("HUDShouldDraw", "D3A.Menus.HUDShouldDraw", D3A.Menus.HUDShouldDraw)
  797. hook.Add("HUDDrawScoreBoard", "D3A.Menus.HUDDrawScoreBoard", D3A.Menus.HUDDrawScoreBoard)
  798. hook.Add("GUIMousePressed", "D3A.Menus.MousePressed", D3A.Menus.MousePressed)
  799. hook.Add("GUIMouseReleased", "D3A.Menus.MouseReleased", D3A.Menus.MouseReleased)
  800. hook.Add("RenderScreenspaceEffects", "D3A.Menus.RenderScreenspaceEffects", D3A.Menus.RenderScreenspaceEffects)
  801.  
  802. gui.EnableScreenClicker(true)
  803.  
  804. D3A.Menus.ToolMode = GetConVarString("gmod_toolmode")
  805. RunConsoleCommand("gmod_toolmode", "\"\"")
  806. end
  807.  
  808. function D3A.Menus.Stop()
  809. D3A.Menus.Opened = false
  810.  
  811. hook.Remove("Think", "D3A.Menus.Think")
  812. hook.Remove("HUDShouldDraw", "D3A.Menus.HUDShouldDraw")
  813. hook.Remove("HUDDrawScoreBoard", "D3A.Menus.HUDDrawScoreBoard")
  814. hook.Remove("GUIMousePressed", "D3A.Menus.MousePressed")
  815. hook.Remove("GUIMouseReleased", "D3A.Menus.MouseReleased")
  816. hook.Remove("RenderScreenspaceEffects", "D3A.Menus.RenderScreenspaceEffects")
  817.  
  818. gui.EnableScreenClicker(false)
  819.  
  820. RunConsoleCommand("gmod_toolmode", D3A.Menus.ToolMode)
  821. D3A.Menus.ToolMode = nil
  822. end
  823.  
  824. D3A.Menus.Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement