File size: 2,235 Bytes
24b81cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
class MainMenuVideo extends UIScriptedMenu
{
	protected string 				m_BackButtonTextID;
	
	protected VideoWidget			m_Video;
	
	override Widget Init()
	{
		layoutRoot 				= GetGame().GetWorkspace().CreateWidgets("gui/layouts/xbox/video_menu.layout");
		m_Video					= VideoWidget.Cast(layoutRoot.FindAnyWidget("video"));
		
		GetGame().GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
		
		m_Video.Load("video\\DayZ_onboarding_MASTER.mp4");
			
		m_Video.Play();
		
		m_Video.SetCallback(VideoCallback.ON_END, StopVideo);
		
		return layoutRoot;
	}
	
	void ~MainMenuVideo()
	{
	}
	
	//after show
	override void OnShow()
	{
		super.OnShow();
		GetGame().GetUIManager().ShowUICursor(false);
		GetGame().GetSoundScene().SetSoundVolume(0.0,0.0);
		
		UpdateControlsElements();
	}

	//after hide
	override void OnHide()
	{
		super.OnHide();
		GetGame().GetUIManager().ShowUICursor(true);
		GetGame().GetSoundScene().SetSoundVolume(1.0,1.0);
	}
	
	protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
	{
		UpdateControlsElements();
	}
	
	void StopVideo()
	{
		if (m_Video)
		{
			m_Video.Unload();
			GetGame().GetUIManager().Back();
		}
	}
	
	void PlayPauseVideo()
	{
		if (m_Video)
		{
			if (m_Video.IsPlaying())
			{
				m_Video.Pause();
			}
			else
			{
				m_Video.Play();
			}
		}
	}
	
	override void Update(float timeslice)
	{
		if (GetUApi().GetInputByID(UAUIBack).LocalPress())
		{
			StopVideo();
		}
	}
	
	override void OnVisibilityChanged(bool isVisible)
	{
		if (!isVisible)
		{
			m_Video.Unload();
		}
	}
	
	//Deprecated
	protected void LoadFooterButtonTexts()
	{
	}
	
	//Deprecated
	protected void LoadTextStrings()
	{
	}
	
	protected void UpdateControlsElements()
	{
		RichTextWidget toolbar_text = RichTextWidget.Cast(layoutRoot.FindAnyWidget("ContextToolbarText"));
		string text;
		
		if (GetGame().GetInput().IsEnabledMouseAndKeyboard() && GetGame().GetInput().GetCurrentInputDevice() == EInputDeviceType.MOUSE_AND_KEYBOARD)
		{
			text = "ESC " + "#menu_back";
		}
		else
		{
			text = string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUIBack", "#menu_back", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
		}
		
		toolbar_text.SetText(text);
	}
}