FrameworkZ 10.8.3
Provides a framework for Project Zomboid with various systems.
Loading...
Searching...
No Matches
Notification.lua
Go to the documentation of this file.
3
4function FrameworkZ.UI.Notification:initialise()
7 ISPanel.initialise(self)
9 self.textLabel = ISLabel:new(self.uiHelper.GetMiddle(self.width, UIFont.Medium, self.text), self:getY() - self:getHeight() / 2 + getTextManager():MeasureStringY(UIFont.Medium, self.text) / 2, self:getHeight(), self.text, 1, 1, 1, 1, UIFont.Medium, true)
10 self.textLabel.r = 0
11 self.textLabel.g = 0
12 self.textLabel.b = 0
13 self.textLabel.a = 1
14 self.textLabel:initialise()
15 self:addChild(self.textLabel)
16
17 self:restartFadeOut()
18
19 FrameworkZ.Timers:Create("NotificationSlide" .. self.ID, 0, 0, function()
20 if self.x > self.x2 then
21 self:setX(self:getX() - self:getWidth() * 0.05)
22 else
23 self:setX(self.x2)
24 FrameworkZ.Timers:Remove("NotificationSlide" .. self.ID)
25 end
26 end)
27end
28
29function FrameworkZ.UI.Notification:restartFadeOut()
30 self.isExpiring = false
31 self.hasExpired = false
32
33 if FrameworkZ.Timers:Exists("NotificationFadeDelay" .. self.ID) then
34 FrameworkZ.Timers:Remove("NotificationFadeDelay" .. self.ID)
35 end
36
37 FrameworkZ.Timers:Create("NotificationFadeDelay" .. self.ID, self.duration, 1, function()
38 self.hasExpired = true
39 end)
40end
41
43 ISPanel.onMouseMove(self, x, y)
44
45 if not self.hasEntered then
46 self.hasEntered = true
47
48 if not self.hasFullyExpired then
49 self:restartFadeOut()
50 self.backgroundColor.a = math.min(self.originalAlpha - 0.25, 1)
51 end
52 end
53end
54
56 ISPanel.onMouseMoveOutside(self, x, y)
57
58 if self.hasEntered then
59 self.hasEntered = false
60
61 if not self.hasFullyExpired then
62 self.backgroundColor.a = self.originalAlpha
63 end
64 end
65end
66
67function FrameworkZ.UI.Notification:update()
68 ISPanel.update(self)
69end
70
71function FrameworkZ.UI.Notification:new(type, text, duration, playerObject)
72 local padding = 10
73 local margin = 10
74 local textWidth = getTextManager():MeasureStringX(UIFont.Medium, text)
75 local textHeight = getTextManager():MeasureStringY(UIFont.Medium, text)
76 local color = FrameworkZ.Notifications.Colors[type]
77 local x = getCore():getScreenWidth() - textWidth - padding - margin * 2
78 local y = padding
79 local width = textWidth + margin * 2
80 local height = textHeight + margin * 2
81
82 local o = {}
83
84 o = ISPanel:new(getCore():getScreenWidth(), y, width, height)
85 setmetatable(o, self)
87 o.backgroundColor = {r = color.r, g = color.g, b = color.b, a = color.a}
88 o.borderColor = {r=1, g=1, b=1, a=color.a}
89 o.moveWithMouse = false
90 o.keepOnScreen = false
91 o.text = text
92 o.duration = duration
93 o.playerObject = playerObject
94 o.x2 = x
95 o.y2 = y
96 o.width2 = width
97 o.height2 = height
98 o.originalAlpha = color.a
99
100 return o
101end
102
void local y()
void self uiHelper()
void local x()
void FrameworkZ DollarFormats __index()
void local height()
void local width
void type()
void self self
Definition MainMenu.lua:89
void self hasExpired()
void FrameworkZ UI Notification()
void processingNotification backgroundColor a()
void processingNotification hasFullyExpired()
void notification isExpiring()
void local textHeight()
void local getTextManager()
void button onMouseMove()
void button onMouseMoveOutside()
void button backgroundColor()
void local color()
Contains all of the User Interfaces for FrameworkZ.