Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
uimanager.c
Go to the documentation of this file.
1 class UIManager
2 {
4  proto native UIScriptedMenu EnterScriptedMenu(int id, UIMenuPanel parent);
5  proto native UIScriptedMenu CreateScriptedMenu(int id, UIMenuPanel parent);
6 
7  proto native void EnterServerBrowser(UIMenuPanel parentMenu);
8 
9  proto native UIScriptedMenu ShowScriptedMenu(UIScriptedMenu menu, UIMenuPanel parent);
10  proto native void HideScriptedMenu(UIScriptedMenu menu);
11 
12  proto native Widget GetWidgetUnderCursor();
13  proto native bool IsDialogVisible();
14  proto native bool IsModalVisible();
15  proto native void CloseSpecificDialog(int id);
16  proto native void CloseDialog();
17  proto native void HideDialog();
18 
43  proto native void ShowDialog(string caption, string text, int id, int butts /*DBT_*/, int def/*DBB_*/, int type /*DMT_*/, UIScriptedMenu handler);
45  proto native bool ShowCursor(bool visible);
46  proto native bool IsCursorVisible();
47  proto native bool IsDialogQueued();
48  proto native bool ShowQueuedDialog();
49  proto native int GetLoginQueuePosition();
50  proto native bool ScreenFadeVisible();
51  proto native void ScreenFadeIn(float duration, string text, int backgroundColor, int textColor);
52  proto native void ScreenFadeOut(float duration);
53  proto native bool IsScaledMode();
54  proto native void SetScaledMode(bool enabled);
55 
57  proto native UIScriptedMenu GetMenu();
58 
60  bool Back()
61  {
62  if (IsDialogVisible() == false)
63  {
64  UIMenuPanel menu = GetMenu();
65  if (menu)
66  {
67  menu.Close();
68  return true;
69  }
70  }
71 
72  return false;
73  }
74 
76  bool CloseAll()
77  {
78  UIMenuPanel menu = GetMenu();
79  while (menu)
80  {
81  if (menu.GetParentMenu())
82  {
83  menu = menu.GetParentMenu();
84  }
85  else
86  {
87  menu.Close();
88  return true;
89  }
90  }
91 
92  return false;
93  }
94 
96  bool CloseAllSubmenus()
97  {
98  UIMenuPanel menu = GetMenu();
99 
100  while (menu && menu.GetParentMenu() && menu.GetParentMenu().GetParentMenu())
101  {
102  menu = menu.GetParentMenu();
103  }
104 
105  if (menu && menu.GetParentMenu())
106  {
107  menu.Close();
108  return true;
109  }
110 
111  return false;
112  }
113 
115  bool CloseMenu(int id)
116  {
117  UIMenuPanel menu = GetMenu();
118 
119  while (menu)
120  {
121  if (menu.GetID() == id)
122  {
123  menu.Close();
124  return true;
125  }
126 
127  menu = menu.GetParentMenu();
128  }
129 
130  return false;
131  }
132 
133  bool HideMenu(int id)
134  {
135  UIScriptedMenu menu = GetMenu();
136 
137  while (menu)
138  {
139  if (menu.GetID() == id)
140  {
141  HideScriptedMenu( menu );
142  return true;
143  }
144 
145  menu = UIScriptedMenu.Cast( menu.GetParentMenu() );
146  }
147 
148  return false;
149  }
150 
152  bool IsMenuOpen(int id)
153  {
154  return FindMenu(id) != null;
155  }
156 
158  UIScriptedMenu FindMenu(int id)
159  {
160  UIScriptedMenu menu = GetMenu();
161 
162  while (menu)
163  {
164  if (menu.GetID() == id)
165  {
166  return menu;
167  }
168 
169  menu = UIScriptedMenu.Cast( menu.GetParentMenu() );
170  }
171 
172  return NULL;
173  }
174 
175  //Window management
176  void OpenWindow( int id )
177  {
178  UIScriptedWindow window = UIScriptedWindow.GetWindow( id );
179 
180  //if window is already opened, close it
181  if ( window )
182  {
183  CloseWindow( id );
184 
185  return;
186  }
187 
188  //create new window
189  switch( id )
190  {
192  window = GetGame().GetMission().CreateScriptedWindow( id );
193  break;
194 
195  default: {};
196  }
197 
198  if ( window )
199  {
200  window.Init();
201 
202  //add to active windows
203  UIScriptedWindow.AddToActiveWindows( id, window );
204  }
205  }
206 
207  void CloseWindow( int id )
208  {
209  UIScriptedWindow window = UIScriptedWindow.GetWindow( id );
210 
211  if ( window )
212  {
213  UIScriptedWindow.RemoveFromActiveWindows( id );
214  window.HideWindow();
215 
216  //delete window;
217  GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(this.DeleteWindow, window );
218  /*
219  wtf? leak
220  Timer delete_timer = new Timer ( CALL_CATEGORY_SYSTEM );
221  Param1<UIScriptedWindow> params = new Param1<UIScriptedWindow>( window );
222  delete_timer.Run( 0.5, this, "DeleteWindow", params, false );*/
223 
224  }
225  }
226 
227  void DeleteWindow( UIScriptedWindow window )
228  {
229  delete window;
230  }
231 
232  bool IsWindowOpened( int id )
233  {
234  if ( UIScriptedWindow.GetWindow( id ) )
235  {
236  return true;
237  }
238 
239  return false;
240  }
241 
242  void ShowUICursor( bool visible )
243  {
244  g_Game.SetMouseCursorDesiredVisibility(visible);
245  }
246 };
247 
250 {
251  const string images[] = {"{655A1BF79F5B291}Gui/textures/loading_screens/loading_screen_1_co.edds", "{84BE5F7442BD4B}Gui/textures/loading_screens/loading_screen_2_co.edds"};
252  Math.Randomize(-1);
253  int index = Math.RandomInt(0, 100) % 2;
254  return images[index];
255 }
GetGame
proto native CGame GetGame()
UIScriptedMenu
Definition: dayzgame.c:63
CALL_CATEGORY_SYSTEM
const int CALL_CATEGORY_SYSTEM
Definition: tools.c:8
GUI_WINDOW_MISSION_LOADER
const int GUI_WINDOW_MISSION_LOADER
Definition: constants.c:207
UIManager
Definition: uimanager.c:1
UIMenuPanel
Part of main menu hierarchy to create custom menus from script.
Definition: uiscriptedmenu.c:2
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
UIScriptedWindow
Definition: uiscriptedwindow.c:1
GetRandomLoadingBackground
string GetRandomLoadingBackground()
Returns random loading background texture path.
Definition: uimanager.c:249
Widget
Definition: enwidgets.c:189
Math
Definition: enmath.c:6