DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
InputDeviceDisconnectWarningMenu.c
См. документацию.
1class InputDeviceDisconnectWarningMenu extends UIScriptedMenu
2{
4 private ref array<int> m_DeviceOrder = {EUAINPUT_DEVICE_CONTROLLER,EUAINPUT_DEVICE_MOUSE,EUAINPUT_DEVICE_KEYBOARD};
6 private bool m_CanClose;
7 private bool m_Initialized;
8 private string m_DevicesText;
9 private string m_CaptionText;
10 private string m_ConfirmationText;
11
12 private WrapSpacerWidget m_WrapperWidget;
16
18 {
19 g_Game.GetMission().AddActiveInputExcludes({"gamepaddisconnect"});
20
22 m_CanClose = false;
23
25 }
26
28 {
29 if (g_Game)
30 {
31 PPERequesterBank.GetRequester(PPERequester_ControllerDisconnectBlur).Stop();
32 g_Game.DeleteTitleScreen(); // Removes any outstanding gamepad identification propmt; the gamepad is already recognized by now
33 if (g_Game.GetMission())
34 g_Game.GetMission().RemoveActiveInputExcludes({"gamepaddisconnect"},true);
35 }
36 }
37
38 override Widget Init()
39 {
40 layoutRoot = g_Game.GetWorkspace().CreateWidgets("gui/layouts/new_ui/notifications/day_z_input_device_warning.layout");
41 m_WrapperWidget = WrapSpacerWidget.Cast(layoutRoot.FindAnyWidget("Wrapper"));
42 m_CaptionWidget = TextWidget.Cast(layoutRoot.FindAnyWidget("Caption"));
43 m_DeviceListWidget = RichTextWidget.Cast(layoutRoot.FindAnyWidget("DeviceList"));
44 m_ActionTextWidget = RichTextWidget.Cast(layoutRoot.FindAnyWidget("ActionText"));
45
46 g_Game.GetMission().GetOnInputDeviceConnected().Insert(UpdateDisconnectedDevices);
47 g_Game.GetMission().GetOnInputDeviceDisconnected().Insert(UpdateDisconnectedDevices);
48
50 if (g_Game.GetUIManager() && g_Game.GetUIManager().IsDialogVisible())
51 {
52 g_Game.GetUIManager().CloseDialog();
53 }
54
55 PPERequesterBank.GetRequester(PPERequester_ControllerDisconnectBlur).Start();
56
57 return layoutRoot;
58 }
59
60 private void BuildMessages()
61 {
63 m_DeviceMessages.Insert(EUAINPUT_DEVICE_CONTROLLER,string.Format("<image set=\"dayz_gui\" name=\"icon_Gamepad\" />"));
64 m_DeviceMessages.Insert(EUAINPUT_DEVICE_MOUSE,string.Format("<image set=\"dayz_gui\" name=\"icon_Mouse\" />"));
65 m_DeviceMessages.Insert(EUAINPUT_DEVICE_KEYBOARD,string.Format("<image set=\"dayz_gui\" name=\"icon_Keyboard\" />"));
66 }
67
69 private void UpdateDisconnectTexts()
70 {
71 int deviceCount = m_DisconnectedDevices.Count();
72 int count = m_DeviceOrder.Count();
73 int idx;
74 int device;
75 bool gamepadInactive = false;
76
77 m_DevicesText = string.Empty;
78 for (int i = 0; i < count; i++)
79 {
80 device = m_DeviceOrder[i];
81 idx = m_DisconnectedDevices.Find(device);
82 if (idx != -1) //is disconnected and relevant
83 {
84 m_DevicesText += m_DeviceMessages.Get(device) + " ";
85 if (device == EUAINPUT_DEVICE_CONTROLLER)
86 {
87 gamepadInactive = true;
88 if (deviceCount > 1)
89 {
90 m_DevicesText += "| ";
91 }
92 }
93 }
94 }
95
96 if (deviceCount > 1)
97 {
98 m_CaptionText = "#str_inputdevice_notification_header_multiple";
99 m_ConfirmationText = "#str_inputdevice_notification_prompt_multiple";
100 }
101 else
102 {
103 m_CaptionText = "#str_inputdevice_notification_header_single";
104 m_ConfirmationText = "#str_inputdevice_notification_prompt_single";
105 }
106 }
107
108 private void SetDisconnectTexts()
109 {
113
114 m_WrapperWidget.Update();
115 }
116
117 private void UpdateDisconnectedDevices(int device = -1)
118 {
119 m_DisconnectedDevices.Clear();
120 m_CanClose = g_Game.GetInput().AreAllAllowedInputDevicesActive(m_DisconnectedDevices);
121 UpdateWarningMenu(device);
122 m_Initialized = true;
123 }
124
125 private void UpdateWarningMenu(int device)
126 {
127 if (m_CanClose)
128 {
129 Close();
130 }
131 else if (layoutRoot)
132 {
135 }
136 }
137
138 //back-up close handling
139 override bool OnMouseButtonUp(Widget w, int x, int y, int button)
140 {
141 bool ret = super.OnMouseButtonUp(w,x,y,button);
142
143 if (m_CanClose)
144 {
145 Close();
146 }
147 return ret | m_CanClose;
148 }
149
150 //back-up close handling
151 override bool OnKeyUp(Widget w, int x, int y, int key)
152 {
153 bool ret = super.OnKeyUp(w,x,y,key);
154
155 if (m_CanClose)
156 {
157 Close();
158 }
159 return ret | m_CanClose;
160 }
161}
map
Определения ControlsXboxNew.c:4
DayZGame g_Game
Определения DayZGame.c:3868
Icon x
Icon y
void Close()
Определения gameplay.c:317
Определения EnWidgets.c:220
RichTextWidget m_DeviceListWidget
void UpdateDisconnectTexts()
Composes message depending on context.
string m_ConfirmationText
void InputDeviceDisconnectWarningMenu()
ref array< int > m_DisconnectedDevices
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
TextWidget m_CaptionWidget
void SetDisconnectTexts()
void ~InputDeviceDisconnectWarningMenu()
ref array< int > m_DeviceOrder
RichTextWidget m_ActionTextWidget
void UpdateWarningMenu(int device)
override bool OnKeyUp(Widget w, int x, int y, int key)
override Widget Init()
WrapSpacerWidget m_WrapperWidget
ref map< int, string > m_DeviceMessages
void UpdateDisconnectedDevices(int device=-1)
Определения DayZGame.c:64
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.