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_NearbyContextWidgetComponentInteract.c
Go to the documentation of this file.
1
class
SCR_NearbyContextWidgetComponentInteract
:
SCR_ScriptedWidgetComponent
2
{
3
protected
ref
SCR_ContextBasicInteractionBlipWidgets
m_Widgets
=
new
SCR_ContextBasicInteractionBlipWidgets
();
4
5
protected
const
float
ENABLED_NEARBY_INTERACTION_GLOW_OPACITY
= 0.6;
6
protected
const
float
DISABLED_NEARBY_INTERACTION_OPACITY
= 0.4;
7
8
protected
BaseUserAction
m_FirstAction
;
9
10
// Invokes when a new Context is assigned to this Widget
11
// Can be used to detect if this Widget is not assigned to the needed context anymore
12
protected
ref
ScriptInvokerVoid
m_OnContextAssigned
;
13
protected
ref
UserActionContext
m_AssignedContext
;
14
16
protected
ref
map<SCR_ENearbyInteractionContextColors, ref SCR_NearbyContextColorsComponentInteract>
m_mCachedActionColors
;
17
18
protected
Color
m_IconColor
;
19
protected
Color
m_GlowColor
;
20
protected
Color
m_BackgroundColor
;
21
22
//------------------------------------------------------------------------------------------------
23
override
void
HandlerAttached
(
Widget
w)
24
{
25
super.HandlerAttached(w);
26
27
m_Widgets
.Init(w);
28
}
29
30
//------------------------------------------------------------------------------------------------
35
void
OnAssigned
(
SCR_ActionContextUIInfo
info,
UserActionContext
context)
36
{
37
m_AssignedContext
= context;
38
39
array<BaseUserAction> allActions = {};
40
context.GetActionsList(allActions);
41
42
if
(!allActions.IsEmpty())
43
m_FirstAction
= allActions[0];
44
45
if
(
m_OnContextAssigned
)
46
m_OnContextAssigned
.Invoke();
47
48
if
(info)
49
info.
OnWidgetAssigned
(
m_wRoot
);
50
51
SetIconFromAction
(info);
52
}
53
54
//------------------------------------------------------------------------------------------------
59
void
OnAssigned
(
SCR_ActionUIInfo
info,
BaseUserAction
context)
60
{
61
m_FirstAction
= context;
62
63
if
(
m_OnContextAssigned
)
64
m_OnContextAssigned
.Invoke();
65
66
SetIconFromAction
(info);
67
}
68
69
//------------------------------------------------------------------------------------------------
70
bool
HasColorData
()
71
{
72
return
m_mCachedActionColors
!= null;
73
}
74
75
//------------------------------------------------------------------------------------------------
76
void
SetColorsData
(
map<SCR_ENearbyInteractionContextColors, ref SCR_NearbyContextColorsComponentInteract>
cachedActionColors)
77
{
78
m_mCachedActionColors
= cachedActionColors;
79
}
80
81
//------------------------------------------------------------------------------------------------
82
void
UpdateColors
(
UserActionContext
ctx,
SCR_ENearbyInteractionContextColors
nearbyColorState =
UIConstants
.NEARBY_INTERACTION_DEFAULT_STATE)
83
{
84
bool
showOuterBackground;
85
array<BaseUserAction> outActions = {};
86
87
if
(ctx.GetActionsList(outActions) > 0)
88
{
89
foreach
(
BaseUserAction
userAct: outActions)
90
{
91
if
(
IsHealingAction
(userAct, showOuterBackground, nearbyColorState))
92
break
;
93
}
94
}
95
96
SCR_NearbyContextColorsComponentInteract nearbyColors;
97
if
(
m_mCachedActionColors
.Find(nearbyColorState, nearbyColors))
98
SetColors
(nearbyColors, showOuterBackground);
99
}
100
101
//------------------------------------------------------------------------------------------------
102
void
UpdateColors
(
BaseUserAction
userAct,
SCR_ENearbyInteractionContextColors
nearbyColorState =
UIConstants
.NEARBY_INTERACTION_DEFAULT_STATE)
103
{
104
bool
showOuterBackground;
105
106
IsHealingAction
(userAct, showOuterBackground, nearbyColorState);
107
108
SCR_NearbyContextColorsComponentInteract nearbyColors;
109
if
(
m_mCachedActionColors
.Find(nearbyColorState, nearbyColors))
110
SetColors
(nearbyColors, showOuterBackground);
111
}
112
113
//------------------------------------------------------------------------------------------------
114
static
bool
IsHealingAction
(
BaseUserAction
userAct)
115
{
116
bool
showOuterBackground;
117
int
nearbyColorState;
118
return
IsHealingAction
(userAct, showOuterBackground, nearbyColorState);
119
}
120
121
//------------------------------------------------------------------------------------------------
122
static
bool
IsHealingAction
(
BaseUserAction
userAct, out
bool
showOuterBackground, out
int
nearbyColorState)
123
{
124
SCR_BaseDamageHealSupportStationAction
supportHealAction =
SCR_BaseDamageHealSupportStationAction
.Cast(userAct);
125
if
(!supportHealAction)
126
return
false
;
127
128
nearbyColorState = supportHealAction.
GetHealthStatus
();
129
SCR_HealSupportStationAction
medAction =
SCR_HealSupportStationAction
.Cast(userAct);
130
if
(medAction)
131
showOuterBackground =
true
;
132
133
return
true
;
134
}
135
136
//------------------------------------------------------------------------------------------------
139
protected
void
SetIconFromAction
(
SCR_ActionUIInfo
info)
140
{
141
if
(
m_FirstAction
)
142
{
143
SCR_ActionUIInfo
actionUIInfo =
SCR_ActionUIInfo
.Cast(
m_FirstAction
.GetUIInfo());
144
if
(actionUIInfo && actionUIInfo.
SetIconTo
(
m_Widgets
.m_wIcon,
m_Widgets
.m_wIconGlow))
145
return
;
146
}
147
148
if
(info && info.
SetIconTo
(
m_Widgets
.m_wIcon,
m_Widgets
.m_wIconGlow))
149
return
;
150
151
m_Widgets
.m_wIcon.LoadImageFromSet(0,
UIConstants
.ICONS_IMAGE_SET,
UIConstants
.ICON_INTERACT_DEFAULT);
152
m_Widgets
.m_wIconGlow.LoadImageFromSet(0,
UIConstants
.ICONS_GLOW_IMAGE_SET,
UIConstants
.ICON_INTERACT_DEFAULT);
153
}
154
155
//------------------------------------------------------------------------------------------------
159
void
SetColors
(notnull SCR_NearbyContextColorsComponentInteract colorset,
bool
showOuterBackground)
160
{
161
m_IconColor
= colorset.m_IconColor;
162
m_GlowColor
= colorset.m_IconGlowColor;
163
m_BackgroundColor
= colorset.m_BackgroundColor;
164
165
m_Widgets
.m_wIcon.SetColor(
m_IconColor
);
166
m_Widgets
.m_wIconGlow.SetColor(
m_GlowColor
);
167
168
m_Widgets
.m_wBackground.SetColor(
m_BackgroundColor
);
169
m_Widgets
.m_wBackgroundOuter.SetColor(colorset.m_OuterBackgroundColor);
170
171
m_Widgets
.m_wBackgroundShadowOuter.SetColor(colorset.m_OuterBackgroundColor);
172
m_Widgets
.m_wBackgroundShadowInner.SetColor(colorset.m_OuterBackgroundColor);
173
174
m_Widgets
.m_wBackgroundShadowOuter.SetVisible(showOuterBackground);
175
m_Widgets
.m_wBackgroundShadowInner.SetVisible(showOuterBackground);
176
m_Widgets
.m_wBackgroundOuter.SetVisible(showOuterBackground);
177
}
178
179
//------------------------------------------------------------------------------------------------
182
void
ChangeVisibility
(
bool
isInLineOfSight)
183
{
184
if
(isInLineOfSight)
185
{
186
m_Widgets
.m_wOverlayBackground.SetOpacity(
UIConstants
.ENABLED_WIDGET_OPACITY);
187
m_Widgets
.m_wIconGlow.SetOpacity(
UIConstants
.DISABLED_WIDGET_OPACITY);
188
m_Widgets
.m_wIcon.SetOpacity(
UIConstants
.ENABLED_WIDGET_OPACITY);
189
190
m_Widgets
.m_wIcon.SetColor(
m_IconColor
);
191
m_Widgets
.m_wIconGlow.SetColor(
m_GlowColor
);
192
}
193
else
194
{
195
m_Widgets
.m_wOverlayBackground.SetOpacity(
UIConstants
.DISABLED_WIDGET_OPACITY);
196
m_Widgets
.m_wIconGlow.SetOpacity(
ENABLED_NEARBY_INTERACTION_GLOW_OPACITY
);
197
m_Widgets
.m_wIcon.SetOpacity(
DISABLED_NEARBY_INTERACTION_OPACITY
);
198
199
m_Widgets
.m_wIcon.SetColor(
Color
.Black);
200
m_Widgets
.m_wIconGlow.SetColor(
m_IconColor
);
201
}
202
}
203
204
//------------------------------------------------------------------------------------------------
206
UserActionContext
GetAssignedContext
()
207
{
208
return
m_AssignedContext
;
209
}
210
211
//------------------------------------------------------------------------------------------------
212
ScriptInvokerVoid
GetOnContextAssigned
()
213
{
214
if
(!
m_OnContextAssigned
)
215
m_OnContextAssigned
=
new
ScriptInvokerVoid
();
216
217
return
m_OnContextAssigned
;
218
}
219
}
SCR_ENearbyInteractionContextColors
SCR_ENearbyInteractionContextColors
Definition
SCR_NearbyContextColorsComponentInteract.c:2
ScriptInvokerVoid
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
Definition
SCR_ScriptInvokerHelper.c:9
BaseUserAction
Definition
BaseUserAction.c:13
Color
Definition
Color.c:13
SCR_ActionContextUIInfo
Definition
SCR_ActionContextUIInfo.c:2
SCR_ActionContextUIInfo::OnWidgetAssigned
void OnWidgetAssigned(Widget widget)
Definition
SCR_ActionContextUIInfo.c:23
SCR_ActionUIInfo
Definition
SCR_ActionUIInfo.c:2
SCR_ActionUIInfo::SetIconTo
bool SetIconTo(ImageWidget imageWidget, ImageWidget glowWidget=null)
Definition
SCR_ActionUIInfo.c:17
SCR_BaseDamageHealSupportStationAction
Allows healing of action owner (not user).
Definition
SCR_BaseDamageHealSupportStationAction.c:3
SCR_BaseDamageHealSupportStationAction::GetHealthStatus
SCR_ENearbyInteractionContextColors GetHealthStatus()
return the Health code color for nearby interactions
Definition
SCR_BaseDamageHealSupportStationAction.c:84
SCR_ContextBasicInteractionBlipWidgets
Definition
SCR_ContextBasicInteractionBlipWidgets.c:4
SCR_HealSupportStationAction
Definition
SCR_HealSupportStationAction.c:2
SCR_NearbyContextWidgetComponentInteract
Definition
SCR_NearbyContextWidgetComponentInteract.c:2
SCR_NearbyContextWidgetComponentInteract::m_GlowColor
Color m_GlowColor
Definition
SCR_NearbyContextWidgetComponentInteract.c:19
SCR_NearbyContextWidgetComponentInteract::m_AssignedContext
ref UserActionContext m_AssignedContext
Definition
SCR_NearbyContextWidgetComponentInteract.c:13
SCR_NearbyContextWidgetComponentInteract::DISABLED_NEARBY_INTERACTION_OPACITY
const float DISABLED_NEARBY_INTERACTION_OPACITY
Definition
SCR_NearbyContextWidgetComponentInteract.c:6
SCR_NearbyContextWidgetComponentInteract::ENABLED_NEARBY_INTERACTION_GLOW_OPACITY
const float ENABLED_NEARBY_INTERACTION_GLOW_OPACITY
Definition
SCR_NearbyContextWidgetComponentInteract.c:5
SCR_NearbyContextWidgetComponentInteract::m_mCachedActionColors
ref map< SCR_ENearbyInteractionContextColors, ref SCR_NearbyContextColorsComponentInteract > m_mCachedActionColors
Holds all the different cached id with the enum as key.
Definition
SCR_NearbyContextWidgetComponentInteract.c:16
SCR_NearbyContextWidgetComponentInteract::m_Widgets
ref SCR_ContextBasicInteractionBlipWidgets m_Widgets
Definition
SCR_NearbyContextWidgetComponentInteract.c:3
SCR_NearbyContextWidgetComponentInteract::SetColorsData
void SetColorsData(map< SCR_ENearbyInteractionContextColors, ref SCR_NearbyContextColorsComponentInteract > cachedActionColors)
Definition
SCR_NearbyContextWidgetComponentInteract.c:76
SCR_NearbyContextWidgetComponentInteract::m_OnContextAssigned
ref ScriptInvokerVoid m_OnContextAssigned
Definition
SCR_NearbyContextWidgetComponentInteract.c:12
SCR_NearbyContextWidgetComponentInteract::ChangeVisibility
void ChangeVisibility(bool isInLineOfSight)
Definition
SCR_NearbyContextWidgetComponentInteract.c:182
SCR_NearbyContextWidgetComponentInteract::SetIconFromAction
void SetIconFromAction(SCR_ActionUIInfo info)
Definition
SCR_NearbyContextWidgetComponentInteract.c:139
SCR_NearbyContextWidgetComponentInteract::IsHealingAction
static bool IsHealingAction(BaseUserAction userAct, out bool showOuterBackground, out int nearbyColorState)
Definition
SCR_NearbyContextWidgetComponentInteract.c:122
SCR_NearbyContextWidgetComponentInteract::OnAssigned
void OnAssigned(SCR_ActionUIInfo info, BaseUserAction context)
Definition
SCR_NearbyContextWidgetComponentInteract.c:59
SCR_NearbyContextWidgetComponentInteract::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_NearbyContextWidgetComponentInteract.c:23
SCR_NearbyContextWidgetComponentInteract::m_BackgroundColor
Color m_BackgroundColor
Definition
SCR_NearbyContextWidgetComponentInteract.c:20
SCR_NearbyContextWidgetComponentInteract::UpdateColors
void UpdateColors(BaseUserAction userAct, SCR_ENearbyInteractionContextColors nearbyColorState=UIConstants.NEARBY_INTERACTION_DEFAULT_STATE)
Definition
SCR_NearbyContextWidgetComponentInteract.c:102
SCR_NearbyContextWidgetComponentInteract::GetOnContextAssigned
ScriptInvokerVoid GetOnContextAssigned()
Definition
SCR_NearbyContextWidgetComponentInteract.c:212
SCR_NearbyContextWidgetComponentInteract::UpdateColors
void UpdateColors(UserActionContext ctx, SCR_ENearbyInteractionContextColors nearbyColorState=UIConstants.NEARBY_INTERACTION_DEFAULT_STATE)
Definition
SCR_NearbyContextWidgetComponentInteract.c:82
SCR_NearbyContextWidgetComponentInteract::IsHealingAction
static bool IsHealingAction(BaseUserAction userAct)
Definition
SCR_NearbyContextWidgetComponentInteract.c:114
SCR_NearbyContextWidgetComponentInteract::m_IconColor
Color m_IconColor
Definition
SCR_NearbyContextWidgetComponentInteract.c:18
SCR_NearbyContextWidgetComponentInteract::GetAssignedContext
UserActionContext GetAssignedContext()
Get the context that currently uses this Widget.
Definition
SCR_NearbyContextWidgetComponentInteract.c:206
SCR_NearbyContextWidgetComponentInteract::HasColorData
bool HasColorData()
Definition
SCR_NearbyContextWidgetComponentInteract.c:70
SCR_NearbyContextWidgetComponentInteract::SetColors
void SetColors(notnull SCR_NearbyContextColorsComponentInteract colorset, bool showOuterBackground)
Definition
SCR_NearbyContextWidgetComponentInteract.c:159
SCR_NearbyContextWidgetComponentInteract::OnAssigned
void OnAssigned(SCR_ActionContextUIInfo info, UserActionContext context)
Definition
SCR_NearbyContextWidgetComponentInteract.c:35
SCR_NearbyContextWidgetComponentInteract::m_FirstAction
BaseUserAction m_FirstAction
Definition
SCR_NearbyContextWidgetComponentInteract.c:8
SCR_ScriptedWidgetComponent
Definition
SCR_ScriptedWidgetComponent.c:8
SCR_ScriptedWidgetComponent::m_wRoot
Widget m_wRoot
Definition
SCR_ScriptedWidgetComponent.c:9
UIConstants
Definition
Constants.c:151
UserActionContext
Definition
UserActionContext.c:16
Widget
Definition
Widget.c:13
map
Definition
Types.c:486
scripts
Game
UI
HUD
SCR_NearbyContextWidgetComponentInteract.c
Generated by
1.17.0