Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.27 KB | None | 0 0
  1. local matClose = Material("shenesis/f4menu/close.png", "noclamp smooth")
  2. local matList = Material("shenesis/f4menu/list.png", "noclamp smooth")
  3.  
  4. local font = LOUNGE_MOTD.Font
  5. local font_bold = LOUNGE_MOTD.FontBold
  6.  
  7. --
  8. function L_QuickLabel(t, f, c, p)
  9. local l = vgui.Create("DLabel", p)
  10. l:SetText(t)
  11. l:SetFont(f)
  12. l:SetColor(c)
  13. l:SizeToContents()
  14.  
  15. return l
  16. end
  17.  
  18. // The MOTD
  19. function LOUNGE_MOTD:Show()
  20. if (IsValid(_LOUNGE_MOTD)) then
  21. _LOUNGE_MOTD:Remove()
  22. end
  23.  
  24. local curpage
  25.  
  26. local scale = math.Clamp(ScrH() / 1080, 0.6, 1)
  27.  
  28. surface.CreateFont("MOTD_LOUNGE_Medium", {font = font, size = 16 * scale})
  29. surface.CreateFont("MOTD_LOUNGE_Large", {font = font, size = 20 * scale})
  30. surface.CreateFont("MOTD_LOUNGE_Larger", {font = font, size = 24 * scale})
  31. surface.CreateFont("MOTD_LOUNGE_MediumB", {font = font_bold, size = 16 * scale})
  32. surface.CreateFont("MOTD_LOUNGE_LargeB", {font = font_bold, size = 20 * scale})
  33. surface.CreateFont("MOTD_LOUNGE_LargerB", {font = font_bold, size = 24 * scale})
  34. surface.CreateFont("MOTD_LOUNGE_LargestB", {font = font_bold, size = 32 * scale})
  35. surface.CreateFont( "Font_UI", { font = "Circular Std Bold", size = 20, italic = false, shadow = false, } )
  36.  
  37. local wi, he = 1500 * scale, 900 * scale
  38.  
  39. local pnl = vgui.Create("EditablePanel")
  40. pnl:SetSize(wi, he)
  41. pnl:Center()
  42. pnl:MakePopup()
  43. pnl.Paint = function(me, w, h)
  44. draw.RoundedBox(4, 0, 0, w, h, self.Style.bg)
  45. end
  46. pnl.Close = function(me)
  47. if (me.m_bClosing) then
  48. return end
  49.  
  50. me.m_bClosing = true
  51. me:AlphaTo(0, 0.1, 0, function()
  52. me:Remove()
  53. end)
  54. end
  55. _LOUNGE_MOTD = pnl
  56.  
  57. local th = 48 * scale
  58. local m = th * 0.25
  59.  
  60. local header = vgui.Create("DPanel", pnl)
  61. header:SetTall(th)
  62. header:Dock(TOP)
  63. header.Paint = function(me, w, h)
  64. draw.RoundedBoxEx(4, 0, 0, w, h, self.Style.header, true, true, false, false)
  65. end
  66.  
  67. local titlelbl = L_QuickLabel(self.Language.motd, "MOTD_LOUNGE_Larger", self.Style.text, header)
  68. titlelbl:Dock(LEFT)
  69. titlelbl:DockMargin(m, 0, 0, 0)
  70.  
  71. local close = vgui.Create("DButton", header)
  72. close:SetText("")
  73. close:SetWide(th)
  74. close:Dock(RIGHT)
  75. close.Paint = function(me, w, h)
  76. if (me.Hovered) then
  77. draw.RoundedBoxEx(4, 0, 0, w, h, self.Style.close_hover, false, true, false, false)
  78. end
  79.  
  80. if (me:IsDown()) then
  81. draw.RoundedBoxEx(4, 0, 0, w, h, self.Style.hover, false, true, false, false)
  82. end
  83.  
  84. surface.SetDrawColor(me:IsDown() and self.Style.text_down or self.Style.text)
  85. surface.SetMaterial(matClose)
  86. surface.DrawTexturedRectRotated(w * 0.5, h * 0.5, 16 * scale, 16 * scale, 0)
  87. end
  88. close.DoClick = function(me)
  89. pnl:Close()
  90. end
  91.  
  92. local body = vgui.Create("DPanel", pnl)
  93. body:SetDrawBackground(false)
  94. body:Dock(FILL)
  95.  
  96. local contents = vgui.Create("DHTML", body)
  97. contents:SetWide(wi - th)
  98. contents:DockPadding(m, m, m, m)
  99. contents:Dock(FILL)
  100.  
  101. local toggled = cookie.GetNumber("LoungeMOTD_ToggleOff", 0) == 0
  102.  
  103. local navbar = vgui.Create("DPanel", body)
  104. navbar:SetWide(toggled and th * 3 or th)
  105. navbar:Dock(LEFT)
  106. navbar:DockPadding(0, th, 0, 0)
  107. navbar.Paint = function(me, w, h)
  108. draw.RoundedBoxEx(4, 0, 0, w, h, self.Style.inbg, true, true, false, false)
  109. end
  110.  
  111. local togglenavbar = vgui.Create("DButton", navbar)
  112. togglenavbar:SetText("")
  113. togglenavbar:SetToolTip(self.Language.toggle)
  114. togglenavbar:SetSize(th, th)
  115. togglenavbar.Paint = function(me, w, h)
  116. surface.SetDrawColor(self.Style.text)
  117. surface.SetMaterial(matList)
  118. surface.DrawTexturedRectRotated(w * 0.5, h * 0.5, 24 * scale, 24 * scale, 0)
  119. end
  120. togglenavbar.DoClick = function()
  121. toggled = !toggled
  122. cookie.Set("LoungeMOTD_ToggleOff", toggled and 0 or 1)
  123.  
  124. navbar:Stop()
  125. navbar:SizeTo(toggled and th * 3 or th, -1, 0.1, 0, 0.2, function()
  126. end)
  127. end
  128.  
  129. for _, page in ipairs (LOUNGE_MOTD.Pages) do
  130. if (page.display and !page.display()) then
  131. continue end
  132.  
  133. local tx = self.Language[page.text] or page.text
  134.  
  135. local btn = vgui.Create("DButton", navbar)
  136. btn:SetText("")
  137. btn:SetToolTip(tx)
  138. btn:SetTall(th)
  139. btn:Dock(TOP)
  140. btn.Paint = function(me, w, h)
  141. if (me.Hovered) then
  142. surface.SetDrawColor(self.Style.hover)
  143. surface.DrawRect(0, 0, w, h)
  144. end
  145.  
  146. if (me:IsDown()) then
  147. surface.SetDrawColor(self.Style.hover)
  148. surface.DrawRect(0, 0, w, h)
  149. end
  150.  
  151. surface.SetDrawColor(self.Style.text)
  152. surface.SetMaterial(page.icon)
  153. surface.DrawTexturedRectRotated(24 * scale, 24 * scale, 24 * scale, 24 * scale, 0)
  154.  
  155. if (curpage == page.id) then
  156. surface.SetDrawColor(self.Style.header)
  157. surface.DrawRect(0, 0, th * 0.1, h)
  158. end
  159. end
  160. btn.DoClick = function()
  161. if (page.urloverlay) then
  162. gui.OpenURL(page.urloverlay)
  163. return
  164. else
  165. contents:OpenURL(page.url)
  166. end
  167. curpage = page.id
  168. end
  169.  
  170. local lbl = L_QuickLabel(tx, "MOTD_LOUNGE_Medium", self.Style.text, btn)
  171. lbl:Dock(LEFT)
  172. lbl:DockMargin(th, 0, 0, 0)
  173.  
  174. if (!curpage and page.url) then
  175. btn:DoClick()
  176. end
  177. end
  178.  
  179. pnl:SetAlpha(0)
  180. pnl:AlphaTo(255, 0.1)
  181. end
  182.  
  183. // The Mini Menu
  184. local function miniMenu()
  185. if IsValid(ba) then ba:Close() end
  186.  
  187. gui.EnableScreenClicker(true)
  188.  
  189. --[ Top of the frame ]--
  190. local ba = FutureRP.CreateDFrame( 500, 170, '', false, false, true )
  191. ba.Paint = function( obj, w, h )
  192. FutureRP.BlurMenu( obj, 13, 20, 200 )
  193. FutureRP.DrawRect( 0, 0, w, h , Color( 0,0,0,220 ) )
  194. FutureRP.DrawRoundedBox( 6, 0, 0, w, 30, Color( 72,8,159,220 ) )
  195. FutureRP.DrawText( 'Do you want to view the server rules?', 'Font_UI', 240, 5, Color( 255, 255, 255 ) )
  196. end
  197.  
  198. function ba:Close()
  199. gui.EnableScreenClicker(false)
  200. self:Remove()
  201. end
  202.  
  203. --[ The 'Yes' button ]--
  204. local YesButton = vgui.Create("DButton", ba)
  205. YesButton:SetSize( ba:GetWide() * 0.3, ba:GetTall() * 0.2 )
  206. YesButton:SetPos( ba:GetWide() * 0.02, ba:GetTall() * 0.35 )
  207. YesButton:SetText( "" )
  208. YesButton.Paint = function()
  209. draw.RoundedBox(0, 0, 0, YesButton:GetWide(), YesButton:GetTall(), Color(72,8,159,220));
  210. draw.SimpleText("Yes, view them.", "Font_UI", YesButton:GetWide() * 0.5, 5, color_white, TEXT_ALIGN_CENTER);
  211. end
  212.  
  213. function YesButton:DoClick()
  214. surface.PlaySound("buttons/button14.wav")
  215. LOUNGE_MOTD:Show()
  216. ba:Close()
  217. end
  218.  
  219. --[ The 'No' button ]--
  220. local NoButton = vgui.Create("DButton", ba)
  221. NoButton:SetSize( ba:GetWide() * 0.3, ba:GetTall() * 0.2 )
  222. NoButton:SetPos( ba:GetWide() * 0.68, ba:GetTall() * 0.35 )
  223. NoButton:SetText( "" )
  224. NoButton.Paint = function()
  225. draw.RoundedBox(0, 0, 0, NoButton:GetWide(), NoButton:GetTall(), Color(72,8,159,220));
  226. draw.SimpleText("No, I'm good.", "Font_UI", NoButton:GetWide() * 0.5, 5, color_white, TEXT_ALIGN_CENTER);
  227. end
  228.  
  229. function NoButton:DoClick()
  230. surface.PlaySound("buttons/button14.wav")
  231. ba:Close()
  232. end
  233.  
  234. end -- Need to add new stuff before this end.
  235.  
  236. // Making the Mini Menu pop up on spawn
  237. hook.Add("InitPostEntity","MiniMOTDMenuShow",function()
  238. timer.Simple(10,function()
  239. miniMenu()
  240. end)
  241. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement