16 void ResizeGroup(notnull array<SCR_HUDSlotUIComponent> slots,
int groupHeight,
int groupWidth)
18 array<SCR_HUDSlotUIComponent> remainingSlots = {};
22 slot.SetHeight(0,
false);
23 slot.SetWidth(0,
false);
26 if (slot.GetRootWidget().IsVisible() && slot.GetContentWidget() && slot.GetContentWidget().IsVisible())
27 remainingSlots.Insert(slot);
31 SortSlotsByPriority(remainingSlots);
34 while (remainingSlots.Count() > 0)
39 if (!currentSlot.m_aHeightSteps.IsEmpty())
41 if (!currentSlot.m_aWidthSteps.IsEmpty())
45 remainingSlots.RemoveOrdered(0);
50 private void Resize(notnull array<SCR_HUDSlotUIComponent> slots, notnull array<SCR_HUDSlotUIComponent> remainingSlots,
int totalSize,
SCR_EHUDManagerResizeType resizeType)
52 int remainingGroupSize;
53 int maxAvailableSizeSum;
54 array<int> sizeSteps =
null;
63 remainingGroupSize = totalSize - GetTotalAssignedHeight(slots);
65 maxAvailableSizeSum = GetMaxAvailableHeightSizeSum(remainingSlots);
66 sizeSteps = currentSlot.m_aHeightSteps;
71 remainingGroupSize = totalSize - GetTotalAssignedWidth(slots);
73 maxAvailableSizeSum = GetMaxAvailableWidthSizeSum(remainingSlots);
74 sizeSteps = currentSlot.m_aWidthSteps;
79 if (maxAvailableSizeSum > remainingGroupSize)
82 for (
int i = sizeSteps.Count() - 1; i >= 0; i--)
84 int stepToUse = sizeSteps[i];
87 int differenceBetweenHighest = sizeSteps[sizeSteps.Count() - 1] - sizeSteps[i];
89 int modifiedMaxAvailableSizeSum = maxAvailableSizeSum - differenceBetweenHighest;
92 if (modifiedMaxAvailableSizeSum <= remainingGroupSize)
95 currentSlot.SetHeight(stepToUse);
97 currentSlot.SetWidth(stepToUse);
104 currentSlot.SetHeight(sizeSteps[0]);
106 currentSlot.SetWidth(sizeSteps[0]);
116 int distributedSize = Math.Min(remainingGroupSize, GetMaxAvailableHeight(currentSlot));
117 currentSlot.SetHeight(distributedSize);
121 int distributedSize = Math.Min(remainingGroupSize, GetMaxAvailableWidth(currentSlot));
122 currentSlot.SetWidth(distributedSize);
131 private int GetTotalAssignedHeight(notnull array<SCR_HUDSlotUIComponent> slots)
136 if (slot.GetRootWidget().IsVisible())
138 totalHeight += slot.GetHeight();
149 private int GetTotalAssignedWidth(notnull array<SCR_HUDSlotUIComponent> slots)
154 if (slot.GetRootWidget().IsVisible())
156 totalWidth += slot.GetWidth();
167 private void SortSlotsByPriority(notnull array<SCR_HUDSlotUIComponent> slots)
169 for (
int i = 0; i < slots.Count() - 1; i++)
171 for (
int j = 0; j < slots.Count() - 1 - i; j++)
176 slots[j] = slots[j + 1];
187 private int GetMaxAvailableHeightSizeSum(notnull array<SCR_HUDSlotUIComponent> remainingSlots)
192 if (slot.GetRootWidget().IsVisible())
193 sum += GetMaxAvailableHeight(slot);
203 private int GetMaxAvailableWidthSizeSum(notnull array<SCR_HUDSlotUIComponent> remainingSlots)
208 if (slot.GetRootWidget().IsVisible())
209 sum += GetMaxAvailableWidth(slot);
222 if (!slot.GetRootWidget().IsVisible())
225 else if (slot.m_bSizeToContent)
226 return GetContentHeight(slot);
228 array<int> heightSteps = slot.m_aHeightSteps;
230 return heightSteps[heightSteps.Count() - 1];
240 if (!slot.GetRootWidget().IsVisible())
243 else if (slot.m_bSizeToContent)
244 return GetContentWidth(slot);
246 array<int> widthSteps = slot.m_aWidthSteps;
248 return widthSteps[widthSteps.Count() - 1];
258 if (!slot.GetRootWidget().IsVisible())
261 else if (slot.m_bSizeToContent)
262 return GetContentHeight(slot);
265 return slot.m_aHeightSteps[0];
275 if (!slot.GetRootWidget().IsVisible())
278 else if (slot.m_bSizeToContent)
279 return GetContentWidth(slot);
282 return slot.m_aWidthSteps[0];
294 array<int> heightSteps = slot.m_aHeightSteps;
295 if (!heightSteps || heightSteps.IsEmpty())
298 return heightSteps[heightSteps.Count() - 1];
301 Widget child = slot.GetContentWidget();
302 if (!child || !slot.GetRootWidget().IsVisible())
305 float childWidth, childHeight;
306 child.GetScreenSize(childWidth, childHeight);
307 childHeight =
GetGame().GetWorkspace().DPIUnscale(childHeight);
319 if (
SCR_Global.IsEditMode() && slot.m_bSizeToContent)
321 array<int> widthSteps = slot.m_aWidthSteps;
322 if (!widthSteps || widthSteps.IsEmpty())
325 return widthSteps[widthSteps.Count() - 1];
328 Widget child = slot.GetRootWidget().GetChildren();
329 if (!child || !slot.GetRootWidget().IsVisible())
332 float childWidth, childHeight;
333 child.GetScreenSize(childWidth, childHeight);
334 childWidth =
GetGame().GetWorkspace().DPIUnscale(childWidth);