3 protected Object m_CachedObject;
4 protected vector m_CursorWPos;
5 protected vector m_ScreenPos;
6 protected int m_CompIdx;
10 m_CachedObject =
null;
31 m_CachedObject =
null;
32 m_CursorWPos =
vector.Zero;
39 return m_CachedObject;
47 int GetCursorCompIdx()
55 private const ref
array<typename> VISION_OBSTRUCTION_PPEFFECTS_TYPES = {
56 PPERequester_BurlapSackEffects,
57 PPERequester_FlashbangEffects
63 protected Object m_DisplayInteractTarget;
70 protected IngameHud m_Hud;
74 protected int m_InteractActionsNum;
75 protected int m_ContinuousInteractActionsNum;
76 protected int m_ItemActionsNum;
77 protected int m_ContinuousItemActionsNum;
78 protected typename m_SelectedActionCategory;
79 protected bool m_HealthEnabled;
80 protected bool m_QuantityEnabled;
81 protected bool m_FixedOnPosition;
82 protected bool m_Hidden;
85 protected Widget m_Container;
86 protected Widget m_ItemLeft;
89 protected float m_MaxWidthChild;
90 protected float m_RootWidth;
91 protected float m_RootHeight;
96 m_ContinuousInteract =
null;
101 m_HealthEnabled =
true;
102 m_QuantityEnabled =
true;
106 m_DisplayInteractTarget =
null;
110 m_UseActionWrapper =
GetUApi().GetInputByID(UAAction).GetPersistentWrapper();
112 GetGame().GetMission().GetOnInputPresetChanged().Insert(OnInputPresetChanged);
113 GetGame().GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
119 void SetHealthVisibility(
bool state)
121 m_HealthEnabled = state;
124 void SetQuantityVisibility(
bool state)
126 m_QuantityEnabled = state;
130 void SetInteractXboxIcon(
string imageset_name,
string image_name);
131 void SetContinuousInteractXboxIcon(
string imageset_name,
string image_name);
132 void SetSingleXboxIcon(
string imageset_name,
string image_name);
133 void SetContinuousXboxIcon(
string imageset_name,
string image_name);
134 protected void SetXboxIcon(
string name,
string imageset_name,
string image_name);
137 protected void SetControllerIcon(
string pWidgetName,
string pInputName)
140 w.SetText(
InputUtils.GetRichtextButtonIconFromInputAction(pInputName,
"", EUAINPUT_DEVICE_CONTROLLER));
143 protected void OnWidgetScriptInit(
Widget w)
150 UpdateControllerInputIcons();
151 UpdatePCIconsVisibility();
153 m_Container = w.FindAnyWidget(
"container");
154 m_ItemLeft = w.FindAnyWidget(
"item_left");
159 protected void OnInputPresetChanged()
161 #ifdef PLATFORM_CONSOLE
162 UpdateControllerInputIcons();
168 UpdatePCIconsVisibility();
172 private void UpdateControllerInputIcons()
174 SetControllerIcon(
"interact",
"UAAction");
175 SetControllerIcon(
"continuous_interact",
"UAAction");
176 SetControllerIcon(
"single",
"UADefaultAction");
177 SetControllerIcon(
"continuous",
"UADefaultAction");
181 private void UpdatePCIconsVisibility()
183 bool showConsoleIcons =
false;
184 #ifdef PLATFORM_CONSOLE
185 showConsoleIcons =
GetGame().GetInput().GetCurrentInputDevice() ==
EInputDeviceType.CONTROLLER || !
GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer();
188 ShowXboxHidePCIcons(
"interact", showConsoleIcons);
189 ShowXboxHidePCIcons(
"continuous_interact", showConsoleIcons);
190 ShowXboxHidePCIcons(
"continuous", showConsoleIcons);
191 ShowXboxHidePCIcons(
"single", showConsoleIcons);
194 protected void PrepareCursorContent()
199 int q_min, q_max = -1;
203 health = GetItemHealth();
204 SetItemHealth(health,
"item",
"item_health_mark", m_HealthEnabled);
206 GetItemQuantity(q_type, q_cur, q_min, q_max);
208 GetItemCargoCount(cargoCount);
210 SetItemQuantity(q_type, q_cur, q_min, q_max,
"item",
"item_quantity_pb",
"item_quantity_text", m_QuantityEnabled);
211 SetInteractActionIcon(
"interact",
"interact_icon_frame",
"interact_btn_inner_icon",
"interact_btn_text");
212 SetItemDesc(GetItemDesc(m_Interact), cargoCount,
"item",
"item_desc");
213 SetActionWidget(m_Interact, GetActionDesc(m_Interact),
"interact",
"interact_action_name");
215 SetInteractActionIcon(
"continuous_interact",
"continuous_interact_icon_frame",
"continuous_interact_btn_inner_icon",
"continuous_interact_btn_text");
216 SetActionWidget(m_ContinuousInteract, GetActionDesc(m_ContinuousInteract),
"continuous_interact",
"continuous_interact_action_name");
218 SetActionWidget(m_Single, GetActionDesc(m_Single),
"single",
"single_action_name");
219 SetActionWidget(m_Continuous, GetActionDesc(m_Continuous),
"continuous",
"continuous_action_name");
220 SetMultipleItemAction(
"single_mlt_wrapper",
"single_mlt_wrapper_not_select");
221 SetMultipleContinuousItemAction(
"continuous_mlt_wrapper",
"continuous_mlt_wrapper_not_select");
222 SetMultipleInteractAction(
"interact_mlt_wrapper",
"interact_mlt_wrapper_not_select");
223 SetMultipleContinuousInteractAction(
"continuous_interact_mlt_wrapper",
"continuous_interact_mlt_wrapper_not_select");
226 protected void BuildFixedCursor()
230 PrepareCursorContent();
238 protected void BuildFloatingCursor(
bool forceRebuild)
240 float pos_x, pos_y = 0.0;
242 PrepareCursorContent();
245 if (forceRebuild ||
m_Target.GetComponentIndex() != m_CachedObject.GetCursorCompIdx())
247 GetOnScreenPosition(pos_x, pos_y);
252 vector screen_pos = TransformToScreenPos(m_CachedObject.GetCursorWorldPos());
254 pos_x = screen_pos[0];
255 pos_y = screen_pos[1];
258 pos_x =
Math.Ceil(pos_x);
259 pos_y =
Math.Ceil(pos_y);
269 parentWdg.GetScreenSize(screen_w, screen_h);
270 m_Root.GetSize(wdg_w, wdg_h);
272 if (pos_x + wdg_w > screen_w)
273 pos_x = screen_w - wdg_w;
275 if (pos_y + wdg_h > screen_h)
276 pos_y = screen_h - wdg_h;
278 m_Root.SetPos(pos_x, pos_y);
281 override bool OnUpdate(
Widget w)
292 protected void HideWidget()
297 m_CachedObject.Invalidate();
327 bool isVisionObstructionActive =
PPEManagerStatic.GetPPEManager().IsAnyRequesterRunning(VISION_OBSTRUCTION_PPEFFECTS_TYPES);
340 bool showTarget = (
m_Target && !m_Hidden) || m_Interact || m_ContinuousInteract;
344 showTarget = m_Single.HasTarget();
347 showTarget = showTarget || m_Continuous.HasTarget();
353 if (
m_Target.GetObject() ==
null && (m_Interact || m_ContinuousInteract || m_Single || m_Continuous))
356 m_CachedObject.Invalidate();
359 m_FixedOnPosition =
false;
365 CheckRefresherFlagVisibility(
m_Target.GetObject());
367 if (
m_Target.GetObject() != m_CachedObject.Get())
369 if (!m_FixedOnPosition)
372 m_CachedObject.Invalidate();
373 BuildFloatingCursor(
true);
381 m_CachedObject.Invalidate();
384 m_FixedOnPosition =
false;
390 else if (
m_Target.GetObject() == m_CachedObject.Get())
392 if (!m_FixedOnPosition)
395 BuildFloatingCursor(
false);
403 m_CachedObject.Invalidate();
406 m_FixedOnPosition =
false;
416 m_CachedObject.Invalidate();
429 m_CachedObject.Invalidate();
431 m_FixedOnPosition =
false;
440 m_MaxWidthChild = 350;
443 protected void ShowXboxHidePCIcons(
string widget,
bool show_xbox_icon)
445 m_Root.FindAnyWidget(widget +
"_btn_icon_xbox").Show(show_xbox_icon);
446 m_Root.FindAnyWidget(widget +
"_btn_icon").Show(!show_xbox_icon);
453 float parent_width, parent_height;
454 vector transformed_pos, screen_pos;
457 screen_pos =
GetGame().GetScreenPosRelative(pWorldPos);
459 m_Root.GetParent().GetScreenSize(parent_width, parent_height);
462 transformed_pos[0] = screen_pos[0] * parent_width;
463 transformed_pos[1] = screen_pos[1] * parent_height;
465 return transformed_pos;
468 protected void GetOnScreenPosition(out
float x, out
float y)
470 const float DEFAULT_HANDLE_OFFSET = 0.2;
471 const string CE_CENTER_COMP_NAME =
"ce_center";
472 const string MEM_LOD_NAME =
LOD.NAME_MEMORY;
475 float pivotOffset = 0.0;
476 float memOffset = 0.0;
479 bool isTargetForced =
false;
494 compIdx =
m_Target.GetComponentIndex();
497 isTargetForced =
true;
508 compName =
object.GetActionComponentName(compIdx);
509 object.GetActionComponentNameList(compIdx, components);
513 m_FixedOnPosition =
true;
517 pivotOffset =
object.ConfigGetFloat(
"actionTargetPivotOffsetY");
518 memOffset =
object.ConfigGetFloat(
"actionTargetMemOffsetY");
521 lod =
object.GetLODByName(MEM_LOD_NAME);
525 lod.GetSelections(memSelections);
528 if (MiscGameplayFunctions.IsComponentInSelection(memSelections, CE_CENTER_COMP_NAME))
530 for (
int i2 = 0; i2 < memSelections.Count(); ++i2)
532 if (memSelections[i2].
GetName() == CE_CENTER_COMP_NAME && memSelections[i2].GetVertexCount() == 1)
534 m_FixedOnPosition =
false;
535 modelPos =
object.GetSelectionPositionMS(CE_CENTER_COMP_NAME);
536 worldPos =
object.ModelToWorld(modelPos);
537 if (memOffset != 0.0)
539 worldPos[1] = worldPos[1] + memOffset;
543 worldPos[1] = worldPos[1] + DEFAULT_HANDLE_OFFSET;
549 m_CachedObject.Store(
object, worldPos, compIdx);
552 else if (!compName.Contains(
"ladder") && IsComponentInSelection(memSelections, compName))
554 for (
int i1 = 0; i1 < memSelections.Count(); ++i1)
557 if (memSelections[i1].
GetName() == compName && memSelections[i1].GetVertexCount() == 1)
559 modelPos =
object.GetSelectionPositionMS(compName);
560 worldPos =
object.ModelToWorld(modelPos);
562 m_FixedOnPosition =
false;
563 if (
object.
GetType() ==
"Fence" ||
object.
GetType() ==
"Watchttower" ||
object.
GetType() ==
"GardenPlot")
564 m_FixedOnPosition =
true;
566 if (memOffset != 0.0)
568 worldPos[1] = worldPos[1] + memOffset;
572 worldPos[1] = worldPos[1] + DEFAULT_HANDLE_OFFSET;
577 if (memSelections[i1].
GetName() == compName && memSelections[i1].GetVertexCount() > 1)
579 for (
int j = 0; j < components.Count(); ++j)
581 if (IsComponentInSelection(memSelections, components[j]))
583 modelPos =
object.GetSelectionPositionMS(components[j]);
584 worldPos =
object.ModelToWorld(modelPos);
586 m_FixedOnPosition =
false;
587 if (memOffset != 0.0)
589 worldPos[1] = worldPos[1] + memOffset;
593 worldPos[1] = worldPos[1] + DEFAULT_HANDLE_OFFSET;
601 m_CachedObject.Store(
object, worldPos, -1);
604 else if (compName.Contains(
"ladder") && IsComponentInSelection(memSelections, compName))
606 vector ladderHandlePointLS, ladderHandlePointWS;
608 float lastDistance = 0;
610 for (
int i3 = 0; i3 < memSelections.Count(); ++i3)
612 if (memSelections[i3].
GetName() == compName && memSelections[i3].GetVertexCount() > 1)
614 ladderHandlePointLS = memSelections[i3].GetVertexPosition(lod, 0);
615 ladderHandlePointWS =
object.ModelToWorld(ladderHandlePointLS);
616 closestHandlePos = ladderHandlePointWS;
617 lastDistance =
Math.AbsFloat(
vector.DistanceSq(ladderHandlePointWS,
m_Player.GetPosition()));
619 for (
int k = 1; k < memSelections[i3].GetVertexCount(); ++k)
621 ladderHandlePointLS = memSelections[i3].GetVertexPosition(lod, k);
622 ladderHandlePointWS =
object.ModelToWorld(ladderHandlePointLS);
624 if (lastDistance >
Math.AbsFloat(
vector.DistanceSq(ladderHandlePointWS,
m_Player.GetPosition())))
626 lastDistance =
Math.AbsFloat(
vector.DistanceSq(ladderHandlePointWS,
m_Player.GetPosition()));
627 closestHandlePos = ladderHandlePointWS;
631 m_FixedOnPosition =
false;
632 worldPos = closestHandlePos;
633 if (memOffset != 0.0)
635 worldPos[1] = worldPos[1] + memOffset;
639 worldPos[1] = worldPos[1] + DEFAULT_HANDLE_OFFSET;
645 m_CachedObject.Store(
object, worldPos, -1);
649 m_FixedOnPosition =
true;
654 m_FixedOnPosition =
true;
659 m_FixedOnPosition =
true;
662 vector pos = TransformToScreenPos(worldPos);
669 isTargetForced =
false;
673 protected bool IsComponentInSelection(
array<Selection> selection,
string compName)
675 return MiscGameplayFunctions.IsComponentInSelection(selection, compName);
680 protected void GetPlayer()
685 protected void GetActionManager()
698 protected void GetActions()
701 m_ContinuousInteract =
null;
720 m_SelectedActionCategory =
m_AM.GetSelectedActionCategory();
724 m_DisplayInteractTarget = m_Interact.GetDisplayInteractObject(
m_Player,
m_Target);
728 m_DisplayInteractTarget = m_Single.GetDisplayInteractObject(
m_Player,
m_Target);
730 else if (m_ContinuousInteract)
732 m_DisplayInteractTarget = m_ContinuousInteract.GetDisplayInteractObject(
m_Player,
m_Target);
736 m_DisplayInteractTarget =
null;
740 protected void GetTarget()
750 item.GetInventory().GetCurrentInventoryLocation(invLocation);
757 protected string GetActionDesc(
ActionBase action)
760 if (action && action.GetText())
761 desc = action.GetText();
767 protected string GetItemDesc(
ActionBase action)
770 Object tgObject = m_DisplayInteractTarget;
780 if (!tgObject.IsAlive())
783 if (!tgParent || tgObject.DisplayNameRuinAttach())
784 desc = tgObject.GetDisplayName();
786 desc = tgParent.GetDisplayName();
792 if (tgParent && (tgParent.IsItemBase() || tgParent.IsTransport()))
794 targetEntity =
EntityAI.Cast(tgParent);
797 if (tgObject.IsItemBase() || tgObject.IsTransport())
799 targetEntity =
EntityAI.Cast(tgObject);
802 if (targetEntity && targetEntity.ShowZonesHealth())
812 if (DamageSystem.GetDamageZoneFromComponentName(targetEntity, tgObject.GetActionComponentName(
m_Target.GetComponentIndex(),
LOD.NAME_FIRE), zone))
814 desc = DamageSystem.GetDamageDisplayName(targetEntity, zone);
819 targetEntity.GetActionComponentNameList(
m_Target.GetComponentIndex(), selections,
LOD.NAME_VIEW);
822 for (
int s = 0; s < selections.Count(); s++)
824 if (DamageSystem.GetDamageZoneFromComponentName(targetEntity, selections[s], zone))
826 desc = DamageSystem.GetDamageDisplayName(targetEntity, zone);
833 if (targetEntity && desc ==
"")
834 desc = targetEntity.GetDisplayName();
840 protected int GetItemHealth()
844 if (m_Interact && !m_Interact.HasTarget())
849 Object tgObject = m_DisplayInteractTarget;
861 if (!tgObject.IsAlive())
863 health = tgObject.GetHealthLevel();
867 if (tgParent && (tgParent.IsItemBase() || tgParent.IsTransport()))
869 targetEntity =
EntityAI.Cast(tgParent);
872 if (tgObject.IsItemBase() || tgObject.IsTransport())
874 targetEntity =
EntityAI.Cast(tgObject);
879 if (!targetEntity.IsDamageDestroyed())
887 if (DamageSystem.GetDamageZoneFromComponentName(targetEntity, tgObject.GetActionComponentName(
m_Target.GetComponentIndex(),
LOD.NAME_FIRE), zone))
889 health = targetEntity.GetHealthLevel(zone);
895 targetEntity.GetActionComponentNameList(
m_Target.GetComponentIndex(), selections,
LOD.NAME_VIEW);
897 for (
int s = 0; s < selections.Count(); s++)
899 if (DamageSystem.GetDamageZoneFromComponentName(targetEntity , selections[s], zone))
901 health = targetEntity.GetHealthLevel(zone);
908 health = targetEntity.GetHealthLevel();
913 health = tgObject.GetHealthLevel();
920 protected void GetItemQuantity(out
int q_type, out
float q_cur, out
int q_min, out
int q_max)
924 if (m_Interact && !m_Interact.HasTarget())
929 Object tgObject = m_DisplayInteractTarget;
935 if (
Class.CastTo(item, tgObject))
944 protected void GetItemCargoCount(out
int cargoCount)
948 Object tgObject = m_DisplayInteractTarget;
954 if (
Class.CastTo(entity, tgObject))
960 cargoCount = AttachmentsWithInventoryOrCargoCount(inventory);
970 protected void SetItemDesc(
string descText,
int cargoCount,
string itemWidget,
string descWidget)
973 widget =
m_Root.FindAnyWidget(itemWidget);
978 string msg = playerT.GetLastUAMessage();
980 if (descText.Length() == 0 && msg.Length() == 0)
988 Class.CastTo(itemName, widget.FindAnyWidget(descWidget));
992 descText =
string.Format(
"[+] %1 %2", descText, msg);
994 descText =
string.Format(
"%1 %2", descText, msg);
996 itemName.SetText(descText);
1000 protected void SetItemHealth(
int health,
string itemWidget,
string healthWidget,
bool enabled)
1006 ImageWidget healthMark;
1007 Class.CastTo(healthMark, widget.FindAnyWidget(healthWidget));
1008 int color = 0x00FFFFFF;
1012 healthMark.GetParent().Show(
false);
1013 widget.Show(enabled);
1017 healthMark.SetColor(
ItemManager.GetItemHealthColor(health));
1018 healthMark.SetAlpha(0.5);
1019 healthMark.GetParent().Show(
true);
1022 widget.Show(enabled);
1025 protected void SetItemQuantity(
int type,
float current,
int min,
int max,
string itemWidget,
string quantityPBWidget,
string quantityTextWidget,
bool enabled)
1029 widget =
m_Root.FindAnyWidget(itemWidget);
1033 ProgressBarWidget progressBar;
1035 Class.CastTo(progressBar, widget.FindAnyWidget(quantityPBWidget));
1036 Class.CastTo(textWidget, widget.FindAnyWidget(quantityTextWidget));
1042 progressBar.Show(
false);
1043 textWidget.Show(
false);
1044 textWidget.GetParent().Show(
false);
1047 if (max > 1 || current > 1)
1049 string qty_text =
string.Format(
"%1/%2",
Math.Round(current).ToString(), max.ToString());
1050 progressBar.Show(
false);
1051 textWidget.SetText(qty_text);
1052 textWidget.Show(
true);
1053 textWidget.GetParent().Show(
true);
1057 progressBar.Show(
false);
1058 textWidget.Show(
false);
1059 textWidget.GetParent().Show(
false);
1063 float qty_num =
Math.Round((current / max) * 100);
1065 textWidget.Show(
false);
1066 progressBar.SetCurrent(qty_num);
1067 progressBar.Show(
true);
1068 textWidget.GetParent().Show(
true);
1077 protected void SetActionWidget(
ActionBase action,
string descText,
string actionWidget,
string descWidget)
1083 if (action.HasTarget() &&
m_AM.GetActionState() < 1)
1086 Class.CastTo(actionName, widget.FindAnyWidget(descWidget));
1088 if (action.GetInput().GetInputType() ==
ActionInputType.AIT_CONTINUOUS)
1090 descText = descText +
" " +
"#action_target_cursor_hold";
1091 actionName.SetText(descText);
1095 actionName.SetText(descText);
1101 actionName.GetTextSize(
x,
y);
1102 if (
x > m_MaxWidthChild);
1103 m_MaxWidthChild =
x;
1117 protected void SetMultipleInteractAction(
string multiActionsWidget,
string multiActionsWidget_NotSelect)
1119 Widget widget, widget_not_select;
1121 widget =
m_Root.FindAnyWidget(multiActionsWidget);
1122 widget_not_select =
m_Root.FindAnyWidget(multiActionsWidget_NotSelect);
1124 if (m_InteractActionsNum > 1)
1129 widget_not_select.Show(
false);
1134 widget_not_select.Show(
true);
1140 widget_not_select.Show(
false);
1144 protected void SetMultipleContinuousInteractAction(
string multiActionsWidget,
string multiActionsWidget_NotSelect)
1146 Widget widget, widget_not_select;
1148 widget =
m_Root.FindAnyWidget(multiActionsWidget);
1149 widget_not_select =
m_Root.FindAnyWidget(multiActionsWidget_NotSelect);
1151 if (m_ContinuousInteractActionsNum > 1)
1156 widget_not_select.Show(
false);
1161 widget_not_select.Show(
true);
1167 widget_not_select.Show(
false);
1172 protected void SetMultipleItemAction(
string multiActionsWidget,
string multiActionsWidget_NotSelect)
1174 Widget widget, widget_not_select;
1176 widget =
m_Root.FindAnyWidget(multiActionsWidget);
1177 widget_not_select =
m_Root.FindAnyWidget(multiActionsWidget_NotSelect);
1179 if (m_ItemActionsNum > 1)
1184 widget_not_select.Show(
false);
1189 widget_not_select.Show(
true);
1195 widget_not_select.Show(
false);
1199 protected void SetMultipleContinuousItemAction(
string multiActionsWidget,
string multiActionsWidget_NotSelect)
1201 Widget widget, widget_not_select;
1203 widget =
m_Root.FindAnyWidget(multiActionsWidget);
1204 widget_not_select =
m_Root.FindAnyWidget(multiActionsWidget_NotSelect);
1206 if (m_ContinuousItemActionsNum > 1)
1211 widget_not_select.Show(
false);
1216 widget_not_select.Show(
true);
1222 widget_not_select.Show(
false);
1226 protected void SetInteractActionIcon(
string actionWidget,
string actionIconFrameWidget,
string actionIconWidget,
string actionIconTextWidget)
1229 ImageWidget iconWidget;
1232 widget =
m_Root.FindAnyWidget(actionWidget);
1233 Class.CastTo(iconWidget, widget.FindAnyWidget(actionIconWidget));
1234 Class.CastTo(textWidget, widget.FindAnyWidget(actionIconTextWidget));
1236 GetDayZGame().GetBacklit().HintShow(m_UseActionWrapper.InputP());
1239 iconWidget.Show(
false);
1241 textWidget.Show(
true);
1244 protected void CheckRefresherFlagVisibility(
Object object)
1248 if (
Class.CastTo(entity,
object) && w)
1250 w.Show(entity.IsRefresherSignalingViable() &&
m_Player.IsTargetInActiveRefresherRange(entity));
1254 protected int AttachmentsWithInventoryOrCargoCount(notnull
GameInventory inventory)
1256 int attachmentsWithInventory = 0;
1259 if (cargo && cargo.GetItemCount() > 0)
1264 for (
int i = 0; i < inventory.AttachmentCount(); i++)
1266 EntityAI attachment = inventory.GetAttachmentFromIndex(i);
1267 int attachmentSlotId = attachment.GetInventory().GetSlotId(0);
1269 if (attachment.GetInventory())
1271 attachmentsWithInventory += 1;
1275 return attachmentsWithInventory;
1278 protected IngameHud GetHud()
1283 IngameHud hud = IngameHud.Cast(
mission.GetHud());