Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
modsmenusimple.c
Go to the documentation of this file.
1 class ModsMenuSimple extends ScriptedWidgetEventHandler
2 {
3  protected const int MOD_DISPLAY_COUNT_MAX = 3;
4 
5  protected Widget m_Root;
6  protected Widget m_MoreButton;
7  protected Widget m_MoreHighlight;
9  protected ModsMenuDetailed m_DetailMenu;
10 
11  void ModsMenuSimple(array<ref ModInfo> data, Widget parent, ModsMenuDetailed detail_menu)
12  {
13  m_Root = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/mods_menu/mods_menu_simple.layout", parent);
14  m_MoreButton = m_Root.FindAnyWidget("ModMore");
15  m_MoreHighlight = m_Root.FindAnyWidget("ModMoreOverlay");
17  m_DetailMenu = detail_menu;
18 
19  m_Root.SetHandler(this);
20  LoadEntries(data);
21  }
22 
23  void ~ModsMenuSimple()
24  {
25  delete m_Root;
26  }
27 
28  void LoadEntries(array<ref ModInfo> data)
29  {
30  m_MoreButton.Show(data.Count() > MOD_DISPLAY_COUNT_MAX);
31  int count = Math.Clamp(data.Count(),0,MOD_DISPLAY_COUNT_MAX);
32 
33  for (int i = 0; i < count; i++)
34  {
35  ref ModsMenuSimpleEntry entry = new ModsMenuSimpleEntry(data[i], i, m_Root, this);
36  m_Data.Insert(data[i], entry);
37  }
38  }
39 
40  void Select(ModInfo mod)
41  {
42  m_DetailMenu.Open();
43  m_DetailMenu.Highlight(mod);
44  }
45 
46  override bool OnMouseButtonUp(Widget w, int x, int y, int button)
47  {
48  if (w == m_MoreButton)
49  {
50  if (m_DetailMenu.IsOpen())
51  m_DetailMenu.Close();
52  else
53  m_DetailMenu.Open();
54  return true;
55  }
56  return false;
57  }
58 
59  override bool OnMouseEnter(Widget w, int x, int y)
60  {
61  if (w == m_MoreButton)
62  {
63  m_MoreHighlight.Show(true);
64  return true;
65  }
66  return false;
67  }
68 
69  override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
70  {
71  if (enterW != m_MoreButton)
72  {
73  m_MoreHighlight.Show(false);
74  return true;
75  }
76  return false;
77  }
78 
79  override bool OnFocus(Widget w, int x, int y)
80  {
81  if (w == m_MoreButton)
82  {
83  m_MoreHighlight.Show(true);
84  return true;
85  }
86  return false;
87  }
88 
89  override bool OnFocusLost(Widget w, int x, int y)
90  {
91  if (w == m_MoreButton)
92  {
93  m_MoreHighlight.Show(false);
94  return true;
95  }
96  return false;
97  }
98 }
GetGame
proto native CGame GetGame()
ModInfo
Definition: modinfo.c:1
m_Data
string m_Data
Definition: universaltemperaturesource.c:205
y
Icon y
OnMouseLeave
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Definition: uihintpanel.c:276
OnMouseButtonUp
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
Definition: radialmenu.c:668
map
map
Definition: controlsxboxnew.c:3
OnFocusLost
override bool OnFocusLost(Widget w, int x, int y)
Definition: serverbrowsertab.c:235
array< ref ModInfo >
x
Icon x
OnFocus
override bool OnFocus(Widget w, int x, int y)
Definition: serverbrowsertab.c:217
Widget
Definition: enwidgets.c:189
Math
Definition: enmath.c:6
m_Root
protected Widget m_Root
Definition: sizetochild.c:91
OnMouseEnter
override bool OnMouseEnter(Widget w, int x, int y)
Definition: uihintpanel.c:267
ScriptedWidgetEventHandler
map: item x vector(index, width, height)
Definition: enwidgets.c:650