Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_NewsTileComponent.c
Go to the documentation of this file.
1
class
SCR_NewsTileComponent
:
SCR_TileBaseComponent
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
35
SCR_InputButtonComponent
m_Read;
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
63
SCR_ServicesStatusHelper
.
RefreshPing
();
64
SCR_ServicesStatusHelper
.
GetOnCommStatusCheckFinished
().Insert(
OnCommStatusCheckFinished
);
65
66
UpdateConnectionButtons
();
67
}
68
69
//------------------------------------------------------------------------------------------------
70
override
void
HandlerDeattached(
Widget
w)
71
{
72
super.HandlerDeattached(w);
73
74
SCR_ServicesStatusHelper
.
GetOnCommStatusCheckFinished
().Remove(
OnCommStatusCheckFinished
);
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
{
107
UpdateConnectionButtons
();
108
}
109
110
//------------------------------------------------------------------------------------------------
111
protected
void
UpdateConnectionButtons
()
112
{
113
SCR_ConnectionUICommon
.ForceConnectionButtonEnabled(m_Read,
SCR_ServicesStatusHelper
.
IsBackendConnectionAvailable
());
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
//------------------------------------------------------------------------------------------------
130
void
ShowTile
(
SCR_NewsEntry
entry)
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
SCR_ECommStatus
This class may become obsolete on BackendAPI update.
Definition
SCR_ServicesStatusHelper.c:3
AnimateWidget
Definition
AnimateWidget.c:3
AnimateWidget::Opacity
static WidgetAnimationOpacity Opacity(Widget widget, float targetValue, float speed, bool toggleVisibility=false)
Definition
AnimateWidget.c:167
SCR_ConnectionUICommon
Definition
SCR_ConnectionUICommon.c:2
SCR_InputButtonComponent
Definition
SCR_InputButtonComponent.c:2
SCR_InputButtonComponent::m_OnActivated
ref ScriptInvoker m_OnActivated
Definition
SCR_InputButtonComponent.c:153
SCR_InputButtonComponent::GetInputButtonComponent
static SCR_InputButtonComponent GetInputButtonComponent(string name, notnull Widget parent, bool searchAllChildren=true)
Definition
SCR_InputButtonComponent.c:1212
SCR_NewsEntry
Definition
SCR_NewsSubMenu.c:3
SCR_NewsTileComponent
Definition
SCR_NewsTileComponent.c:2
SCR_NewsTileComponent::OnRead
void OnRead()
Definition
SCR_NewsTileComponent.c:173
SCR_NewsTileComponent::OnCommStatusCheckFinished
void OnCommStatusCheckFinished(SCR_ECommStatus status, float responseTime, float lastSuccessTime, float lastFailTime)
Definition
SCR_NewsTileComponent.c:105
SCR_NewsTileComponent::UpdateConnectionButtons
void UpdateConnectionButtons()
Definition
SCR_NewsTileComponent.c:111
SCR_NewsTileComponent::ShowTile
void ShowTile(SCR_NewsEntry entry)
Definition
SCR_NewsTileComponent.c:130
SCR_NewsTileComponent::SetRead
void SetRead()
Definition
SCR_NewsTileComponent.c:117
SCR_ScriptedWidgetComponent::m_wRoot
Widget m_wRoot
Definition
SCR_ScriptedWidgetComponent.c:9
SCR_ServicesStatusHelper
Definition
SCR_ServicesStatusHelper.c:16
SCR_ServicesStatusHelper::IsBackendConnectionAvailable
static bool IsBackendConnectionAvailable()
Definition
SCR_ServicesStatusHelper.c:413
SCR_ServicesStatusHelper::GetOnCommStatusCheckFinished
static ScriptInvokerCommStatus GetOnCommStatusCheckFinished()
Definition
SCR_ServicesStatusHelper.c:422
SCR_ServicesStatusHelper::RefreshPing
static void RefreshPing()
Definition
SCR_ServicesStatusHelper.c:94
SCR_TileBaseComponent
Definition
SCR_TileBaseComponent.c:2
TextWidget
Definition
TextWidget.c:16
UIConstants
Definition
Constants.c:151
Widget
Definition
Widget.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
ScriptInvoker
ScriptInvokerBase< func > ScriptInvoker
Definition
tools.c:134
scripts
Game
UI
Components
MainMenu
SCR_NewsTileComponent.c
Generated by
1.17.0