Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.26 KB | None | 0 0
  1. hook.Add("InitPostEntity" , "FixNotePaints" , function()
  2. NOTIFY_GENERIC = 0
  3. NOTIFY_ERROR = 1
  4. NOTIFY_UNDO = 2
  5. NOTIFY_HINT = 3
  6. NOTIFY_CLEANUP = 4
  7.  
  8. local NoticeMaterial = {}
  9. NoticeMaterial[ NOTIFY_GENERIC ] = surface.GetTextureID( "vgui/notices/generic" )
  10. NoticeMaterial[ NOTIFY_ERROR ] = surface.GetTextureID( "vgui/notices/error" )
  11. NoticeMaterial[ NOTIFY_UNDO ] = surface.GetTextureID( "vgui/notices/undo" )
  12. NoticeMaterial[ NOTIFY_HINT ] = surface.GetTextureID( "vgui/notices/hint" )
  13. NoticeMaterial[ NOTIFY_CLEANUP ] = surface.GetTextureID( "vgui/notices/cleanup" )
  14.  
  15. local HUDNote_c = 0
  16. local HUDNote_i = 1
  17. local HUDNotes = {}
  18.  
  19. function GAMEMODE:AddNotify( str, type, length )
  20.  
  21. local tab = {}
  22. tab.text = str
  23. tab.recv = SysTime()
  24. tab.len = length
  25. tab.velx = -5
  26. tab.vely = 0
  27. tab.x = ScrW() + 200
  28. tab.y = ScrH()
  29. tab.a = 255
  30. tab.type = type
  31.  
  32. table.insert( HUDNotes, tab )
  33.  
  34. HUDNote_c = HUDNote_c + 1
  35. HUDNote_i = HUDNote_i + 1
  36.  
  37. end
  38.  
  39.  
  40. local function DrawNotice( self, k, v, i )
  41.  
  42. local H = ScrH() / 1024
  43. local x = v.x - 75 * H
  44. local y = v.y - 300 * H
  45.  
  46. if ( !v.w ) then
  47.  
  48. surface.SetFont( "GModNotify" )
  49. v.w, v.h = surface.GetTextSize( v.text )
  50.  
  51. end
  52.  
  53. local w = v.w
  54. local h = v.h
  55.  
  56. w = w + 16
  57. h = h + 16
  58.  
  59. draw.RoundedBox( 4, x - w - h + 8, y - 8, w + h, h, Color( 30, 30, 30, v.a * 0.4 ) )
  60.  
  61. // Draw Icon
  62.  
  63. surface.SetDrawColor( 255, 255, 255, v.a )
  64. surface.SetTexture( NoticeMaterial[ v.type ] )
  65. surface.DrawTexturedRect( x - w - h + 16, y - 4, h - 8, h - 8 )
  66.  
  67.  
  68. draw.SimpleText( v.text, "GModNotify", x+1, y+1, Color(0,0,0,v.a*0.8), TEXT_ALIGN_RIGHT )
  69. draw.SimpleText( v.text, "GModNotify", x-1, y-1, Color(0,0,0,v.a*0.5), TEXT_ALIGN_RIGHT )
  70. draw.SimpleText( v.text, "GModNotify", x+1, y-1, Color(0,0,0,v.a*0.6), TEXT_ALIGN_RIGHT )
  71. draw.SimpleText( v.text, "GModNotify", x-1, y+1, Color(0,0,0,v.a*0.6), TEXT_ALIGN_RIGHT )
  72. draw.SimpleText( v.text, "GModNotify", x, y, Color(255,255,255,v.a), TEXT_ALIGN_RIGHT )
  73.  
  74. local ideal_y = ScrH() - (HUDNote_c - i) * (h + 4)
  75. local ideal_x = ScrW()
  76.  
  77. local timeleft = v.len - (SysTime() - v.recv)
  78.  
  79. // Cartoon style about to go thing
  80. if ( timeleft < 0.8 ) then
  81. ideal_x = ScrW() - 50
  82. end
  83.  
  84. // Gone!
  85. if ( timeleft < 0.5 ) then
  86.  
  87. ideal_x = ScrW() + w * 2
  88.  
  89. end
  90.  
  91. local spd = RealFrameTime() * 15
  92.  
  93. v.y = v.y + v.vely * spd
  94. v.x = v.x + v.velx * spd
  95.  
  96. local dist = ideal_y - v.y
  97. v.vely = v.vely + dist * spd * 1
  98. if (math.abs(dist) < 2 && math.abs(v.vely) < 0.1) then v.vely = 0 end
  99. local dist = ideal_x - v.x
  100. v.velx = v.velx + dist * spd * 1
  101. if (math.abs(dist) < 2 && math.abs(v.velx) < 0.1) then v.velx = 0 end
  102.  
  103. // Friction.. kind of FPS independant.
  104. v.velx = v.velx * (0.95 - RealFrameTime() * 8 )
  105. v.vely = v.vely * (0.95 - RealFrameTime() * 8 )
  106.  
  107. end
  108.  
  109.  
  110. function GAMEMODE:PaintNotes()
  111.  
  112. if ( !HUDNotes ) then return end
  113.  
  114. local i = 0
  115. for k, v in pairs( HUDNotes ) do
  116.  
  117. if ( v != 0 ) then
  118.  
  119. i = i + 1
  120. DrawNotice( self, k, v, i)
  121.  
  122. end
  123.  
  124. end
  125.  
  126. for k, v in pairs( HUDNotes ) do
  127.  
  128. if ( v != 0 && v.recv + v.len < SysTime() ) then
  129.  
  130. HUDNotes[ k ] = 0
  131. HUDNote_c = HUDNote_c - 1
  132.  
  133. if (HUDNote_c == 0) then HUDNotes = {} end
  134.  
  135. end
  136.  
  137. end
  138.  
  139. end
  140. end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement