Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_EntityToolbarItemEditorUIComponent.c
Go to the documentation of this file.
2 {
3  [Attribute()]
4  protected string m_sIconWidgetName;
5 
6  [Attribute()]
7  protected string m_sNameWidgetName;
8 
9  protected SCR_EditableEntityComponent m_Entity;
10  protected TextWidget m_NameWidget;
11 
12  //------------------------------------------------------------------------------------------------
13  override void InitToolbarItem(Widget widget)
14  {
15  }
16 
17  //------------------------------------------------------------------------------------------------
21  void SetEntity(SCR_EditableEntityComponent entity, Widget widget, SCR_EditableEntitySlotManagerUIComponent slotManager)
22  {
23  if (slotManager)
24  {
25  Widget slotWidget = widget.FindAnyWidget(m_sIconWidgetName);
26  if (slotWidget)
27  {
29  if (slot)
30  slotManager.InsertSlotExternal(entity, slot);
31  }
32  }
33  else
34  {
35  Debug.Error2(ToString(), string.Format("SCR_EditableEntitySlotManagerUIComponent UI component is missing on %1!", widget.GetName()));
36  }
37 
38  SCR_UIInfo info = entity.GetInfo();
39  if (info)
40  {
41  m_NameWidget = TextWidget.Cast(widget.FindAnyWidget(m_sNameWidgetName));
42  if (m_NameWidget)
43  {
44  //--- Set name after a delay - GetPlayerID() would return incorrect value for newly created players
45  GetGame().GetCallqueue().CallLater(SetName, 1, false, entity);
46 
47  //--- Add refresh event (e.g., when group identity changes)
48  if (entity.GetOnUIRefresh())
49  {
50  entity.GetOnUIRefresh().Insert(RefreshName);
51  m_Entity = entity;
52  }
53  }
54  }
55  }
56 
57  //------------------------------------------------------------------------------------------------
58  protected void SetName(SCR_EditableEntityComponent entity)
59  {
60  int playerID = entity.GetPlayerID();
61  if (playerID > 0)
62  {
63  m_NameWidget.SetText(GetGame().GetPlayerManager().GetPlayerName(playerID));
64  }
65  else
66  {
67  SCR_UIInfo info = entity.GetInfo();
68  if (info)
69  info.SetNameTo(m_NameWidget);
70  }
71  }
72 
73  //------------------------------------------------------------------------------------------------
74  protected void RefreshName()
75  {
76  SetName(m_Entity);
77  }
78 
79  //------------------------------------------------------------------------------------------------
80  override void HandlerDeattached(Widget w)
81  {
82  super.HandlerDeattached(w);
83 
84  if (m_Entity)
85  m_Entity.GetOnUIRefresh().Remove(RefreshName);
86  }
87 }
SCR_EntityToolbarItemEditorUIComponent
Definition: SCR_EntityToolbarItemEditorUIComponent.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_EditableEntityBaseSlotUIComponent
Definition: SCR_EditableEntityBaseSlotUIComponent.c:6
m_Entity
enum EAITargetInfoCategory m_Entity
m_sIconWidgetName
protected string m_sIconWidgetName
Definition: SCR_GroupEditableEntityUIComponent.c:6
SCR_EditableEntitySlotManagerUIComponent
Definition: SCR_EditableEntitySlotManagerUIComponent.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_UIInfo
Definition: SCR_UIInfo.c:7
SCR_BaseToolbarItemEditorUIComponent
Definition: SCR_BaseToolbarItemEditorUIComponent.c:1
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13