Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ToolboxMultilineComponent.c
Go to the documentation of this file.
2 {
3  [Attribute("4")]
4  protected int m_iMaxItemsInRow;
5 
6  [Attribute("36")]
7  float m_fElementHeight;
8 
9  //------------------------------------------------------------------------------------------------
10  override void HandlerAttached(Widget w)
11  {
12  super.HandlerAttached(w);
13  m_iMaxItemsInRow = Math.Max(m_iMaxItemsInRow, 1);
14  }
15 
16  //------------------------------------------------------------------------------------------------
17  override protected void CreateWidgets()
18  {
19  float padding = m_fElementSpacing * 0.5;
20  LayoutSlot.SetPadding(m_wButtonRow, -padding, -padding, -padding, -padding);
21  foreach (int i, string name : m_aElementNames)
22  {
23  Widget button = GetGame().GetWorkspace().CreateWidgets(m_ElementLayout, m_wButtonRow);
24 
25  int row = Math.Floor(i / m_iMaxItemsInRow);
26  int column = i % m_iMaxItemsInRow;
27  UniformGridSlot.SetRow(button, row);
28  UniformGridSlot.SetColumn(button, column);
29 
31  if (!comp)
32  continue;
33 
34  m_aSelectionElements.Insert(comp);
35 
37  if (textComp)
38  textComp.SetText(name);
39 
40  comp.m_OnClicked.Insert(OnElementClicked);
41  comp.m_OnToggled.Insert(OnElementChanged);
42 
43  SizeLayoutWidget size = SizeLayoutWidget.Cast(comp.GetRootWidget().GetChildren());
44  if (!size)
45  return;
46 
47  size.EnableHeightOverride(m_fElementHeight > 0);
48  size.SetHeightOverride(m_fElementHeight);
49  }
50 
51  SetInitialState();
52  }
53 
54  //------------------------------------------------------------------------------------------------
55  protected void RemoveWidgets()
56  {
57  foreach (SCR_ButtonBaseComponent comp : m_aSelectionElements)
58  {
59  comp.GetRootWidget().RemoveFromHierarchy();
60  }
61  m_aSelectionElements.Clear();
62  }
63 
64  //------------------------------------------------------------------------------------------------
65  void SetMaxItemsInRow(int maxItems)
66  {
67  if (m_iMaxItemsInRow == maxItems)
68  return;
69 
70  m_iMaxItemsInRow = maxItems;
71  m_iMaxItemsInRow = Math.Max(m_iMaxItemsInRow, 1);
72  RemoveWidgets();
73  CreateWidgets();
74  }
75 
76  //------------------------------------------------------------------------------------------------
77  int GetMaxItemsInRow()
78  {
79  return m_iMaxItemsInRow;
80  }
81 
82  //------------------------------------------------------------------------------------------------
83  SizeLayoutWidget FindSizeWidget(Widget root)
84  {
85  Widget child = root.GetChildren();
86  while (child)
87  {
88  SizeLayoutWidget size = SizeLayoutWidget.Cast(child);
89  if (size)
90  return size;
91  child = child.GetChildren();
92  }
93  return null;
94  }
95 };
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_ButtonTextComponent
Definition: SCR_ButtonTextComponent.c:2
SCR_ButtonBaseComponent
Base class for any button, regardless its own content.
Definition: SCR_ButtonBaseComponent.c:3
SCR_ToolboxComponent
Definition: SCR_ToolboxComponent.c:2
SCR_ToolboxMultilineComponent
Definition: SCR_ToolboxMultilineComponent.c:1