Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if IsValid(GLOBALMACHIN) then GLOBALMACHIN:Remove() end
- local function centerChild(viewContainer, codeContainer, child)
- local x, y = child:GetPos()
- codeContainer:MoveTo(-x + viewContainer:GetWide() * 0.5 - child:GetWide() * 0.5, 0, 0.25)
- end
- GLOBALMACHIN = vgui.Create("DFrame")
- GLOBALMACHIN:SetSize(800, 400)
- local viewContainer = vgui.Create("DPanel", GLOBALMACHIN)
- viewContainer:SetSize(500, 100)
- viewContainer:Center()
- local codeContainer = vgui.Create("DPanel", viewContainer)
- codeContainer:SetSize(0, 100)
- for i = 1, 9 do
- local pnl = vgui.Create("DButton", codeContainer)
- pnl:SetSize(100, 100)
- pnl:SetPos((i - 1) * (pnl:GetWide() + 5), 0)
- pnl:SetText(i)
- codeContainer:SetWide(codeContainer:GetWide() + pnl:GetWide() + 5)
- function pnl:OnMousePressed()
- local x, y = self:GetPos()
- codeContainer:MoveTo(-x + viewContainer:GetWide() * 0.5 - self:GetWide() * 0.5, 0, 0.25)
- end
- end
- codeContainer:SetWide(codeContainer:GetWide() - 5)
- local intChildActual = math.Round(#codeContainer:GetChildren() * 0.5)
- centerChild(viewContainer, codeContainer, codeContainer:GetChild(intChildActual - 1))
- timer.Simple(1, function()
- intChildActual = intChildActual + 1
- centerChild(viewContainer, codeContainer, codeContainer:GetChild(intChildActual - 1))
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement