Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Menu Handling System
- surface.CreateFont("tahoma", 20, 700, true, false, "D3AMenu-Title")
- surface.CreateFont("tahoma", 18, 600, true, false, "D3AMenu-Button")
- D3A.Menus = {}
- D3A.Menus.Ignore = false
- D3A.Menus.Dir = "D3A/Menus/"
- D3A.Menus.CurTab = 1
- D3A.Menus.OpenTab = {}
- local function ParseHome()
- -- EXAMPLE HOME FILE
- -- TITLE:Home Page
- -- OBJECTS:
- -- 1:Button:Test:RunConsoleCommand("say", "Hi.")
- if (file.Exists(D3A.Menus.Dir .. "HomePage.txt")) then
- local inf = file.Read(D3A.Menus.Dir .. "HomePage.txt")
- inf = string.Explode("\n", inf)
- D3A.Menus.Home = {}
- D3A.Menus.Home.UID = "HOMEPAGE"
- D3A.Menus.Home.Home = true
- D3A.Menus.Home.Selected = true
- D3A.Menus.Home.Objects = {}
- local cnt = #inf
- for i=1, cnt do
- local v = inf[i]
- if (string.find(v, "TITLE:")) then
- D3A.Menus.Home.Name = string.sub(v, 7)
- else
- local id = tonumber(string.sub(v, 1, 1))-- 1
- v = string.sub(v, string.find(v, ":") + 1)
- local type = string.sub(v, 1, string.find(v, ":") - 1)
- v = string.sub(v, string.find(v, ":") + 1)
- if (type == "CSwatch") then
- local csw = {}
- csw.Modifier = v
- csw.R = 0
- csw.G = 0
- csw.B = 0
- D3A.Menus.Home.Objects[id] = csw
- elseif (type == "Value") then
- local text = string.sub(v, 1, string.find(v, ":") - 1)
- v = string.sub(v, string.find(v, ":") + 1)
- local min = string.sub(v, 1, string.find(v, ":") - 1)
- v = string.sub(v, string.find(v, ":") + 1)
- local max = v
- local val = {}
- val.Type = "Value"
- val.Text = text
- val.Min = min
- val.Max = max
- val.Val = min
- D3A.Menus.Home.Objects[id] = val
- else
- local text = string.sub(v, 1, string.find(v, ":") - 1)
- v = string.sub(v, string.find(v, ":") + 1)
- local func = v
- local obj = {}
- obj.Text = text
- obj.Function = function() RunString(func) end
- obj.Type = type
- D3A.Menus.Home.Objects[id] = obj
- end
- end
- end
- else
- file.Write(D3A.Menus.Dir .. "HomePage.txt", "TITLE:Home Page\n1:Button:Customize home page:D3A.Menus.CustomizeHomepage()")
- ParseHome()
- end
- end
- ParseHome()
- if (file.Exists(D3A.Menus.Dir .. "FGColor.txt")) then
- RunString(file.Read(D3A.Menus.Dir .. "FGColor.txt"))
- else
- file.Write(D3A.Menus.Dir .. "FGColor.txt", "D3A.Menus.FG = Color(40, 90, 40, 180)")
- D3A.Menus.FG = Color(40, 90, 40, 180)
- end
- if (file.Exists(D3A.Menus.Dir .. "BGColor.txt")) then
- RunString(file.Read(D3A.Menus.Dir .. "BGColor.txt"))
- else
- file.Write(D3A.Menus.Dir .. "BGColor.txt", "D3A.Menus.BG = Color(255, 255, 255, 30)")
- D3A.Menus.BG = Color(255, 255, 255, 30)
- end
- if (file.Exists(D3A.Menus.Dir .. "TextColor.txt")) then
- RunString(file.Read(D3A.Menus.Dir .. "TextColor.txt"))
- else
- file.Write(D3A.Menus.Dir .. "TextColor.txt", "D3A.Menus.Text = Color(255, 255, 255, 255)")
- D3A.Menus.Text = Color(255, 255, 255, 255)
- end
- if (file.Exists(D3A.Menus.Dir .. "BorderColor.txt")) then
- RunString(file.Read(D3A.Menus.Dir .. "BorderColor.txt"))
- else
- file.Write(D3A.Menus.Dir .. "BorderColor.txt", "D3A.Menus.Border = Color(180, 180, 180, 50)")
- D3A.Menus.Border = Color(180, 180, 180, 50)
- end
- if (file.Exists(D3A.Menus.Dir .. "SelectedColor.txt")) then
- RunString(file.Read(D3A.Menus.Dir .. "SelectedColor.txt"))
- else
- file.Write(D3A.Menus.Dir .. "SelectedColor.txt", "D3A.Menus.Selected = Color(20, 200, 20, 60)")
- D3A.Menus.Selected = Color(20, 200, 20, 60)
- end
- if (file.Exists(D3A.Menus.Dir .. "ClickedColor.txt")) then
- RunString(file.Read(D3A.Menus.Dir .. "ClickedColor.txt"))
- else
- file.Write(D3A.Menus.Dir .. "ClickedColor.txt", "D3A.Menus.Clicked = Color(200, 255, 200, 60)")
- D3A.Menus.Clicked = Color(200, 255, 200, 60)
- end
- D3A.Window = {}
- -- Start settings
- D3A.Window.Minimized = false
- D3A.Window.X = 75
- D3A.Window.Y = 45
- D3A.Window.Width = ScrW() - 150
- D3A.Window.Height = ScrH() - 102
- D3A.Window.Center = D3A.Window.X + (D3A.Window.Width / 2)
- D3A.Window.Tabs = {}
- D3A.Window.Tabs[1] = D3A.Menus.Home
- /* D3A.Window.Tabs[1] = {}
- D3A.Window.Tabs[1].Name = "MOTD"
- D3A.Window.Tabs[1].Selected = false
- D3A.Window.Tabs[1].Objects = {}
- D3A.Window.Tabs[1].Objects[1] = {}
- D3A.Window.Tabs[1].Objects[1].Type = "Button"
- D3A.Window.Tabs[1].Objects[1].Text = "Test me for wincest."
- D3A.Window.Tabs[1].Objects[1].Function = function()
- print("God hates you soooo much.")
- end
- D3A.Window.Tabs[2] = {}
- D3A.Window.Tabs[2].Name = "MOTD 2"
- D3A.Window.Tabs[2].Selected = false
- D3A.Window.Tabs[2].Objects = {}
- D3A.Window.Tabs[2].Objects[1] = {}
- D3A.Window.Tabs[2].Objects[1].Type = "Button"
- D3A.Window.Tabs[2].Objects[1].Text = "Test me for wincest."
- D3A.Window.Tabs[2].Objects[1].Function = function()
- print("God hates you soooo much.")
- end*/
- -- End settings
- -- Non-Menu Variables
- local First = true
- local Timers = {}
- local Notifications = {}
- local NotificationsY = ScrH() - 45
- local NotificationGone = false
- local vcEn = LocalPlayer():GetNetworkedBool("voicechatenable", true)
- -- Menu Variables not worthy of publicity
- local TabButtons = {}
- local TabPointers = {}
- function D3A.Menus.MakeNotification(Message)
- surface.PlaySound("buttons/combine_button1.wav")
- local Msg = Message:ReadString()
- local Note = {}
- Note.String = Msg
- Note.Y = (ScrH() / 2) + 20
- Note.EndY = NotificationsY
- Note.Alpha = 255
- Note.MoveAmt = 7.5
- Note.Lived = 0
- NotificationsY = NotificationsY - 45
- Notifications[#Notifications+1] = Note
- end
- usermessage.Hook("D3A.Menus.MakeNotification", D3A.Menus.MakeNotification)
- function D3A.Menus.SetActiveTab(tab)
- local min = {}
- min.Type = "Button"
- min.Text = "Minimize"
- min.Function = function() D3A.Window.Minimized = true end
- min.X1 = 0
- min.X2 = 0
- min.Y1 = 0
- min.Y2 = 0
- local min2 = {}
- min2.Type = "Button"
- min2.Text = "Close tabs"
- min2.Function = function()
- for k, v in ipairs(D3A.Window.Tabs) do
- if !(v.UID == "HOMEPAGE") then
- D3A.Window.Tabs[k] = nil
- TabPointers[v.UID] = nil
- end
- end
- D3A.Menus.SetActiveTab(1)
- D3A.Window.Minimized = true
- end
- min2.X1 = 0
- min2.X2 = 0
- min2.Y1 = 0
- min2.Y2 = 0
- if (D3A.Window.Tabs[tab]) then
- D3A.Menus.OpenTab = D3A.Window.Tabs[tab].Objects
- D3A.Menus.OpenTabName = D3A.Window.Tabs[tab].Name
- D3A.Menus.OpenTab[-1] = min
- D3A.Menus.OpenTab[-2] = min2
- for k, v in ipairs(D3A.Window.Tabs) do
- D3A.Window.Tabs[k].Selected = false
- end
- D3A.Window.Tabs[tab].Selected = true
- else
- D3A.Menus.OpenTab = {}
- D3A.Menus.OpenTabName = "None"
- D3A.Menus.OpenTab[-1] = min
- D3A.Menus.OpenTab[-2] = min2
- end
- end
- D3A.Menus.SetActiveTab(1)
- function D3A.Menus.New(Message)
- D3A.Window.Minimized = false
- local uid = Message:ReadString()
- local title = Message:ReadString()
- if (!TabPointers[uid]) then
- local cnt = #D3A.Window.Tabs
- TabPointers[uid] = cnt + 1
- local tab = {}
- tab.UID = uid
- tab.Name = title
- tab.Selected = false
- tab.Objects = {}
- table.insert(D3A.Window.Tabs, tab)
- else
- D3A.Window.Tabs[TabPointers[uid]].Name = title
- D3A.Window.Tabs[TabPointers[uid]].Objects = {}
- end
- D3A.Menus.SetActiveTab(TabPointers[uid])
- print("New tab: " .. title .. ". UID: " .. uid .. ". Pointer: " .. TabPointers[uid])
- end
- usermessage.Hook("D3A.Menus.New", D3A.Menus.New)
- function D3A.Menus.MOTD()
- D3A.Window.Minimized = false
- local uid = "MOTD"
- local title = "Message of the Day"
- if (!TabPointers[uid]) then
- local cnt = #D3A.Window.Tabs
- TabPointers[uid] = cnt + 1
- local tab = {}
- tab.UID = uid
- tab.Name = title
- tab.Selected = false
- tab.Objects = {}
- table.insert(D3A.Window.Tabs, tab)
- else
- D3A.Window.Tabs[TabPointers[uid]].Objects = {}
- end
- D3A.Menus.SetActiveTab(TabPointers[uid])
- print("New tab: " .. title .. ". UID: " .. uid .. ". Pointer: " .. TabPointers[uid])
- end
- usermessage.Hook("D3A.Menus.MOTD", D3A.Menus.MOTD)
- --function D3A.Menus.Close(Message)
- -- end
- usermessage.Hook("D3A.Menus.Close", function() end)
- function D3A.Menus.AddButton(Message)
- local uid = Message:ReadString()
- local txt = Message:ReadString()
- local func = Message:ReadString()
- if (!TabPointers[uid]) then return end
- if (!D3A.Window.Tabs[TabPointers[uid]]) then return end
- local bt = {}
- bt.Type = "Button"
- bt.Text = txt
- bt.Function = function() RunString(func) end
- table.insert(D3A.Window.Tabs[TabPointers[uid]].Objects, bt)
- print("New button: " .. txt .. ". UID: " .. uid .. ". Pointer: " .. TabPointers[uid] .. ". Function: " .. func)
- end
- usermessage.Hook("D3A.Menus.AddButton", D3A.Menus.AddButton)
- function D3A.Menus.AddValue(Message)
- local uid = Message:ReadString()
- local txt = Message:ReadString()
- local min = Message:ReadInt()
- local max = Message:ReadInt()
- if (!TabPointers[uid]) then return end
- if (!D3A.Window.Tabs[TabPointers[uid]]) then return end
- local val = {}
- va.Type = "Value"
- va.Text = txt
- va.Min = min
- va.Max = max
- va.Val = min
- table.insert(D3A.Window.Tabs[TabPointers[uid]].Objects, val)
- print("New value modifier: " .. txt .. ". UID: " .. uid .. ". Pointer: " .. TabPointers[uid] .. ". Minimum: " .. min .. ". Maximum: " .. max)
- end
- usermessage.Hook("D3A.Menus.AddValue", D3A.Menus.AddValue)
- function D3A.Menus.AddText(Message)
- local uid = Message:ReadString()
- local txt = Message:ReadString()
- if (!TabPointers[uid]) then return end
- local text = {}
- text.Type = "String"
- text.Text = txt
- table.insert(D3A.Window.Tabs[TabPointers[uid]].Objects, text)
- print("New text: " .. txt .. ". UID: " .. uid .. ". Pointer: " .. TabPointers[uid])
- end
- usermessage.Hook("D3A.Menus.AddText", D3A.Menus.AddText)
- function D3A.Menus.Close(UID)
- Saved[UID] = nil
- end
- function D3A.Menus.HUDShouldDraw(E)
- if (E == "CHudCrosshair") then
- return false
- end
- end
- function D3A.Menus.RenderScreenspaceEffects()
- local CModify = {}
- CModify["$pp_colour_contrast"] = 0.4
- CModify["$pp_colour_colour"] = 0.5
- CModify["$pp_colour_mulg"] = 4
- DrawColorModify(CModify)
- end
- function D3A.Menus.HUDPaint()
- if !(D3A.Window.Minimized) then
- draw.RoundedBox(6, D3A.Window.X-3, D3A.Window.Y-3, D3A.Window.Width+6, D3A.Window.Height+6, D3A.Menus.Border)
- draw.RoundedBox(6, D3A.Window.X, D3A.Window.Y, D3A.Window.Width, D3A.Window.Height, D3A.Menus.BG)
- draw.RoundedBox(4, D3A.Window.X+3, D3A.Window.Y+3, D3A.Window.Width-6, D3A.Window.Height-6, D3A.Menus.FG)
- surface.SetFont("D3AMenu-Title")
- local w = surface.GetTextSize("The D3vine Admin Mod") / 2
- draw.RoundedBox(4, D3A.Window.Center-w-4, D3A.Window.Y+6, w*2+8, 26, D3A.Menus.BG)
- draw.SimpleText("The D3vine Admin Mod", "D3AMenu-Title", D3A.Window.Center-w, D3A.Window.Y+8, D3A.Menus.Text)
- -- Below title, Y = 35
- draw.RoundedBox(4, D3A.Window.X+8, D3A.Window.Y+36, D3A.Window.Width-16, 20, D3A.Menus.BG)
- surface.SetFont("D3AMenu-Button")
- local pX = D3A.Window.X+11
- local pY = D3A.Window.Y+38
- TabButtons = {}
- for k, v in ipairs(D3A.Window.Tabs) do
- local w = surface.GetTextSize(v.Name)
- if (v.Selected) then
- draw.RoundedBox(4, pX, pY, w+8, 16, D3A.Menus.Selected)
- end
- TabButtons[k] = {}
- TabButtons[k].X1 = pX
- TabButtons[k].Y1 = pY
- TabButtons[k].X2 = pX + w + 8
- TabButtons[k].Y2 = pY + 16
- draw.RoundedBox(4, pX, pY, w+8, 16, D3A.Menus.BG)
- draw.SimpleText(v.Name, "D3AMenu-Button", pX+4, pY-1, D3A.Menus.Text)
- pX = pX + w + 12
- end
- if (!D3A.Window.Tabs[1]) then
- draw.SimpleText("No tabs open", "D3AMenu-Button", pX, pY-1, D3A.Menus.Text)
- end
- draw.RoundedBox(4, D3A.Window.X+8, D3A.Window.Y+60, D3A.Window.Width-16, D3A.Window.Height-68, D3A.Menus.BG)
- local b2 = D3A.Menus.OpenTab[-1]
- local b1 = D3A.Menus.OpenTab[-2]
- local w1 = D3A.Window.X + D3A.Window.Width
- local tW1 = surface.GetTextSize(b1.Text) + 4
- w1 = w1 - tW1
- w1 = w1 - 10
- -- Close button settings
- b1.X1 = w1
- b1.X2 = tW1 + 4 + w1
- b1.Y1 = D3A.Window.Y + 6
- b1.Y2 = b1.Y1 + 26
- if (b1.Selected) then
- draw.RoundedBox(4, w1 - 1, D3A.Window.Y + 5, tW1 + 6, 28, D3A.Menus.Selected)
- end
- if (b1.Clicked) then
- draw.RoundedBox(4, w1 - 1, D3A.Window.Y + 5, tW1 + 6, 28, D3A.Menus.Clicked)
- end
- draw.RoundedBox(4, w1, D3A.Window.Y + 6, tW1 + 4, 26, D3A.Menus.BG)
- draw.SimpleText(b1.Text, "D3AMenu-Button", w1 + 4, D3A.Window.Y + 10, D3A.Menus.Text)
- -- Minimize button settings
- local tW2 = surface.GetTextSize(b2.Text) + 4
- local w2 = w1 - tW2 - 9
- b2.X1 = w2
- b2.X2 = tW2 + 4 + w2
- b2.Y1 = D3A.Window.Y + 6
- b2.Y2 = b2.Y1 + 26
- if (b2.Selected) then
- draw.RoundedBox(4, w2 - 1, D3A.Window.Y + 5, tW2 + 6, 28, D3A.Menus.Selected)
- end
- if (b2.Clicked) then
- draw.RoundedBox(4, w2 - 1, D3A.Window.Y + 5, tW2 + 6, 28, D3A.Menus.Clicked)
- end
- draw.RoundedBox(4, w2, D3A.Window.Y + 6, tW2 + 4, 26, D3A.Menus.BG)
- draw.SimpleText(b2.Text, "D3AMenu-Button", w2 + 4, D3A.Window.Y + 10, D3A.Menus.Text)
- local pY = D3A.Window.Y + 65
- local pX = D3A.Window.X + 13
- local maxY = D3A.Window.Y + D3A.Window.Height - 30
- local buttonWidth = 4
- surface.SetFont("D3AMenu-Button")
- for k, v in pairs(D3A.Menus.OpenTab) do
- if (tonumber(k) > 0) then
- if (v.Type == "Value") then
- buttonWidth = 200
- break
- end
- if (v.Type == "Button") then
- local w = surface.GetTextSize(v.Text) + 4
- if (w > buttonWidth) then
- buttonWidth = w
- end
- end
- end
- end
- local tabCount = 0
- for k, v in pairs(D3A.Menus.OpenTab) do
- if (tonumber(k) > 0) then tabCount = tabCount + 1 end
- end
- if (tabCount > 0) then
- for i=1, tabCount do
- local v = D3A.Menus.OpenTab[i]
- if (v.Type == "Button") then
- if (pY > maxY) then
- pY = D3A.Window.Y + 65
- pX = pX + buttonWidth + 11
- end
- draw.RoundedBox(4, pX, pY, buttonWidth + 2, 26, D3A.Menus.FG)
- draw.SimpleText(v.Text, "D3AMenu-Button", pX + 3, pY + 4, D3A.Menus.Text)
- if (v.Selected) then
- draw.RoundedBox(4, pX-1, pY-1, buttonWidth + 4, 28, D3A.Menus.Selected)
- end
- if (v.Clicked) then
- draw.RoundedBox(4, pX-1, pY-1, buttonWidth + 4, 28, D3A.Menus.Clicked)
- end
- v.X1 = pX
- v.Y1 = pY
- v.X2 = pX + buttonWidth + 2
- v.Y2 = pY + 26
- pY = pY + 33
- end
- if (v.Type == "String") then
- draw.SimpleText(v.Text, "D3AMenu-Button", pX + 3, pY, D3A.Menus.Text)
- pY = pY + 29
- end
- if (v.Type == "Value") then
- surface.SetFont("D3AMenu-Button")
- local text = v.Text .. ": " .. v.Val
- local w = surface.GetTextSize(text)
- draw.SimpleText(text, "D3AMenu-Button", pX + 100 - (w/2), pY, D3A.Menus.Text)
- draw.RoundedBox(4, pX + 6, pY + 18, buttonWidth, 8, D3A.Menus.FG)
- local x
- if (v.X1) then
- x = v.X1
- else
- x = pX - 1 + (v.Val - v.Min) / (v.Max - v.Min) * 200
- end
- draw.RoundedBox(4, x, pY + 15, 14, 14, D3A.Menus.FG)
- if (v.Selected) then
- draw.RoundedBox(4, x, pY + 15, 14, 14, D3A.Menus.Selected)
- end
- if (v.Clicked) then
- draw.RoundedBox(4, x, pY + 15, 14, 14, D3A.Menus.Clicked)
- end
- v.X1 = x
- v.X2 = x + 14
- v.Y1 = pY + 15
- v.Y2 = pY + 29
- draw.SimpleText("X1: " .. v.X1, "D3AMenu-Button", 400, 50, D3A.Menus.Text)
- draw.SimpleText("X2: " .. v.X2, "D3AMenu-Button", 400, 100, D3A.Menus.Text)
- draw.SimpleText("Y1: " .. v.Y1, "D3AMenu-Button", 400, 150, D3A.Menus.Text)
- draw.SimpleText("Y2: " .. v.Y2, "D3AMenu-Button", 400, 200, D3A.Menus.Text)
- draw.SimpleText("mX: " .. gui.MouseX(), "D3AMenu-Button", 400, 250, D3A.Menus.Text)
- draw.SimpleText("mY: " .. gui.MouseY(), "D3AMenu-Button", 400, 300, D3A.Menus.Text)
- pY = pY + 35
- end
- end
- end
- end
- local timerY = 45
- for k, v in pairs(Timers) do
- surface.SetFont("D3AMenu-Button")
- local width = surface.GetTextSize(v.Text .. " - " .. v.Time) + 5
- draw.RoundedBox(6, ScrW() - width - 7, timerY - 3, width + 6, 31, D3A.Menus.BG)
- local perc = v.Time / v.OrigTime
- local perc = math.Round(perc * width)
- draw.RoundedBox(4, ScrW() - width - 4, timerY, perc, 25, D3A.Menus.FG)
- draw.SimpleText(v.Text .. " - " .. v.Time, "D3AMenu-Button", ScrW() - width, timerY + 3, D3A.Menus.Text)
- timerY = timerY + 50
- end
- for k, v in pairs(Notifications) do
- surface.SetFont("D3AMenu-Button")
- local width = surface.GetTextSize(v.String) + 10
- draw.RoundedBox(6, (ScrW() / 2) - (width / 2), v.Y, width, 28, Color(255, 255, 255, 30 * v.Alpha/255))
- draw.RoundedBox(4, (ScrW() / 2) - (width / 2) + 3, v.Y + 3, width - 6, 22, Color(40, 90, 40, v.Alpha))
- draw.SimpleText(v.String, "D3AMenu-Button", (ScrW() / 2) - (width / 2) + 5, v.Y + 5, Color(255, 255, 255, v.Alpha))
- end
- if (!vcEn) and (D3A.Window.Minimized) then
- surface.SetFont("D3AMenu-Button")
- local w = surface.GetTextSize("Voicechat is disabled") + 8
- draw.RoundedBox(6, ScrW() / 2 - (w*0.5) - 3, 44, w + 6, 31, D3A.Menus.BG)
- draw.RoundedBox(4, ScrW() / 2 - (w*0.5), 47, w, 25, D3A.Menus.FG)
- draw.SimpleText("Voicechat is disabled", "D3AMenu-Button", ScrW() / 2 - (w*0.5) + 4, 50, D3A.Menus.Text)
- end
- end
- function D3A.Menus.Think()
- gui.EnableScreenClicker(true)
- if (#D3A.Window.Tabs == 0) then
- D3A.Window.Tabs[1] = D3A.Menus.Home
- D3A.Menus.SetActiveTab(1)
- end
- local mX = gui.MouseX()
- local mY = gui.MouseY()
- for k, v in pairs(D3A.Menus.OpenTab) do
- --if (v.Type == "Button") then
- if (v.Y2) then
- if (mX > v.X1) and (mX < v.X2) and (mY > v.Y1) and (mY < v.Y2) then
- v.Selected = true
- D3A.Menus.SelectedObj = v
- else
- v.Selected = false
- end
- end
- --end
- end
- if (D3A.Menus.ClickedOn) then
- if (D3A.Menus.ClickedOn.Type == "Value") then
- local diff = mX - D3A.Menus.ClickedOn.X1
- D3A.Menus.ClickedOn.X1 = mX - diff
- D3A.Menus.ClickedOn.X2 = mX - diff + 14
- end
- end
- end
- function PRINTTAB()
- PrintTable(TabButtons)
- PrintTable(D3A.Menus.OpenTab)
- end
- function D3A.Menus.MousePressed(Button)
- local mX = gui.MouseX()
- local mY = gui.MouseY()
- for k, v in pairs(TabButtons) do
- if (mX >= v.X1) and (mX <= v.X2) and (mY >= v.Y1) and (mY <= v.Y2) then
- if (Button == 107) then
- D3A.Menus.SetActiveTab(k)
- elseif (Button == 108) or (Button == 109) then
- if (D3A.Window.Tabs[k].Home) then return end
- local cnt = #D3A.Window.Tabs
- for pt=k, cnt do
- print(pt .. " - " .. k)
- local curTab = D3A.Window.Tabs[pt]
- if (pt == k) then
- D3A.Window.Tabs[pt] = nil
- PrintTable(TabPointers)
- print(curTab.UID)
- TabPointers[curTab.UID] = nil
- if (D3A.Menus.OpenTabName == curTab.Name) then
- D3A.Menus.SetActiveTab(pt-1)
- end
- elseif (pt > k) then
- D3A.Window.Tabs[pt-1] = curTab
- D3A.Window.Tabs[pt] = nil
- TabPointers[curTab.UID] = pt-1
- end
- end
- end
- return
- end
- end
- for k, v in pairs(D3A.Menus.OpenTab) do
- if (v.Selected) then
- v.Clicked = true
- D3A.Menus.ClickedOn = v
- else
- v.Clicked = false
- end
- end
- end
- function D3A.Menus.MouseReleased(Button)
- local mX = gui.MouseX()
- local mY = gui.MouseY()
- if (!D3A.Menus.ClickedOn) then return end
- local v = D3A.Menus.ClickedOn
- v.Clicked = nil
- D3A.Menus.ClickedOn = nil
- if (!v.Selected) then
- return
- end
- if (Button == 109) then
- // Middle Mouse
- elseif (Button == 107) then
- if (v.Function) then
- v.Function()
- end
- elseif (Button == 108) then
- // Right Click
- end
- end
- function D3A.Menus.KeyPress(pl, Key)
- if (D3A.Menus.Ignore) then return end
- if (First) then
- First = nil
- RunConsoleCommand("SetMyTeam_" .. LocalPlayer():UserID())
- for k, v in pairs(ents.FindByClass("prop_physics")) do
- if (v:GetNetworkedBool("voicechatter")) then
- vcEnt = v
- vcEn = v:GetNetworkedBool("voicechatenable", false)
- end
- end
- end
- if (Key == 262144) then
- if (D3A.Menus.OpenShft) then
- D3A.Menus.Ignore = true
- timer.Simple(0.2, function() D3A.Menus.Ignore = false end)
- D3A.Window.Minimized = !D3A.Window.Minimized
- else
- D3A.Menus.OpenCtrl = true
- end
- end
- if (Key == 131072) then
- if (D3A.Menus.OpenCtrl) then
- D3A.Menus.Ignore = true
- timer.Simple(0.2, function() D3A.Menus.Ignore = false end)
- D3A.Window.Minimized = !D3A.Window.Minimized
- else
- D3A.Menus.OpenShft = true
- end
- end
- end
- function D3A.Menus.KeyRelease(pl, Key)
- if (Key == 262144) then
- D3A.Menus.OpenCtrl = false
- end
- if (Key == 131072) then
- D3A.Menus.OpenShft = false
- end
- end
- hook.Add("Think", "D3AWindowHandler", function()
- if (!D3A.Window.Minimized) and (!D3A.Menus.Opened) then
- D3A.Menus.Start()
- elseif (D3A.Window.Minimized) and (D3A.Menus.Opened) then
- D3A.Menus.Stop()
- end
- end)
- -- Hooks
- hook.Add("HUDPaint", "D3A.Menus.HUDPaint", D3A.Menus.HUDPaint)
- hook.Add("KeyPress", "D3A.Menus.KeyPress", D3A.Menus.KeyPress)
- hook.Add("KeyRelease", "D3A.Menus.KeyRelease", D3A.Menus.KeyRelease)
- function D3A.Menus.AddTimer(Message)
- local ID = Message:ReadString()
- local Text = Message:ReadString()
- local Time = Message:ReadLong()
- Timers[ID] = {}
- Timers[ID].Text = Text
- Timers[ID].Time = Time
- Timers[ID].OrigTime = Time
- end
- usermessage.Hook("D3A.Menus.AddTimer", D3A.Menus.AddTimer)
- function D3A.Menus.CheckTimers()
- vcEn = LocalPlayer():GetNetworkedBool("voicechatenable", true)
- for k, v in pairs(Timers) do
- v.Time = v.Time - 1
- if (v.Time == 0) then
- Timers[k] = nil
- end
- end
- end
- timer.Create("D3A.Menus.Timers", 1, 0, D3A.Menus.CheckTimers)
- function D3A.Menus.CheckNotifications()
- for k, v in pairs(Notifications) do
- if (NotificationGone) then
- v.EndY = v.EndY + 45
- end
- v.Lived = v.Lived + .01
- v.Alpha = 255 - ((v.Lived / 3.5) * 255)
- if (v.Y < v.EndY) then
- v.Y = v.Y + v.MoveAmt
- end
- if (v.Alpha <= 15) then
- Notifications[k] = nil
- NotificationsY = NotificationsY + 45
- for i, l in pairs(Notifications) do
- l.EndY = l.EndY + 45
- end
- end
- end
- NotificationGone = false
- end
- timer.Create("D3A.Menus.Notifications", 0.01, 0, D3A.Menus.CheckNotifications)
- function D3A.Menus.Start()
- D3A.Menus.Opened = true
- hook.Add("Think", "D3A.Menus.Think", D3A.Menus.Think)
- hook.Add("HUDShouldDraw", "D3A.Menus.HUDShouldDraw", D3A.Menus.HUDShouldDraw)
- hook.Add("HUDDrawScoreBoard", "D3A.Menus.HUDDrawScoreBoard", D3A.Menus.HUDDrawScoreBoard)
- hook.Add("GUIMousePressed", "D3A.Menus.MousePressed", D3A.Menus.MousePressed)
- hook.Add("GUIMouseReleased", "D3A.Menus.MouseReleased", D3A.Menus.MouseReleased)
- hook.Add("RenderScreenspaceEffects", "D3A.Menus.RenderScreenspaceEffects", D3A.Menus.RenderScreenspaceEffects)
- gui.EnableScreenClicker(true)
- D3A.Menus.ToolMode = GetConVarString("gmod_toolmode")
- RunConsoleCommand("gmod_toolmode", "\"\"")
- end
- function D3A.Menus.Stop()
- D3A.Menus.Opened = false
- hook.Remove("Think", "D3A.Menus.Think")
- hook.Remove("HUDShouldDraw", "D3A.Menus.HUDShouldDraw")
- hook.Remove("HUDDrawScoreBoard", "D3A.Menus.HUDDrawScoreBoard")
- hook.Remove("GUIMousePressed", "D3A.Menus.MousePressed")
- hook.Remove("GUIMouseReleased", "D3A.Menus.MouseReleased")
- hook.Remove("RenderScreenspaceEffects", "D3A.Menus.RenderScreenspaceEffects")
- gui.EnableScreenClicker(false)
- RunConsoleCommand("gmod_toolmode", D3A.Menus.ToolMode)
- D3A.Menus.ToolMode = nil
- end
- D3A.Menus.Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement