Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_MapMarkerSquadLeaderComponent.c
Go to the documentation of this file.
2 {
3  bool m_bIsHovered;
4  protected bool m_bIsInit;
5  protected Widget m_wOwnSquadBackground;
6  protected Widget m_wOwnSquadIcon;
7  protected Widget m_wOwnSquadIconGlow;
8  protected Widget m_wGroupInfo;
9  protected Widget m_wGroupInfoList;
10  protected TextWidget m_wGroupFrequency;
11 
12  protected ref array<Widget> m_aGroupMemberEntries = {};
13 
14  [Attribute("{CCD81F58E9D6EEA6}UI/layouts/Map/MapMarkerGroupInfo.layout", desc: "group info layout")]
15  protected ResourceName m_sGroupInfoLayout;
16 
17  [Attribute("{B09864CA15145CD3}UI/layouts/Map/MapMarkerGroupInfoLine.layout", desc: "group info line layout")]
18  protected ResourceName m_sLineLayout;
19 
20  [Attribute("lineText", desc: "line text widget")]
21  protected string m_sLineTextWidgetName;
22 
23  [Attribute("lineIcon", desc: "line icon widget")]
24  protected string m_sLineIconWidgetName;
25 
26  [Attribute("40", desc: "pixels, group info offset")]
27  protected int m_iGroupInfoOffset;
28 
29  //------------------------------------------------------------------------------------------------
32  void SetGroupActive(bool state, string factionName = string.Empty)
33  {
34  Color iconColor = Color.FromInt(Color.BLACK);
35 
36  if (state)
37  {
38  /*m_wOwnSquadBackground.SetVisible(true);
39  m_wOwnSquadIcon.SetVisible(true);
40  m_wOwnSquadIconGlow.SetVisible(true);
41 
42  // TODO temp set until these are added to configs
43  if (factionName == "US")
44  iconColor = new Color(0.0, 0.18, 0.61, 1.0);
45  else if (factionName == "USSR")
46  iconColor = new Color(0.51, 0.02, 0.02, 1.0);*/
47  }
48  else
49  {
50  m_wOwnSquadBackground.SetVisible(false);
51  m_wOwnSquadIcon.SetVisible(false);
52  m_wOwnSquadIconGlow.SetVisible(false);
53  }
54 
55  //m_wOwnSquadIcon.SetColor(iconColor);
56  //m_wOwnSquadIconGlow.SetColor(iconColor);
57  }
58 
59  //------------------------------------------------------------------------------------------------
63  void UpdateGroupInfoPosition(int screenX, int screenY)
64  {
65  if (m_wGroupInfo)
66  FrameSlot.SetPos(m_wGroupInfo, GetGame().GetWorkspace().DPIUnscale(screenX), GetGame().GetWorkspace().DPIUnscale(screenY) - m_iGroupInfoOffset); // needs unscaled coords
67  }
68 
69  //------------------------------------------------------------------------------------------------
70  override bool OnMouseButtonDown(Widget w, int x, int y, int button)
71  {
72  if (button != 0) // LMB only
73  return true;
74 
75  GetGame().OpenGroupMenu();
76 
77  return true;
78  }
79 
80  //------------------------------------------------------------------------------------------------
81  override bool OnMouseEnter(Widget w, int x, int y)
82  {
83  m_MarkerEnt.LayerChangeLogic(0);
84 
85  SCR_AIGroup group = SCR_MapMarkerSquadLeader.Cast(m_MarkerEnt).GetGroup();
86  if (group)
87  {
88  if (!m_bIsInit)
89  {
90  m_wGroupInfo = GetGame().GetWorkspace().CreateWidgets(m_sGroupInfoLayout, m_wRoot.GetParent());
91  if (!m_wGroupInfo)
92  return false;
93 
94  m_wGroupInfoList = m_wGroupInfo.FindAnyWidget("groupInfoList");
95  m_wGroupFrequency = TextWidget.Cast(m_wGroupInfo.FindAnyWidget("groupFrequency"));
96 
97  int capacity = group.GetMaxMembers();
98 
99  for (int i = 0; i < capacity; i++)
100  {
101  m_aGroupMemberEntries.Insert(GetGame().GetWorkspace().CreateWidgets(m_sLineLayout, m_wGroupInfoList));
102  }
103 
104  m_bIsInit = true;
105  }
106 
107  float fFrequency = Math.Round(group.GetRadioFrequency() * 0.1) * 0.01; // Format the frequency text: round and convert to 2 digits with one possible decimal place (39500 -> 39.5)
108  m_wGroupFrequency.SetText(fFrequency.ToString(3, 1));
109 
110  int playerCount = group.GetPlayerCount();
111  array<int> membersCopy = {};
112  membersCopy.Copy(group.GetPlayerIDs());
113 
114  PlayerManager pManager = GetGame().GetPlayerManager();
115  int leaderID = group.GetLeaderID();
116 
117  // leader entry first, order of IDs is not guaranteed
118  foreach (int id : membersCopy)
119  {
120  if (id == leaderID)
121  {
122  Widget entry = m_aGroupMemberEntries[0];
123  TextWidget txtW = TextWidget.Cast(entry.FindWidget(m_sLineTextWidgetName));
124  txtW.SetText(pManager.GetPlayerName(id));
125  entry.SetVisible(true);
126 
127  if (GetGame().GetPlayerController().GetPlayerId() == id)
128  txtW.SetColor(GUIColors.ORANGE);
129  else
130  txtW.SetColor(GUIColors.DEFAULT);
131 
132  ImageWidget imgW = ImageWidget.Cast(entry.FindWidget(m_sLineIconWidgetName));
133  imgW.SetOpacity(1);
134 
135  membersCopy.RemoveItem(id);
136  break;
137  }
138  }
139 
140  // members
141  foreach (int i, Widget entry : m_aGroupMemberEntries)
142  {
143  if (i == 0) // leader
144  continue;
145 
146  if (i < playerCount)
147  {
148  TextWidget txtW = TextWidget.Cast(entry.FindWidget(m_sLineTextWidgetName));
149  txtW.SetText(pManager.GetPlayerName(membersCopy[i-1]));
150  entry.SetVisible(true);
151 
152  if (GetGame().GetPlayerController().GetPlayerId() == membersCopy[i-1])
153  txtW.SetColor(GUIColors.ORANGE);
154  else
155  txtW.SetColor(GUIColors.DEFAULT);
156 
157  ImageWidget imgW = ImageWidget.Cast(entry.FindWidget(m_sLineIconWidgetName));
158  imgW.SetOpacity(0);
159 
160  continue;
161  }
162 
163  entry.SetVisible(false);
164  }
165 
166  m_wGroupInfo.SetVisible(true);
167  }
168 
169  m_bIsHovered = true;
170 
171  return true;
172  }
173 
174  //------------------------------------------------------------------------------------------------
175  override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
176  {
177  m_wGroupInfo.SetVisible(false);
178  m_bIsHovered = false;
179 
180  m_MarkerEnt.LayerChangeLogic(m_iLayerID);
181 
182  return true;
183  }
184 
185  //------------------------------------------------------------------------------------------------
186  override void HandlerAttached(Widget w)
187  {
188  super.HandlerAttached(w);
189 
190  m_wOwnSquadBackground = m_wRoot.FindAnyWidget("OwnSquadBackground");
191  m_wOwnSquadIcon = m_wRoot.FindAnyWidget("OwnSquadIcon");
192  m_wOwnSquadIconGlow = m_wRoot.FindAnyWidget("OwnSquadIconGlow");
193  }
194 }
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_MapMarkerDynamicWComponent
Attached to root of marker dynamic base layout.
Definition: SCR_MapMarkerDynamicWComponent.c:2
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
GetPlayerController
proto external PlayerController GetPlayerController()
Definition: SCR_PlayerDeployMenuHandlerComponent.c:307
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_bIsHovered
protected bool m_bIsHovered
Definition: SCR_CampaignMobileAssemblyStandaloneComponent.c:23
SCR_AIGroup
Definition: SCR_AIGroup.c:68
SCR_MapMarkerSquadLeaderComponent
Definition: SCR_MapMarkerSquadLeaderComponent.c:1
PlayerManager
Definition: PlayerManager.c:12
GetPlayerId
proto external int GetPlayerId()
Definition: SCR_SpawnRequestComponent.c:39