4 static const string PRESET_OLD =
"#STR_UAPRESET_0";
5 static const string PRESET_NEW =
"#STR_UAPRESET_1";
6 static const int VARIANT_OLD = 0;
7 static const int VARIANT_NEW = 1;
8 static int m_CurrentPresetIDConsole = -1;
12 static protected ref
array<int> m_UnsortedInputActions;
14 static const float ICON_SCALE_NORMAL = 1.21;
15 static const float ICON_SCALE_TOOLBAR = 1.81;
17 static string GetButtonNameFromInput(
string pInputName,
int pInputDeviceType)
20 for (
int i = 0; i < inp.AlternativeCount(); i++)
22 inp.SelectAlternative(i);
23 if (inp.CheckBindDevice(0, pInputDeviceType))
25 return GetUApi().GetButtonName(inp.GetBindKey(0));
38 for (
int i = 0; i < inp.AlternativeCount(); i++)
40 inp.SelectAlternative(i);
41 if (inp.BindingCount() > 0 && inp.Binding(0) != 0 && inp.CheckBindDevice(0,pInputDeviceType))
46 buttons.Insert(
GetUApi().GetButtonName( inp.Binding(0) ));
48 for (
int j = 1; j < inp.BindingCount(); j++)
50 if (inp.Binding(j) != 0 && inp.CheckBindDevice(j,pInputDeviceType))
52 buttons.Insert(
GetUApi().GetButtonName( inp.Binding(j) ));
59 buttons.Insert(
GetUApi().GetButtonName(inp.GetBindKey(0)));
63 if (buttons.Count() > 0)
69 output.Insert(i,buttons);
77 static array<string> GetButtonIconPathFromInput(notnull
UAInput pInput,
int pInputDeviceType = EUAINPUT_DEVICE_CONTROLLER)
81 for (
int i = 0; i < pInput.AlternativeCount(); i++)
83 pInput.SelectAlternative(i);
85 for (
int bk = 0; bk < pInput.BindKeyCount(); bk++)
87 if (pInput.CheckBindDevice(0, pInputDeviceType))
89 buttonIcons.Insert(
GetUApi().GetButtonIcon(pInput.Binding(bk)));
91 if (bk == pInput.BindKeyCount() - 1)
100 buttonIcons.Invert();
108 static array<string> GetButtonIconPathFromInput(
string pInputName,
int pInputDeviceType)
113 buttonIcons =
InputUtils.GetButtonIconPathFromInput(inp, pInputDeviceType);
121 if (buttons.Count() == 0 )
126 for (
int i = 0; i < buttons.Count(); i++)
129 buttons.Get(i).Split(
":", parts);
131 if (parts.Count() < 2)
136 pImageSet.Insert(parts[1].SubstringInverted(parts[1], parts[1].Length() - 6, parts[1].Length()));
143 if (parts[2] ==
"cross")
149 if (parts[2] ==
"circle")
156 pIconName.Insert(parts[2]);
160 static void GetImagesetAndIconFromInputAction(
string pInputAction,
int pInputDeviceType, out
array<string> pImageSet, out
array<string> pIconName)
164 InputUtils.GetImagesetAndIconFromInputAction(inp, pInputDeviceType, pImageSet, pIconName);
167 static string GetRichtextButtonIconFromInputAction(notnull
UAInput pInput,
string pLocalizedDescription,
int pInputDeviceType = EUAINPUT_DEVICE_CONTROLLER,
float pScale = ICON_SCALE_NORMAL,
bool pVertical =
false)
171 InputUtils.GetImagesetAndIconFromInputAction(pInput, pInputDeviceType, imageSets, iconNames);
173 if (imageSets.Count() == 0)
178 string result =
string.Format(
"<image set=\"%1\" name=\"%2\" scale=\"%3\" />", imageSets.Get(0), iconNames.Get(0), pScale);
180 string divider =
" ";
183 divider =
string.Format(
"\n%1\n", divider);
186 if (imageSets.Count() > 1)
189 for (
int i = 1; i < imageSets.Count(); i++)
191 result =
string.Format(
"%1%2<image set=\"%3\" name=\"%4\" scale=\"%5\" />", result, divider, imageSets.Get(i), iconNames.Get(i), pScale);
195 return string.Format(
"%1 %2", result, pLocalizedDescription);
198 static string GetRichtextButtonIconFromInputAction(
string pInputAction,
string pLocalizedDescription,
int pInputDeviceType = EUAINPUT_DEVICE_CONTROLLER,
float pScale = ICON_SCALE_NORMAL,
bool pVertical =
false)
204 InputUtils.GetImagesetAndIconFromInputAction(inp, pInputDeviceType, imageSets, iconNames);
206 return InputUtils.GetRichtextButtonIconFromInputAction(inp, pLocalizedDescription, pInputDeviceType, pScale, pVertical);
209 static void UpdateConsolePresetID()
212 GetGame().GetInput().GetProfileName(
GetUApi().PresetCurrent(), profile_name);
214 if (profile_name == PRESET_OLD)
216 m_CurrentPresetIDConsole = VARIANT_OLD;
220 m_CurrentPresetIDConsole = VARIANT_NEW;
224 static int GetConsolePresetID()
226 return m_CurrentPresetIDConsole;
231 return m_InputActionSortingMap;
236 return m_UnsortedInputActions;
239 static bool InitInputMetadata()
241 if (!m_InputActionSortingMap)
246 if (!m_UnsortedInputActions)
250 GetUApi().GetActiveInputs(m_UnsortedInputActions);
254 for (
int i = 0; i <
GetUApi().SortingCount(); i++)
258 for (
int j = 0; j < m_UnsortedInputActions.Count(); j++)
260 input_id = m_UnsortedInputActions[j];
261 inp =
GetUApi().GetInputByID(input_id);
262 if (inp.HasSorting(i))
264 sorting_content.Insert(input_id);
265 sorted_actions.Insert(input_id);
269 if (sorting_content.Count() > 0)
271 sorting_content.Sort();
272 m_InputActionSortingMap.Insert(i,sorting_content);
277 int count = sorted_actions.Count();
278 for (i = 0; i < count; i++)
280 m_UnsortedInputActions.RemoveItem(sorted_actions[i]);