Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_EditableCommentComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/Editor (Editables)", description: "", icon: "WBData/ComponentEditorProps/componentEditor.png")]
3 {
4 }
5 
7 
9 class SCR_EditableCommentComponent : SCR_EditableEntityComponent
10 {
11  [Attribute(category: "Comment", defvalue: "1 1 1 1")]
12  private ref Color m_sColor;
13 
14  [Attribute(category: "Comment", defvalue: "1", uiwidget: UIWidgets.Slider, params: "0.5 2 0.1")]
15  private float m_fSizeCoef;
16 
17  [Attribute(category: "Comment")]
18  private bool m_bBold;
19 
20  [Attribute(category: "Comment")]
21  private bool m_bItalic;
22 
23  //------------------------------------------------------------------------------------------------
26  void ApplyTo(TextWidget textWidget)
27  {
28  textWidget.SetText(GetDisplayName());
29  textWidget.SetColor(m_sColor);
30  textWidget.SetBold(m_bBold);
31  textWidget.SetItalic(m_bItalic);
32 
33  float size;
34  textWidget.GetTextSize(size, size);
35  textWidget.SetExactFontSize(size * m_fSizeCoef);
36  }
37 
38  //------------------------------------------------------------------------------------------------
41  void ApplyTo(ImageWidget iconWidget)
42  {
43  iconWidget.SetColor(m_sColor);
44 
45  SCR_UIInfo info = GetInfo();
46  if (info)
47  info.SetIconTo(iconWidget);
48  }
49 
50  //------------------------------------------------------------------------------------------------
52  Color GetColor()
53  {
54  return Color.FromInt(m_sColor.PackToInt());
55  }
56 
57  //------------------------------------------------------------------------------------------------
59  float GetSizeCoef()
60  {
61  return m_fSizeCoef;
62  }
63 
64  //------------------------------------------------------------------------------------------------
67  bool IsBold()
68  {
69  return m_bBold;
70  }
71 
72  //------------------------------------------------------------------------------------------------
75  bool IsItalic()
76  {
77  return m_bItalic;
78  }
79 
80 #ifdef WORKBENCH
81  private static const float _WB_DRAW_DISTANCE_SQ = 1500 * 1500; //--- Squared value
82 
83  //------------------------------------------------------------------------------------------------
84  override void _WB_AfterWorldUpdate(IEntity owner, float timeSlice)
85  {
86  SCR_UIInfo info = GetInfo();
87  if (!info)
88  return;
89 
90  GenericEntity genericOwner = GenericEntity.Cast(owner);
91  if (!genericOwner)
92  return;
93 
94  WorldEditorAPI api = genericOwner._WB_GetEditorAPI();
95  if (!api)
96  return;
97 
98  IEntitySource src = api.EntityToSource(genericOwner);
99  if (!src)
100  return;
101 
102  if (!api.IsEntityVisible(src) || !api.IsEntityLayerVisible(src.GetSubScene(), src.GetLayerID()))
103  return;
104 
105  vector cameraTransform[4];
106  genericOwner.GetWorld().GetCurrentCamera(cameraTransform);
107 
108  vector pos;
109  if (!GetPos(pos))
110  return;
111 
112  int colorBackground = 0x00000000;
113  if (api.IsEntitySelected(src))
114  {
115  colorBackground = ARGBF(1, 0, 0, 0);
116  }
117  else
118  {
119  //--- Draw only if near when not selected
120  if (vector.DistanceSq(pos, cameraTransform[3]) > _WB_DRAW_DISTANCE_SQ)
121  return;
122  }
123 
124  float testSize = 16 * m_fSizeCoef;
125  int color = m_sColor.PackToInt();
126 
127  string displayName = GetDisplayName();
128  int underscore = displayName.LastIndexOf("_");
129  if (underscore != -1)
130  {
131  underscore++;
132  displayName = displayName.Substring(underscore, displayName.Length() - underscore);
133  }
134 
135  DebugTextWorldSpace.Create(genericOwner.GetWorld(), displayName, DebugTextFlags.CENTER | DebugTextFlags.FACE_CAMERA | DebugTextFlags.ONCE, pos[0], pos[1], pos[2], testSize, color, colorBackground);
136  }
137 #endif
138 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
IsBold
bool IsBold()
Definition: SCR_EditableCommentComponent.c:67
GetInfo
override SCR_UIInfo GetInfo(IEntity owner=null)
Definition: SCR_EditablePlayerDelegateComponent.c:140
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
GetPos
override bool GetPos(out vector pos)
Definition: SCR_EditableFactionComponent.c:325
IsItalic
bool IsItalic()
Definition: SCR_EditableCommentComponent.c:75
GetSizeCoef
float GetSizeCoef()
Definition: SCR_EditableCommentComponent.c:59
SCR_UIInfo
Definition: SCR_UIInfo.c:7
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
ApplyTo
void ApplyTo(ImageWidget iconWidget)
Definition: SCR_EditableCommentComponent.c:41
SCR_EditableCommentComponentClass
Definition: SCR_EditableCommentComponent.c:2
Attribute
SCR_EditableCommentComponentClass SCR_EditableEntityComponentClass Attribute(category:"Comment", defvalue:"1 1 1 1")
Definition: SCR_EditableCommentComponent.c:11
GetColor
Color GetColor()
Definition: SCR_EditableCommentComponent.c:52
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_EditableEntityComponentClass
Definition: SCR_EditableEntityComponentClass.c:2
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180