Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AttributeDescriptionUIComponent.c
Go to the documentation of this file.
1 
3 class SCR_AttributeDescriptionUIComponent: ScriptedWidgetComponent
4 {
5  [Attribute("Content")]
6  protected string m_sContentTextName;
7 
8  [Attribute("Icon")]
9  protected string m_sIconName;
10 
11  [Attribute("Line")]
12  protected string m_sLineName;
13 
14  [Attribute("Background")]
15  protected string m_sBackgroundName;
16 
17  protected RichTextWidget m_ContentText;
18  protected ImageWidget m_Icon;
19  protected ImageWidget m_Line;
20  protected Widget m_Background;
21 
22  protected void SetAttributeDescription(SCR_EditorAttributeUIInfo uiInfo, string customContent = string.Empty, string param1 = string.Empty, string param2 = string.Empty, string param3 = string.Empty)
23  {
24  //Hide description
25  if (!uiInfo)
26  {
27  m_Background.SetVisible(false);
28  m_Icon.SetVisible(false);
29  m_ContentText.SetVisible(false);
30  m_Line.SetVisible(false);
31 
32  return;
33  }
34  else
35  {
36  m_Background.SetVisible(true);
37  m_ContentText.SetVisible(true);
38  m_Line.SetVisible(true);
39  }
40 
41  //Default Description
42  if (customContent.IsEmpty())
43  {
44  m_ContentText.SetTextFormat(uiInfo.GetDescription(), param1, param2, param3);
45 
46  if (uiInfo.GetIconPath().IsEmpty())
47  {
48  m_Icon.SetVisible(false);
49  }
50  else
51  {
52  uiInfo.SetIconTo(m_Icon);
53 
54  if (uiInfo.GetDescriptionIconColor())
55  m_Icon.SetColor(uiInfo.GetDescriptionIconColor());
56 
57  m_Icon.SetVisible(true);
58  }
59  }
60  //Custom description
61  else
62  {
63  m_ContentText.SetTextFormat(customContent, param1, param2, param3);
64 
65  if (uiInfo.GetIconPath().IsEmpty())
66  {
67  m_Icon.SetVisible(false);
68  }
69  else
70  {
71  uiInfo.SetIconTo(m_Icon);
72 
73  if (uiInfo.GetDescriptionIconColor())
74  m_Icon.SetColor(uiInfo.GetDescriptionIconColor());
75 
76  m_Icon.SetVisible(true);
77  }
78  }
79  }
80 
81  protected void OnCategoryChanged(ResourceName currentCategory)
82  {
83  if (GetGame().GetInputManager().IsUsingMouseAndKeyboard())
84  {
85  GetGame().GetCallqueue().CallLater(SetAttributeDescription, 1, false, null, string.Empty, string.Empty, string.Empty, string.Empty);
86  }
87  }
88 
89  override void HandlerAttached(Widget w)
90  {
91  SCR_AttributesManagerEditorComponent attributesManager = SCR_AttributesManagerEditorComponent.Cast(SCR_AttributesManagerEditorComponent.GetInstance(SCR_AttributesManagerEditorComponent));
92  if (!attributesManager)
93  return;
94 
95  m_ContentText = RichTextWidget.Cast(w.FindAnyWidget(m_sContentTextName));
96  m_Icon = ImageWidget.Cast(w.FindAnyWidget(m_sIconName));
97  m_Line = ImageWidget.Cast(w.FindAnyWidget(m_sLineName));
98 
99  if (!m_ContentText || !m_Icon)
100  return;
101 
102  m_Background = w.FindAnyWidget(m_sBackgroundName);
103 
104  //Hide desciption at start
105  SetAttributeDescription(null);
106 
107  attributesManager.GetOnAttributeDescriptionChanged().Insert(SetAttributeDescription);
108  }
109 
110  override void HandlerDeattached(Widget w)
111  {
112  SCR_AttributesManagerEditorComponent attributesManager = SCR_AttributesManagerEditorComponent.Cast(SCR_AttributesManagerEditorComponent.GetInstance(SCR_AttributesManagerEditorComponent));
113  if (!attributesManager || !m_ContentText || !m_Icon)
114  return;
115 
116  attributesManager.GetOnAttributeDescriptionChanged().Remove(SetAttributeDescription);
117  }
118 
119 };
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_EditorAttributeUIInfo
UIInfo used by editor attribute system.
Definition: SCR_EditorAttributeUIInfo.c:3
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_AttributeDescriptionUIComponent
Definition: SCR_AttributeDescriptionUIComponent.c:3
GetInputManager
protected InputManager GetInputManager()
Definition: SCR_BaseManualCameraComponent.c:65