Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SimpleWarningOverlayComponent.c
Go to the documentation of this file.
1/*
2 Component that takes care of displaying error states on tiles. Includes a darkening background, different text visualization modes, and the main icon is a button that will enlarge on mouse hover
3 Since it is meant to either be non-interactable or to be part of tiles, it is not focusable: the menu should provide a gamepad alternative to clicking the icon button.
4*/
5//------------------------------------------------------------------------------------------------
7{
8 [Attribute("1")]
9 protected bool m_bShowTextBackground;
10
11 [Attribute("-10")]
13
14 [Attribute(UIColors.GetColorAttribute(UIColors.WARNING_DISABLED))]
15 protected ref Color m_NakedTextColor;
16
17 [Attribute("1")]
19
20 [Attribute("1")]
21 protected bool m_bShowIconGlow;
22
23 [Attribute("0")]
24 protected bool m_bEnableIconButton;
25
26 [Attribute("86")]
27 protected float m_fIconSize;
28
29 [Attribute("1.1")]
31
32 [Attribute("0 0 0")]
34
35 [Attribute("0")]
36 protected bool m_bBlurBackground;
37
45
46 protected SCR_ModularButtonComponent m_WarningIconButton;
47
49
50 //------------------------------------------------------------------------------------------------
51 override void HandlerAttached(Widget w)
52 {
53 // Needed before super call for SetWarning()
54 m_wWarningImageGlow = ImageWidget.Cast(w.FindAnyWidget("WarningImageGlow"));
57
58 super.HandlerAttached(w);
59
60 m_wTextBackground = SmartPanelWidget.Cast(w.FindAnyWidget("WarningTextBackground"));
63
64 m_wWarningOuterBackground = ImageWidget.Cast(w.FindAnyWidget("WarningOuterBackground"));
67
68 m_wWarningOuterBlur = BlurWidget.Cast(w.FindAnyWidget("WarningOuterBlur"));
71
72 // Adjust text padding
73 m_wWarningTextSize = SizeLayoutWidget.Cast(w.FindAnyWidget("WarningTextSize"));
75 {
77 {
79 AlignableSlot.SetPadding(m_wWarning, 0, 0, 0, 0);
80 }
81 }
82
83 m_wWarningVerticalLayout = w.FindAnyWidget("WarningVerticalLayout");
86
87 m_wWarningImageOverlay = w.FindAnyWidget("WarningImageOverlay");
90
91 ButtonWidget warningIconButton = ButtonWidget.Cast(w.FindAnyWidget("WarningIconButton"));
92 if (warningIconButton)
93 m_WarningIconButton = SCR_ModularButtonComponent.FindComponent(warningIconButton);
94
96 {
97 SCR_ButtonEffectSize effect = SCR_ButtonEffectSize.Cast(m_WarningIconButton.FindEffect("ButtonSize"));
98 if (effect)
99 {
101
102 effect.m_vDefault = size;
104
105 m_WarningIconButton.InvokeAllEnabledEffects(true);
106
108 }
109 }
110
112 }
113
114 //------------------------------------------------------------------------------------------------
115 override void ResetWarningColor()
116 {
117 Color textColor = m_TextColor;
119 textColor = m_NakedTextColor;
120
121 SetWarningColor(m_Color, textColor);
122 }
123
124 //------------------------------------------------------------------------------------------------
125 override void SetWarning(string text, string iconName, ResourceName imageset = string.Empty)
126 {
127 super.SetWarning(text, iconName, imageset);
128
129 // TODO: glow for different imagesets
130 if (m_wWarningImageGlow && !iconName.IsEmpty() && imageset == UIConstants.ICONS_IMAGE_SET)
131 m_wWarningImageGlow.LoadImageFromSet(0, UIConstants.ICONS_GLOW_IMAGE_SET, iconName);
132 }
133
134 //------------------------------------------------------------------------------------------------
136 {
138 if (handler)
139 return SCR_SimpleWarningOverlayComponent.Cast(handler);
140
141 return null;
142 }
143
144 //------------------------------------------------------------------------------------------------
146 {
148 }
149
150 //------------------------------------------------------------------------------------------------
152 {
153 m_OnWarningIconButtonClicked.Invoke(this);
154 }
155
156 //------------------------------------------------------------------------------------------------
157 void SetIconButtonEnabled(bool enabled)
158 {
160 return;
161
162 float safeSize = m_fIconSize;
163 float padding;
164
165 if (enabled)
166 {
167 // When the icon button is enabled, we need to account for it's on hover enlargement animation
169 padding = (m_fIconSize - safeSize) / 2;
170 }
171
172 LayoutSlot.SetPadding(m_wWarningImageSize, 0, padding, 0, padding);
173
174 m_wWarningImageSize.SetWidthOverride(safeSize);
175 m_wWarningImageSize.SetHeightOverride(safeSize);
176
177 m_WarningIconButton.SetEnabled(enabled);
178 }
179
180 //------------------------------------------------------------------------------------------------
181 void SetBlurUnderneath(bool blur)
182 {
184 m_wWarningOuterBlur.SetVisible(blur);
185 }
186
187 //------------------------------------------------------------------------------------------------
192}
int size
ScriptInvokerBase< ScriptInvokerScriptedWidgetComponentMethod > ScriptInvokerScriptedWidgetComponent
Definition Color.c:13
void SetWarningColor(Color color, Color textColor)
ScriptInvokerScriptedWidgetComponent GetOnWarningIconButtonClicked()
static override SCR_SimpleWarningOverlayComponent FindComponent(notnull Widget w)
ref ScriptInvokerScriptedWidgetComponent m_OnWarningIconButtonClicked
override void SetWarning(string text, string iconName, ResourceName imageset=string.Empty)
static override SCR_SimpleWarningOverlayComponent FindComponentInHierarchy(notnull Widget root)
SCR_FieldOfViewSettings Attribute