Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
missionbase.c
Go to the documentation of this file.
2 {
3  PluginDeveloper m_ModuleDeveloper;
4  PluginKeyBinding m_ModuleKeyBinding
5  PluginAdditionalInfo m_ModuleServerInfo;
6 
7  ref WidgetEventHandler m_WidgetEventHandler;
8  ref WorldData m_WorldData;
9  ref WorldLighting m_WorldLighting;
10 
11  ref array<PlayerBase> m_DummyPlayers = new array<PlayerBase>;
12 
13  autoptr ObjectSnapCallback m_InventoryDropCallback;
14 
15  void MissionBase()
16  {
17  SetDispatcher(new DispatcherCaller);
18 
20 
21  m_WidgetEventHandler = new WidgetEventHandler;
22 
23  m_InventoryDropCallback = new EntityPlacementCallback;
24 
25  //Debug.DestroyAllShapes();
26 
27  //TODO clea up after Gamescom
28  m_ModuleServerInfo = PluginAdditionalInfo.Cast( GetPlugin(PluginAdditionalInfo) );
29  //
30  SoundSetMap.Init();
31 
32  if (GetGame().IsServer())
33  {
34  InitialiseWorldData();
35  }
36  else
37  {
38  GetDayZGame().GetAnalyticsClient().RegisterEvents();
39  m_WorldLighting = new WorldLighting;
40  }
41 
42  GetOnInputDeviceConnected().Insert(UpdateInputDevicesAvailability);
43  GetOnInputDeviceDisconnected().Insert(UpdateInputDevicesAvailability);
44 
45  // There is a possibility different maps/servers may be using different effects
46  SEffectManager.Cleanup();
47  GetUApi().UpdateControls();
48  }
49 
50  void ~MissionBase()
51  {
53 
54  if ( GetGame().IsClient() )
55  {
56  GetDayZGame().GetAnalyticsClient().UnregisterEvents();
57  }
58  TriggerEffectManager.DestroyInstance();
59  }
60 
61  override ObjectSnapCallback GetInventoryDropCallback()
62  {
63  return m_InventoryDropCallback;
64  }
65 
66  void InitialiseWorldData()
67  {
68  string worldName = "empty";
69  GetGame().GetWorldName(worldName);
70  worldName.ToLower();
71 
72  switch (worldName)
73  {
74  case "chernarusplus":
75  m_WorldData = new ChernarusPlusData();
76  break;
77 
78  case "enoch":
79  m_WorldData = new EnochData();
80  break;
81 
82  #ifdef PLATFORM_CONSOLE
83  case "mainmenuscenexbox":
84  m_WorldData = new MainMenuWorldData();
85  break
86  #endif
87 
88  default:
89  m_WorldData = new ChernarusPlusData();
90  break;
91  }
92  }
93 
94  override WorldLighting GetWorldLighting()
95  {
96  return m_WorldLighting;
97  }
98 
99  override WorldData GetWorldData()
100  {
101  return m_WorldData;
102  }
103 
104  override UIScriptedMenu CreateScriptedMenu(int id)
105  {
106  UIScriptedMenu menu = NULL;
107 
108  switch (id)
109  {
110  case MENU_MAIN:
111 #ifdef PLATFORM_CONSOLE
112  menu = new MainMenuConsole;
113 #else
114  menu = new MainMenu;
115 #endif
116  break;
117  case MENU_INGAME:
118 #ifdef PLATFORM_CONSOLE
119  menu = new InGameMenuXbox;
120 #else
121  menu = new InGameMenu;
122 #endif
123  break;
124  case MENU_CHARACTER:
125  menu = new CharacterCreationMenu;
126  break;
127  case MENU_OPTIONS:
128  menu = new OptionsMenu;
129  break;
130  case MENU_STARTUP:
131  menu = new StartupMenu;
132  break;
133  case MENU_LOADING:
134  menu = new LoadingMenu;
135  break;
136  case MENU_INVENTORY:
137  menu = new InventoryMenu;
138  break;
139  case MENU_INSPECT:
140  menu = new InspectMenuNew;
141  break;
142  case MENU_EARLYACCESS:
143  menu = new EarlyAccessMenu;
144  break;
145  case MENU_SCRIPTCONSOLE:
146  menu = new ScriptConsole;
147  break;
149  menu = new ScriptConsoleNewPresetDialog;
150  break;
152  menu = new ScriptConsoleRenamePresetDialog;
153  break;
155  menu = new ScriptConsoleUniversalInfoDialog;
156  break;
157  case MENU_CHAT_INPUT:
158  menu = new ChatInputMenu;
159  break;
161  menu = new PresetsMenu;
162  break;
163  case MENU_NOTE:
164  menu = new NoteMenu;
165  break;
166  case MENU_MAP:
167  menu = new MapMenu;
168  break;
169  case MENU_BOOK:
170  menu = new BookMenu;
171  break;
172  case MENU_SCENE_EDITOR:
173  menu = new SceneEditorMenu;
174  break;
175  case MENU_HELP_SCREEN:
176  menu = new HelpScreen;
177  break;
178  case MENU_GESTURES:
179  menu = new GesturesMenu;
180  break;
181  case MENU_LOGOUT:
182  menu = new LogoutMenu;
183  break;
184  case MENU_TITLE_SCREEN:
185  menu = new TitleScreenMenu;
186  break;
187  case MENU_XBOX_CONTROLS:
188  menu = new ControlsXboxNew;
189  break;
191  menu = new RadialQuickbarMenu;
192  break;
193  case MENU_SERVER_BROWSER:
194  menu = new ServerBrowserMenuNew;
195  break;
196  case MENU_LOGIN_QUEUE:
197  menu = new LoginQueueBase;
198  break;
199  case MENU_LOGIN_TIME:
200  menu = new LoginTimeBase;
201  break;
202  case MENU_CAMERA_TOOLS:
203  menu = new CameraToolsMenu;
204  break;
205  case MENU_VIDEO:
206  menu = new MainMenuVideo;
207  break;
208  case MENU_KEYBINDINGS:
209  menu = new KeybindingsMenu;
210  break;
211  case MENU_TUTORIAL:
212  menu = new TutorialsMenu;
213  break;
214  case MENU_CREDITS:
215  menu = new CreditsMenu;
216  break;
217  case MENU_INVITE_TIMER:
218  menu = new InviteMenu;
219  break;
221  menu = new ItemDropWarningMenu;
222  break;
224  menu = new InputDeviceDisconnectWarningMenu;
225  break;
227  menu = new PlayerRepositionWarningMenu;
228  break;
230  menu = new RespawnDialogue;
231  break;
232  case MENU_CONNECT_ERROR:
233  menu = new ConnectErrorScriptModuleUI;
234  break;
235  case MENU_LOC_ADD:
236  menu = new ScriptConsoleAddLocation;
237  break;
238  case MENU_MISSION_LOADER:
239  menu = new MissionLoader;
240  break;
241  }
242 
243  if (menu)
244  {
245  menu.SetID(id);
246  }
247 
248  return menu;
249  }
250 
251  void SpawnItems();
252 
253  void UpdateInputDevicesAvailability()
254  {
255  g_Game.RefreshMouseCursorVisibility();
256  }
257 
258  override void OnKeyPress(int key)
259  {
260  super.OnKeyPress(key);
261 
262 #ifdef DIAG_DEVELOPER
263  if ( PluginKeyBinding.instance )
264  {
265  PluginKeyBinding.instance.OnKeyPress(key);
266  }
267 #endif
268  }
269 
270  int m_WidgetsTotal;
271  int m_WidgetsInvisible;
272 
273  void DumpCurrentUILayout()
274  {
275  UIScriptedMenu current_menu = GetGame().GetUIManager().GetMenu();
276 
277  if ( current_menu )
278  {
279  Widget widget_root = current_menu.GetLayoutRoot();
280 
281  if ( widget_root )
282  {
283  m_WidgetsTotal = 0;
284  m_WidgetsInvisible = 0;
285 
286  Print( widget_root.GetName() +" ("+ widget_root.GetTypeName() +")");
287 
288  DumpWidget(widget_root.GetChildren(), 1);
289 
290  Print( "Widgets TOTAL: "+ m_WidgetsTotal.ToString() +" INVISIBLE: "+ m_WidgetsInvisible.ToString() +" VISIBLE: "+ (m_WidgetsTotal - m_WidgetsInvisible).ToString() );
291  }
292  }
293  }
294 
295  void DumpWidget(Widget w, int tabs)
296  {
297  if ( !w )
298  {
299  return;
300  }
301 
302  m_WidgetsTotal++;
303 
304  string tmp;
305  for (int i = 0; i < tabs; i++)
306  {
307  tmp += " ";
308  }
309 
310  string invisible = "";
311 
312  if ( !w.IsVisibleHierarchy() )
313  {
314  invisible = "[invisible]";
315  m_WidgetsInvisible++;
316  }
317 
318  Print( tmp +"- "+ w.GetName() +" ("+ w.GetTypeName() +") "+ invisible );
319 
320  bool collapse = false;
321  if ( w.GetChildren() )
322  {
323  collapse = true;
324  Print(tmp +"{");
325  }
326 
327  DumpWidget(w.GetChildren(), tabs + 1);
328 
329  if ( collapse )
330  {
331  Print(tmp +"}");
332  }
333 
334  DumpWidget(w.GetSibling(), tabs);
335  }
336 
337  override void OnKeyRelease(int key)
338  {
339  super.OnKeyRelease(key);
340 
341  if ( GetGame().IsDebug() )
342  {
343  if ( PluginKeyBinding.instance != NULL )
344  {
345  PluginKeyBinding.instance.OnKeyRelease(key);
346  }
347  }
348  }
349 
350  override void OnMouseButtonPress(int button)
351  {
352  super.OnMouseButtonPress(button);
353 
354  if ( GetGame().IsDebug() )
355  {
356  if ( PluginKeyBinding.instance != NULL )
357  {
358  PluginKeyBinding.instance.OnMouseButtonPress(button);
359  }
360  }
361  }
362 
363  override void OnMouseButtonRelease(int button)
364  {
365  super.OnMouseButtonRelease(button);
366 
367  if ( GetGame().IsDebug() )
368  {
369  if ( PluginKeyBinding.instance != NULL )
370  {
371  PluginKeyBinding.instance.OnMouseButtonRelease(button);
372  }
373  }
374  }
375 
376  void OnLog(string msg_log)
377  {
378  if ( PluginDeveloper.GetInstance() )
379  {
380  if ( GetGame().IsServer() && !GetGame().IsMultiplayer() )
381  {
382  PluginDeveloper.GetInstance().PrintLogClient(msg_log);
383  }
384  else if ( GetGame().IsMultiplayer() && GetGame().IsClient() )
385  {
386  PluginDeveloper.GetInstance().PrintLogClient(msg_log);
387  }
388  }
389  }
390 
391  void UpdateDummyScheduler()
392  {
393  for(int i = 0; i < m_DummyPlayers.Count(); i++)
394  {
395  if (m_DummyPlayers.Get(i))
396  {
397  m_DummyPlayers.Get(i).OnTick();
398  }
399  }
400  }
401 
402  override void AddDummyPlayerToScheduler(Man player)
403  {
404  m_DummyPlayers.Insert(PlayerBase.Cast( player ));
405  }
406 
407 #ifdef DIAG_DEVELOPER
408  void UpdateInputDeviceDiag()
409  {
410  DisplayInputDebug(DiagMenu.GetBool(DiagMenuIDs.MISC_INPUT_DEVICE_DISCONNECT_DBG));
411  }
412 
413  void DisplayInputDebug(bool show)
414  {
415  DbgUI.BeginCleanupScope();
416  DbgUI.Begin("InputDeviceDebug", 60, 60);
417 
418  if (show)
419  {
420  DbgUI.Text("Gamepad: " + g_Game.GetInput().IsActiveGamepadSelected());
421  DbgUI.Text("Mouse: " + g_Game.GetInput().IsMouseConnected());
422  DbgUI.Text("Keyboard: " + g_Game.GetInput().IsKeyboardConnected());
423  }
424 
425  DbgUI.End();
426  DbgUI.EndCleanupScope();
427  }
428 #endif
429 }
430 
431 class MissionDummy extends MissionBase
432 {
433 }
MENU_WARNING_TELEPORT
const int MENU_WARNING_TELEPORT
Definition: constants.c:200
GetGame
proto native CGame GetGame()
MENU_INSPECT
const int MENU_INSPECT
Definition: constants.c:169
UIScriptedMenu
Definition: dayzgame.c:63
SoundSetMap
Definition: soundsetmap.c:1
SpawnItems
void SpawnItems(ActionData action_data)
Definition: actionskinning.c:257
MENU_WARNING_ITEMDROP
const int MENU_WARNING_ITEMDROP
Definition: constants.c:198
MENU_HELP_SCREEN
const int MENU_HELP_SCREEN
Definition: constants.c:183
MENU_SCENE_EDITOR
const int MENU_SCENE_EDITOR
Definition: constants.c:167
MENU_LOC_ADD
const int MENU_LOC_ADD
Definition: constants.c:162
MENU_SCRIPTCONSOLE_DIALOG_PRESET_RENAME
const int MENU_SCRIPTCONSOLE_DIALOG_PRESET_RENAME
Definition: constants.c:178
MENU_BOOK
const int MENU_BOOK
Definition: constants.c:182
PlayerRepositionWarningMenu
Definition: itemdropwarningmenu.c:121
MENU_CONNECT_ERROR
const int MENU_CONNECT_ERROR
Definition: constants.c:201
MENU_STARTUP
const int MENU_STARTUP
Definition: constants.c:174
MENU_MAP
const int MENU_MAP
Definition: constants.c:181
DbgUI
Definition: dbgui.c:59
MENU_SERVER_BROWSER
const int MENU_SERVER_BROWSER
Definition: constants.c:190
GetDayZGame
DayZGame GetDayZGame()
Definition: dayzgame.c:3729
DiagMenu
Definition: endebug.c:232
MENU_RADIAL_QUICKBAR
const int MENU_RADIAL_QUICKBAR
Definition: constants.c:188
PluginManagerDelete
void PluginManagerDelete()
Definition: pluginmanager.c:297
SetDispatcher
void SetDispatcher(Dispatcher dispatcher)
Definition: dispatcher.c:31
MENU_WARNING_INPUTDEVICE_DISCONNECT
const int MENU_WARNING_INPUTDEVICE_DISCONNECT
Definition: constants.c:202
MENU_SCRIPTCONSOLE_UNIVERSAL_INFO_DIALOG
const int MENU_SCRIPTCONSOLE_UNIVERSAL_INFO_DIALOG
Definition: constants.c:203
ConnectErrorScriptModuleUI
Definition: connecterrorscriptmodule.c:51
Print
proto void Print(void var)
Prints content of variable to console/log.
MENU_SCRIPTCONSOLE
const int MENU_SCRIPTCONSOLE
Definition: constants.c:175
MENU_CHARACTER
const int MENU_CHARACTER
Definition: constants.c:164
MENU_LOADING
const int MENU_LOADING
Definition: constants.c:171
WorldLighting
Definition: worldlighting.c:1
LoginQueueBase
void LoginQueueBase()
Definition: dayzgame.c:112
MENU_LOGIN_TIME
const int MENU_LOGIN_TIME
Definition: constants.c:197
MENU_INVENTORY
const int MENU_INVENTORY
Definition: constants.c:170
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition: pluginmanager.c:316
TriggerEffectManager
Definition: triggereffectmanager.c:3
EntityPlacementCallback
Definition: entityplacementcallback.c:1
DiagMenuIDs
DiagMenuIDs
Definition: ediagmenuids.c:1
PlayerBase
Definition: playerbaseclient.c:1
MENU_GESTURES
const int MENU_GESTURES
Definition: constants.c:184
MissionBaseWorld
Definition: missionbase.c:1
MENU_CHAT_INPUT
const int MENU_CHAT_INPUT
Definition: constants.c:176
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
MENU_CAMERA_TOOLS
const int MENU_CAMERA_TOOLS
Definition: constants.c:191
MENU_INVITE_TIMER
const int MENU_INVITE_TIMER
Definition: constants.c:196
MENU_SCRIPTCONSOLE_DIALOG_PRESET_NAME
const int MENU_SCRIPTCONSOLE_DIALOG_PRESET_NAME
Definition: constants.c:177
MENU_KEYBINDINGS
const int MENU_KEYBINDINGS
Definition: constants.c:193
MENU_CREDITS
const int MENU_CREDITS
Definition: constants.c:195
WorldData
Keeps information about currently loaded world, like temperature.
Definition: worlddata.c:2
MENU_XBOX_CONTROLS
const int MENU_XBOX_CONTROLS
Definition: constants.c:187
MENU_OPTIONS
const int MENU_OPTIONS
Definition: constants.c:173
LoginTimeBase
LoginTime when using -connect since mission is not created yet.
Definition: dayzgame.c:323
MENU_LOGIN_QUEUE
const int MENU_LOGIN_QUEUE
Definition: constants.c:189
array< PlayerBase >
MENU_CONTROLS_PRESET
const int MENU_CONTROLS_PRESET
Definition: constants.c:179
MENU_RESPAWN_DIALOGUE
const int MENU_RESPAWN_DIALOGUE
Definition: constants.c:199
MENU_INGAME
const int MENU_INGAME
Definition: constants.c:168
MENU_TITLE_SCREEN
const int MENU_TITLE_SCREEN
Definition: constants.c:186
MENU_LOGOUT
const int MENU_LOGOUT
Definition: constants.c:185
MENU_MISSION_LOADER
const int MENU_MISSION_LOADER
Definition: constants.c:204
InventoryMenu
void InventoryMenu()
Definition: inventorymenu.c:20
MENU_VIDEO
const int MENU_VIDEO
Definition: constants.c:192
Widget
Definition: enwidgets.c:189
GetUApi
proto native UAInputAPI GetUApi()
MENU_NOTE
const int MENU_NOTE
Definition: constants.c:180
MENU_EARLYACCESS
const int MENU_EARLYACCESS
Definition: constants.c:166
PluginManagerInit
void PluginManagerInit()
Definition: pluginmanager.c:287
MissionBase
Definition: missiongameplay.c:1
SEffectManager
Manager class for managing Effect (EffectParticle, EffectSound)
Definition: effectmanager.c:5
MENU_MAIN
const int MENU_MAIN
Definition: constants.c:172
WidgetEventHandler
Definition: widgeteventhandler.c:1
MENU_TUTORIAL
const int MENU_TUTORIAL
Definition: constants.c:194