10 protected IngameHud
m_Hud;
14 protected int m_InteractActionsNum;
15 protected int m_ContinuousInteractActionsNum;
16 protected int m_ItemActionsNum;
17 protected int m_ContinuousItemActionsNum;
18 protected bool m_HealthEnabled;
19 protected bool m_QuantityEnabled;
21 protected ref WidgetFadeTimer m_FadeTimer;
22 protected bool m_Faded;
23 protected bool m_Hidden;
26 protected Widget m_ItemLeft;
29 protected float m_MaxWidthChild;
30 protected float m_RootWidth;
31 protected float m_RootHeight;
33 void ItemActionsWidget()
36 m_ContinuousInteract =
null;
41 m_FadeTimer =
new WidgetFadeTimer;
44 m_HealthEnabled =
true;
45 m_QuantityEnabled =
true;
50 m_UseActionWrapper =
GetUApi().GetInputByID(UAAction).GetPersistentWrapper();
57 void ~ItemActionsWidget()
63 void SetInteractXboxIcon(
string imageset_name,
string image_name) {};
64 void SetContinuousInteractXboxIcon(
string imageset_name,
string image_name) {};
65 void SetSingleXboxIcon(
string imageset_name,
string image_name) {};
66 void SetContinuousXboxIcon(
string imageset_name,
string image_name) {};
67 protected void SetXboxIcon(
string name,
string imageset_name,
string image_name) {};
70 protected void SetControllerIcon(
string pWidgetName,
string pInputName)
73 w.SetText(
InputUtils.GetRichtextButtonIconFromInputAction(pInputName,
"", EUAINPUT_DEVICE_CONTROLLER));
76 protected void ShowXboxHidePCIcons(
string widget,
bool show_xbox_icon)
78 m_Root.FindAnyWidget(widget +
"_btn_icon_xbox").Show(show_xbox_icon);
79 m_Root.FindAnyWidget(widget +
"_btn_icon").Show(!show_xbox_icon);
88 m_ItemLeft = w.FindAnyWidget(
"ia_item_left");
91 UpdateControllerInputIcons();
92 UpdatePCIconsVisibility();
97 #ifdef PLATFORM_CONSOLE
98 UpdateControllerInputIcons();
104 UpdatePCIconsVisibility();
108 private void UpdateControllerInputIcons()
110 SetControllerIcon(
"ia_interact",
"UAAction");
111 SetControllerIcon(
"ia_continuous_interact",
"UAAction");
112 SetControllerIcon(
"ia_single",
"UADefaultAction");
113 SetControllerIcon(
"ia_continuous",
"UADefaultAction");
117 private void UpdatePCIconsVisibility()
119 bool showConsoleIcons =
false;
120 #ifdef PLATFORM_CONSOLE
121 showConsoleIcons =
GetGame().GetInput().GetCurrentInputDevice() ==
EInputDeviceType.CONTROLLER || !
GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer();
124 ShowXboxHidePCIcons(
"ia_interact", showConsoleIcons);
125 ShowXboxHidePCIcons(
"ia_continuous_interact", showConsoleIcons);
126 ShowXboxHidePCIcons(
"ia_single", showConsoleIcons);
127 ShowXboxHidePCIcons(
"ia_continuous", showConsoleIcons);
130 protected void BuildCursor()
133 int quantityType = 0;
136 float quantityCurrent = -1.0;
139 health = GetItemHealth();
140 SetItemHealth(health,
"ia_item",
"ia_item_health_mark", m_HealthEnabled);
144 if (m_EntityInHands && m_EntityInHands.IsWeapon())
146 SetWeaponQuantity(0, 0,
"ia_item",
"ia_item_quantity_pb",
"ia_item_quantity_text", m_QuantityEnabled);
147 SetWeaponModeAndZeroing(
"ia_item_subdesc",
"ia_item_subdesc_up",
"ia_item_subdesc_down",
true);
150 else if (m_EntityInHands && m_EntityInHands.IsTransmitter())
152 SetRadioFrequency(GetRadioFrequency(),
"ia_item_subdesc",
"ia_item_subdesc_up",
"ia_item_subdesc_down", m_QuantityEnabled);
154 SetItemQuantity(quantityType, quantityCurrent,
quantityMin,
quantityMax,
"ia_item",
"ia_item_quantity_pb",
"ia_item_quantity_text",
true);
159 SetItemQuantity(quantityType, quantityCurrent,
quantityMin,
quantityMax,
"ia_item",
"ia_item_quantity_pb",
"ia_item_quantity_text", m_QuantityEnabled);
160 SetWeaponModeAndZeroing(
"ia_item_subdesc",
"",
"",
false);
163 SetItemDesc(m_EntityInHands, GetItemDesc(m_EntityInHands),
"ia_item",
"ia_item_desc");
164 SetInteractActionIcon(
"ia_interact",
"ia_interact_icon_frame",
"ia_interact_btn_inner_icon",
"ia_interact_btn_text");
165 SetActionWidget(m_Interact, GetActionDesc(m_Interact),
"ia_interact",
"ia_interact_action_name");
167 SetInteractActionIcon(
"ia_continuous_interact",
"ia_continuous_interact_icon_frame",
"ia_continuous_interact_btn_inner_icon",
"ia_continuous_interact_btn_text");
168 SetActionWidget(m_ContinuousInteract, GetActionDesc(m_ContinuousInteract),
"ia_continuous_interact",
"ia_continuous_interact_action_name");
170 SetActionWidget(m_Single, GetActionDesc(m_Single),
"ia_single",
"ia_single_action_name");
171 SetActionWidget(m_Continuous, GetActionDesc(m_Continuous),
"ia_continuous",
"ia_continuous_action_name");
172 SetMultipleInteractAction(
"ia_interact_mlt_wrapper");
173 SetMultipleContinuousInteractAction(
"ia_continuous_interact_mlt_wrapper");
174 SetMultipleItemAction(
"ia_single_mlt_wrapper");
175 SetMultipleContinuousItemAction(
"ia_continuous_mlt_wrapper");
202 if ((m_EntityInHands || !m_Hidden) &&
GetGame().GetUIManager().GetMenu() ==
null)
204 CheckForActionWidgetOverrides();
206 CheckRefresherFlagVisibility();
212 m_MaxWidthChild = 200;
232 m_ContinuousInteract =
null;
247 if (!m_Interact && !m_ContinuousInteract && !m_Continuous && !m_Single)
256 protected void GetEntityInHands()
264 m_EntityInHands = eai;
268 m_EntityInHands =
null;
272 protected string GetActionDesc(
ActionBase action)
274 if (action && action.GetText())
275 return action.GetText();
280 protected string GetItemDesc(
EntityAI entity)
283 return m_EntityInHands.GetDisplayName();
288 protected int GetItemHealth()
291 return m_EntityInHands.GetHealthLevel();
296 protected void GetItemQuantity(out
int q_type, out
float q_cur, out
int q_min, out
int q_max)
308 q_cur = (q_cur / q_max);
322 protected string GetRadioFrequency()
325 if (
Class.CastTo(trans, m_EntityInHands))
327 return trans.GetTunedFrequency().ToString();
334 protected void SetItemDesc(
EntityAI entity,
string descText,
string itemWidget,
string descWidget)
338 widget =
m_Root.FindAnyWidget(itemWidget);
340 if (entity &&
m_Player && !
m_Player.GetItemAccessor().IsItemInHandsHidden())
344 Class.CastTo(itemName, widget.FindAnyWidget(descWidget));
345 itemName.SetText(descText);
352 protected void SetItemHealth(
int health,
string itemWidget,
string healthWidget,
bool enabled)
356 widget =
m_Root.FindAnyWidget(itemWidget);
360 ImageWidget healthMark;
361 Class.CastTo(healthMark, widget.FindAnyWidget(healthWidget));
366 healthMark.GetParent().Show(
false);
369 healthMark.SetColor(
Colors.COLOR_PRISTINE);
370 healthMark.SetAlpha(0.5);
371 healthMark.GetParent().Show(
true);
374 healthMark.SetColor(
Colors.COLOR_WORN);
375 healthMark.SetAlpha(0.5);
376 healthMark.GetParent().Show(
true);
379 healthMark.SetColor(
Colors.COLOR_DAMAGED);
380 healthMark.SetAlpha(0.5);
381 healthMark.GetParent().Show(
true);
384 healthMark.SetColor(
Colors.COLOR_BADLY_DAMAGED);
385 healthMark.SetAlpha(0.5);
386 healthMark.GetParent().Show(
true);
389 healthMark.SetColor(
Colors.COLOR_RUINED);
390 healthMark.SetAlpha(0.5);
391 healthMark.GetParent().Show(
true);
394 healthMark.SetColor(0x00FFFFFF);
395 healthMark.SetAlpha(0.5);
396 healthMark.GetParent().Show(
true);
406 protected void SetItemQuantity(
int type,
float current,
int min,
int max,
string itemWidget,
string quantityPBWidget,
string quantityTextWidget,
bool enabled)
410 widget =
m_Root.FindAnyWidget(itemWidget);
414 ProgressBarWidget progressBar;
416 Class.CastTo(progressBar, widget.FindAnyWidget(quantityPBWidget));
417 Class.CastTo(textWidget, widget.FindAnyWidget(quantityTextWidget));
423 progressBar.Show(
false);
424 textWidget.Show(
false);
425 textWidget.GetParent().Show(
false);
428 if (max > 1 || current > 1)
430 string qty_text =
string.Format(
"%1/%2",
Math.Round(current).ToString(), max.ToString());
431 progressBar.Show(
false);
432 textWidget.SetText(qty_text);
433 textWidget.Show(
true);
434 textWidget.GetParent().Show(
true);
439 progressBar.Show(
false);
440 textWidget.Show(
false);
441 textWidget.GetParent().Show(
false);
445 textWidget.Show(
false);
446 progressBar.SetCurrent(current);
447 progressBar.Show(
true);
448 textWidget.GetParent().Show(
true);
457 protected void SetWeaponQuantity(
int chamber,
int mag,
string itemWidget,
string quantityPBWidget,
string quantityTextWidget,
bool enabled)
461 widget =
m_Root.FindAnyWidget(itemWidget);
467 ProgressBarWidget progressBar;
469 Class.CastTo(progressBar, widget.FindAnyWidget(quantityPBWidget));
470 Class.CastTo(textWidget, widget.FindAnyWidget(quantityTextWidget));
474 int mag_quantity = -1;
476 if (
Class.CastTo(wpn, m_EntityInHands))
481 for (
int j = 0; j < wpn.GetMuzzleCount(); j++)
483 if (wpn.IsChamberFull(j)&& !wpn.IsChamberFiredOut(j))
486 wpn_qty = mag_quantity.ToString();
490 for (
int i = 0; i < wpn.GetMuzzleCount(); i++)
492 if (i > 0 && (wpn.GetMuzzleCount() < 3 || i%2 == 0))
494 wpn_qty = wpn_qty +
" ";
496 if (wpn.IsChamberEmpty(i))
498 wpn_qty = wpn_qty +
"0";
500 else if (wpn.IsChamberFiredOut(i))
502 wpn_qty = wpn_qty +
"F";
506 wpn_qty = wpn_qty +
"1";
509 maga = wpn.GetMagazine(i);
512 mag_quantity = maga.GetAmmoCount();
514 else if (wpn.GetInternalMagazineMaxCartridgeCount(i) > 0)
516 mag_quantity = wpn.GetInternalMagazineCartridgeCount(i);
523 if (mag_quantity != -1)
524 wpn_qty =
string.Format(
"X (+%1)", mag_quantity);
530 if (mag_quantity != -1)
532 wpn_qty = wpn_qty +
" (" + mag_quantity.ToString() +
")";
538 progressBar.Show(
false);
539 textWidget.SetText(wpn_qty);
540 textWidget.Show(
true);
541 textWidget.GetParent().Show(
true);
547 protected void SetWeaponModeAndZeroing(
string itemWidget,
string upWidget,
string downWidget,
bool enabled)
551 widget =
m_Root.FindAnyWidget(itemWidget);
558 Class.CastTo(txtModeWidget, widget.FindAnyWidget(upWidget));
559 Class.CastTo(txtZeroingWidget, widget.FindAnyWidget(downWidget));
562 string zeroing =
string.Empty;
564 zeroing =
string.Format(
"%1 m", w.GetCurrentZeroing(w.GetCurrentMuzzle()));
566 txtModeWidget.SetText(
m_Player.GetWeaponManager().GetCurrentModeName());
567 txtZeroingWidget.SetText(zeroing);
575 protected string WeaponModeTextTemp()
580 protected void SetRadioFrequency(
string freq,
string itemWidget,
string upWidget,
string downWidget,
bool enabled)
584 widget =
m_Root.FindAnyWidget(itemWidget);
590 Class.CastTo(txtUpWidget, widget.FindAnyWidget(upWidget));
591 Class.CastTo(txtDownWidget, widget.FindAnyWidget(downWidget));
593 txtUpWidget.SetText(freq);
594 txtDownWidget.SetText(
"MHz");
601 protected void SetActionWidget(
ActionBase action,
string descText,
string actionWidget,
string descWidget)
605 if (action && (!action.HasTarget() || (
m_Player &&
m_Player.GetCommand_Vehicle())))
608 Class.CastTo(actionName, widget.FindAnyWidget(descWidget));
611 if (action.GetInput().GetInputType() ==
ActionInputType.AIT_CONTINUOUS)
613 descText = descText +
" " +
"#action_target_cursor_hold";
614 actionName.SetText(descText);
618 actionName.SetText(descText);
630 protected void SetMultipleInteractAction(
string multiActionsWidget)
634 widget =
m_Root.FindAnyWidget(multiActionsWidget);
635 widget.Show(m_InteractActionsNum > 1);
639 protected void SetMultipleContinuousInteractAction(
string multiActionsWidget)
643 widget =
m_Root.FindAnyWidget(multiActionsWidget);
644 widget.Show(m_ContinuousInteractActionsNum > 1);
647 protected void SetMultipleItemAction(
string multiActionsWidget)
651 widget =
m_Root.FindAnyWidget(multiActionsWidget);
652 widget.Show(m_ItemActionsNum > 1);
656 protected void SetMultipleContinuousItemAction(
string multiActionsWidget)
660 widget =
m_Root.FindAnyWidget(multiActionsWidget);
661 widget.Show(m_ContinuousItemActionsNum > 1);
664 protected void SetInteractActionIcon(
string actionWidget,
string actionIconFrameWidget,
string actionIconWidget,
string actionIconTextWidget)
666 string keyName =
string.Empty;
667 Widget widget, frameWidget;
668 ImageWidget iconWidget;
671 widget =
m_Root.FindAnyWidget(actionWidget);
672 Class.CastTo(frameWidget, widget.FindAnyWidget(actionIconFrameWidget));
673 Class.CastTo(iconWidget, widget.FindAnyWidget(actionIconWidget));
674 Class.CastTo(textWidget, widget.FindAnyWidget(actionIconTextWidget));
676 m_UseActionWrapper.InputP().SelectAlternative(0);
677 for (
int c = 0; c < m_UseActionWrapper.InputP().BindKeyCount(); c++)
679 int _hc = m_UseActionWrapper.InputP().GetBindKey(0);
680 keyName =
GetUApi().GetButtonName(_hc);
684 iconWidget.Show(
false);
685 textWidget.SetText(keyName);
686 textWidget.Show(
true);
689 protected void CheckRefresherFlagVisibility()
695 w.Show(entity.IsRefresherSignalingViable() &&
m_Player.IsTargetInActiveRefresherRange(entity));
697 else if (w.IsVisible())
703 protected void CheckForActionWidgetOverrides()
707 if (
Class.CastTo(item, m_EntityInHands) && item.GetActionWidgetOverride(actionName))
717 protected IngameHud GetHud()
722 IngameHud hud = IngameHud.Cast(
mission.GetHud());