File size: 2,102 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

class ConsoleToolbarWidgetHandlerBase : ScriptedWidgetEventHandler
{
	Widget m_ToolbarWidget; //'toolbar_bg'
	RichTextWidget m_ToolbarText;
	
	void OnWidgetScriptInit(Widget w)
	{
		m_ToolbarWidget = w;
		m_ToolbarWidget.SetHandler(this);
		
		m_ToolbarText = RichTextWidget.Cast(m_ToolbarWidget.FindAnyWidget("ContextToolbarText"));
		#ifdef PLATFORM_CONSOLE
		if (GetGame().GetMission())
		{
			GetGame().GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
		}
		#endif
		UpdateControlsElements();
	}
	
	protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
	{
		#ifdef PLATFORM_CONSOLE
		UpdateControlsElements(pInputDeviceType);
		#endif
	}
	
	protected void UpdateControlsElements(EInputDeviceType pInputDeviceType = EInputDeviceType.UNKNOWN)
	{
		#ifndef PLATFORM_CONSOLE
		m_ToolbarWidget.Show(false);
		#endif
	}
}

class PasswordMenuToolbarHandler : ConsoleToolbarWidgetHandlerBase
{
	override protected void UpdateControlsElements(EInputDeviceType pInputDeviceType = EInputDeviceType.UNKNOWN)
	{
		#ifdef PLATFORM_CONSOLE
		string text = "";
		text += string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUICtrlY", "#server_browser_show / #server_browser_hide", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
		text += string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUICtrlX", "#server_browser_menu_connect", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
		text += string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUIBack", "#STR_settings_menu_root_toolbar_bg_ConsoleToolbar_Back_BackText0", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
		m_ToolbarText.SetText(text);
		
		bool toolbarShow = false;
		if (pInputDeviceType == EInputDeviceType.UNKNOWN)
		{
			toolbarShow = !GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer() || GetGame().GetInput().GetCurrentInputDevice() == EInputDeviceType.CONTROLLER;
		}
		else
		{
			toolbarShow = pInputDeviceType == EInputDeviceType.CONTROLLER;
		}
		m_ToolbarWidget.Show(toolbarShow);
		#endif
	}
};