mainmenuvideo.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. class MainMenuVideo extends UIScriptedMenu
  2. {
  3. protected string m_BackButtonTextID;
  4. protected VideoWidget m_Video;
  5. override Widget Init()
  6. {
  7. layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/xbox/video_menu.layout");
  8. m_Video = VideoWidget.Cast(layoutRoot.FindAnyWidget("video"));
  9. GetGame().GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
  10. m_Video.Load("video\\DayZ_onboarding_MASTER.mp4");
  11. m_Video.Play();
  12. m_Video.SetCallback(VideoCallback.ON_END, StopVideo);
  13. return layoutRoot;
  14. }
  15. void ~MainMenuVideo()
  16. {
  17. }
  18. //after show
  19. override void OnShow()
  20. {
  21. super.OnShow();
  22. GetGame().GetUIManager().ShowUICursor(false);
  23. GetGame().GetSoundScene().SetSoundVolume(0.0,0.0);
  24. UpdateControlsElements();
  25. }
  26. //after hide
  27. override void OnHide()
  28. {
  29. super.OnHide();
  30. GetGame().GetUIManager().ShowUICursor(true);
  31. GetGame().GetSoundScene().SetSoundVolume(1.0,1.0);
  32. }
  33. protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
  34. {
  35. UpdateControlsElements();
  36. }
  37. void StopVideo()
  38. {
  39. if (m_Video)
  40. {
  41. m_Video.Unload();
  42. GetGame().GetUIManager().Back();
  43. }
  44. }
  45. void PlayPauseVideo()
  46. {
  47. if (m_Video)
  48. {
  49. if (m_Video.IsPlaying())
  50. {
  51. m_Video.Pause();
  52. }
  53. else
  54. {
  55. m_Video.Play();
  56. }
  57. }
  58. }
  59. override void Update(float timeslice)
  60. {
  61. if (GetUApi().GetInputByID(UAUIBack).LocalPress())
  62. {
  63. StopVideo();
  64. }
  65. }
  66. override void OnVisibilityChanged(bool isVisible)
  67. {
  68. if (!isVisible)
  69. {
  70. m_Video.Unload();
  71. }
  72. }
  73. //Deprecated
  74. protected void LoadFooterButtonTexts()
  75. {
  76. }
  77. //Deprecated
  78. protected void LoadTextStrings()
  79. {
  80. }
  81. protected void UpdateControlsElements()
  82. {
  83. RichTextWidget toolbar_text = RichTextWidget.Cast(layoutRoot.FindAnyWidget("ContextToolbarText"));
  84. string text;
  85. if (GetGame().GetInput().IsEnabledMouseAndKeyboard() && GetGame().GetInput().GetCurrentInputDevice() == EInputDeviceType.MOUSE_AND_KEYBOARD)
  86. {
  87. text = "ESC " + "#menu_back";
  88. }
  89. else
  90. {
  91. text = string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUIBack", "#menu_back", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
  92. }
  93. toolbar_text.SetText(text);
  94. }
  95. }