Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
missionmainmenu.c
Go to the documentation of this file.
1class 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
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 g_Game.GetUIManager().ShowUICursor(true);
83 g_Game.SetMissionState(DayZGame.MISSION_STATE_MAINMENU);
84 m_DynamicMusicPlayer.SetCategory(EDynamicMusicPlayerCategory.MENU, true);
85
86 g_Game.LoadingHide(true);
87 ProgressAsync.DestroyAllPendingProgresses();
88 }
89
90 override void OnMissionFinish()
91 {
92 if ( m_mainmenu )
93 m_mainmenu.Cleanup();
94 GetGame().GetUIManager().CloseAll();
95 m_mainmenu = NULL;
96
97 m_IntroScenePC = null;
98 m_IntroSceneXbox = null;
99 m_CreditsMenu = null;
100#ifndef FEATURE_CURSOR
101 g_Game.GetUIManager().ShowUICursor(false);
102#endif
103 }
104
105 override void OnUpdate(float timeslice)
106 {
107 super.OnUpdate(timeslice);
108
109#ifdef DIAG_DEVELOPER
110 UpdateInputDeviceDiag();
111#endif
112
113 if ( g_Game.IsLoading() )
114 {
115 return;
116 }
117
118 if (m_IntroScenePC)
119 {
120 m_IntroScenePC.Update();
121 }
122 }
123
124 void OnMenuEnter(int menu_id)
125 {
126 switch (menu_id)
127 {
128 case MENU_CREDITS:
129 {
130 m_CreditsMenu = CreditsMenu.Cast(GetGame().GetUIManager().GetMenu());
131 }
132 }
133 }
134
135 void OnInputDeviceChanged(int device)
136 {
137 if (m_CreditsMenu)
138 {
139 m_CreditsMenu.UpdateInfoPanelText(device);
140 }
141 }
142
143 int SortedInsert( array<int> list, int number )
144 {
145 int find_number = number;
146 int index_min = 0;
147 int index_max = list.Count() - 1;
148 int target_index = Math.Floor( index_max / 2 );
149
150 if ( index_max == -1 )
151 {
152 list.Insert( number );
153 return 0;
154 }
155
156 while ( true )
157 {
158 int target_value = list[target_index];
159
160 if ( find_number == target_value || ((index_max - index_min) <= 1) )
161 {
162 for ( int i = index_min; i <= index_max; i++ )
163 {
164 if ( find_number <= list[i] )
165 {
166 list.InsertAt( find_number, i );
167 return i;
168 }
169 }
170
171 index_max++;
172 list.InsertAt( find_number, index_max );
173 return target_index;
174 }
175 else if ( find_number < target_value )
176 {
177 index_max = target_index;
178 target_index = Math.Floor( target_index / 2 );
179 }
180 else if ( find_number > target_value )
181 {
182 index_min = target_index;
183 target_index += Math.Floor( (index_max - index_min) / 2 );
184 }
185 }
186
187 return target_index;
188 }
189
193 private AbstractWave m_MenuMusic;
194
195 void PlayMusic()
196 {
197 if ( !m_MenuMusic )
198 {
199 SoundParams soundParams = new SoundParams( "Music_Menu_SoundSet" );
200 SoundObjectBuilder soundBuilder = new SoundObjectBuilder( soundParams );
201 SoundObject soundObject = soundBuilder.BuildSoundObject();
202 soundObject.SetKind( WaveKind.WAVEMUSIC );
203 m_MenuMusic = GetGame().GetSoundScene().Play2D(soundObject, soundBuilder);
204 m_MenuMusic.Loop( true );
205 m_MenuMusic.Play();
206 }
207 }
208
209 void StopMusic()
210 {
211 if ( m_MenuMusic )
212 m_MenuMusic.Stop();
213 }
214
215 AbstractWave GetMenuMusic()
216 {
217 return m_MenuMusic;
218 }
219}
void Reset()
Definition inventory.c:1123
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
Definition inventory.c:175
Definition enmath.c:7
UIManager GetUIManager()
override void OnInit()
override void OnMissionFinish()
override void OnMissionStart()
override void UpdateInputDevicesAvailability()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZGame g_Game
Definition dayzgame.c:3868
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
Definition endebug.c:90
const int MENU_TITLE_SCREEN
Definition constants.c:196
const int MENU_MAIN
Definition constants.c:182
const int MENU_CREDITS
Definition constants.c:205
class AbstractSoundScene SoundObjectBuilder(SoundParams soundParams)
void AbstractWave()
Definition sound.c:167
class SoundObject SoundParams(string name)
WaveKind
Definition sound.c:2