Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
missionmainmenu.c
Go to the documentation of this file.
1 class MissionMainMenu extends MissionBase
2 {
3  private UIScriptedMenu m_mainmenu;
4  private CreditsMenu m_CreditsMenu;
5  private ref DayZIntroScenePC m_IntroScenePC;
6  private ref DayZIntroSceneXbox m_IntroSceneXbox;
7  private AbstractWave m_MenuMusic;
8  bool m_NoCutscene;
9 
10  override void OnInit()
11  {
12  if (!m_NoCutscene)
13  {
14  CreateIntroScene();
15  }
16 
17  if (!m_mainmenu)
18  {
19  #ifdef PLATFORM_CONSOLE
20  if ( g_Game.GetGameState() != DayZGameState.PARTY )
21  {
22  m_mainmenu = UIScriptedMenu.Cast( g_Game.GetUIManager().EnterScriptedMenu( MENU_TITLE_SCREEN, null ) );
23  }
24  #else
25  m_mainmenu = UIScriptedMenu.Cast( g_Game.GetUIManager().EnterScriptedMenu( MENU_MAIN, null ) );
26  #endif
27  }
28 
29  GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
30  }
31 
32  override void Reset()
33  {
34  #ifdef PLATFORM_CONSOLE
35  delete m_IntroSceneXbox;
36  #else
37  delete m_IntroScenePC;
38  #endif
39 
40  CreateIntroScene();
41  }
42 
43  DayZIntroScenePC GetIntroScenePC()
44  {
45  #ifdef PLATFORM_CONSOLE
46  Error("missionMainMenu->GetIntroScenePC on PLATFORM_CONSOLE is not implemented!");
47  return null;
48  #else
49  return m_IntroScenePC;
50  #endif
51  }
52 
53  DayZIntroSceneXbox GetIntroSceneXbox()
54  {
55  #ifdef PLATFORM_CONSOLE
56  return m_IntroSceneXbox;
57  #else
58  Error("missionMainMenu->GetIntroScenePC on PLATFORM_PC is not implemented!");
59  return null;
60  #endif
61  }
62 
63  void CreateIntroScene()
64  {
65 #ifdef PLATFORM_CONSOLE
66  m_IntroSceneXbox = new DayZIntroSceneXbox;
67 #else
68  m_IntroScenePC = new DayZIntroScenePC;
69 #endif
70  }
71 
72  override void UpdateInputDevicesAvailability()
73  {
74  super.UpdateInputDevicesAvailability();
75 
76  g_Game.GetInput().UpdateConnectedInputDeviceList();
77  g_Game.UpdateInputDeviceDisconnectWarning();
78  }
79 
80  override void OnMissionStart()
81  {
82  if (m_mainmenu)
83  {
84  //m_mainmenu.FadeIn(2.0); //Fade in method is currently commented in MainMenu class
85  }
86  g_Game.GetUIManager().ShowUICursor(true);
87  g_Game.SetMissionState( DayZGame.MISSION_STATE_MAINMENU );
88 
89  //Print("*** MissionMainMenu.OnMissionStart()");
90  g_Game.LoadingHide(true);
91  ProgressAsync.DestroyAllPendingProgresses();
92  PlayMusic();
93  }
94 
95  override void OnMissionFinish()
96  {
97  if ( m_mainmenu )
98  m_mainmenu.Cleanup();
99  GetGame().GetUIManager().CloseAll();
100  m_mainmenu = NULL;
101 
102  m_IntroScenePC = null;
103  m_IntroSceneXbox = null;
104  m_CreditsMenu = null;
105 #ifndef FEATURE_CURSOR
106  g_Game.GetUIManager().ShowUICursor(false);
107 #endif
108  }
109 
110  override void OnUpdate(float timeslice)
111  {
112  super.OnUpdate(timeslice);
113 
114 #ifdef DIAG_DEVELOPER
115  UpdateInputDeviceDiag();
116 #endif
117 
118  if ( g_Game.IsLoading() )
119  {
120  return;
121  }
122 
123  if (m_IntroScenePC)
124  {
125  m_IntroScenePC.Update();
126  }
127  }
128 
129  void OnMenuEnter(int menu_id)
130  {
131  switch (menu_id)
132  {
133  case MENU_CREDITS:
134  {
135  m_CreditsMenu = CreditsMenu.Cast(GetGame().GetUIManager().GetMenu());
136  }
137  }
138  }
139 
140  void OnInputDeviceChanged(int device)
141  {
142  if (m_CreditsMenu)
143  {
144  m_CreditsMenu.UpdateInfoPanelText(device);
145  }
146  }
147 
148  void PlayMusic()
149  {
150  if ( !m_MenuMusic )
151  {
152  SoundParams soundParams = new SoundParams( "Music_Menu_SoundSet" );
153  SoundObjectBuilder soundBuilder = new SoundObjectBuilder( soundParams );
154  SoundObject soundObject = soundBuilder.BuildSoundObject();
155  soundObject.SetKind( WaveKind.WAVEMUSIC );
156  m_MenuMusic = GetGame().GetSoundScene().Play2D(soundObject, soundBuilder);
157  m_MenuMusic.Loop( true );
158  m_MenuMusic.Play();
159  }
160  }
161 
162  void StopMusic()
163  {
164  if ( m_MenuMusic )
165  m_MenuMusic.Stop();
166  }
167 
168  AbstractWave GetMenuMusic()
169  {
170  return m_MenuMusic;
171  }
172 
173  int SortedInsert( array<int> list, int number )
174  {
175  int find_number = number;
176  int index_min = 0;
177  int index_max = list.Count() - 1;
178  int target_index = Math.Floor( index_max / 2 );
179 
180  if ( index_max == -1 )
181  {
182  list.Insert( number );
183  return 0;
184  }
185 
186  while ( true )
187  {
188  int target_value = list[target_index];
189 
190  if ( find_number == target_value || ((index_max - index_min) <= 1) )
191  {
192  for ( int i = index_min; i <= index_max; i++ )
193  {
194  if ( find_number <= list[i] )
195  {
196  list.InsertAt( find_number, i );
197  return i;
198  }
199  }
200 
201  index_max++;
202  list.InsertAt( find_number, index_max );
203  return target_index;
204  }
205  else if ( find_number < target_value )
206  {
207  index_max = target_index;
208  target_index = Math.Floor( target_index / 2 );
209  }
210  else if ( find_number > target_value )
211  {
212  index_min = target_index;
213  target_index += Math.Floor( (index_max - index_min) / 2 );
214  }
215  }
216 
217  return target_index;
218  }
219 }
GetGame
proto native CGame GetGame()
UIScriptedMenu
Definition: dayzgame.c:63
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
SoundObject
class SoundObjectBuilder SoundObject(SoundParams soundParams)
SoundObjectBuilder
void SoundObjectBuilder(SoundParams soundParams)
OnInputDeviceChanged
protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
Definition: inventory.c:167
ProgressAsync
Definition: progressasync.c:1
SoundParams
Definition: sound.c:100
DayZIntroSceneXbox
Definition: dayzintroscenexbox.c:1
DayZIntroScenePC
Definition: dayzintroscenepc.c:1
OnUpdate
proto native void OnUpdate()
Definition: tools.c:349
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
WaveKind
WaveKind
Definition: sound.c:1
MENU_CREDITS
const int MENU_CREDITS
Definition: constants.c:195
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
MENU_TITLE_SCREEN
const int MENU_TITLE_SCREEN
Definition: constants.c:186
Reset
void Reset()
Definition: inventory.c:1106
SoundObjectBuilder
Definition: sound.c:45
OnInit
void OnInit()
Definition: aibehaviour.c:49
Math
Definition: enmath.c:6
AbstractWave
Definition: sound.c:118
MissionBase
Definition: missiongameplay.c:1
MENU_MAIN
const int MENU_MAIN
Definition: constants.c:172