DayZ 1.24
Loading...
Searching...
No Matches
ModsMenuDetailed.c
Go to the documentation of this file.
1class ModsMenuDetailed extends ScriptedWidgetEventHandler
2{
3 protected Widget m_Root;
4 protected Widget m_Content;
8
10
11 //protected MainMenu m_Menu;
13 protected ModsMenuTooltip m_Tooltip;
16
18 {
19 m_Root = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/mods_menu/mods_menu_detailed.layout", parent);
20 m_Content = m_Root.FindAnyWidget("ModsDetailedContent");
21 m_Scroll = ScrollWidget.Cast(m_Root.FindAnyWidget("ModsDetailedScroller"));
22 m_CloseButton = m_Root.FindAnyWidget("ModsDetailedHeaderButton");
23
26 m_Tooltip = tooltip;
27
28 m_Root.SetHandler(this);
29
31 }
32
34 {
35 delete m_Root;
36 }
37
38 void Open()
39 {
40 if (!m_Root.IsVisible())
41 m_Scroll.VScrollToPos(0);
42 m_Root.Show(true);
43 GetGame().GetMission().GetOnModMenuVisibilityChanged().Invoke(false);
44 }
45
46 void Close()
47 {
49 m_Root.Show(false);
50 GetGame().GetMission().GetOnModMenuVisibilityChanged().Invoke(true);
51 }
52
53 bool IsOpen()
54 {
55 return m_Root.IsVisible();
56 }
57
59 {
60 return m_Highlighted;
61 }
62
64 {
65 Highlight(m_Data.GetKey(0));
66 }
67
69 {
70 if (m_Highlighted)
71 {
72 m_Data.Get(m_Highlighted).Deselect();
73 m_Content.Update();
74 }
75
76 m_Highlighted = mod_ref;
77 if (m_Highlighted)
78 {
79 m_Data.Get(m_Highlighted).Select();
80 m_Content.Update();
81 ScrollToMod(m_Highlighted);
82 }
83 }
84
86 {
87 /*
88 if( mod_ref )
89 {
90 float scroll_pos_x, scroll_pos_y;
91 float scroll_size_x, scroll_size_y;
92 float mod_pos_x, mod_pos_y;
93 float mod_size_x, mod_size_y;
94
95 Widget mod_widget = m_Data.Get( mod_ref ).GetWidget();
96 if( mod_widget )
97 {
98 m_Content.Update();
99 m_Scroll.Update();
100 m_Scroll.GetScreenPos( scroll_pos_x, scroll_pos_y );
101 m_Scroll.GetScreenSize( scroll_size_x, scroll_size_y );
102 mod_widget.GetScreenPos( mod_pos_x, mod_pos_y );
103 mod_widget.GetScreenSize( mod_size_x, mod_size_y );
104 if( mod_pos_y + mod_size_y >= scroll_pos_y + scroll_size_y )
105 {
106 m_Scroll.VScrollToPos( mod_pos_y + mod_size_y - scroll_pos_y );
107 }
108 else if( mod_pos_y <= scroll_pos_y )
109 {
110 m_Scroll.VScrollToPos( mod_pos_y - scroll_pos_y );
111 }
112 m_Scroll.VScrollToPos( mod_pos_y - scroll_pos_y );
113 }
114 }
115 */
116 }
117
118 void Select(ModInfo mod_ref, bool show)
119 {
120 if (mod_ref)
121 {
122 if (show)
123 {
124 m_Highlighted = mod_ref;
125 m_Data.Get(mod_ref).Select();
126 }
127 else
128 {
129 m_Data.Get(mod_ref).Deselect();
130 if (m_Highlighted == mod_ref)
131 m_Highlighted = null;
132 }
133 }
134
135 ScrollToMod(m_Highlighted);
136 }
137
139 {
140 if (m_Tooltip)
141 {
142 m_TooltipMod = mod_ref;
143 if (!m_TooltipTimer)
144 m_TooltipTimer = new Timer(CALL_CATEGORY_GUI);
145
146 m_TooltipTimer.Run(1, this, "ShowTooltip");
147 }
148 }
149
151 {
152 if (m_Tooltip)
153 m_Tooltip.ShowTooltip(m_TooltipMod);
154 }
155
157 {
158 if (m_TooltipTimer)
159 m_TooltipTimer.Stop();
160
161 m_TooltipMod = null;
162 if (m_Tooltip)
163 m_Tooltip.HideTooltip();
164 }
165
167 {
168 foreach (ModInfo var : data)
169 {
170 ModsMenuDetailedEntry entry = new ModsMenuDetailedEntry(var, m_Content, this);
171 m_Data.Insert(var, entry);
172 }
173
174 m_Content.Update();
175 float y_c = m_Scroll.GetContentHeight();
176 float x, y;
177 m_Content.GetScreenSize(x, y);
178 if (y > y_c)
179 m_Scroll.SetAlpha(1);
180 }
181
182 override bool OnMouseButtonUp(Widget w, int x, int y, int button)
183 {
184 if (w == m_CloseButton)
185 {
186 Close();
187 return true;
188 }
189 return false;
190 }
191}
Icon x
Icon y
ButtonWidget m_CloseButton
ServerBrowserMenuNew m_Menu
Widget m_Root
Definition SizeToChild.c:85
map: item x vector(index, width, height)
Definition EnWidgets.c:651
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
void ModsMenuDetailedEntry(ModInfo data, Widget parent, ModsMenuDetailed parent_menu)
void ScrollToMod(ModInfo mod_ref)
void Highlight(ModInfo mod_ref)
void LoadEntries(array< ref ModInfo > data)
void Select(ModInfo mod_ref, bool show)
void PrepareTooltip(ModInfo mod_ref)
ref map< ref ModInfo, ref ModsMenuDetailedEntry > m_Data
void ModsMenuDetailed(array< ref ModInfo > data, Widget parent, ModsMenuTooltip tooltip, UIScriptedMenu menu_parent)
proto native CGame GetGame()
proto string Get(int index)
Gets n-th character from string.
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.
const int CALL_CATEGORY_GUI
Definition tools.c:9