Dayz Explorer 1.28.160049
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;
5 protected Widget m_CloseButton;
6 protected ScrollWidget m_Scroll;
8
9 protected ModInfo m_Highlighted;
10
11 //protected MainMenu m_Menu;
12 protected UIScriptedMenu m_Menu;
13 protected ModsMenuTooltip m_Tooltip;
14 protected ref Timer m_TooltipTimer;
15 protected ModInfo m_TooltipMod;
16
17 void ModsMenuDetailed(array<ref ModInfo> data, Widget parent, ModsMenuTooltip tooltip, UIScriptedMenu menu_parent)
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
24 m_Menu = menu_parent;
26 m_Tooltip = tooltip;
27
28 m_Root.SetHandler(this);
29
30 LoadEntries(data);
31 }
32
33 void ~ModsMenuDetailed()
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 {
48 Highlight( null );
49 m_Root.Show( false );
50 GetGame().GetMission().GetOnModMenuVisibilityChanged().Invoke(true);
51 }
52
53 bool IsOpen()
54 {
55 return m_Root.IsVisible();
56 }
57
58 ModInfo GetHighlighted()
59 {
60 return m_Highlighted;
61 }
62
63 void HighlightFirst()
64 {
65 Highlight( m_Data.GetKey( 0 ) );
66 }
67
68 void Highlight( ModInfo mod_ref )
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
85 void ScrollToMod( ModInfo mod_ref )
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 {
132 m_Highlighted = null;
133 }
134 }
135 }
136
137 ScrollToMod( m_Highlighted );
138 }
139
140 void PrepareTooltip( ModInfo mod_ref )
141 {
142 if ( m_Tooltip )
143 {
144 m_TooltipMod = mod_ref;
145 if ( !m_TooltipTimer )
146 m_TooltipTimer = new Timer(CALL_CATEGORY_GUI);
147
148 m_TooltipTimer.Run( 1, this, "ShowTooltip" );
149 }
150 }
151
152 void ShowTooltip()
153 {
154 if ( m_Tooltip )
155 m_Tooltip.ShowTooltip( m_TooltipMod );
156 }
157
158 void HideTooltip()
159 {
160 if ( m_TooltipTimer )
161 m_TooltipTimer.Stop();
162
163 m_TooltipMod = null;
164 if ( m_Tooltip )
165 m_Tooltip.HideTooltip();
166 }
167
168 void LoadEntries( array<ref ModInfo> data )
169 {
170 foreach (ModInfo var : data)
171 {
172 ModsMenuDetailedEntry entry = new ModsMenuDetailedEntry(var, m_Content, this);
173 m_Data.Insert(var, entry);
174 }
175
176 m_Content.Update();
177 float y_c = m_Scroll.GetContentHeight();
178 float x, y;
179 m_Content.GetScreenSize( x, y );
180 if ( y > y_c )
181 {
182 m_Scroll.SetAlpha( 1 );
183 }
184 }
185
186 override bool OnMouseButtonUp(Widget w, int x, int y, int button)
187 {
188 if ( w == m_CloseButton )
189 {
190 Close();
191 return true;
192 }
193 return false;
194 }
195}
Open
Implementations only.
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
const int CALL_CATEGORY_GUI
Definition tools.c:9
Icon x
Icon y
bool IsOpen()
Definition itembase.c:8938
void Close()
ButtonWidget m_CloseButton
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
Definition radialmenu.c:668
ServerBrowserMenuNew m_Menu
Widget m_Root
Definition sizetochild.c:91