Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local events_tutorial =
- {
- {
- pos = function(pnl) if pnl.part and pnl.part:IsValid() and pnl.part.ClassName == "group" then return true end end,
- wait = MOUSE_RIGHT,
- text = [[right this group]],
- },
- {
- pos = function(pnl) if pnl.ClassName == "DMenuOption" and pnl:GetText():find("event") then return true end end,
- wait = MOUSE_RIGHT,
- text = [[add the event part to it]],
- },
- {
- pos = function(pnl) if pnl.pac3_sort_pos and pnl.lbl:GetText():find("event") then return true end end,
- wait = MOUSE_RIGHT,
- text = [[change the event to something]],
- }
- }
- tutorial = tutorial or {}
- tutorial.Panels = tutorial.Panels or {}
- local function handle_position(var)
- local T = type(var)
- if T == "function" then
- for key, pnl in pairs(tutorial.Panels) do
- if pnl:IsValid() then
- if var(pnl) == true then
- return Vector(pnl:LocalToScreen(pnl:GetWide(), pnl:GetTall()/2))
- end
- else
- tutorial.Panels[key] = nil
- end
- end
- end
- if T == "Vector" then
- return var
- end
- end
- local function handle_wait(var)
- local T = type(var)
- if T == "function" then
- return var
- end
- if T == "number" then
- return function() return input.IsMouseDown(var) end
- end
- end
- function tutorial.BeginTutorial(data)
- local i = 1
- local function step()
- local step_data = data[i]
- timer.Simple(0.2, function()
- if step_data then
- local pos = handle_position(step_data.pos)
- local done = handle_wait(step_data.wait)
- local text = markup.Parse(step_data.text)
- print(pos, done, text)
- tutorial.busy = true
- hook.Add("PostRenderVGUI", "tutorial", function()
- if done() then
- step()
- else
- local flash = math.abs(math.sin(CurTime() * 5)) * 50
- local w, h = text:Size()
- surface.SetDrawColor(Color(flash, flash, flash, 255))
- surface.DrawRect(pos.x - 5, pos.y - 5, w + 5*2, h + 5*2)
- text:Draw(pos.x , pos.y, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
- end
- end)
- i = i + 1
- else
- hook.Remove("PostRenderVGUI", "tutorial")
- tutorial.busy = false
- end
- end)
- end
- step()
- end
- tutorial.vgui_Create = tutorial.vgui_Create or vgui.Create
- function vgui.Create(...)
- local args = {tutorial.vgui_Create(...)}
- table.insert(tutorial.Panels, args[1])
- return unpack(args)
- end
- tutorial.BeginTutorial(events_tutorial)
Advertisement
Add Comment
Please, Sign In to add comment