Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DamageStateUIComponent.c
Go to the documentation of this file.
1 class SCR_DamageStateUIComponent : ScriptedWidgetComponent
2 {
3  [Attribute(desc: "Config to get visuals from", params: "conf class=SCR_DamageStateConfig")]
4  protected ref SCR_DamageStateConfig m_DamageStateConfig;
5 
6  [Attribute(desc: "If true will auto set icon, background and outline for the given type as well as colors")]
7  protected bool m_bAutoSetVisuals;
8 
9  [Attribute(desc: "Damage type of visuals. Will be set automatically m_bAutoSetVisuals = true. Will be ignored if custom is set", uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EDamageType))]
10  protected EDamageType m_eDamageType;
11 
12  [Attribute("Icon", desc: "Icon to set")]
13  protected string m_sIconName;
14 
15  [Attribute("Outline", desc: "Outline to set")]
16  protected string m_sOutlineName;
17 
18  [Attribute("Background", desc: "Background to set")]
19  protected string m_sBackgroundName;
20 
21  protected SCR_DamageStateUIInfo m_UiInfo;
22 
23  protected Widget m_wRoot;
24 
29  void SetVisuals(EDamageType damageType)
30  {
31  if (!m_DamageStateConfig)
32  return;
33 
34  m_eDamageType = damageType;
35 
36  SetVisuals(m_DamageStateConfig.GetUiInfo(damageType));
37  }
38 
43  void SetVisuals(SCR_DamageStateUIInfo uiInfo, int iconIndex = -1)
44  {
45  m_UiInfo = uiInfo;
46 
47  m_wRoot.SetVisible(m_UiInfo != null);
48 
49  if (!m_UiInfo)
50  return;
51 
52  ImageWidget icon = ImageWidget.Cast(m_wRoot.FindAnyWidget(m_sIconName));
53  ImageWidget outline = ImageWidget.Cast(m_wRoot.FindAnyWidget(m_sOutlineName));
54  ImageWidget background = ImageWidget.Cast(m_wRoot.FindAnyWidget(m_sBackgroundName));
55 
56  ResourceName image;
57  string quadName;
58 
59  if (icon)
60  {
61  icon.SetVisible(m_UiInfo.SetIconTo(icon, iconIndex));
62  icon.SetColor(m_UiInfo.GetColor());
63  }
64 
65  if (outline)
66  {
67  image = m_UiInfo.GetOutlineImage();
68  quadName = m_UiInfo.GetOutlineQuadName();
69 
70  outline.SetVisible(m_UiInfo.SetImageTo(outline, image, quadName));
71  outline.SetColor(m_UiInfo.GetOutlineColor());
72  }
73 
74  if (background)
75  {
76  image = m_UiInfo.GetBackgroundImage();
77  quadName = m_UiInfo.GetBackgroundQuadName();
78 
79  background.SetVisible(m_UiInfo.SetImageTo(background, image, quadName));
80  background.SetColor(m_UiInfo.GetBackgroundColor());
81  }
82  }
83 
88  void SetSize(float size)
89  {
90  ImageWidget icon = ImageWidget.Cast(m_wRoot.FindAnyWidget(m_sIconName));
91  ImageWidget outline = ImageWidget.Cast(m_wRoot.FindAnyWidget(m_sOutlineName));
92  ImageWidget background = ImageWidget.Cast(m_wRoot.FindAnyWidget(m_sBackgroundName));
93 
94  if (icon)
95  icon.SetSize(size, size);
96  if (outline)
97  outline.SetSize(size, size);
98  if (background)
99  background.SetSize(size, size);
100  }
101 
106  SCR_DamageStateUIInfo GetUiInfo()
107  {
108  return m_UiInfo;
109  }
110 
111  override void HandlerAttached(Widget w)
112  {
113  m_wRoot = w;
114 
115  if (!m_DamageStateConfig)
116  {
117  Print("'SCR_DamageStateUIComponent' is missing 'SCR_DamageStateConfig'", LogLevel.ERROR);
118  return;
119  }
120 
121  if (m_bAutoSetVisuals)
122  SetVisuals(m_eDamageType);
123  }
124 };
SCR_DamageStateUIInfo
Definition: SCR_DamageStateUIInfo.c:2
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_DamageStateUIComponent
Definition: SCR_DamageStateUIComponent.c:1
SCR_DamageStateConfig
Definition: SCR_DamageStateConfig.c:2
Attribute
typedef Attribute
Post-process effect of scripted camera.
EDamageType
EDamageType
Definition: EDamageType.c:12
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24