Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_HUDGroupUIComponent.c
Go to the documentation of this file.
2{
3 [Attribute("1")]
4 protected bool m_bEnableDebugFont;
5
6 [Attribute("20")]
8 private int m_iDebugFontSize;
9
10 protected float m_fWidth;
11 protected float m_fHeight;
12
13 protected Widget m_wRoot;
14
16 protected ref array<SCR_HUDSlotUIComponent> m_aSlots = {};
17
18 //------------------------------------------------------------------------------------------------
23 {
24 return m_wRoot;
25 }
26
27 //------------------------------------------------------------------------------------------------
28 int GetSlotComponents(notnull out array<SCR_HUDSlotUIComponent> slotComponents)
29 {
30 slotComponents.Clear();
31
32 foreach (SCR_HUDSlotUIComponent slot : m_aSlots)
33 {
34 slotComponents.Insert(slot);
35 }
36
37 return slotComponents.Count();
38 }
39
40 //------------------------------------------------------------------------------------------------
42 {
43 foreach (SCR_HUDSlotUIComponent slot : m_aSlots)
44 {
45 Widget slotWidget = slot.GetRootWidget();
46 if (!slotWidget)
47 continue;
48
49 if (slotWidget.GetName() == slotName)
50 return slot;
51 }
52
53 return null;
54 }
55
56#ifdef WORKBENCH
57 //------------------------------------------------------------------------------------------------
58 override bool OnUpdate(Widget w)
59 {
61 return false;
62
63 m_wRoot.GetScreenSize(m_fWidth, m_fHeight);
65
66 return false;
67 }
68#endif
69
70 //------------------------------------------------------------------------------------------------
75 {
76 WorkspaceWidget workspace = GetGame().GetWorkspace();
77
78 m_wRoot.GetScreenSize(m_fWidth, m_fHeight);
79 m_fWidth = workspace.DPIUnscale(m_fWidth);
80 m_fHeight = workspace.DPIUnscale(m_fHeight);
81
83 }
84
85 //------------------------------------------------------------------------------------------------
86 override void HandlerAttached(Widget w)
87 {
88 m_wRoot = w;
89
90 Widget iteratedWidget = w.GetChildren();
91 while (iteratedWidget)
92 {
93 SCR_HUDSlotUIComponent slot = SCR_HUDSlotUIComponent.Cast(iteratedWidget.FindHandler(SCR_HUDSlotUIComponent));
94 if (!slot)
95 {
96 iteratedWidget = iteratedWidget.GetSibling();
97 continue;
98 }
99
100 slot.Initialize();
101 m_aSlots.Insert(slot);
102 iteratedWidget = iteratedWidget.GetSibling();
103 }
104
105#ifdef WORKBENCH
106 if (!SCR_Global.IsEditMode())
107 return;
108
109 WorkspaceWidget workspace = GetGame().GetWorkspace();
110 foreach (SCR_HUDSlotUIComponent slot : m_aSlots)
111 {
112 FrameWidget slotFrame = FrameWidget.Cast(slot.GetRootWidget());
113 if (!slotFrame)
114 {
115 Debug.Error2("Wrong Slot Widget Type", "SCR_HUDSlotUIComponent Requires to be attached to a FrameWidget!");
116 return;
117 }
118
119 slot.m_wDebugOverlay = OverlayWidget.Cast(workspace.CreateWidget(WidgetType.OverlayWidgetTypeID, WidgetFlags.VISIBLE, Color.FromInt(Color.BLACK), 0, slot.GetRootWidget()));
120 if (!slot.m_wDebugOverlay || !m_bEnableDebugFont)
121 return;
122
123 slot.m_wDebugImg = ImageWidget.Cast(workspace.CreateWidget(WidgetType.ImageWidgetTypeID, WidgetFlags.VISIBLE, new Color(Math.RandomFloat(0, 0.1), Math.RandomFloat(0, 0.1), Math.RandomFloat(0, 0.1), 1), 0, slot.m_wDebugOverlay));
124 LayoutSlot.SetHorizontalAlign(slot.m_wDebugImg, LayoutHorizontalAlign.Stretch);
125 LayoutSlot.SetVerticalAlign(slot.m_wDebugImg, LayoutVerticalAlign.Stretch);
126
127 slot.m_wDebugVertical = workspace.CreateWidget(WidgetType.VerticalLayoutWidgetTypeID, WidgetFlags.VISIBLE, Color.FromInt(Color.BLACK), 0, slot.m_wDebugOverlay);
128 OverlaySlot.SetHorizontalAlign(slot.m_wDebugVertical, LayoutHorizontalAlign.Stretch);
129 OverlaySlot.SetVerticalAlign(slot.m_wDebugVertical, LayoutVerticalAlign.Stretch);
130
131 slot.m_wDebugNameText = TextWidget.Cast(workspace.CreateWidget(WidgetType.TextWidgetTypeID, WidgetFlags.VISIBLE, Color.FromInt(Color.WHITE), 0, slot.m_wDebugVertical));
132 OverlaySlot.SetHorizontalAlign(slot.m_wDebugNameText, LayoutHorizontalAlign.Center);
133 slot.m_wDebugNameText.SetText(slot.GetRootWidget().GetName());
134 slot.m_wDebugNameText.SetExactFontSize(m_iDebugFontSize);
135
136 slot.m_wDebugPriorityText = TextWidget.Cast(workspace.CreateWidget(WidgetType.TextWidgetTypeID, WidgetFlags.VISIBLE, Color.FromInt(Color.WHITE), 0, slot.m_wDebugVertical));
137 OverlaySlot.SetHorizontalAlign(slot.m_wDebugPriorityText, LayoutHorizontalAlign.Center);
138 slot.SetPriority(slot.GetPriority());
139 slot.m_wDebugPriorityText.SetExactFontSize(m_iDebugFontSize);
140
141 slot.m_wDebugHeightText = RichTextWidget.Cast(workspace.CreateWidget(WidgetType.RichTextWidgetTypeID, WidgetFlags.VISIBLE, Color.FromInt(Color.WHITE), 0, slot.m_wDebugVertical));
142 OverlaySlot.SetHorizontalAlign(slot.m_wDebugHeightText, LayoutHorizontalAlign.Center);
143 slot.m_wDebugHeightText.SetExactFontSize(m_iDebugFontSize);
144
145 slot.m_wDebugWidthText = RichTextWidget.Cast(workspace.CreateWidget(WidgetType.RichTextWidgetTypeID, WidgetFlags.VISIBLE, Color.FromInt(Color.WHITE), 0, slot.m_wDebugVertical));
146 OverlaySlot.SetHorizontalAlign(slot.m_wDebugWidthText, LayoutHorizontalAlign.Center);
147 slot.m_wDebugWidthText.SetExactFontSize(m_iDebugFontSize);
148 }
149
150#endif
151 }
152};
ArmaReforgerScripted GetGame()
Definition game.c:1398
ref array< SCR_WeaponRackSlotEntity > m_aSlots
float m_fHeight
Widget m_wRoot
override void OnUpdate()
Definition Color.c:13
Definition Debug.c:13
Definition Math.c:13
static bool IsEditMode()
Definition Functions.c:1566
ref array< SCR_HUDSlotUIComponent > m_aSlots
int GetSlotComponents(notnull out array< SCR_HUDSlotUIComponent > slotComponents)
ref SCR_HUDSizeCalculator m_HUDSizeCalculator
override void HandlerAttached(Widget w)
SCR_HUDSlotUIComponent FindSlotComponent(string slotName)
SCR_FieldOfViewSettings Attribute
WidgetFlags
Widget flags. See enf::Widget::SetFlags().
Definition WidgetFlags.c:14
LayoutHorizontalAlign
LayoutVerticalAlign