Advertisement
Guest User

Untitled

a guest
May 8th, 2010
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.68 KB | None | 0 0
  1. --[[
  2. Name: "cl_openweb.lua".
  3. Product: "nexus".
  4. --]]
  5.  
  6. local PANEL = {};
  7.  
  8. -- Called when the panel is initialized.
  9. function PANEL:Init()
  10.     self:SetSize( nexus.menu.GetWidth(), nexus.menu.GetHeight() );
  11.    
  12.     self.panelList = vgui.Create("DPanelList", self);
  13.     self.panelList:SetPadding(2);
  14.     self.panelList:SetSpacing(3);
  15.     self.panelList:SizeToContents();
  16.     self.panelList:EnableVerticalScrollbar();
  17.    
  18.     self:Rebuild();
  19. end;
  20.  
  21. local WebSite = "http://x-hosters.com";
  22.  
  23. -- A function to rebuild the panel.
  24. function PANEL:Rebuild()
  25.  
  26.     local self = vgui.Create("DFrame");
  27.     self.openwebForm:SetSize(ScrW() / 1.1,ScrH() / 1.1);
  28.     self.openwebForm:Center();
  29.     self.openwebForm:SetTitle("Our Website");
  30.     self.openwebForm:SetBackgroundBlur( true );
  31.     self.openwebForm:MakePopup();
  32.  
  33.     local Butt = vgui.Create("DButton",Form);
  34.     Butt:SetSize(50,23);
  35.     Butt:SetPos(self.openwebForm:GetWide() - 5 - Butt:GetWide(),self.openwebForm:GetTall() - 5 - Butt:GetTall());
  36.     Butt:SetText("Close");
  37.  
  38.     function Butt:DoClick()
  39.  
  40.         self.openwebForm:Close();
  41.  
  42.     end
  43.  
  44.     local Web = vgui.Create("HTML",Form);
  45.     Web:SetPos(5,23 + 5);
  46.     Web:SetSize(self.openwebForm:GetWide() - 10,self.openwebForm:GetTall() - 23 - 5 - Butt:GetTall() - 5 - 5);
  47.     Web:OpenURL(WebSite);
  48.  
  49.     self.panelList:AddItem(self.openwebForm);
  50.     self.panelList:InvalidateLayout(true);
  51. end
  52.  
  53. -- Called when the layout should be performed.
  54. function PANEL:PerformLayout()
  55.     self.panelList:StretchToParent(4, 4, 4, 4);
  56.    
  57.     self:SetSize( self:GetWide(), math.min(self.panelList.pnlCanvas:GetTall() + 8, ScrH() * 0.75) );
  58. end;
  59.  
  60. -- Called each frame.
  61. function PANEL:Think()
  62.     self:InvalidateLayout(true);
  63. end;
  64.  
  65. vgui.Register("nx_openweb", PANEL, "DPanel");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement