Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EditableCommentComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/Editor (Editables)", description: "", icon: "WBData/ComponentEditorProps/componentEditor.png")]
5
7
9class 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 //------------------------------------------------------------------------------------------------
53 {
54 return Color.FromInt(m_sColor.PackToInt());
55 }
56
57 //------------------------------------------------------------------------------------------------
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 int _WB_GetAfterWorldUpdateSpecs(IEntity owner, IEntitySource src)
85 {
86 return EEntityFrameUpdateSpecs.CALL_WHEN_ENTITY_VISIBLE;
87 }
88
89 //------------------------------------------------------------------------------------------------
90 override void _WB_AfterWorldUpdate(IEntity owner, float timeSlice)
91 {
92 SCR_UIInfo info = GetInfo();
93 if (!info)
94 return;
95
96 GenericEntity genericOwner = GenericEntity.Cast(owner);
97 if (!genericOwner)
98 return;
99
100 WorldEditorAPI api = genericOwner._WB_GetEditorAPI();
101 if (!api)
102 return;
103
104 IEntitySource src = api.EntityToSource(genericOwner);
105 if (!src)
106 return;
107
108 if (!api.IsEntityVisible(src) || !api.IsEntityLayerVisible(src.GetSubScene(), src.GetLayerID()))
109 return;
110
111 vector cameraTransform[4];
112 genericOwner.GetWorld().GetCurrentCamera(cameraTransform);
113
114 vector pos;
115 if (!GetPos(pos))
116 return;
117
118 int colorBackground = 0x00000000;
119 if (api.IsEntitySelected(src))
120 {
121 colorBackground = ARGBF(1, 0, 0, 0);
122 }
123 else
124 {
125 //--- Draw only if near when not selected
126 if (vector.DistanceSq(pos, cameraTransform[3]) > _WB_DRAW_DISTANCE_SQ)
127 return;
128 }
129
130 float testSize = 16 * m_fSizeCoef;
131 int color = m_sColor.PackToInt();
132
133 string displayName = GetDisplayName();
134 int underscore = displayName.LastIndexOf("_");
135 if (underscore != -1)
136 {
137 underscore++;
138 displayName = displayName.Substring(underscore, displayName.Length() - underscore);
139 }
140
141 DebugTextWorldSpace.Create(genericOwner.GetWorld(), displayName, DebugTextFlags.CENTER | DebugTextFlags.FACE_CAMERA | DebugTextFlags.ONCE, pos[0], pos[1], pos[2], testSize, color, colorBackground);
142 }
143#endif
144}
int size
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
float GetSizeCoef()
void ApplyTo(ImageWidget iconWidget)
override SCR_UIInfo GetInfo()
enum EVehicleType IEntity
Definition Color.c:13
event int _WB_GetAfterWorldUpdateSpecs(IEntity owner, IEntitySource src)
Called after _WB_OnInit or also later when editor needs to know whether _WB_AfterWorldUpdate needs to...
event void _WB_AfterWorldUpdate(IEntity owner, float timeSlice)
Called after updating world in Workbench. The entity must be selected. You can use editor API here an...
proto external WorldEditorAPI _WB_GetEditorAPI()
This returns world editor API, which is safe to use from editor events bellow.
proto external BaseWorld GetWorld()
bool SetIconTo(ImageWidget imageWidget)
Definition SCR_UIInfo.c:102
DebugTextFlags
SCR_FieldOfViewSettings Attribute
proto int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.