Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_NewsTileComponent.c
Go to the documentation of this file.
2{
3 [Attribute("Title")]
4 string m_sTitleName;
5
6 [Attribute("Description")]
7 string m_sDescriptionName;
8
9 [Attribute("Image")]
10 string m_sImageName;
11
12 [Attribute("Author")]
13 string m_sAuthorName;
14
15 [Attribute("Date")]
16 string m_sDateName;
17
18 [Attribute("Footer")]
19 string m_sFooterName;
20
21 [Attribute("Unread")]
22 string m_sUnreadImageName;
23
24 [Attribute("Read")]
25 string m_sReadButtonName;
26
27 Widget m_wFooter;
28 Widget m_wUnreadImage;
29 TextWidget m_wTitle;
30 TextWidget m_wAuthor;
31 TextWidget m_wDate;
32 TextWidget m_wDescription;
33 ref SCR_NewsEntry m_Entry;
34
36
37 ref ScriptInvoker m_OnRead = new ScriptInvoker();
38
39 //------------------------------------------------------------------------------------------------
40 override void HandlerAttached(Widget w)
41 {
42 super.HandlerAttached(w);
43
44 m_wUnreadImage = w.FindAnyWidget(m_sUnreadImageName);
45 m_wTitle = TextWidget.Cast(w.FindAnyWidget(m_sTitleName));
46 m_wAuthor = TextWidget.Cast(w.FindAnyWidget(m_sAuthorName));
47 m_wDate = TextWidget.Cast(w.FindAnyWidget(m_sDateName));
48 m_wDescription = TextWidget.Cast(w.FindAnyWidget(m_sDescriptionName));
49 m_wFooter = w.FindAnyWidget(m_sFooterName);
50
51 if (!m_sReadButtonName.IsEmpty())
52 m_Read = SCR_InputButtonComponent.GetInputButtonComponent(m_sReadButtonName, w);
53
54 if (m_Read)
55 m_Read.m_OnActivated.Insert(OnRead);
56
57 if (!m_wFooter)
58 return;
59
60 m_wFooter.SetOpacity(0);
61 m_wFooter.SetEnabled(false);
62
65
67 }
68
69 //------------------------------------------------------------------------------------------------
70 override void HandlerDeattached(Widget w)
71 {
72 super.HandlerDeattached(w);
73
75 }
76
77 //------------------------------------------------------------------------------------------------
78 override bool OnFocus(Widget w, int x, int y)
79 {
80 if (m_wFooter)
81 {
82 m_wFooter.SetEnabled(true);
83 AnimateWidget.Opacity(m_wFooter, 1, m_fAnimationRate);
84 }
85
86 SetRead();
87
88 m_OnFocused.Invoke(this);
89 return super.OnFocus(w, x, y);
90 }
91
92 //------------------------------------------------------------------------------------------------
93 override bool OnFocusLost(Widget w, int x, int y)
94 {
95 if (m_wFooter)
96 {
97 AnimateWidget.Opacity(m_wFooter, 0, m_fAnimationRate);
98 m_wFooter.SetEnabled(false);
99 }
100
101 return super.OnFocusLost(w, x, y);
102 }
103
104 //------------------------------------------------------------------------------------------------
105 protected void OnCommStatusCheckFinished(SCR_ECommStatus status, float responseTime, float lastSuccessTime, float lastFailTime)
106 {
108 }
109
110 //------------------------------------------------------------------------------------------------
111 protected void UpdateConnectionButtons()
112 {
114 }
115
116 //------------------------------------------------------------------------------------------------
117 void SetRead()
118 {
119 if (!m_Entry || m_Entry.m_bRead)
120 return;
121
122 m_Entry.m_bRead = true;
123 if (m_wUnreadImage)
124 AnimateWidget.Opacity(m_wUnreadImage, 0, UIConstants.FADE_RATE_DEFAULT);
125 }
126
127 //------------------------------------------------------------------------------------------------
131 {
132 m_wRoot.SetOpacity(entry != null);
133 m_wRoot.SetEnabled(entry != null);
134
135 m_Entry = entry;
136 if (!entry)
137 return;
138
139 if (m_wTitle)
140 m_wTitle.SetText(entry.m_Item.Title());
141
142 if (m_wDescription)
143 m_wDescription.SetText(entry.m_Item.Excerpt());
144
145 if (m_wAuthor)
146 m_wAuthor.SetText(entry.m_Item.Slug());
147
148 if (m_wDate)
149 m_wDate.SetText(entry.m_Item.Date());
150
151 string imagePreview = entry.m_Item.Path();
152
153 if (m_wImage && !imagePreview.IsEmpty())
154 {
155 // Try to load image
156 bool loaded = m_wImage.LoadImageTexture(1, imagePreview, false, true);
157
158 // Set image 0 - Placeholder if load image failed
159 // Set image 1 - Downloaded image
160 m_wImage.SetImage(loaded);
161
162 // Refresh the size
163 int sx, sy;
164 m_wImage.GetImageSize(loaded, sx, sy);
165 m_wImage.SetSize(sx, sy);
166 }
167
168 if (m_wUnreadImage)
169 m_wUnreadImage.SetOpacity(!entry.m_bRead);
170 }
171
172 //------------------------------------------------------------------------------------------------
173 void OnRead()
174 {
175 SetRead();
176 m_OnRead.Invoke(this);
177 }
178}
SCR_ECommStatus
This class may become obsolete on BackendAPI update.
static WidgetAnimationOpacity Opacity(Widget widget, float targetValue, float speed, bool toggleVisibility=false)
static SCR_InputButtonComponent GetInputButtonComponent(string name, notnull Widget parent, bool searchAllChildren=true)
void OnCommStatusCheckFinished(SCR_ECommStatus status, float responseTime, float lastSuccessTime, float lastFailTime)
void ShowTile(SCR_NewsEntry entry)
static ScriptInvokerCommStatus GetOnCommStatusCheckFinished()
SCR_FieldOfViewSettings Attribute
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134