Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SimpleWarningComponent.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
3 {
4  [Attribute("#AR-Account_LoginTimeout")]
5  protected string m_sWarning;
6 
7  [Attribute("warning")]
8  protected string m_sIconName;
9 
10  [Attribute(UIColors.GetColorAttribute(UIColors.WARNING))]
11  protected ref Color m_Color;
12 
13  [Attribute(UIColors.GetColorAttribute(UIColors.WARNING))]
14  protected ref Color m_TextColor;
15 
16  protected TextWidget m_wWarning;
17  protected Widget m_wWarningWrapper;
18  protected ImageWidget m_wWarningImage;
19  protected SizeLayoutWidget m_wWarningImageSize;
20 
21  //------------------------------------------------------------------------------------------------
22  override void HandlerAttached(Widget w)
23  {
24  super.HandlerAttached(w);
25 
26  m_wWarning = TextWidget.Cast(w.FindAnyWidget("WarningText"));
27  m_wWarningImage = ImageWidget.Cast(w.FindAnyWidget("WarningImage"));
28  m_wWarningImageSize = SizeLayoutWidget.Cast(w.FindAnyWidget("WarningImageSize"));
29  m_wWarningWrapper = w.FindAnyWidget("WarningWrapper");
30  ResetWarning();
31  ResetWarningColor();
32  }
33 
34  //------------------------------------------------------------------------------------------------
35  void ResetWarning()
36  {
37  SetWarning(m_sWarning, m_sIconName);
38  }
39 
40  //------------------------------------------------------------------------------------------------
41  void ResetWarningColor()
42  {
43  SetWarningColor(m_Color, m_TextColor);
44  }
45 
46  //------------------------------------------------------------------------------------------------
47  void SetWarning(string text, string iconName)
48  {
49  if (m_wWarning)
50  m_wWarning.SetText(text);
51 
52  if (m_wWarningImage && !iconName.IsEmpty())
53  m_wWarningImage.LoadImageFromSet(0, UIConstants.ICONS_IMAGE_SET, iconName);
54  }
55 
56  //------------------------------------------------------------------------------------------------
57  void SetWarningColor(Color color, Color textColor)
58  {
59  if (m_wWarning)
60  m_wWarning.SetColor(textColor);
61 
62  if (m_wWarningImage)
63  m_wWarningImage.SetColor(color);
64  }
65 
66  //------------------------------------------------------------------------------------------------
67  void SetWarningVisible(bool visible, bool preserveSpace = true)
68  {
69  m_wRoot.SetVisible(visible || !visible && preserveSpace);
70 
71  if (m_wWarningWrapper)
72  m_wWarningWrapper.SetVisible(visible);
73  }
74 
75  //------------------------------------------------------------------------------------------------
76  void SetIconVisible(bool visible, bool preserveSpace = false)
77  {
78  if (m_wWarningImage)
79  m_wWarningImage.SetVisible(visible);
80 
81  if (m_wWarningImageSize)
82  m_wWarningImageSize.SetVisible(visible || !visible && preserveSpace);
83  }
84 
85  //------------------------------------------------------------------------------------------------
86  static SCR_SimpleWarningComponent FindComponentInHierarchy(notnull Widget root)
87  {
88  ScriptedWidgetEventHandler handler = SCR_WidgetTools.FindHandlerInChildren(root, SCR_SimpleWarningComponent);
89  if (handler)
90  return SCR_SimpleWarningComponent.Cast(handler);
91 
92  return null;
93  }
94 
95  //------------------------------------------------------------------------------------------------
96  static SCR_SimpleWarningComponent FindComponent(notnull Widget w)
97  {
98  return SCR_SimpleWarningComponent.Cast(w.FindHandler(SCR_SimpleWarningComponent));
99  }
100 }
SCR_WidgetTools
Definition: SCR_WidgetTools.c:1
SCR_SimpleWarningComponent
Definition: SCR_SimpleWarningComponent.c:2
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
UIConstants
Definition: Constants.c:130
Attribute
typedef Attribute
Post-process effect of scripted camera.
UIColors
Definition: Constants.c:16
m_Color
ref Color m_Color
Definition: SCR_GeneratorBaseEntity.c:3
SCR_ScriptedWidgetComponent
Definition: SCR_ScriptedWidgetComponent.c:7