From 65534fbadff0c6e3effb1f7c89dccaa48884d267 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 8 Jan 2015 23:26:19 +0000 Subject: [PATCH 1/2] Added "Display Time" functions to ZS notifications Mappers can now specify how long a HUD message lasts on screen in seconds. --- .../entities/point_zsmessage/init.lua | 11 ++++++++--- .../gamemode/vgui/dexnotificationslist.lua | 19 +++++++++++++++---- gamemodes/zombiesurvival/zombiesurvival.fgd | 2 ++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/gamemodes/zombiesurvival/entities/entities/point_zsmessage/init.lua b/gamemodes/zombiesurvival/entities/entities/point_zsmessage/init.lua index 28555a5..f33dced 100644 --- a/gamemodes/zombiesurvival/entities/entities/point_zsmessage/init.lua +++ b/gamemodes/zombiesurvival/entities/entities/point_zsmessage/init.lua @@ -2,6 +2,7 @@ ENT.Type = "point" function ENT:Initialize() self.SendTo = self.SendTo or -1 + self.DisplayTime = self.DisplayTime or GAMEMODE.NotifyFadeTime end function ENT:Think() @@ -16,18 +17,18 @@ function ENT:AcceptInput(name, caller, activator, args) args = string.gsub(args, "", "") if self.SendTo == 0 then - GAMEMODE:CenterNotifyAll(args) + GAMEMODE:CenterNotifyAll(args,{CustomTime = self.DisplayTime}) elseif self.SendTo == -1 then for _, pl in pairs(player.GetAll()) do if pl == activator or pl == caller then - pl:CenterNotify(args) + pl:CenterNotify(args,{CustomTime = self.DisplayTime}) break end end else for _, pl in pairs(player.GetAll()) do if pl:Team() == self.SendTo then - pl:CenterNotify(args) + pl:CenterNotify(args,{CustomTime = self.DisplayTime}) end end end @@ -41,6 +42,8 @@ function ENT:AcceptInput(name, caller, activator, args) SetGlobalString("hudoverride"..TEAM_UNDEAD, "") elseif name == "clearhumanhudmessage" or name == "clearsurvivorhudmessage" then SetGlobalString("hudoverride"..TEAM_HUMAN, "") + elseif name == "setdisplaytime" then + self.DisplayTime = tonumber(args) end end @@ -57,5 +60,7 @@ function ENT:KeyValue(key, value) else self.SendTo = 0 end + elseif key == "displaytime" then + self.DisplayTime = tonumber(value) end end diff --git a/gamemodes/zombiesurvival/gamemode/vgui/dexnotificationslist.lua b/gamemodes/zombiesurvival/gamemode/vgui/dexnotificationslist.lua index bd8fd11..117f5de 100644 --- a/gamemodes/zombiesurvival/gamemode/vgui/dexnotificationslist.lua +++ b/gamemodes/zombiesurvival/gamemode/vgui/dexnotificationslist.lua @@ -160,12 +160,23 @@ function PANEL:AddNotification(...) notif:Dock(TOP) + local args = {...} + + local FadeTime = GAMEMODE.NotifyFadeTime + + for k, v in pairs(args) do + if type(v) == "table" and v.CustomTime and type(v.CustomTime == "number") then + FadeTime = v.CustomTime + break + end + end + notif:SetAlpha(1) notif:AlphaTo(255, 0.5) - notif:AlphaTo(1, 1, GAMEMODE.NotifyFadeTime - 1) - - notif.DieTime = CurTime() + GAMEMODE.NotifyFadeTime - + notif:AlphaTo(1, 1, FadeTime - 1) + + notif.DieTime = CurTime() + FadeTime + return notif end diff --git a/gamemodes/zombiesurvival/zombiesurvival.fgd b/gamemodes/zombiesurvival/zombiesurvival.fgd index 980e596..baffb7e 100644 --- a/gamemodes/zombiesurvival/zombiesurvival.fgd +++ b/gamemodes/zombiesurvival/zombiesurvival.fgd @@ -635,6 +635,7 @@ "private" : "Activator Only" "all" : "All" ] + displaytime(integer) : "Display Time (centre message only)" : 8 : "How long the input message displays for, does not have an effect on HUD messages." // Inputs input message(string) : "What to display. Supports the markup library." @@ -642,6 +643,7 @@ input setzombiehudmessage(string) : "Set a message to display in the zombie wave hud." input clearhumanhudmessage(void) : "Clear the message to display in the human wave hud." input clearzombiehudmessage(void) : "Clear the message to display in the zombie wave hud." + input setdisplaytime(integer) : "Change how long the input message displays for." ] @PointClass base(Targetname) = logic_pantsmode : "ZS: When activated, this will set the special Pants Mode on." From 02c0808e4c64ee63f3d0f50d2f8c87a9c0b0dfd6 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 9 Jan 2015 03:10:57 +0000 Subject: [PATCH 2/2] Added color and position modifiers to point_zsmessage New keyvalues: textcolor and position New inputs: settextcolour and setdisplaytime Color is any "R G B" string Position is either "Center" or "Top Right" ("top" if not using smartedit)" --- .../entities/point_zsmessage/init.lua | 37 +++++++++++++++++-- gamemodes/zombiesurvival/zombiesurvival.fgd | 9 ++++- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/gamemodes/zombiesurvival/entities/entities/point_zsmessage/init.lua b/gamemodes/zombiesurvival/entities/entities/point_zsmessage/init.lua index f33dced..9a5b0b8 100644 --- a/gamemodes/zombiesurvival/entities/entities/point_zsmessage/init.lua +++ b/gamemodes/zombiesurvival/entities/entities/point_zsmessage/init.lua @@ -3,6 +3,10 @@ ENT.Type = "point" function ENT:Initialize() self.SendTo = self.SendTo or -1 self.DisplayTime = self.DisplayTime or GAMEMODE.NotifyFadeTime + self.Position = self.Position or "center" + self.Red = self.Red or 255 + self.Green = self.Green or 255 + self.Blue = self.Blue or 255 end function ENT:Think() @@ -16,19 +20,33 @@ function ENT:AcceptInput(name, caller, activator, args) args = string.gsub(args, "<.-=.->", "") args = string.gsub(args, "", "") + local TextColor = Color(self.Red, self.Green, self.Blue) + if self.SendTo == 0 then - GAMEMODE:CenterNotifyAll(args,{CustomTime = self.DisplayTime}) + if self.Position == "top" then + GAMEMODE:TopNotifyAll(TextColor, args, {CustomTime = self.DisplayTime}) + else + GAMEMODE:CenterNotifyAll(TextColor, args, {CustomTime = self.DisplayTime}) + end elseif self.SendTo == -1 then for _, pl in pairs(player.GetAll()) do if pl == activator or pl == caller then - pl:CenterNotify(args,{CustomTime = self.DisplayTime}) + if self.Position == "top" then + pl:TopNotify(TextColor, args, {CustomTime = self.DisplayTime}) + else + pl:CenterNotify(TextColor, args, {CustomTime = self.DisplayTime}) + end break end end else for _, pl in pairs(player.GetAll()) do if pl:Team() == self.SendTo then - pl:CenterNotify(args,{CustomTime = self.DisplayTime}) + if self.Position == "top" then + pl:TopNotify(TextColor, args, {CustomTime = self.DisplayTime}) + else + pl:CenterNotify(TextColor, args, {CustomTime = self.DisplayTime}) + end end end end @@ -44,6 +62,8 @@ function ENT:AcceptInput(name, caller, activator, args) SetGlobalString("hudoverride"..TEAM_HUMAN, "") elseif name == "setdisplaytime" then self.DisplayTime = tonumber(args) + elseif name == "settextcolor" or name == "settextcolour" then + self:ApplyColor(args) end end @@ -62,5 +82,16 @@ function ENT:KeyValue(key, value) end elseif key == "displaytime" then self.DisplayTime = tonumber(value) + elseif key == "position" then + self.Position = string.lower(value) + elseif key == "textcolor" or key == "textcolour" then + self:ApplyColor(value) end end + +function ENT:ApplyColor(colorstring) + local col = string.ToColor(colorstring.." 255") + self.Red = col.r or 255 + self.Green = col.g or 255 + self.Blue = col.b or 255 +end diff --git a/gamemodes/zombiesurvival/zombiesurvival.fgd b/gamemodes/zombiesurvival/zombiesurvival.fgd index baffb7e..406f04e 100644 --- a/gamemodes/zombiesurvival/zombiesurvival.fgd +++ b/gamemodes/zombiesurvival/zombiesurvival.fgd @@ -635,7 +635,13 @@ "private" : "Activator Only" "all" : "All" ] - displaytime(integer) : "Display Time (centre message only)" : 8 : "How long the input message displays for, does not have an effect on HUD messages." + displaytime(integer) : "Display Time" : 8 : "How long the input message displays for, does not have an effect on HUD messages." + position(choices) : "Message Position" : "center" : "Where the message is seen." = + [ + "center" : "Center" + "top" : "Top Right" + ] + textcolor(color255) : "Text Colour" : "255 255 255" : "Sets the color of an input message." // Inputs input message(string) : "What to display. Supports the markup library." @@ -644,6 +650,7 @@ input clearhumanhudmessage(void) : "Clear the message to display in the human wave hud." input clearzombiehudmessage(void) : "Clear the message to display in the zombie wave hud." input setdisplaytime(integer) : "Change how long the input message displays for." + input settextcolor(string) : "Takes an 'R G B' string to change the color of the next message." ] @PointClass base(Targetname) = logic_pantsmode : "ZS: When activated, this will set the special Pants Mode on."