4 private ref
array<int> m_DeviceOrder = {EUAINPUT_DEVICE_CONTROLLER,EUAINPUT_DEVICE_MOUSE,EUAINPUT_DEVICE_KEYBOARD};
6 private bool m_CanClose;
8 private string m_DevicesText;
9 private string m_CaptionText;
10 private string m_ConfirmationText;
12 private WrapSpacerWidget m_WrapperWidget;
17 void InputDeviceDisconnectWarningMenu()
19 g_Game.GetMission().AddActiveInputExcludes({
"gamepaddisconnect"});
27 void ~InputDeviceDisconnectWarningMenu()
31 PPERequesterBank.GetRequester(PPERequester_ControllerDisconnectBlur).Stop();
32 g_Game.DeleteTitleScreen();
34 g_Game.GetMission().RemoveActiveInputExcludes({
"gamepaddisconnect"},
true);
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"));
46 g_Game.GetMission().GetOnInputDeviceConnected().Insert(UpdateDisconnectedDevices);
47 g_Game.GetMission().GetOnInputDeviceDisconnected().Insert(UpdateDisconnectedDevices);
49 UpdateDisconnectedDevices();
50 if (
g_Game.GetUIManager() &&
g_Game.GetUIManager().IsDialogVisible())
52 g_Game.GetUIManager().CloseDialog();
55 PPERequesterBank.GetRequester(PPERequester_ControllerDisconnectBlur).Start();
60 private void BuildMessages()
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\" />"));
69 private void UpdateDisconnectTexts()
71 int deviceCount = m_DisconnectedDevices.Count();
72 int count = m_DeviceOrder.Count();
75 bool gamepadInactive =
false;
77 m_DevicesText =
string.Empty;
78 for (
int i = 0; i < count; i++)
80 device = m_DeviceOrder[i];
81 idx = m_DisconnectedDevices.Find(device);
84 m_DevicesText += m_DeviceMessages.Get(device) +
" ";
85 if (device == EUAINPUT_DEVICE_CONTROLLER)
87 gamepadInactive =
true;
90 m_DevicesText +=
"| ";
98 m_CaptionText =
"#str_inputdevice_notification_header_multiple";
99 m_ConfirmationText =
"#str_inputdevice_notification_prompt_multiple";
103 m_CaptionText =
"#str_inputdevice_notification_header_single";
104 m_ConfirmationText =
"#str_inputdevice_notification_prompt_single";
108 private void SetDisconnectTexts()
110 m_CaptionWidget.SetText(m_CaptionText);
111 m_DeviceListWidget.SetText(m_DevicesText);
112 m_ActionTextWidget.SetText(m_ConfirmationText);
114 m_WrapperWidget.Update();
117 private void UpdateDisconnectedDevices(
int device = -1)
119 m_DisconnectedDevices.Clear();
120 m_CanClose =
g_Game.GetInput().AreAllAllowedInputDevicesActive(m_DisconnectedDevices);
121 UpdateWarningMenu(device);
125 private void UpdateWarningMenu(
int device)
133 UpdateDisconnectTexts();
134 SetDisconnectTexts();
141 bool ret = super.OnMouseButtonUp(w,
x,
y,button);
147 return ret | m_CanClose;
151 override bool OnKeyUp(
Widget w,
int x,
int y,
int key)
153 bool ret = super.OnKeyUp(w,
x,
y,key);
159 return ret | m_CanClose;