9 protected bool m_bShowTextBackground;
12 protected int m_iNakedTextTopPadding;
15 protected ref Color m_NakedTextColor;
18 protected bool m_bShowDarkeningBackground;
21 protected bool m_bShowIconGlow;
24 protected bool m_bEnableIconButton;
27 protected float m_fIconSize;
30 protected float m_fIconSizeHoveredMultiplier;
33 protected vector m_vWarningPositionOffset;
35 protected SmartPanelWidget m_wTextBackground;
36 protected ImageWidget m_wWarningImageGlow;
37 protected ImageWidget m_wWarningOuterBackground;
38 protected SizeLayoutWidget m_wWarningTextSize;
39 protected Widget m_wWarningImageOverlay;
40 protected Widget m_wWarningVerticalLayout;
42 protected SCR_ModularButtonComponent m_WarningIconButton;
47 override void HandlerAttached(Widget w)
50 m_wWarningImageGlow = ImageWidget.Cast(w.FindAnyWidget(
"WarningImageGlow"));
51 if (m_wWarningImageGlow)
52 m_wWarningImageGlow.SetVisible(m_bShowIconGlow);
54 super.HandlerAttached(w);
56 m_wTextBackground = SmartPanelWidget.Cast(w.FindAnyWidget(
"WarningTextBackground"));
57 if (m_wTextBackground)
58 m_wTextBackground.SetVisible(m_bShowTextBackground);
60 m_wWarningOuterBackground = ImageWidget.Cast(w.FindAnyWidget(
"WarningOuterBackground"));
61 if (m_wWarningOuterBackground)
62 m_wWarningOuterBackground.SetVisible(m_bShowDarkeningBackground);
65 m_wWarningTextSize = SizeLayoutWidget.Cast(w.FindAnyWidget(
"WarningTextSize"));
66 if (m_wWarningTextSize)
68 if (m_wWarning && !m_bShowTextBackground)
70 AlignableSlot.SetPadding(m_wWarningTextSize, 0, m_iNakedTextTopPadding, 0, 0);
71 AlignableSlot.SetPadding(m_wWarning, 0, 0, 0, 0);
75 m_wWarningVerticalLayout = w.FindAnyWidget(
"WarningVerticalLayout");
76 if (m_wWarningVerticalLayout)
77 FrameSlot.SetPos(m_wWarningVerticalLayout, m_vWarningPositionOffset[0], m_vWarningPositionOffset[1]);
79 m_wWarningImageOverlay = w.FindAnyWidget(
"WarningImageOverlay");
80 if (m_wWarningImageOverlay)
81 FrameSlot.SetSize(m_wWarningImageOverlay, m_fIconSize, m_fIconSize);
83 ButtonWidget warningIconButton = ButtonWidget.Cast(w.FindAnyWidget(
"WarningIconButton"));
84 if (warningIconButton)
85 m_WarningIconButton = SCR_ModularButtonComponent.FindComponent(warningIconButton);
87 if (m_WarningIconButton)
92 vector size = {m_fIconSize, m_fIconSize, 0};
94 effect.m_vDefault = size;
95 effect.m_vHovered = size * m_fIconSizeHoveredMultiplier;
97 m_WarningIconButton.InvokeAllEnabledEffects(
false);
99 m_WarningIconButton.m_OnClicked.Insert(OnWarningIconButtonClicked);
103 SetIconButtonEnabled(m_bEnableIconButton);
107 override void ResetWarningColor()
109 Color textColor = m_TextColor;
110 if (!m_bShowTextBackground)
111 textColor = m_NakedTextColor;
113 SetWarningColor(
m_Color, textColor);
117 override void SetWarning(
string text,
string iconName)
119 super.SetWarning(text, iconName);
121 if (m_wWarningImageGlow && !iconName.IsEmpty())
122 m_wWarningImageGlow.LoadImageFromSet(0,
UIConstants.ICONS_IMAGE_SET, iconName);
142 protected void OnWarningIconButtonClicked()
144 m_OnWarningIconButtonClicked.Invoke(
this);
148 void SetIconButtonEnabled(
bool enabled)
150 if (!m_wWarningImageSize || !m_WarningIconButton)
153 float safeSize = m_fIconSize;
159 safeSize *= m_fIconSizeHoveredMultiplier;
160 padding = (m_fIconSize - safeSize) / 2;
163 LayoutSlot.SetPadding(m_wWarningImageSize, 0, padding, 0, padding);
165 m_wWarningImageSize.SetWidthOverride(safeSize);
166 m_wWarningImageSize.SetHeightOverride(safeSize);
168 m_WarningIconButton.SetEnabled(enabled);
174 return m_OnWarningIconButtonClicked;