Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_StickyNotificationUIComponent.c
Go to the documentation of this file.
2{
3 [Attribute("StickyNotificationMessage")]
4 protected string m_sTextName;
5
6 [Attribute("OptionalMessageLayout")]
8
9 //Reference
11 protected Widget m_Root;
13
14 [Attribute("1", desc: "Wether or not the notification message list shrinks if a new stick notification is added (and increases again on deactivate). Do not change in runtime unless you are certain the notification log knows this notification is not active!")]
16
17 protected bool m_bStickyNotificationActive = false;
18
19 protected TextWidget m_Text;
21
23
24 protected void SetStickyActive(bool newActive, bool fade = true)
25 {
26 if (newActive == m_bStickyNotificationActive)
27 {
28 //Still set visiblity
29 if (!fade)
30 SetVisible(newActive);
31
32 return;
33 }
34
36
38
39 if (fade)
40 Fade(newActive);
41 else
42 SetVisible(newActive);
43 }
44
45 //------------------------------------------------------------------------------------------------
50 {
52 }
53
54 //------------------------------------------------------------------------------------------------
62
63 //------------------------------------------------------------------------------------------------
71
72 //------------------------------------------------------------------------------------------------
73 protected void SetVisible(bool visible)
74 {
75 if (visible)
76 m_Root.SetOpacity(1);
77 else
78 m_Root.SetOpacity(0);
79
80 m_Root.SetVisible(visible);
81 }
82
83 //------------------------------------------------------------------------------------------------
84 protected void Fade(bool fadeIn)
85 {
86 if (fadeIn)
87 {
88 if (!m_FadeUIComponent.IsFadingIn())
89 m_FadeUIComponent.FadeIn(false);
90 }
91 else
92 {
93 if (!m_Root.IsVisible() || !m_FadeUIComponent.IsFadingOut())
94 m_FadeUIComponent.FadeOut(false);
95 }
96 }
97
98 //------------------------------------------------------------------------------------------------
99 protected void OnButton()
100 {
101 }
102
103 //------------------------------------------------------------------------------------------------
106 {
107 if (SCR_Global.IsEditMode() || !m_Root)
108 return;
109
110 m_NotificationsLog = notificationLog;
111
112 //Disable clicking on the UI
113 if (!m_NotificationsLog.HasNotificationInput())
114 {
115 m_Root.SetEnabled(false);
116 return;
117 }
118
119 SCR_EditorManagerEntity editorManager = notificationLog.GetEditorManager();
120 if (!editorManager)
121 return;
122
123 m_Root.SetEnabled(editorManager.IsOpened());
124 editorManager.GetOnOpened().Insert(EditorOpened);
125 editorManager.GetOnClosed().Insert(EditorClosed);
126 }
127
128 //------------------------------------------------------------------------------------------------
129 protected void OnDestroy()
130 {
131 }
132
133 //------------------------------------------------------------------------------------------------
134 protected void EditorOpened()
135 {
136 if (m_Root)
137 m_Root.SetEnabled(true);
138 }
139
140 //------------------------------------------------------------------------------------------------
141 protected void EditorClosed()
142 {
143 if (m_Root)
144 m_Root.SetEnabled(false);
145 }
146
147 //------------------------------------------------------------------------------------------------
148 override void HandlerAttached(Widget w)
149 {
150 if (SCR_Global.IsEditMode())
151 return;
152
153 m_Root = w;
156 Print("SCR_NotificationVotingInProgressUIComponent could not find SCR_FadeUIComponent! Make sure this component comes after the SCR_FadeUIComponent!", LogLevel.ERROR);
157
158 m_Text = TextWidget.Cast(w.FindAnyWidget(m_sTextName));
159 if (!m_Text)
160 Print("SCR_NotificationVotingInProgressUIComponent could not find m_Text!", LogLevel.ERROR);
161
163
164 ScriptInvoker onPressed = ButtonActionComponent.GetOnAction(w);
165 if (onPressed)
166 onPressed.Insert(OnButton);
167 }
168
169 //------------------------------------------------------------------------------------------------
170 override void HandlerDeattached(Widget w)
171 {
172 OnDestroy();
173
175 {
176 SCR_EditorManagerEntity editorManager = m_NotificationsLog.GetEditorManager();
177 if (editorManager)
178 {
179 editorManager.GetOnOpened().Remove(EditorOpened);
180 editorManager.GetOnClosed().Remove(EditorClosed);
181 }
182 }
183 }
184}
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Component to execute action when the button or its shortcut is pressed.
static bool IsEditMode()
Definition Functions.c:1566
void SetStickyActive(bool newActive, bool fade=true)
void OnInit(SCR_NotificationsLogComponent notificationLog)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134