missiongameplay.c 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745
  1. class MissionGameplay extends MissionBase
  2. {
  3. int m_LifeState;
  4. bool m_Initialized;
  5. protected UIManager m_UIManager;
  6. Widget m_HudRootWidget;
  7. ImageWidget m_MicrophoneIcon;
  8. ref InventoryMenu m_InventoryMenu;
  9. ref Chat m_Chat;
  10. ref ActionMenu m_ActionMenu;
  11. ref IngameHud m_Hud;
  12. ref HudDebug m_HudDebug;
  13. ref LogoutMenu m_Logout;
  14. ref DebugMonitor m_DebugMonitor;
  15. ref Watermark m_Watermark;
  16. protected ref ScriptInvoker m_OnConnectivityChanged;
  17. protected ref GameplayEffectWidgets m_EffectWidgets;
  18. ref Timer m_ChatChannelHideTimer;
  19. ref WidgetFadeTimer m_ChatChannelFadeTimer;
  20. ref WidgetFadeTimer m_MicFadeTimer;
  21. Widget m_ChatChannelArea;
  22. TextWidget m_ChatChannelText;
  23. NoteMenu m_Note;
  24. protected ref Timer m_ToggleHudTimer;
  25. protected const int HOLD_LIMIT_TIME = 300; //ms
  26. protected int m_ActionDownTime;
  27. protected int m_ActionUpTime;
  28. protected bool m_InitOnce;
  29. protected bool m_ControlDisabled; //DEPRECATED; disabled mode stored below
  30. protected int m_ControlDisabledMode;
  31. protected ref array<string> m_ActiveInputExcludeGroups; //exclude groups defined in 'specific.xml' file
  32. protected ref array<int> m_ActiveInputRestrictions; //additional scripted restrictions
  33. protected bool m_ProcessInputExcludes;
  34. protected bool m_QuickbarHold;
  35. protected bool m_PlayerRespawning;
  36. protected int m_RespawnModeClient; //for client-side usage
  37. protected bool m_PauseQueued;
  38. // von control info
  39. protected bool m_VoNActive;
  40. protected Widget m_VoiceLevels;
  41. protected ref map<int,ImageWidget> m_VoiceLevelsWidgets;
  42. protected ref map<int,ref WidgetFadeTimer> m_VoiceLevelTimers;
  43. protected bool m_InputBufferFull;
  44. UIScriptedMenu m_ConnectionMenu;
  45. void MissionGameplay()
  46. {
  47. DestroyAllMenus();
  48. m_Initialized = false;
  49. m_EffectWidgets = new GameplayEffectWidgets;
  50. m_HudRootWidget = null;
  51. m_Chat = new Chat;
  52. m_ActionMenu = new ActionMenu;
  53. m_LifeState = -1;
  54. m_Hud = new IngameHud;
  55. m_VoNActive = false;
  56. m_PauseQueued = false;
  57. m_ChatChannelFadeTimer = new WidgetFadeTimer;
  58. m_MicFadeTimer = new WidgetFadeTimer;
  59. m_ChatChannelHideTimer = new Timer(CALL_CATEGORY_GUI);
  60. m_ToggleHudTimer = new Timer(CALL_CATEGORY_GUI);
  61. m_ActiveRefresherLocations = new array<vector>;
  62. SyncEvents.RegisterEvents();
  63. }
  64. void ~MissionGameplay()
  65. {
  66. DestroyInventory();
  67. #ifndef NO_GUI
  68. if (g_Game.GetUIManager() && g_Game.GetUIManager().ScreenFadeVisible())
  69. {
  70. g_Game.GetUIManager().ScreenFadeOut(0);
  71. }
  72. Continue();
  73. #endif
  74. }
  75. InventoryMenu GetInventory()
  76. {
  77. return m_InventoryMenu;
  78. }
  79. override void OnInit()
  80. {
  81. super.OnInit();
  82. if ( m_Initialized )
  83. {
  84. return;
  85. }
  86. #ifndef BULDOZER
  87. #ifdef DIAG_DEVELOPER
  88. if (!GetGame().IsMultiplayer())//to make it work in single during development
  89. {
  90. CfgGameplayHandler.LoadData();
  91. UndergroundAreaLoader.SpawnAllTriggerCarriers();
  92. }
  93. #endif
  94. #endif
  95. PPEffects.Init(); //DEPRECATED, left in for legacy purposes only
  96. MapMarkerTypes.Init();
  97. m_UIManager = GetGame().GetUIManager();
  98. m_Initialized = true;
  99. // init hud ui
  100. if ( !m_HudRootWidget )
  101. {
  102. m_HudRootWidget = GetGame().GetWorkspace().CreateWidgets("gui/layouts/day_z_hud.layout");
  103. m_HudRootWidget.Show(false);
  104. m_Chat.Init(m_HudRootWidget.FindAnyWidget("ChatFrameWidget"));
  105. m_ActionMenu.Init( m_HudRootWidget.FindAnyWidget("ActionsPanel"), TextWidget.Cast( m_HudRootWidget.FindAnyWidget("DefaultActionWidget") ) );
  106. m_Hud.Init( m_HudRootWidget.FindAnyWidget("HudPanel") );
  107. // von enabled icon
  108. m_MicrophoneIcon = ImageWidget.Cast( m_HudRootWidget.FindAnyWidget("mic") );
  109. m_MicrophoneIcon.Show(false);
  110. // von voice level
  111. m_VoiceLevels = m_HudRootWidget.FindAnyWidget("VoiceLevelsPanel");
  112. m_VoiceLevelsWidgets = new map<int, ImageWidget>; // [key] voice level
  113. m_VoiceLevelTimers = new map<int,ref WidgetFadeTimer>; // [key] voice level
  114. if ( m_VoiceLevels )
  115. {
  116. m_VoiceLevelsWidgets.Set(VoiceLevelWhisper, ImageWidget.Cast( m_VoiceLevels.FindAnyWidget("Whisper") ));
  117. m_VoiceLevelsWidgets.Set(VoiceLevelTalk, ImageWidget.Cast( m_VoiceLevels.FindAnyWidget("Talk") ));
  118. m_VoiceLevelsWidgets.Set(VoiceLevelShout, ImageWidget.Cast( m_VoiceLevels.FindAnyWidget("Shout") ));
  119. m_VoiceLevelTimers.Set(VoiceLevelWhisper, new WidgetFadeTimer);
  120. m_VoiceLevelTimers.Set(VoiceLevelTalk, new WidgetFadeTimer);
  121. m_VoiceLevelTimers.Set(VoiceLevelShout, new WidgetFadeTimer);
  122. }
  123. HideVoiceLevelWidgets();
  124. // chat channel
  125. m_ChatChannelArea = m_HudRootWidget.FindAnyWidget("ChatChannelPanel");
  126. m_ChatChannelText = TextWidget.Cast( m_HudRootWidget.FindAnyWidget("ChatChannelText") );
  127. }
  128. // init hud ui
  129. #ifdef DEVELOPER
  130. m_HudDebug = new HudDebug;
  131. if ( !m_HudDebug.IsInitialized() )
  132. {
  133. m_HudDebug.Init( GetGame().GetWorkspace().CreateWidgets("gui/layouts/debug/day_z_hud_debug.layout") );
  134. PluginConfigDebugProfile.GetInstance().SetLogsEnabled(LogManager.IsLogsEnable());
  135. }
  136. #endif
  137. // experimental hud watermark
  138. #ifndef DIAG_DEVELOPER
  139. #ifdef BUILD_EXPERIMENTAL
  140. m_Watermark = new Watermark();
  141. #endif
  142. #endif
  143. }
  144. UIManager GetUIManager()
  145. {
  146. return m_UIManager;
  147. }
  148. override void OnMissionStart()
  149. {
  150. g_Game.SetConnecting(false);
  151. #ifndef FEATURE_CURSOR
  152. //! Only once the game is loaded should we take control of the cursor
  153. GetUIManager().ShowUICursor(false);
  154. #endif
  155. g_Game.SetMissionState(DayZGame.MISSION_STATE_GAME);
  156. #ifndef BULDOZER
  157. #ifdef DIAG_DEVELOPER
  158. if (!GetGame().IsMultiplayer())
  159. {
  160. // We will load the Effect areas on Default mission start
  161. EffectAreaLoader.CreateZones();
  162. }
  163. #endif
  164. #endif
  165. }
  166. void InitInventory()
  167. {
  168. if ( !m_InventoryMenu )
  169. {
  170. m_InventoryMenu = InventoryMenu.Cast( GetUIManager().CreateScriptedMenu(MENU_INVENTORY, null) );
  171. }
  172. }
  173. void TickScheduler(float timeslice)
  174. {
  175. PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
  176. if( player )
  177. player.OnScheduledTick(timeslice);
  178. if (g_Game.m_AutotestEnabled)
  179. {
  180. if (!AutotestRunner.IsDone())
  181. {
  182. if (!AutotestRunner.IsRunning())
  183. AutotestRunner.Start();
  184. AutotestRunner.Update(timeslice);
  185. }
  186. else
  187. {
  188. g_Game.RequestExit(0);
  189. }
  190. }
  191. }
  192. void SendMuteListToServer( map<string, bool> mute_list )
  193. {
  194. if( mute_list && mute_list.Count() > 0 )
  195. {
  196. ScriptRPC rpc = new ScriptRPC();
  197. rpc.Write(mute_list);
  198. rpc.Send(null, ERPCs.RPC_USER_SYNC_PERMISSIONS, true, null);
  199. }
  200. }
  201. override void UpdateInputDevicesAvailability()
  202. {
  203. super.UpdateInputDevicesAvailability();
  204. g_Game.GetInput().UpdateConnectedInputDeviceList();
  205. g_Game.UpdateInputDeviceDisconnectWarning();
  206. }
  207. override void OnMissionFinish()
  208. {
  209. PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
  210. //Print("OnMissionFinish");
  211. GetUIManager().HideDialog();
  212. DestroyAllMenus();
  213. m_Chat.Destroy();
  214. delete m_HudRootWidget;
  215. if (m_DebugMonitor)
  216. m_DebugMonitor.Hide();
  217. #ifndef FEATURE_CURSOR
  218. g_Game.GetUIManager().ShowUICursor(false);
  219. #endif
  220. PPEManagerStatic.GetPPEManager().StopAllEffects(PPERequesterCategory.ALL);
  221. EnableAllInputs();
  222. g_Game.SetMissionState( DayZGame.MISSION_STATE_FINNISH );
  223. }
  224. override void OnUpdate(float timeslice)
  225. {
  226. #ifdef DIAG_DEVELOPER
  227. UpdateInputDeviceDiag();
  228. #endif
  229. #ifdef FEATURE_CURSOR
  230. if (GetTimeStamp() == 0)
  231. {
  232. if (!g_Game.IsAppActive() || IsCLIParam("launchPaused"))
  233. {
  234. m_PauseQueued = true;
  235. }
  236. else
  237. {
  238. //! Only once the game is loaded should we take control of the cursor
  239. GetUIManager().ShowUICursor(false);
  240. }
  241. }
  242. #endif
  243. if (m_PauseQueued && !IsPaused())
  244. {
  245. Pause();
  246. }
  247. Man player = GetGame().GetPlayer();
  248. PlayerBase playerPB = PlayerBase.Cast(player);
  249. TickScheduler(timeslice);
  250. UpdateDummyScheduler();//for external entities
  251. UIScriptedMenu menu = m_UIManager.GetMenu();
  252. InventoryMenu inventory = InventoryMenu.Cast( m_UIManager.FindMenu(MENU_INVENTORY) );
  253. NoteMenu note_menu = NoteMenu.Cast( m_UIManager.FindMenu(MENU_NOTE) );
  254. GesturesMenu gestures_menu = GesturesMenu.Cast(m_UIManager.FindMenu(MENU_GESTURES));
  255. RadialQuickbarMenu quickbar_menu = RadialQuickbarMenu.Cast(m_UIManager.FindMenu(MENU_RADIAL_QUICKBAR));
  256. InspectMenuNew inspect = InspectMenuNew.Cast( m_UIManager.FindMenu(MENU_INSPECT) );
  257. Input input = GetGame().GetInput();
  258. ActionBase runningAction;
  259. bool manualInputUnlockProcessed = false;
  260. if ( playerPB )
  261. {
  262. #ifdef DIAG_DEVELOPER
  263. if ( DiagMenu.GetBool(DiagMenuIDs.MISC_HOLOGRAM) )
  264. {
  265. DbgUI.Begin("Hologram Debug", 5, 5);
  266. }
  267. #endif
  268. if ( playerPB.GetHologramLocal() )
  269. {
  270. playerPB.GetHologramLocal().UpdateHologram( timeslice );
  271. }
  272. #ifdef DIAG_DEVELOPER
  273. else if ( DiagMenu.GetBool(DiagMenuIDs.MISC_HOLOGRAM) )
  274. {
  275. DbgUI.Text("No active Hologram");
  276. }
  277. if ( DiagMenu.GetBool(DiagMenuIDs.MISC_HOLOGRAM) )
  278. {
  279. DbgUI.End();
  280. }
  281. #endif
  282. runningAction = playerPB.GetActionManager().GetRunningAction();
  283. }
  284. #ifdef PLATFORM_CONSOLE
  285. //'Special behaviour' for colliding VON distance input actions [CONSOLE ONLY]
  286. if (GetUApi().GetInputByID(UAVoiceModifierHelper).LocalValue() && !menu)
  287. {
  288. GetUApi().GetInputByID(UAUIQuickbarRadialOpen).Lock();
  289. GetUApi().GetInputByID(UAZoomInToggle).Lock();
  290. GetUApi().GetInputByID(UAPersonView).Lock();
  291. GetUApi().GetInputByID(UALeanLeft).Lock();
  292. GetUApi().GetInputByID(UALeanRight).Lock();
  293. }
  294. else if (GetUApi().GetInputByID(UAVoiceModifierHelper).LocalRelease()) //unlocks on release, if already excluded, all the other inputs should be locked/unlocked in the exclude (if defined properly!)
  295. {
  296. GetUApi().GetInputByID(UAUIQuickbarRadialOpen).Unlock();
  297. GetUApi().GetInputByID(UAZoomInToggle).Unlock();
  298. GetUApi().GetInputByID(UAPersonView).Unlock();
  299. if (playerPB && !playerPB.IsSprinting())
  300. {
  301. GetUApi().GetInputByID(UALeanLeft).Unlock();
  302. GetUApi().GetInputByID(UALeanRight).Unlock();
  303. }
  304. manualInputUnlockProcessed = true;
  305. }
  306. //Radial quickbar
  307. if (GetUApi().GetInputByID(UAUIQuickbarRadialOpen).LocalPress() && playerPB)
  308. {
  309. //open quickbar menu
  310. if ( playerPB.IsAlive() && !playerPB.IsRaised() && !playerPB.IsUnconscious() && !playerPB.GetCommand_Vehicle() ) //player hands not raised, player is not in prone and player is not interacting with vehicle
  311. {
  312. if ( !GetUIManager().IsMenuOpen( MENU_RADIAL_QUICKBAR ) )
  313. {
  314. RadialQuickbarMenu.OpenMenu();
  315. m_Hud.ShowHudUI( false );
  316. }
  317. }
  318. }
  319. bool b1 = RadialQuickbarMenu.GetItemToAssign() != null;
  320. //close quickbar menu from world
  321. if (GetUIManager().IsMenuOpen( MENU_RADIAL_QUICKBAR ) && (!RadialQuickbarMenu.GetMenuInstance().GetParentMenu() || RadialQuickbarMenu.GetMenuInstance().GetParentMenu() != inventory) && (GetUApi().GetInputByID(UAUIQuickbarRadialOpen).LocalRelease() || !GetUApi().GetInputByID(UAUIQuickbarRadialOpen).LocalValue()))
  322. {
  323. RadialQuickbarMenu.CloseMenu();
  324. m_Hud.ShowHudUI( true );
  325. }
  326. //Radial Quickbar from inventory
  327. if ((RadialQuickbarMenu.instance && RadialQuickbarMenu.GetMenuInstance().GetParentMenu() && RadialQuickbarMenu.GetMenuInstance().GetParentMenu() == inventory) && GetUApi().GetInputByID(UAUIQuickbarRadialInventoryOpen).LocalRelease())
  328. {
  329. //close radial quickbar menu
  330. if (GetGame().GetUIManager().IsMenuOpen(MENU_RADIAL_QUICKBAR))
  331. {
  332. RadialQuickbarMenu.CloseMenu();
  333. RadialQuickbarMenu.SetItemToAssign(NULL);
  334. if (GetGame().GetUIManager().IsMenuOpen(MENU_INVENTORY))
  335. {
  336. AddActiveInputExcludes({"inventory"});
  337. AddActiveInputRestriction(EInputRestrictors.INVENTORY);
  338. }
  339. }
  340. }
  341. if (playerPB)
  342. {
  343. //Special behaviour for leaning [CONSOLE ONLY]
  344. if (playerPB.IsRaised() || playerPB.IsInRasedProne())
  345. {
  346. GetUApi().GetInputByID(UALeanLeftGamepad).Unlock();
  347. GetUApi().GetInputByID(UALeanRightGamepad).Unlock();
  348. manualInputUnlockProcessed = true;
  349. }
  350. else if (!GetUApi().GetInputByID(UALeanLeftGamepad).IsLocked() || !GetUApi().GetInputByID(UALeanRightGamepad).IsLocked())
  351. {
  352. GetUApi().GetInputByID(UALeanLeftGamepad).Lock();
  353. GetUApi().GetInputByID(UALeanRightGamepad).Lock();
  354. }
  355. //Special behaviour for freelook & zeroing [CONSOLE ONLY]
  356. if (playerPB.IsRaised())
  357. {
  358. GetUApi().GetInputByID(UALookAround).Lock(); //disable freelook
  359. GetUApi().GetInputByID(UALookAroundToggle).Lock(); //disable freelook
  360. GetUApi().GetInputByID(UAZeroingUp).Unlock(); //enable zeroing
  361. GetUApi().GetInputByID(UAZeroingDown).Unlock();
  362. manualInputUnlockProcessed = true;
  363. }
  364. else if (GetUApi().GetInputByID(UALookAround).IsLocked() || GetUApi().GetInputByID(UALookAroundToggle).IsLocked())
  365. {
  366. GetUApi().GetInputByID(UALookAround).Unlock(); //enable freelook
  367. GetUApi().GetInputByID(UALookAroundToggle).Unlock(); //enable freelook
  368. GetUApi().GetInputByID(UAZeroingUp).Lock(); //disable zeroing
  369. GetUApi().GetInputByID(UAZeroingDown).Lock();
  370. manualInputUnlockProcessed = true;
  371. }
  372. }
  373. #endif
  374. if (manualInputUnlockProcessed)
  375. {
  376. RefreshExcludes();
  377. }
  378. //Gestures
  379. if ( GetUApi().GetInputByID(UAUIGesturesOpen).LocalPress() && playerPB)
  380. {
  381. //open gestures menu
  382. if ( !playerPB.IsRaised() && (playerPB.GetActionManager().ActionPossibilityCheck(playerPB.m_MovementState.m_CommandTypeId) || playerPB.IsEmotePlaying()) && !playerPB.GetCommand_Vehicle() )
  383. {
  384. if (GesturesMenu.CanOpenMenu() && !GetUIManager().IsMenuOpen(MENU_GESTURES))
  385. {
  386. GesturesMenu.OpenMenu();
  387. m_Hud.ShowHudUI(false);
  388. }
  389. }
  390. }
  391. if ( GetUApi().GetInputByID(UAUIGesturesOpen).LocalRelease() || GetUApi().GetInputByID(UAUIGesturesOpen).LocalValue() == 0 )
  392. {
  393. //close gestures menu
  394. if ( GetUIManager().IsMenuOpen( MENU_GESTURES ) )
  395. {
  396. GesturesMenu.CloseMenu();
  397. m_Hud.ShowHudUI( true );
  398. }
  399. }
  400. if (player && m_LifeState == EPlayerStates.ALIVE && !player.IsUnconscious() )
  401. {
  402. // enables HUD on spawn
  403. if (m_HudRootWidget)
  404. {
  405. m_HudRootWidget.Show(true);
  406. }
  407. #ifndef NO_GUI
  408. // fade out black screen
  409. if ( GetUIManager().ScreenFadeVisible() )
  410. {
  411. GetUIManager().ScreenFadeOut(0.5);
  412. }
  413. #endif
  414. if (GetUApi().GetInputByID(UAGear).LocalPress())
  415. {
  416. if (!inventory && playerPB.CanManipulateInventory() && IsMapUnfoldActionRunning(runningAction))
  417. {
  418. ShowInventory();
  419. menu = m_InventoryMenu;
  420. }
  421. else if (menu == inventory && m_InventoryMenu && m_InventoryMenu.IsOpened())
  422. {
  423. HideInventory();
  424. }
  425. }
  426. if (GetUApi().GetInputByID(UAUIMenu).LocalPress() && menu && inventory && menu == inventory)
  427. {
  428. HideInventory();
  429. }
  430. #ifndef PLATFORM_CONSOLE
  431. if (GetUApi().GetInputByID(UAChat).LocalPress() && input.IsEnabledMouseAndKeyboardEvenOnServer())
  432. {
  433. ChatInputMenu chat = ChatInputMenu.Cast( m_UIManager.FindMenu(MENU_CHAT) );
  434. if ( menu == NULL )
  435. {
  436. ShowChat();
  437. }
  438. }
  439. #endif
  440. // voice level updated
  441. VONManager.GetInstance().HandleInput(input);
  442. if (GetUApi().GetInputByID(UAUIQuickbarToggle).LocalHold())
  443. {
  444. if (!m_QuickbarHold)
  445. {
  446. m_QuickbarHold = true;
  447. m_Hud.ShowHudPlayer(m_Hud.GetHudVisibility().IsContextFlagActive(EHudContextFlags.HUD_HIDE));
  448. }
  449. }
  450. if (GetUApi().GetInputByID(UAUIQuickbarToggle).LocalRelease())
  451. {
  452. if (!m_QuickbarHold)
  453. {
  454. m_Hud.ShowQuickbarPlayer(m_Hud.GetHudVisibility().IsContextFlagActive(EHudContextFlags.QUICKBAR_HIDE));
  455. }
  456. m_QuickbarHold = false;
  457. }
  458. if (GetUApi().GetInputByID(UAZeroingUp).LocalPress() || GetUApi().GetInputByID(UAZeroingDown).LocalPress() || GetUApi().GetInputByID(UAToggleWeapons).LocalPress())
  459. {
  460. m_Hud.ZeroingKeyPress();
  461. }
  462. if (menu == NULL)
  463. {
  464. m_ActionMenu.Refresh();
  465. if (GetUApi().GetInputByID(UANextActionCategory).LocalPress())
  466. {
  467. m_ActionMenu.NextActionCategory();
  468. }
  469. else if (GetUApi().GetInputByID(UAPrevActionCategory).LocalPress())
  470. {
  471. m_ActionMenu.PrevActionCategory();
  472. }
  473. else if (GetUApi().GetInputByID(UANextAction).LocalPress())
  474. {
  475. m_ActionMenu.NextAction();
  476. }
  477. else if (GetUApi().GetInputByID(UAPrevAction).LocalPress())
  478. {
  479. m_ActionMenu.PrevAction();
  480. }
  481. }
  482. else
  483. {
  484. m_ActionMenu.Hide();
  485. }
  486. //hologram rotation
  487. if (menu == NULL && playerPB.IsPlacingLocal() && playerPB.GetHologramLocal().GetParentEntity().PlacementCanBeRotated())
  488. {
  489. if (GetUApi().GetInputByID(UANextAction).LocalRelease())
  490. {
  491. playerPB.GetHologramLocal().SubtractProjectionRotation(15);
  492. }
  493. if (GetUApi().GetInputByID(UAPrevAction).LocalRelease())
  494. {
  495. playerPB.GetHologramLocal().AddProjectionRotation(15);
  496. }
  497. }
  498. if (CfgGameplayHandler.GetMapIgnoreMapOwnership() && !CfgGameplayHandler.GetUse3DMap())
  499. {
  500. if (GetUApi().GetInputByID(UAMapToggle).LocalPress() && !m_UIManager.GetMenu())
  501. {
  502. if (IsMapUnfoldActionRunning(runningAction))
  503. {
  504. HandleMapToggleByKeyboardShortcut(player);
  505. }
  506. }
  507. }
  508. }
  509. // life state check
  510. if (player)
  511. {
  512. int life_state = player.GetPlayerState();
  513. m_LifeState = life_state;
  514. }
  515. if (menu && !menu.UseKeyboard() && menu.UseMouse())
  516. {
  517. int i;
  518. for (i = 0; i < 5; i++)
  519. {
  520. input.DisableKey(i | INPUT_DEVICE_MOUSE);
  521. input.DisableKey(i | INPUT_ACTION_TYPE_DOWN_EVENT | INPUT_DEVICE_MOUSE);
  522. input.DisableKey(i | INPUT_ACTION_TYPE_DOUBLETAP | INPUT_DEVICE_MOUSE);
  523. }
  524. for (i = 0; i < 6; i++)
  525. {
  526. input.DisableKey(i | INPUT_DEVICE_MOUSE_AXIS);
  527. }
  528. }
  529. if (!m_UIManager.IsDialogVisible())
  530. {
  531. if (menu)
  532. {
  533. if (menu == inspect)
  534. {
  535. if (GetUApi().GetInputByID(UAGear).LocalPress())
  536. {
  537. if (ItemManager.GetInstance().GetSelectedItem() == NULL)
  538. {
  539. HideInventory();
  540. }
  541. }
  542. else if (GetUApi().GetInputByID(UAUIBack).LocalPress())
  543. {
  544. if (ItemManager.GetInstance().GetSelectedItem() == NULL)
  545. {
  546. HideInventory();
  547. }
  548. }
  549. }
  550. else if (menu == note_menu && (!IsInputExcludeActive("inventory") || !IsInputRestrictionActive(EInputRestrictors.INVENTORY)))
  551. {
  552. AddActiveInputExcludes({"inventory"});
  553. AddActiveInputRestriction(EInputRestrictors.INVENTORY);
  554. }
  555. else if (menu == gestures_menu && !gestures_menu.IsMenuClosing() && !IsInputExcludeActive("radialmenu"))
  556. {
  557. AddActiveInputExcludes({"radialmenu"});
  558. GetUApi().GetInputByID(UAUIGesturesOpen).Unlock();
  559. }
  560. else if (menu == quickbar_menu && !quickbar_menu.IsMenuClosing() && !IsInputExcludeActive("radialmenu"))
  561. {
  562. AddActiveInputExcludes({"radialmenu"});
  563. GetUApi().GetInputByID(UAUIQuickbarRadialOpen).Unlock();
  564. }
  565. else if (IsPaused())
  566. {
  567. InGameMenuXbox menu_xb = InGameMenuXbox.Cast(GetGame().GetUIManager().GetMenu());
  568. if (!g_Game.GetUIManager().ScreenFadeVisible() && (!menu_xb || !menu_xb.IsOnlineOpen() && !menu_xb.FeedbackDialogVisible()))
  569. {
  570. if (GetUApi().GetInputByID(UAUIMenu).LocalPress())
  571. {
  572. Continue();
  573. }
  574. else if (GetUApi().GetInputByID(UAUIBack).LocalPress())
  575. {
  576. Continue();
  577. }
  578. }
  579. else if (GetUApi().GetInputByID(UAUIBack).LocalPress())
  580. {
  581. if (menu_xb && menu_xb.IsOnlineOpen())
  582. {
  583. menu_xb.CloseOnline();
  584. }
  585. }
  586. }
  587. }
  588. else if (GetUApi().GetInputByID(UAUIMenu).LocalPress())
  589. {
  590. if (IsMapUnfoldActionRunning(runningAction))
  591. {
  592. Pause();
  593. }
  594. }
  595. }
  596. UpdateDebugMonitor();
  597. SEffectManager.Event_OnFrameUpdate(timeslice);
  598. if (!GetGame().IsMultiplayer())
  599. m_WorldData.UpdateBaseEnvTemperature( timeslice );
  600. #ifdef DIAG_DEVELOPER
  601. DisplayHairDebug();
  602. #endif
  603. if (m_ProcessInputExcludes)
  604. {
  605. PerformRefreshExcludes();
  606. m_ProcessInputExcludes = false;
  607. }
  608. super.OnUpdate( timeslice );
  609. }
  610. override void OnKeyPress(int key)
  611. {
  612. super.OnKeyPress(key);
  613. m_Hud.KeyPress(key);
  614. }
  615. override void OnKeyRelease(int key)
  616. {
  617. super.OnKeyRelease(key);
  618. }
  619. override void OnEvent(EventType eventTypeId, Param params)
  620. {
  621. super.OnEvent(eventTypeId, params);
  622. InventoryMenu menu;
  623. Man player = GetGame().GetPlayer();
  624. switch (eventTypeId)
  625. {
  626. case ChatMessageEventTypeID:
  627. ChatMessageEventParams chat_params = ChatMessageEventParams.Cast( params );
  628. if (m_LifeState == EPlayerStates.ALIVE)
  629. {
  630. m_Chat.Add(chat_params);
  631. }
  632. break;
  633. case ChatChannelEventTypeID:
  634. ChatChannelEventParams cc_params = ChatChannelEventParams.Cast( params );
  635. ChatInputMenu chatMenu = ChatInputMenu.Cast( GetUIManager().FindMenu(MENU_CHAT_INPUT) );
  636. if (chatMenu)
  637. {
  638. chatMenu.UpdateChannel();
  639. }
  640. else
  641. {
  642. m_ChatChannelText.SetText(ChatInputMenu.GetChannelName(cc_params.param1));
  643. m_ChatChannelFadeTimer.FadeIn(m_ChatChannelArea, 0.5, true);
  644. m_ChatChannelHideTimer.Run(2, m_ChatChannelFadeTimer, "FadeOut", new Param3<Widget, float, bool>(m_ChatChannelArea, 0.5, true));
  645. }
  646. break;
  647. case WindowsResizeEventTypeID:
  648. DestroyAllMenus();
  649. m_Hud.OnResizeScreen();
  650. break;
  651. case SetFreeCameraEventTypeID:
  652. SetFreeCameraEventParams set_free_camera_event_params = SetFreeCameraEventParams.Cast( params );
  653. PluginDeveloper plugin_developer = PluginDeveloper.Cast( GetPlugin(PluginDeveloper) );
  654. plugin_developer.OnSetFreeCameraEvent( PlayerBase.Cast( player ), set_free_camera_event_params.param1 );
  655. break;
  656. case NetworkInputBufferEventTypeID:
  657. NetworkInputBufferEventParams networkInputBufferParams = NetworkInputBufferEventParams.Cast(params);
  658. if (networkInputBufferParams)
  659. {
  660. OnInputBufferEvent(networkInputBufferParams.param1);
  661. }
  662. break;
  663. }
  664. }
  665. override void OnItemUsed(InventoryItem item, Man owner)
  666. {
  667. if (item && GetUIManager().GetMenu() == NULL)
  668. {
  669. if (item.IsInherited(ItemBook))
  670. {
  671. BookMenu bookMenu = BookMenu.Cast( GetUIManager().EnterScriptedMenu(MENU_BOOK, NULL) );
  672. if (bookMenu)
  673. {
  674. bookMenu.ReadBook(item);
  675. }
  676. }
  677. }
  678. }
  679. #ifdef DEVELOPER
  680. override void SetInputSuppression(bool state)
  681. {
  682. m_SuppressNextFrame = state;
  683. }
  684. override bool GetInputSuppression()
  685. {
  686. return m_SuppressNextFrame;
  687. }
  688. #endif
  689. //! Deprecated; removes last input exclude and associated controls restrictions
  690. override void PlayerControlEnable( bool bForceSupress )
  691. {
  692. super.PlayerControlEnable(bForceSupress);
  693. if (m_ControlDisabledMode != -1)
  694. {
  695. switch (m_ControlDisabledMode)
  696. {
  697. case INPUT_EXCLUDE_ALL:
  698. {
  699. RemoveActiveInputExcludes({"menu"},bForceSupress);
  700. break;
  701. }
  702. case INPUT_EXCLUDE_INVENTORY:
  703. {
  704. RemoveActiveInputExcludes({"inventory"},bForceSupress);
  705. RemoveActiveInputRestriction(EInputRestrictors.INVENTORY);
  706. break;
  707. }
  708. case INPUT_EXCLUDE_MAP:
  709. {
  710. RemoveActiveInputExcludes({"loopedactions"},bForceSupress);
  711. RemoveActiveInputRestriction(EInputRestrictors.MAP);
  712. break;
  713. }
  714. case INPUT_EXCLUDE_MOUSE_ALL:
  715. {
  716. RemoveActiveInputExcludes({"radialmenu"},bForceSupress);
  717. break;
  718. }
  719. case INPUT_EXCLUDE_MOUSE_RADIAL:
  720. {
  721. RemoveActiveInputExcludes({"radialmenu"},bForceSupress);
  722. break;
  723. }
  724. }
  725. m_ControlDisabledMode = -1;
  726. PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
  727. if (player)
  728. {
  729. HumanInputController hic = player.GetInputController();
  730. hic.LimitsDisableSprint(false);
  731. }
  732. }
  733. }
  734. //! Deprecated; simple input restrictions
  735. override void PlayerControlDisable(int mode)
  736. {
  737. super.PlayerControlDisable(mode);
  738. switch (mode)
  739. {
  740. case INPUT_EXCLUDE_ALL:
  741. {
  742. AddActiveInputExcludes({"menu"});
  743. break;
  744. }
  745. case INPUT_EXCLUDE_INVENTORY:
  746. {
  747. AddActiveInputExcludes({"inventory"});
  748. AddActiveInputRestriction(EInputRestrictors.INVENTORY);
  749. break;
  750. }
  751. case INPUT_EXCLUDE_MAP:
  752. {
  753. AddActiveInputExcludes({"loopedactions"});
  754. AddActiveInputRestriction(EInputRestrictors.MAP);
  755. break;
  756. }
  757. case INPUT_EXCLUDE_MOUSE_ALL:
  758. {
  759. AddActiveInputExcludes({"radialmenu"});
  760. break;
  761. }
  762. case INPUT_EXCLUDE_MOUSE_RADIAL:
  763. {
  764. AddActiveInputExcludes({"radialmenu"});
  765. break;
  766. }
  767. default:
  768. {
  769. Debug.Log("Unknown controls disable mode");
  770. return;
  771. }
  772. }
  773. m_ControlDisabledMode = mode;
  774. PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
  775. if ( player )
  776. {
  777. ItemBase item = player.GetItemInHands();
  778. if (item && item.IsWeapon())
  779. player.RequestResetADSSync();
  780. }
  781. }
  782. //! Removes one or more exclude groups and refreshes excludes
  783. override void RemoveActiveInputExcludes(array<string> excludes, bool bForceSupress = false)
  784. {
  785. super.RemoveActiveInputExcludes(excludes,bForceSupress);
  786. if (excludes.Count() != 0)
  787. {
  788. bool changed = false;
  789. if (m_ActiveInputExcludeGroups)
  790. {
  791. foreach (string excl : excludes)
  792. {
  793. if (m_ActiveInputExcludeGroups.Find(excl) != -1)
  794. {
  795. m_ActiveInputExcludeGroups.RemoveItem(excl);
  796. changed = true;
  797. }
  798. }
  799. if (changed)
  800. {
  801. RefreshExcludes();
  802. }
  803. }
  804. // supress control for next frame
  805. GetUApi().SupressNextFrame(bForceSupress);
  806. }
  807. }
  808. //! Removes one restriction (specific behaviour oudside regular excludes, defined below)
  809. override void RemoveActiveInputRestriction(int restrictor)
  810. {
  811. //unique behaviour outside regular excludes
  812. if (restrictor > -1)
  813. {
  814. switch (restrictor)
  815. {
  816. case EInputRestrictors.INVENTORY:
  817. {
  818. GetUApi().GetInputByID(UAWalkRunForced).ForceEnable(false); // force walk off!
  819. break;
  820. }
  821. case EInputRestrictors.MAP:
  822. {
  823. GetUApi().GetInputByID(UAWalkRunForced).ForceEnable(false); // force walk off!
  824. break;
  825. }
  826. }
  827. if (m_ActiveInputRestrictions && m_ActiveInputRestrictions.Find(restrictor) != -1)
  828. {
  829. m_ActiveInputRestrictions.RemoveItem(restrictor);
  830. }
  831. }
  832. }
  833. //! Adds one or more exclude groups to disable and refreshes excludes
  834. override void AddActiveInputExcludes(array<string> excludes)
  835. {
  836. super.AddActiveInputExcludes(excludes);
  837. if (excludes.Count() != 0)
  838. {
  839. bool changed = false;
  840. if (!m_ActiveInputExcludeGroups)
  841. {
  842. m_ActiveInputExcludeGroups = new array<string>;
  843. }
  844. foreach (string excl : excludes)
  845. {
  846. if (m_ActiveInputExcludeGroups.Find(excl) == -1)
  847. {
  848. m_ActiveInputExcludeGroups.Insert(excl);
  849. changed = true;
  850. }
  851. }
  852. if (changed)
  853. {
  854. RefreshExcludes();
  855. #ifdef BULDOZER
  856. GetUApi().SupressNextFrame(true);
  857. #endif
  858. }
  859. }
  860. }
  861. //! Adds one input restriction (specific behaviour oudside regular excludes, defined below)
  862. override void AddActiveInputRestriction(int restrictor)
  863. {
  864. //unique behaviour outside regular excludes
  865. if (restrictor > -1)
  866. {
  867. switch (restrictor)
  868. {
  869. case EInputRestrictors.INVENTORY:
  870. {
  871. GetUApi().GetInputByID(UAWalkRunForced).ForceEnable(true); // force walk on!
  872. PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
  873. if ( player )
  874. {
  875. ItemBase item = player.GetItemInHands();
  876. if (item && item.IsWeapon())
  877. player.RequestResetADSSync();
  878. }
  879. break;
  880. }
  881. case EInputRestrictors.MAP:
  882. {
  883. GetUApi().GetInputByID(UAWalkRunForced).ForceEnable(true); // force walk on!
  884. break;
  885. }
  886. }
  887. if (!m_ActiveInputRestrictions)
  888. {
  889. m_ActiveInputRestrictions = new array<int>;
  890. }
  891. if (m_ActiveInputRestrictions.Find(restrictor) == -1)
  892. {
  893. m_ActiveInputRestrictions.Insert(restrictor);
  894. }
  895. }
  896. }
  897. //! queues refresh of input excludes
  898. override void RefreshExcludes()
  899. {
  900. m_ProcessInputExcludes = true;
  901. }
  902. //! applies queued excludes (0 == clear excludes)
  903. protected void PerformRefreshExcludes()
  904. {
  905. if (m_ActiveInputExcludeGroups)
  906. {
  907. foreach (string excl : m_ActiveInputExcludeGroups)
  908. {
  909. GetUApi().ActivateExclude(excl);
  910. }
  911. }
  912. GetUApi().UpdateControls();
  913. }
  914. //! Removes all active input excludes and restrictions
  915. override void EnableAllInputs(bool bForceSupress = false)
  916. {
  917. m_ControlDisabledMode = -1;
  918. if (m_ActiveInputRestrictions)
  919. {
  920. int count = m_ActiveInputRestrictions.Count();
  921. for (int i = 0; i < count; i++)
  922. {
  923. RemoveActiveInputRestriction(m_ActiveInputRestrictions[0]);
  924. }
  925. m_ActiveInputRestrictions.Clear(); //redundant?
  926. }
  927. if (m_ActiveInputExcludeGroups)
  928. {
  929. m_ActiveInputExcludeGroups.Clear();
  930. }
  931. GetUApi().UpdateControls(); //it is meant to happen instantly, does not wait for update to process
  932. GetUApi().SupressNextFrame(bForceSupress); // supress control for next frame
  933. }
  934. //! returns if ANY exclude groups, restriction (or deprecated disable, if applicable) is active
  935. override bool IsControlDisabled()
  936. {
  937. bool active = false;
  938. if (m_ActiveInputExcludeGroups)
  939. {
  940. active |= m_ActiveInputExcludeGroups.Count() > 0;
  941. }
  942. if (m_ActiveInputRestrictions)
  943. {
  944. active |= m_ActiveInputRestrictions.Count() > 0;
  945. }
  946. active |= m_ControlDisabledMode >= INPUT_EXCLUDE_ALL; //legacy stuff, Justin case
  947. return active;
  948. }
  949. //! Returns true if the particular input exclude group had been activated via script and is active
  950. override bool IsInputExcludeActive(string exclude)
  951. {
  952. return m_ActiveInputExcludeGroups && m_ActiveInputExcludeGroups.Find(exclude) != -1;
  953. }
  954. //! Returns true if the particular 'restriction' (those govern special behaviour outside regular input excludes, *EInputRestrictors*) is active
  955. override bool IsInputRestrictionActive(int restriction)
  956. {
  957. return m_ActiveInputRestrictions && m_ActiveInputRestrictions.Find(restriction) != -1;
  958. }
  959. //! (mostly)DEPRECATED; only set on the old 'PlayerControlDisable' method
  960. override int GetControlDisabledMode()
  961. {
  962. return m_ControlDisabledMode;
  963. }
  964. void CloseAllMenus()
  965. {
  966. GetUIManager().CloseAll();
  967. }
  968. void DestroyAllMenus()
  969. {
  970. if( GetUIManager() )
  971. {
  972. GetUIManager().HideDialog();
  973. GetUIManager().CloseAll();
  974. }
  975. DestroyInventory();
  976. if( m_Chat )
  977. m_Chat.Clear();
  978. }
  979. void MoveHudForInventory( bool inv_open )
  980. {
  981. #ifdef PLATFORM_CONSOLE
  982. IngameHud hud = IngameHud.Cast( GetHud() );
  983. if( hud )
  984. {
  985. if( inv_open )
  986. {
  987. hud.GetHudPanelWidget().SetPos( 0, -0.055 );
  988. }
  989. else
  990. {
  991. hud.GetHudPanelWidget().SetPos( 0, 0 );
  992. }
  993. }
  994. #endif
  995. }
  996. override void ShowInventory()
  997. {
  998. UIScriptedMenu menu = GetUIManager().GetMenu();
  999. if ( !menu && GetGame().GetPlayer().GetHumanInventory().CanOpenInventory() && !GetGame().GetPlayer().IsInventorySoftLocked() )
  1000. {
  1001. if( !m_InventoryMenu )
  1002. {
  1003. InitInventory();
  1004. }
  1005. if( !GetUIManager().FindMenu( MENU_INVENTORY ) )
  1006. {
  1007. GetUIManager().ShowScriptedMenu(m_InventoryMenu, null);
  1008. PlayerBase.Cast(GetGame().GetPlayer()).OnInventoryMenuOpen();
  1009. }
  1010. AddActiveInputExcludes({"inventory"});
  1011. AddActiveInputRestriction(EInputRestrictors.INVENTORY);
  1012. }
  1013. }
  1014. override void HideInventory()
  1015. {
  1016. if (m_InventoryMenu)
  1017. {
  1018. GetUIManager().HideScriptedMenu(m_InventoryMenu);
  1019. RemoveActiveInputExcludes({"inventory"},false);
  1020. RemoveActiveInputRestriction(EInputRestrictors.INVENTORY);
  1021. PlayerBase.Cast(GetGame().GetPlayer()).OnInventoryMenuClose();
  1022. VicinityItemManager.GetInstance().ResetRefreshCounter();
  1023. }
  1024. }
  1025. void DestroyInventory()
  1026. {
  1027. if (m_InventoryMenu)
  1028. {
  1029. if (!m_InventoryMenu.GetParentMenu() && GetUIManager().GetMenu() != m_InventoryMenu)
  1030. {
  1031. m_InventoryMenu.SetParentMenu(GetUIManager().GetMenu()); //hack; guarantees the 'm_pCurrentMenu' will be set to whatever is on top currently
  1032. }
  1033. m_InventoryMenu.Close();
  1034. m_InventoryMenu = NULL;
  1035. }
  1036. }
  1037. override void ResetGUI()
  1038. {
  1039. DestroyInventory();
  1040. InitInventory();
  1041. }
  1042. override void ShowChat()
  1043. {
  1044. m_ChatChannelHideTimer.Stop();
  1045. m_ChatChannelFadeTimer.Stop();
  1046. m_ChatChannelArea.Show(false);
  1047. m_UIManager.EnterScriptedMenu(MENU_CHAT_INPUT, NULL);
  1048. int level = GetGame().GetVoiceLevel();
  1049. UpdateVoiceLevelWidgets(level);
  1050. AddActiveInputExcludes({"menu"});
  1051. }
  1052. override void HideChat()
  1053. {
  1054. RemoveActiveInputExcludes({"menu"},true);
  1055. }
  1056. void ShowVehicleInfo()
  1057. {
  1058. if ( GetHud() )
  1059. GetHud().ShowVehicleInfo();
  1060. }
  1061. void HideVehicleInfo()
  1062. {
  1063. if ( GetHud() )
  1064. GetHud().HideVehicleInfo();
  1065. }
  1066. override Hud GetHud()
  1067. {
  1068. return m_Hud;
  1069. }
  1070. HudDebug GetHudDebug()
  1071. {
  1072. return m_HudDebug;
  1073. }
  1074. override void RefreshCrosshairVisibility()
  1075. {
  1076. if (GetHudDebug())
  1077. GetHudDebug().RefreshCrosshairVisibility();
  1078. }
  1079. override void HideCrosshairVisibility()
  1080. {
  1081. if (GetHudDebug())
  1082. GetHudDebug().HideCrosshairVisibility();
  1083. }
  1084. override bool IsPaused()
  1085. {
  1086. return GetGame().GetUIManager().IsMenuOpen(MENU_INGAME);
  1087. }
  1088. override void Pause()
  1089. {
  1090. if (IsPaused() || (GetGame().GetUIManager().GetMenu() && GetGame().GetUIManager().GetMenu().GetID() == MENU_INGAME))
  1091. {
  1092. return;
  1093. }
  1094. m_PauseQueued = true;
  1095. if ( g_Game.IsClient() && g_Game.GetGameState() != DayZGameState.IN_GAME )
  1096. {
  1097. return;
  1098. }
  1099. PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
  1100. if ( player && !player.IsPlayerLoaded() || IsPlayerRespawning() )
  1101. {
  1102. return;
  1103. }
  1104. CloseAllMenus();
  1105. // open ingame menu
  1106. UIScriptedMenu menu = GetUIManager().EnterScriptedMenu( MENU_INGAME, GetGame().GetUIManager().GetMenu() );
  1107. if (!menu || !menu.IsVisible())
  1108. {
  1109. return;
  1110. }
  1111. AddActiveInputExcludes({"menu"});
  1112. AddActiveInputRestriction(EInputRestrictors.INVENTORY);
  1113. m_PauseQueued = false;
  1114. }
  1115. override void Continue()
  1116. {
  1117. UIScriptedMenu menu = GetGame().GetUIManager().GetMenu();
  1118. if (menu)
  1119. {
  1120. int menu_id = menu.GetID();
  1121. if (!IsPaused() || (menu_id != MENU_INGAME && menu_id != MENU_LOGOUT && menu_id != MENU_RESPAWN_DIALOGUE) || (m_Logout && m_Logout.layoutRoot.IsVisible()))
  1122. {
  1123. return;
  1124. }
  1125. }
  1126. RemoveActiveInputExcludes({"menu"},true);
  1127. RemoveActiveInputRestriction(EInputRestrictors.INVENTORY);
  1128. GetUIManager().CloseMenu(MENU_INGAME);
  1129. }
  1130. override bool IsMissionGameplay()
  1131. {
  1132. return true;
  1133. }
  1134. override void AbortMission()
  1135. {
  1136. #ifdef BULDOZER
  1137. GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(g_Game.RequestExit, IDC_MAIN_QUIT);
  1138. #else
  1139. GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(GetGame().AbortMission);
  1140. #endif
  1141. }
  1142. override void CreateLogoutMenu(UIMenuPanel parent)
  1143. {
  1144. // prevent creating logout dialog if input buffer has reached server config maximumClientInputs limit.
  1145. if (GetGame() && m_InputBufferFull)
  1146. return;
  1147. // prevent creating the logout dialog if the in-game menu was closed before (DZ-23150)
  1148. UIScriptedMenu menu = GetUIManager().GetMenu();
  1149. if (menu && menu.GetID() != MENU_LOGOUT && menu.IsClosing())
  1150. return;
  1151. PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
  1152. // do not show logout screen if player's dead
  1153. if (!player || player.IsDamageDestroyed())
  1154. {
  1155. // exit the game immediately
  1156. AbortMission();
  1157. return;
  1158. }
  1159. if (parent)
  1160. {
  1161. m_Logout = LogoutMenu.Cast(parent.EnterScriptedMenu(MENU_LOGOUT));
  1162. if (m_Logout)
  1163. {
  1164. m_Logout.SetLogoutTime();
  1165. }
  1166. }
  1167. }
  1168. override void StartLogoutMenu(int time)
  1169. {
  1170. if (m_Logout)
  1171. {
  1172. if (time > 0)
  1173. {
  1174. // character will be deleted from server int "time" seconds
  1175. m_Logout.SetTime(time);
  1176. m_Logout.Show();
  1177. GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(m_Logout.UpdateTime, 1000, true);
  1178. }
  1179. else
  1180. {
  1181. // no waiting time -> player is most likely dead
  1182. m_Logout.Exit();
  1183. }
  1184. }
  1185. }
  1186. override void CreateDebugMonitor()
  1187. {
  1188. if (!m_DebugMonitor)
  1189. {
  1190. m_DebugMonitor = new DebugMonitor();
  1191. m_DebugMonitor.Init();
  1192. }
  1193. else
  1194. m_DebugMonitor.Show();
  1195. }
  1196. override void HideDebugMonitor()
  1197. {
  1198. if (m_DebugMonitor)
  1199. {
  1200. m_DebugMonitor.Hide();
  1201. }
  1202. }
  1203. protected void HandleMapToggleByKeyboardShortcut(Man player)
  1204. {
  1205. UIManager um = GetGame().GetUIManager();
  1206. if (um && !um.IsMenuOpen(MENU_MAP))
  1207. {
  1208. um.CloseAll();
  1209. if (!CfgGameplayHandler.GetUse3DMap())
  1210. {
  1211. um.EnterScriptedMenu(MENU_MAP, null);
  1212. GetGame().GetMission().AddActiveInputExcludes({"map"});
  1213. GetGame().GetMission().AddActiveInputRestriction(EInputRestrictors.MAP);
  1214. }
  1215. }
  1216. }
  1217. protected bool IsMapUnfoldActionRunning(ActionBase pAction)
  1218. {
  1219. return !pAction || pAction.Type() != ActionUnfoldMap;
  1220. }
  1221. /*void ChangeBleedingIndicatorVisibility(bool visible)
  1222. {
  1223. PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
  1224. if (player)
  1225. {
  1226. BleedingSourcesManagerRemote manager = player.GetBleedingManagerRemote();
  1227. if (manager && manager.GetBleedingSourcesCount() > 0)
  1228. {
  1229. manager.ChangeBleedingIndicatorVisibility(visible);
  1230. }
  1231. }
  1232. }*/
  1233. void UpdateDebugMonitor()
  1234. {
  1235. if (!m_DebugMonitor) return;
  1236. PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
  1237. if (player)
  1238. {
  1239. DebugMonitorValues values = player.GetDebugMonitorValues();
  1240. if (values)
  1241. {
  1242. m_DebugMonitor.SetHealth(values.GetHealth());
  1243. m_DebugMonitor.SetBlood(values.GetBlood());
  1244. m_DebugMonitor.SetLastDamage(values.GetLastDamage());
  1245. m_DebugMonitor.SetPosition(MiscGameplayFunctions.TruncateVec(player.GetPosition(),1));
  1246. }
  1247. }
  1248. float currFPS = GetGame().GetAvgFPS(10); // Not using last, but average of last x to prevent jitter
  1249. float minFPS, maxFPS, avgFPS;
  1250. GetGame().GetFPSStats(minFPS, maxFPS, avgFPS);
  1251. m_DebugMonitor.SetFramerate(currFPS, minFPS, maxFPS, avgFPS);
  1252. }
  1253. void SetActionDownTime( int time_down )
  1254. {
  1255. m_ActionDownTime = time_down;
  1256. }
  1257. void SetActionUpTime( int time_up )
  1258. {
  1259. m_ActionUpTime = time_up;
  1260. }
  1261. int LocalPressTime()
  1262. {
  1263. return m_ActionDownTime;
  1264. }
  1265. int LocalReleaseTime()
  1266. {
  1267. return m_ActionUpTime;
  1268. }
  1269. float GetHoldActionTime()
  1270. {
  1271. float hold_action_time = LocalReleaseTime() - LocalPressTime();
  1272. return hold_action_time;
  1273. }
  1274. void DisplayHairDebug()
  1275. {
  1276. #ifndef SERVER
  1277. ShowHairDebugValues(DiagMenu.GetBool(DiagMenuIDs.MISC_HAIR_DISPLAY_DEBUG));
  1278. #endif
  1279. }
  1280. void ShowHairDebugValues(bool state)
  1281. {
  1282. #ifdef DIAG_DEVELOPER
  1283. if ( state )
  1284. {
  1285. PluginDiagMenuClient diagmenu = PluginDiagMenuClient.Cast(GetPlugin(PluginDiagMenuClient));
  1286. int i = DiagMenu.GetValue(DiagMenuIDs.MISC_HAIR_LEVEL);
  1287. bool bState = diagmenu.m_HairHidingStateMap.Get(i);
  1288. string selectionState;
  1289. if (!bState)
  1290. selectionState = "Hidden";
  1291. else
  1292. selectionState = "Shown";
  1293. string selectionName = diagmenu.m_HairSelectionArray.Get(i);
  1294. DbgUI.BeginCleanupScope();
  1295. DbgUI.Begin("Hair Debug", 50, 150);
  1296. DbgUI.Text("Current Hair Selection:" + selectionName);
  1297. DbgUI.Text("State: " + selectionState);
  1298. DbgUI.End();
  1299. DbgUI.EndCleanupScope();
  1300. }
  1301. else
  1302. {
  1303. DbgUI.BeginCleanupScope();
  1304. DbgUI.Begin("Hair Debug", 50, 50);
  1305. DbgUI.End();
  1306. DbgUI.EndCleanupScope();
  1307. }
  1308. #endif
  1309. }
  1310. override void UpdateVoiceLevelWidgets(int level)
  1311. {
  1312. for ( int n = 0; n < m_VoiceLevelsWidgets.Count(); n++ )
  1313. {
  1314. int voiceKey = m_VoiceLevelsWidgets.GetKey(n);
  1315. ImageWidget voiceWidget = m_VoiceLevelsWidgets.Get(n);
  1316. // stop fade timer since it will be refreshed
  1317. WidgetFadeTimer timer = m_VoiceLevelTimers.Get(n);
  1318. timer.Stop();
  1319. // show widgets according to the level
  1320. if ( voiceKey <= level )
  1321. {
  1322. voiceWidget.SetAlpha(1.0); // reset from possible previous fade out
  1323. voiceWidget.Show(true);
  1324. if ( !m_VoNActive && !GetUIManager().FindMenu(MENU_CHAT_INPUT) )
  1325. timer.FadeOut(voiceWidget, 3.0);
  1326. }
  1327. else
  1328. voiceWidget.Show(false);
  1329. }
  1330. // fade out microphone icon when switching levels without von on
  1331. if ( !m_VoNActive )
  1332. {
  1333. if ( !GetUIManager().FindMenu(MENU_CHAT_INPUT) )
  1334. {
  1335. m_MicrophoneIcon.SetAlpha(1.0);
  1336. m_MicrophoneIcon.Show(true);
  1337. m_MicFadeTimer.FadeOut(m_MicrophoneIcon, 3.0);
  1338. }
  1339. }
  1340. else
  1341. {
  1342. // stop mic icon fade timer when von is activated
  1343. m_MicFadeTimer.Stop();
  1344. }
  1345. }
  1346. override ImageWidget GetMicrophoneIcon()
  1347. {
  1348. return m_MicrophoneIcon;
  1349. }
  1350. override WidgetFadeTimer GetMicWidgetFadeTimer()
  1351. {
  1352. return m_MicFadeTimer;
  1353. }
  1354. override map<int,ImageWidget> GetVoiceLevelWidgets()
  1355. {
  1356. return m_VoiceLevelsWidgets;
  1357. }
  1358. override map<int,ref WidgetFadeTimer> GetVoiceLevelTimers()
  1359. {
  1360. return m_VoiceLevelTimers;
  1361. }
  1362. override bool IsVoNActive()
  1363. {
  1364. return m_VoNActive;
  1365. }
  1366. override void SetVoNActive(bool active)
  1367. {
  1368. m_VoNActive = active;
  1369. }
  1370. override void HideVoiceLevelWidgets()
  1371. {
  1372. for ( int n = 0; n < m_VoiceLevelsWidgets.Count(); n++ )
  1373. {
  1374. ImageWidget voiceWidget = m_VoiceLevelsWidgets.Get( n );
  1375. voiceWidget.Show(false);
  1376. }
  1377. }
  1378. override UIScriptedMenu GetNoteMenu()
  1379. {
  1380. return m_Note;
  1381. };
  1382. override void SetNoteMenu(UIScriptedMenu menu)
  1383. {
  1384. m_Note = NoteMenu.Cast(menu);
  1385. };
  1386. override void OnPlayerRespawned(Man player)
  1387. {
  1388. #ifdef DIAG_DEVELOPER
  1389. if (m_HudDebug)
  1390. m_HudDebug.RefreshByLocalProfile();
  1391. #endif
  1392. PlayerBase playerBase = PlayerBase.Cast(player);
  1393. if (playerBase)
  1394. {
  1395. GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(playerBase.ShowDeadScreen, false, 0);
  1396. }
  1397. GetGame().GetSoundScene().SetSoundVolume(g_Game.m_volume_sound,1);
  1398. GetGame().GetSoundScene().SetSpeechExVolume(g_Game.m_volume_speechEX,1);
  1399. GetGame().GetSoundScene().SetMusicVolume(g_Game.m_volume_music,1);
  1400. GetGame().GetSoundScene().SetVOIPVolume(g_Game.m_volume_VOIP,1);
  1401. GetGame().GetSoundScene().SetRadioVolume(g_Game.m_volume_radio,1);
  1402. }
  1403. override void SetPlayerRespawning(bool state)
  1404. {
  1405. m_PlayerRespawning = state;
  1406. }
  1407. override bool IsPlayerRespawning()
  1408. {
  1409. return m_PlayerRespawning;
  1410. }
  1411. override array<vector> GetActiveRefresherLocations()
  1412. {
  1413. return m_ActiveRefresherLocations;
  1414. }
  1415. override void SetRespawnModeClient(int mode)
  1416. {
  1417. m_RespawnModeClient = mode;
  1418. }
  1419. override int GetRespawnModeClient()
  1420. {
  1421. return m_RespawnModeClient;
  1422. }
  1423. override GameplayEffectWidgets GetEffectWidgets()
  1424. {
  1425. return m_EffectWidgets;
  1426. }
  1427. ScriptInvoker GetConnectivityInvoker()
  1428. {
  1429. if (!m_OnConnectivityChanged)
  1430. {
  1431. m_OnConnectivityChanged = new ScriptInvoker();
  1432. }
  1433. return m_OnConnectivityChanged;
  1434. }
  1435. protected void OnInputBufferEvent(bool state)
  1436. {
  1437. if (m_InputBufferFull != state)
  1438. {
  1439. m_InputBufferFull = state;
  1440. if (m_InputBufferFull)
  1441. {
  1442. if (GetGame().GetUIManager().GetMenu() && GetGame().GetUIManager().GetMenu().GetID() == MENU_INVENTORY)
  1443. {
  1444. GetGame().GetMission().HideInventory();
  1445. }
  1446. GetGame().GetUIManager().CloseAll();
  1447. m_ConnectionMenu = GetGame().GetUIManager().EnterScriptedMenu(MENU_CONNECTION_DIALOGUE, GetGame().GetUIManager().GetMenu());
  1448. GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(InputBufferCheck, 0.500, true);
  1449. }
  1450. }
  1451. }
  1452. protected void InputBufferCheck()
  1453. {
  1454. PlayerBase player;
  1455. ActionManagerBase amb;
  1456. ActionBase action;
  1457. if (m_InputBufferFull)
  1458. {
  1459. if (m_ConnectionMenu && (!GetGame().GetPlayer().IsAlive() || GetGame().GetPlayer().IsUnconscious()))
  1460. {
  1461. m_ConnectionMenu.Close();
  1462. player = PlayerBase.Cast(GetGame().GetPlayer());
  1463. if (!player)
  1464. return;
  1465. amb = player.GetActionManager();
  1466. if (!amb)
  1467. return;
  1468. action = amb.GetRunningAction();
  1469. if (action && amb.GetActionState(action) != UA_NONE)
  1470. {
  1471. amb.RequestInterruptAction();
  1472. }
  1473. return;
  1474. }
  1475. if (!m_ConnectionMenu)
  1476. {
  1477. if (GetGame().GetUIManager().GetMenu() && GetGame().GetUIManager().GetMenu().GetID() == MENU_INVENTORY)
  1478. {
  1479. GetGame().GetMission().HideInventory();
  1480. }
  1481. GetGame().GetUIManager().CloseAll();
  1482. m_ConnectionMenu = GetGame().GetUIManager().EnterScriptedMenu(MENU_CONNECTION_DIALOGUE, GetGame().GetUIManager().GetMenu());
  1483. }
  1484. }
  1485. else
  1486. {
  1487. if (m_ConnectionMenu)
  1488. {
  1489. GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Remove(InputBufferCheck);
  1490. m_ConnectionMenu.Close();
  1491. player = PlayerBase.Cast(GetGame().GetPlayer());
  1492. if (!player)
  1493. return;
  1494. amb = player.GetActionManager();
  1495. if (!amb)
  1496. return;
  1497. action = amb.GetRunningAction();
  1498. if (action && amb.GetActionState(action) != UA_NONE)
  1499. {
  1500. amb.RequestInterruptAction();
  1501. }
  1502. }
  1503. }
  1504. }
  1505. }