DayZ 1.24
Loading...
Searching...
No Matches
ModsMenuSimple.c
Go to the documentation of this file.
1class ModsMenuSimple extends ScriptedWidgetEventHandler
2{
3 protected const int MOD_DISPLAY_COUNT_MAX = 3;
4
5 protected Widget m_Root;
9 protected ModsMenuDetailed m_DetailMenu;
10
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);
21 }
22
24 {
25 delete m_Root;
26 }
27
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
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}
Icon x
Icon y
Widget m_Root
Definition SizeToChild.c:85
Definition EnMath.c:7
map: item x vector(index, width, height)
Definition EnWidgets.c:651
ref map< ModInfo, ref ModsMenuSimpleEntry > m_Data
override bool OnFocusLost(Widget w, int x, int y)
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
ModsMenuDetailed m_DetailMenu
void ModsMenuSimple(array< ref ModInfo > data, Widget parent, ModsMenuDetailed detail_menu)
void LoadEntries(array< ref ModInfo > data)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
void ModsMenuSimpleEntry(ModInfo data, int index, Widget parent, ModsMenuSimple parent_menu)
override bool OnFocus(Widget w, int x, int y)
override bool OnMouseEnter(Widget w, int x, int y)
proto native CGame GetGame()
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
proto void Insert(int index, string input)
Inserts a string into the n-th index, increasing the string length by the size of the input.