Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_InventoryDamageInfoUI.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
4 [EntityEditorProps(category: "GameScripted/UI/Inventory", description: "Inventory Item Info UI class")]
5 class SCR_InventoryDamageInfoUI : ScriptedWidgetComponent
6 {
7 
8  protected Widget m_wInfoWidget;
9  protected TextWidget m_wTextName;
10  protected SCR_SlotUIComponent m_pFrameSlotUI;
11  protected Widget m_wWidgetUnderCursor;
12  protected bool m_bForceShow;
13  protected string m_sTextName;
14 
15  protected RichTextWidget m_wTourniquetHintIconWidget;
16  protected ImageWidget m_wDamageIconWidget, m_wBleedingIconWidget, m_wTourniquetIconWidget, m_wSalineBagIconWidget, m_wMorphineIconWidget, m_wFractureIconWidget, m_wFractureIcon2Widget;
17  protected TextWidget m_wDamageRegenTextWidget, m_wDamageTextWidget, m_wBleedingTextWidget, m_wTourniquetTextWidget, m_wSalineBagTextWidget, m_wMorphineTextWidget, m_wTourniquetHintTextWidget, m_wFractureTextWidget, m_wFractureText2Widget;
18 
19  protected ResourceName m_sMedicalIconsImageSet = "{B9199157B90D6216}UI/Textures/InventoryIcons/Medical/Medical-icons.imageset";
20  protected string m_sBloodIcon = "Blood_UI";
21  protected string m_sTourniquetIcon = "Tourniquet_UI";
22  protected string m_sSalineBagIcon = "Saline-bag_UI";
23  protected string m_sMorphineIcon = "Morphine_UI";
24  protected string m_sFractureIcon = "Bone-Fracture_UI";
25  protected string m_sTourniquetHintText = "#AR-RemoveTourniquetAction";
26  protected string m_sDamageRegenText = "#AR-DamageInfo_Regeneration";
27  protected string m_sTourniquetText = "#AR-DamageInfo_TourniquetApplied";
28  protected string m_sSalinebagText = "#AR-DamageInfo_SalineBagApplied";
29  protected string m_sMorphineText = "#AR-DamageInfo_MorphineApplied";
30  protected string m_sArmFractureText = "#AR_Inventory_ArmsDamage";
31  protected string m_sLegFractureText = "#AR_Inventory_LegsDamage";
32 
33  //------------------------------------------------------------------------------------------------
34  void Show(float fDelay = 0.0, Widget w = null, bool forceShow = false)
35  {
36  m_bForceShow = forceShow;
37  m_wWidgetUnderCursor = w;
38  if (fDelay == 0)
39  {
40  ShowInfoWidget(true);
41  }
42  else
43  {
44  // CallLater delays showing up of damageInfoUI
45  GetGame().GetCallqueue().Remove(ShowInfoWidget);
46  GetGame().GetCallqueue().CallLater(ShowInfoWidget, fDelay * 1000, false, true);
47  }
48  }
49 
50  //------------------------------------------------------------------------------------------------
51  protected void ShowInfoWidget(bool bShow)
52  {
53  if (m_bForceShow)
54  {
55  m_wInfoWidget.SetVisible(true);
56  return;
57  }
58 
59  if (!m_wWidgetUnderCursor)
60  return;
61 
62  if (WidgetManager.GetWidgetUnderCursor() != m_wWidgetUnderCursor)
63  return; //the cursor is on different position already
64 
65  m_wInfoWidget.SetVisible(true);
66  }
67 
68  //------------------------------------------------------------------------------------------------
69  void SetDamageStateVisible(bool visible, bool regenerating, string iconIntensity, string damageText)
70  {
71  if (!m_sMedicalIconsImageSet || !m_wDamageIconWidget || !m_wDamageTextWidget || !m_wDamageRegenTextWidget)
72  return;
73 
74  if (!iconIntensity.IsEmpty())
75  m_wDamageIconWidget.LoadImageFromSet(0, m_sMedicalIconsImageSet, iconIntensity);
76 
77  string regenText = m_sDamageRegenText;
78  m_wDamageIconWidget.SetVisible(visible);
79 
80  if (!regenerating)
81  regenText = "";
82 
83  m_wDamageTextWidget.SetText(damageText);
84  m_wDamageRegenTextWidget.SetText(regenText);
85  m_wDamageTextWidget.SetVisible(visible);
86  m_wDamageRegenTextWidget.SetVisible(visible);
87  }
88 
89  //------------------------------------------------------------------------------------------------
90  void SetBleedingStateVisible(bool visible, string bleedingText)
91  {
92  if (!m_sMedicalIconsImageSet || !m_wBleedingIconWidget || !m_wBleedingTextWidget)
93  return;
94 
95  m_wBleedingIconWidget.LoadImageFromSet(0, m_sMedicalIconsImageSet, m_sBloodIcon);
96  m_wBleedingIconWidget.SetVisible(visible);
97 
98  m_wBleedingTextWidget.SetVisible(visible);
99  m_wBleedingTextWidget.SetText(bleedingText);
100  }
101 
102  //------------------------------------------------------------------------------------------------
103  void SetTourniquetStateVisible(bool visible)
104  {
105  if (!m_sMedicalIconsImageSet || !m_wTourniquetIconWidget || !m_wTourniquetTextWidget)
106  return;
107 
108  m_wTourniquetIconWidget.LoadImageFromSet(0, m_sMedicalIconsImageSet, m_sTourniquetIcon);
109  m_wTourniquetIconWidget.SetVisible(visible);
110 
111  m_wTourniquetTextWidget.SetText(m_sTourniquetText);
112  m_wTourniquetTextWidget.SetVisible(visible);
113  SetTourniquetHintVisible(visible);
114  }
115 
116  //------------------------------------------------------------------------------------------------
117  void SetSalineBagStateVisible(bool visible)
118  {
119  if (!m_sMedicalIconsImageSet || !m_wSalineBagIconWidget || !m_wSalineBagTextWidget)
120  return;
121 
122  m_wSalineBagIconWidget.LoadImageFromSet(0, m_sMedicalIconsImageSet, m_sSalineBagIcon);
123  m_wSalineBagIconWidget.SetVisible(visible);
124 
125  m_wSalineBagTextWidget.SetText(m_sSalinebagText);
126  m_wSalineBagTextWidget.SetVisible(visible);
127  }
128 
129  //------------------------------------------------------------------------------------------------
130  void SetTourniquetHintVisible(bool visible)
131  {
132  if (!m_wTourniquetHintIconWidget || !m_wTourniquetHintTextWidget)
133  return;
134 
135  m_wTourniquetHintIconWidget.SetVisible(visible);
136 
137  m_wTourniquetHintTextWidget.SetText(m_sTourniquetHintText);
138  m_wTourniquetHintTextWidget.SetVisible(visible);
139  }
140 
141  //------------------------------------------------------------------------------------------------
142  void SetMorphineStateVisible(bool visible)
143  {
144  if (!m_wMorphineIconWidget || !m_wMorphineTextWidget)
145  return;
146 
147  m_wMorphineIconWidget.LoadImageFromSet(0, m_sMedicalIconsImageSet, m_sMorphineIcon);
148  m_wMorphineIconWidget.SetVisible(visible);
149 
150  m_wMorphineTextWidget.SetText(m_sMorphineText);
151  m_wMorphineTextWidget.SetVisible(visible);
152  }
153 
154  //------------------------------------------------------------------------------------------------
155  void SetFractureStateVisible(bool armFractured, bool legFractured)
156  {
157  if (!m_wFractureIconWidget || !m_wFractureIcon2Widget || !m_wFractureTextWidget || !m_wFractureText2Widget)
158  return;
159 
160  m_wFractureIconWidget.LoadImageFromSet(0, m_sMedicalIconsImageSet, m_sFractureIcon);
161  m_wFractureIcon2Widget.LoadImageFromSet(0, m_sMedicalIconsImageSet, m_sFractureIcon);
162 
163  m_wFractureIconWidget.SetVisible(armFractured);
164  m_wFractureIcon2Widget.SetVisible(legFractured);
165 
166  m_wFractureTextWidget.SetText(m_sArmFractureText);
167  m_wFractureText2Widget.SetText(m_sLegFractureText);
168 
169  m_wFractureTextWidget.SetVisible(armFractured);
170  m_wFractureText2Widget.SetVisible(legFractured);
171  }
172 
173  //------------------------------------------------------------------------------------------------
174  void Hide()
175  {
176  if (!m_wInfoWidget)
177  return;
178 
179  m_wInfoWidget.SetVisible(false);
180  m_wInfoWidget.SetEnabled(false);
181  }
182 
183  //------------------------------------------------------------------------------------------------
184  void Move(float x, float y)
185  {
186  if (!m_pFrameSlotUI)
187  return;
188 
189  m_pFrameSlotUI.SetPosX(x);
190  m_pFrameSlotUI.SetPosY(y);
191  }
192 
193  //------------------------------------------------------------------------------------------------
194  void SetName(string sName)
195  {
196  if (!m_wTextName)
197  return;
198 
199  if (sName.IsEmpty())
200  {
201  m_wTextName.GetParent().SetVisible(false);
202  return;
203  }
204 
205  m_sTextName = sName;
206  m_wTextName.SetText(sName);
207  m_wTextName.GetParent().SetVisible(true);
208  }
209 
210  //------------------------------------------------------------------------------------------------
211  string GetName()
212  {
213  return m_sTextName;
214  }
215 
216  //------------------------------------------------------------------------------------------------
217  override void HandlerAttached(Widget w)
218  {
219  if (!w)
220  return;
221  m_wInfoWidget = w;
222  m_wTextName = TextWidget.Cast( w.FindAnyWidget( "ItemInfo_name" ) );
223  Widget wItemInfo = m_wInfoWidget.FindAnyWidget( "ItemInfo" );
224  if (!wItemInfo)
225  return;
226  m_pFrameSlotUI = SCR_SlotUIComponent.Cast(wItemInfo.FindHandler(SCR_SlotUIComponent));
227 
228  m_wDamageIconWidget = ImageWidget.Cast( w.FindAnyWidget( "DamageInfo_icon" ) );
229  m_wDamageTextWidget = TextWidget.Cast( w.FindAnyWidget( "DamageInfo_text" ) );
230  m_wFractureIconWidget = ImageWidget.Cast( w.FindAnyWidget( "FractureInfo_icon" ) );
231  m_wFractureIcon2Widget = ImageWidget.Cast( w.FindAnyWidget( "FractureInfo_icon2" ) );
232  m_wFractureTextWidget = TextWidget.Cast( w.FindAnyWidget( "FractureInfo_text" ) );
233  m_wFractureText2Widget = TextWidget.Cast( w.FindAnyWidget( "FractureInfo_text2" ) );
234  m_wDamageRegenTextWidget = TextWidget.Cast( w.FindAnyWidget( "DamageRegenInfo_text" ) );
235  m_wBleedingIconWidget = ImageWidget.Cast( w.FindAnyWidget( "BleedingInfo_icon" ) );
236  m_wBleedingTextWidget = TextWidget.Cast( w.FindAnyWidget( "BleedingInfo_text" ) );
237  m_wTourniquetIconWidget = ImageWidget.Cast( w.FindAnyWidget( "TourniquetInfo_icon" ) );
238  m_wTourniquetTextWidget = TextWidget.Cast( w.FindAnyWidget( "TourniquetInfo_text" ) );
239  m_wTourniquetHintIconWidget = RichTextWidget.Cast( w.FindAnyWidget( "TourniquetHint_icon" ) );
240  m_wTourniquetHintTextWidget = TextWidget.Cast( w.FindAnyWidget( "TourniquetHint_text" ) );
241  m_wSalineBagIconWidget = ImageWidget.Cast( w.FindAnyWidget( "SalineBagInfo_icon" ) );
242  m_wSalineBagTextWidget = TextWidget.Cast( w.FindAnyWidget( "SalineBagInfo_text" ) );
243  m_wMorphineIconWidget = ImageWidget.Cast( w.FindAnyWidget( "MorphineInfo_icon" ) );
244  m_wMorphineTextWidget = TextWidget.Cast( w.FindAnyWidget( "MorphineInfo_text" ) );
245  }
246 
247  //------------------------------------------------------------------------------------------------
248  void Destroy()
249  {
250  if (m_wInfoWidget)
251  {
252  GetGame().GetCallqueue().Remove(ShowInfoWidget);
253  m_wInfoWidget.RemoveHandler(m_pFrameSlotUI);
254  m_wInfoWidget.RemoveHandler(this);
255  m_wInfoWidget.RemoveFromHierarchy();
256  }
257  }
258 
259  //------------------------------------------------------------------------------------------------
260  Widget GetInfoWidget()
261  {
262  return m_wInfoWidget.FindAnyWidget("size");
263  }
264 };
SCR_InventoryDamageInfoUI
Definition: SCR_InventoryDamageInfoUI.c:5
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_SlotUIComponent
Definition: SCR_SlotUIComponent.c:6
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180