Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_NearbyContextWidgetComponentInteract.c
Go to the documentation of this file.
2{
4
5 protected const float ENABLED_NEARBY_INTERACTION_GLOW_OPACITY = 0.6;
6 protected const float DISABLED_NEARBY_INTERACTION_OPACITY = 0.4;
7
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
14
17
18 protected Color m_IconColor;
19 protected Color m_GlowColor;
21
22 //------------------------------------------------------------------------------------------------
23 override void HandlerAttached(Widget w)
24 {
25 super.HandlerAttached(w);
26
27 m_Widgets.Init(w);
28 }
29
30 //------------------------------------------------------------------------------------------------
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
46 m_OnContextAssigned.Invoke();
47
48 if (info)
50
52 }
53
54 //------------------------------------------------------------------------------------------------
60 {
61 m_FirstAction = context;
62
64 m_OnContextAssigned.Invoke();
65
67 }
68
69 //------------------------------------------------------------------------------------------------
71 {
72 return m_mCachedActionColors != null;
73 }
74
75 //------------------------------------------------------------------------------------------------
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 {
125 if (!supportHealAction)
126 return false;
127
128 nearbyColorState = supportHealAction.GetHealthStatus();
130 if (medAction)
131 showOuterBackground = true;
132
133 return true;
134 }
135
136 //------------------------------------------------------------------------------------------------
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);
198
199 m_Widgets.m_wIcon.SetColor(Color.Black);
200 m_Widgets.m_wIconGlow.SetColor(m_IconColor);
201 }
202 }
203
204 //------------------------------------------------------------------------------------------------
210
211 //------------------------------------------------------------------------------------------------
219}
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
Definition Color.c:13
void OnWidgetAssigned(Widget widget)
bool SetIconTo(ImageWidget imageWidget, ImageWidget glowWidget=null)
SCR_ENearbyInteractionContextColors GetHealthStatus()
return the Health code color for nearby interactions
ref map< SCR_ENearbyInteractionContextColors, ref SCR_NearbyContextColorsComponentInteract > m_mCachedActionColors
Holds all the different cached id with the enum as key.
void SetColorsData(map< SCR_ENearbyInteractionContextColors, ref SCR_NearbyContextColorsComponentInteract > cachedActionColors)
static bool IsHealingAction(BaseUserAction userAct, out bool showOuterBackground, out int nearbyColorState)
void OnAssigned(SCR_ActionUIInfo info, BaseUserAction context)
void UpdateColors(BaseUserAction userAct, SCR_ENearbyInteractionContextColors nearbyColorState=UIConstants.NEARBY_INTERACTION_DEFAULT_STATE)
void UpdateColors(UserActionContext ctx, SCR_ENearbyInteractionContextColors nearbyColorState=UIConstants.NEARBY_INTERACTION_DEFAULT_STATE)
UserActionContext GetAssignedContext()
Get the context that currently uses this Widget.
void SetColors(notnull SCR_NearbyContextColorsComponentInteract colorset, bool showOuterBackground)
void OnAssigned(SCR_ActionContextUIInfo info, UserActionContext context)
Definition Types.c:486