Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_PlayerEditableEntityUIComponent.c
Go to the documentation of this file.
1 //#define FAKE_PLAYER //--- Allow placing AIs which are pretending to be players. Used for video capture.
2 
4 {
5  [Attribute("1 1 1 1")]
6  protected ref Color m_ColorPossessed;
7 
8  const string WIDGET_NAME = "Name"; //--- ToDo: Don't hardcode
9 
10  //------------------------------------------------------------------------------------------------
11  protected void SetName(TextWidget nameWidget, int playerID)
12  {
13  string playerName = GetGame().GetPlayerManager().GetPlayerName(playerID);
14  if (playerName.IsEmpty())
15  return;
16 
17  nameWidget.SetText(GetGame().GetPlayerManager().GetPlayerName(playerID));
18  GetGame().GetCallqueue().Remove(SetName);
19  }
20 
21  override void OnShownOffScreen(bool offScreen)
22  {
23  Widget nameWidget = GetWidget().FindAnyWidget(WIDGET_NAME);
24  if (!nameWidget)
25  return;
26 
27  if (offScreen)
28  nameWidget.SetOpacity(0);
29  else
30  nameWidget.SetOpacity(1);
31  }
32 
33  //------------------------------------------------------------------------------------------------
35  {
36  Widget widget = GetWidget();
37  if (!widget)
38  return;
39 
40  TextWidget nameWidget = TextWidget.Cast(widget.FindAnyWidget(WIDGET_NAME));
41  if (!nameWidget)
42  return;
43 
44  int playerID;
45  SCR_EditablePlayerDelegateComponent delegate = SCR_EditablePlayerDelegateComponent.Cast(entity);
46  if (delegate)
47  {
48  playerID = delegate.GetPlayerID();
49  }
50  else
51  {
53  if (playersManager)
54  {
55  playerID = playersManager.GetPlayerID(entity);
56  if (playersManager.IsPossessed(entity))
57  widget.SetColor(m_ColorPossessed);
58  }
59  }
60 
61  if (playerID == 0)
62  return;
63 
64  ArmaReforgerScripted game = GetGame();
65  if (!game)
66  return;
67 
68  //--- Assign name after it's been initialized (ToDo: Better solution? Callback?)
69  if (game.GetCallqueue()) game.GetCallqueue().CallLater(SetName, 0, true, nameWidget, playerID);
70 
72  if (sceneSlot && sceneSlot.GetOffScreenWidget())
73  sceneSlot.GetOffScreenWidget().SetColor(widget.GetColor());
74  }
75 }
SCR_PlayersManagerEditorComponent
Definition: SCR_PlayersManagerEditorComponent.c:9
WIDGET_NAME
protected string WIDGET_NAME
Definition: SCR_MapRTWBaseUI.c:21
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_PlayerEditableEntityUIComponent
Definition: SCR_PlayerEditableEntityUIComponent.c:3
SCR_EditableEntityBaseSlotUIComponent
Definition: SCR_EditableEntityBaseSlotUIComponent.c:6
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_EditableEntitySceneSlotUIComponent
Definition: SCR_EditableEntitySceneSlotUIComponent.c:1
SCR_BaseEditableEntityUIComponent
Definition: SCR_BaseEditableEntityUIComponent.c:8
SCR_UIInfo
Definition: SCR_UIInfo.c:7
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
GetWidget
protected Widget GetWidget()
Definition: SCR_VonDisplay.c:155