missiongameplay.c 43 KB

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