missiongameplay.c 40 KB

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