summaryrefslogtreecommitdiff
path: root/gamemode/cl_notice.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-05-30 21:01:18 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-05-30 21:01:18 -0400
commitd62058fcdea5fc6736a2a373f47dc6c14c70c319 (patch)
tree79a1325190e3f1f1b6d6a2dbcdfc1ba3fa866ac9 /gamemode/cl_notice.lua
parentc38f00182ba6c282806eecb39a42e64d5feafa37 (diff)
downloadredead-d62058fcdea5fc6736a2a373f47dc6c14c70c319.tar.gz
redead-d62058fcdea5fc6736a2a373f47dc6c14c70c319.tar.bz2
redead-d62058fcdea5fc6736a2a373f47dc6c14c70c319.zip
Removed exessive whitespace so future commits will be cleaner
Diffstat (limited to 'gamemode/cl_notice.lua')
-rw-r--r--gamemode/cl_notice.lua79
1 files changed, 39 insertions, 40 deletions
diff --git a/gamemode/cl_notice.lua b/gamemode/cl_notice.lua
index c2a7333..3003c6b 100644
--- a/gamemode/cl_notice.lua
+++ b/gamemode/cl_notice.lua
@@ -16,17 +16,17 @@ function DoNotice( msg )
local len = msg:ReadShort()
local once = msg:ReadBool()
local col = Color( r, g, b, 255 )
-
+
if once and not CV_NoobHelp:GetBool() then return end
-
+
MsgN( str )
-
+
str = string.gsub( str, " ", " " )
-
+
GAMEMODE:AddNotify( str, col, len )
-
+
end
-usermessage.Hook( "ToxNotice", DoNotice )
+usermessage.Hook( "ToxNotice", DoNotice )
function GM:AddNotify( msg, col, len )
@@ -40,30 +40,30 @@ function GM:AddNotify( msg, col, len )
tab.y = ScrH()
tab.a = 255
tab.col = col
-
+
table.insert( NoteQueue, tab )
-
+
end
function NotifyThink()
if NextNotify < CurTime() then
-
+
NextNotify = CurTime() + 0.3
-
+
if NoteQueue[1] then
-
+
NoteQueue[1].recv = SysTime()
-
+
table.insert( HUDNotes, NoteQueue[1] )
-
+
HUDNote_c = HUDNote_c + 1
HUDNote_i = HUDNote_i + 1
-
+
table.remove( NoteQueue, 1 )
-
+
end
-
+
end
end
@@ -74,58 +74,58 @@ local function DrawNotice( self, k, v, i )
local H = ScrH() / 1024
local x = v.x - 25 * H //74
local y = v.y - 300 * H //580 * H
-
+
if !v.w then
-
+
surface.SetFont( "Notice" )
v.w, v.h = surface.GetTextSize( v.text )
-
+
end
-
+
local w = v.w
local h = v.h
w = w - 16
h = h + 16
draw.RoundedBox( 4, x - w - h + 8, y - 8, w + h, h, Color( 10, 10, 10, v.a * 0.5 ) )
-
+
draw.SimpleText( v.text, "Notice", x+1, y+1, Color(0,0,0,v.a*0.8), TEXT_ALIGN_RIGHT )
draw.SimpleText( v.text, "Notice", x-1, y-1, Color(0,0,0,v.a*0.5), TEXT_ALIGN_RIGHT )
draw.SimpleText( v.text, "Notice", x+1, y-1, Color(0,0,0,v.a*0.6), TEXT_ALIGN_RIGHT )
draw.SimpleText( v.text, "Notice", x-1, y+1, Color(0,0,0,v.a*0.6), TEXT_ALIGN_RIGHT )
draw.SimpleText( v.text, "Notice", x, y, v.col, TEXT_ALIGN_RIGHT )
-
+
local ideal_y = ScrH() - (HUDNote_c - i) * (h + 4)
local ideal_x = ScrW()
-
+
local timeleft = v.len - ( SysTime() - v.recv )
-
+
//gone from screen
-
+
if ( timeleft < 0.5 ) then
-
+
ideal_x = ScrW() + w * 4 //2
-
+
end
-
+
local spd = RealFrameTime() * 15
-
+
v.y = v.y + v.vely * spd
v.x = v.x + v.velx * spd
-
+
local dist = ideal_y - v.y
v.vely = v.vely + dist * spd * 1
-
+
if (math.abs(dist) < 2 && math.abs(v.vely) < 0.1) then v.vely = 0 end
-
+
local dist = ideal_x - v.x
-
+
v.velx = v.velx + dist * spd * 1
-
+
if (math.abs(dist) < 2 && math.abs(v.velx) < 0.1) then v.velx = 0 end
-
+
//friction that is FPS independant
-
+
v.velx = v.velx * (0.95 - RealFrameTime() * 8 )
v.vely = v.vely * (0.95 - RealFrameTime() * 8 )
@@ -134,15 +134,15 @@ end
function PaintNotes()
if ( !HUDNotes ) then return end
-
+
local i = 0
for k, v in pairs( HUDNotes ) do
if ( v != 0 ) then
i = i + 1
- DrawNotice( self, k, v, i)
+ DrawNotice( self, k, v, i)
end
end
-
+
for k, v in pairs( HUDNotes ) do
if ( v != 0 && v.recv + v.len < SysTime() ) then
HUDNotes[ k ] = 0
@@ -153,4 +153,3 @@ function PaintNotes()
end
hook.Add("HUDPaint", "PaintNotes", PaintNotes)
-