DayZ 1.24
Loading...
Searching...
No Matches
ActionTargetsCursor.c
Go to the documentation of this file.
2{
5 protected vector m_ScreenPos;
6 protected int m_CompIdx;
7
9 {
12 m_CompIdx = -1;
13 }
14
16 void Store(Object obj, vector pos, int compIdx)
17 {
18 if (!m_CachedObject)
19 {
20 m_CachedObject = obj;
21 m_CursorWPos = pos;
23 }
24 }
25
28 {
30 {
33 m_CompIdx = -1;
34 }
35 }
36
38 {
39 return m_CachedObject;
40 }
41
43 {
44 return m_CursorWPos;
45 }
46
48 {
49 return m_CompIdx;
50 }
51};
52
54{
59
61 protected ActionTarget m_Target;
64
65 protected ActionBase m_Interact;
66 protected ActionBase m_ContinuousInteract;
67 protected ActionBase m_Single;
68 protected ActionBase m_Continuous;
70 protected IngameHud m_Hud;
71
73
74 protected int m_InteractActionsNum;
76 protected int m_ItemActionsNum;
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;
83
84 protected Widget m_Root;
86 protected Widget m_ItemLeft;
87
89 protected float m_MaxWidthChild;
90 protected float m_RootWidth;
91 protected float m_RootHeight;
92
94 {
97 m_Single = null;
99 m_AM = null;
100
101 m_HealthEnabled = true;
102 m_QuantityEnabled = true;
103
105 m_Hidden = false;
107
108 m_Hud = GetHud();
109
110 m_UseActionWrapper = GetUApi().GetInputByID(UAAction).GetPersistentWrapper();
111
112 GetGame().GetMission().GetOnInputPresetChanged().Insert(OnInputPresetChanged);
113 GetGame().GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
114 }
115
117
118 // Controls appearance of the builded cursor
120 {
122 }
123
125 {
127 }
128
134 protected void SetXboxIcon(string name, string imageset_name, string image_name);
136
137 protected void SetControllerIcon(string pWidgetName, string pInputName)
138 {
139 RichTextWidget w = RichTextWidget.Cast(m_Root.FindAnyWidget(pWidgetName + "_btn_icon_xbox"));
141 }
142
144 {
145 m_Root = w;
146 m_Root.Show(false);
147 m_Root.SetHandler(this);
148
152
153 m_Container = w.FindAnyWidget("container");
154 m_ItemLeft = w.FindAnyWidget("item_left");
155
156 m_Root.Update();
157 }
158
159 protected void OnInputPresetChanged()
160 {
161#ifdef PLATFORM_CONSOLE
163#endif
164 }
165
170
173 {
174 SetControllerIcon("interact", "UAAction");
175 SetControllerIcon("continuous_interact", "UAAction");
176 SetControllerIcon("single", "UADefaultAction");
177 SetControllerIcon("continuous", "UADefaultAction");
178 }
179
182 {
183 bool showConsoleIcons = false;
184#ifdef PLATFORM_CONSOLE
185 showConsoleIcons = GetGame().GetInput().GetCurrentInputDevice() == EInputDeviceType.CONTROLLER || !GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer();
186#endif
187
189 ShowXboxHidePCIcons("continuous_interact", showConsoleIcons);
192 }
193
194 protected void PrepareCursorContent()
195 {
196 int health = -1;
197 int cargoCount = 0;
198 int q_type = 0;
199 int q_min, q_max = -1;
200 float q_cur = -1.0;
201
204 SetItemHealth(health, "item", "item_health_mark", m_HealthEnabled);
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");
214
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");
217
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");
224 }
225
226 protected void BuildFixedCursor()
227 {
228 int w, h, x, y;
229
231 GetScreenSize(w, h);
232 x = w / 2 + 32;
233 y = h / 2 + 32;
234
235 m_Root.SetPos(x, y);
236 }
237
239 {
240 float pos_x, pos_y = 0.0;
241
243
245 if (forceRebuild || m_Target.GetComponentIndex() != m_CachedObject.GetCursorCompIdx())
248 else
249 {
251
252 pos_x = screen_pos[0];
253 pos_y = screen_pos[1];
254 }
255
256 pos_x = Math.Ceil(pos_x);
257 pos_y = Math.Ceil(pos_y);
258
259 Widget parentWdg = m_Root.GetParent();
260
261 float screen_w = 0;
262 float screen_h = 0;
263
264 float wdg_w = 0;
265 float wdg_h = 0;
266
267 parentWdg.GetScreenSize(screen_w, screen_h);
268 m_Root.GetSize(wdg_w, wdg_h);
269
270 if (pos_x + wdg_w > screen_w)
271 pos_x = screen_w - wdg_w;
272
273 if (pos_y + wdg_h > screen_h)
274 pos_y = screen_h - wdg_h;
275
276 m_Root.SetPos(pos_x, pos_y);
277 }
278
279 override bool OnUpdate(Widget w)
280 {
281 if (m_Root == w)
282 {
283 Update();
284 return true;
285 }
286
287 return false;
288 }
289
290 protected void HideWidget()
291 {
292 if (m_Root.IsVisible())
293 {
294 m_Root.Show(false);
295 m_CachedObject.Invalidate();
296 }
297 }
298
299 void Update()
300 {
301 if (m_Player && !m_Player.IsAlive()) // handle respawn
302 {
303 m_Player = null;
304 m_AM = null;
305 }
306
307 if (!m_Player)
308 GetPlayer();
309
310 if (!m_AM)
312
313 if (m_Player.IsInVehicle() || m_AM.GetRunningAction())
314 m_Hidden = true;
315
316
317 /*
318 #ifdef DIAG_DEVELOPER
319 if (DeveloperFreeCamera.IsFreeCameraEnabled())
320 HideWidget();
321 return;
322 #endif
323 */
324
326
328 if (GetGame().GetUIManager().GetMenu() || !g_Game.GetProfileOption(EDayZProfilesOptions.HUD) || m_Hud.IsHideHudPlayer() || m_Player.IsUnconscious() || isVisionObstructionActive)
329 {
330 HideWidget();
331 return;
332 }
333
334 GetTarget();
335 GetActions();
336
339 if (!showTarget)
340 {
341 if (m_Single)
342 showTarget = m_Single.HasTarget();
343
344 if (m_Continuous)
345 showTarget = showTarget || m_Continuous.HasTarget();
346 }
347
348 if (showTarget)
349 {
351 if (m_Target.GetObject() == null && (m_Interact || m_ContinuousInteract || m_Single || m_Continuous))
352 {
353 //Print(">> fixed widget");
354 m_CachedObject.Invalidate();
356 m_Root.Show(true);
357 m_FixedOnPosition = false;
358 m_Hidden = false;
359 return;
360 }
361 else if (m_Target.GetObject() != null && !m_Target.GetObject().IsHologram() && (!m_Target.GetParent() || m_Target.GetParent() && !m_Target.GetParent().IsHologram()))
362 {
365 if (m_Target.GetObject() != m_CachedObject.Get())
366 {
368 {
369 //Print(">> non-cached widget");
370 m_CachedObject.Invalidate();
372 m_Root.Show(true);
373 m_Hidden = false;
374 return;
375 }
376 else
377 {
378 //Print(">> non-cached widget (fixed)");
379 m_CachedObject.Invalidate();
381 m_Root.Show(true);
382 m_FixedOnPosition = false;
383 m_Hidden = false;
384 return;
385 }
386 }
388 else if (m_Target.GetObject() == m_CachedObject.Get())
389 {
391 {
392 //Print(">> cached widget");
393 BuildFloatingCursor(false);
394 m_Root.Show(true);
395 m_Hidden = false;
396 return;
397 }
398 else
399 {
400 //Print(">> cached widget (fixed)");
401 m_CachedObject.Invalidate();
403 m_Root.Show(true);
404 m_FixedOnPosition = false;
405 m_Hidden = false;
406 return;
407 }
408 }
409 }
410 else
411 {
412 if (m_Root.IsVisible())
413 {
414 m_CachedObject.Invalidate();
415 m_Root.Show(false);
416 m_Hidden = false;
417
418 // remove previous backlit
419 GetDayZGame().GetBacklit().HintClear();
420 }
421 }
422 }
423 else
424 {
425 if (m_Root.IsVisible())
426 {
427 m_CachedObject.Invalidate();
428 m_Root.Show(false);
429 m_FixedOnPosition = false;
430
431 // remove previous backlit
432 GetDayZGame().GetBacklit().HintClear();
433 }
434
435 m_Hidden = false;
436 }
437
438 m_MaxWidthChild = 350;
439 }
441 protected void ShowXboxHidePCIcons(string widget, bool show_xbox_icon)
442 {
443 m_Root.FindAnyWidget(widget + "_btn_icon_xbox").Show(show_xbox_icon);
444 m_Root.FindAnyWidget(widget + "_btn_icon").Show(!show_xbox_icon);
445 }
446
447
450 {
453
455 screen_pos = GetGame().GetScreenPosRelative(pWorldPos);
457 m_Root.GetParent().GetScreenSize(parent_width, parent_height);
458
462
463 return transformed_pos;
464 }
466 protected void GetOnScreenPosition(out float x, out float y)
467 {
468 const float DEFAULT_HANDLE_OFFSET = 0.2;
469 const string CE_CENTER_COMP_NAME = "ce_center";
470 const string MEM_LOD_NAME = LOD.NAME_MEMORY;
471
472 int compIdx;
473 float pivotOffset = 0.0;
474 float memOffset = 0.0;
475 string compName;
476
477 bool isTargetForced = false;
478
481
482 LOD lod;
483
485 array<string> components = new array<string>; // for components with multiple selection
486
488
489 if (m_Target)
490 {
491 object = m_Target.GetObject();
492 compIdx = m_Target.GetComponentIndex();
493
494 if (m_Target.GetCursorHitPos() == vector.Zero)
495 isTargetForced = true;
496 }
497 else
498 return;
499
500 if (object)
501 {
502 if (!isTargetForced)
503 {
504 compName = object.GetActionComponentName(compIdx);
505 object.GetActionComponentNameList(compIdx, components);
506
507 if (!object.IsInventoryItem() && (object.HasFixedActionTargetCursorPosition() || object.GetActionComponentNameList(compIdx, components) == 0))
508 {
509 m_FixedOnPosition = true;
510 return;
511 }
512
513 pivotOffset = object.ConfigGetFloat("actionTargetPivotOffsetY");
514 memOffset = object.ConfigGetFloat("actionTargetMemOffsetY");
515
517 lod = object.GetLODByName(MEM_LOD_NAME);
518 if (lod != null)
519 {
521 lod.GetSelections(memSelections);
522
523 // items with CE_Center mem point
524 if (MiscGameplayFunctions.IsComponentInSelection(memSelections, CE_CENTER_COMP_NAME))
525 {
526 for (int i2 = 0; i2 < memSelections.Count(); ++i2)
527 {
528 if (memSelections[i2].GetName() == CE_CENTER_COMP_NAME && memSelections[i2].GetVertexCount() == 1)
529 {
530 m_FixedOnPosition = false;
531 modelPos = object.GetSelectionPositionMS(CE_CENTER_COMP_NAME);
532 worldPos = object.ModelToWorld(modelPos);
533 if (memOffset != 0.0)
534 worldPos[1] = worldPos[1] + memOffset;
535 else
537 }
538 }
539
541 m_CachedObject.Store(object, worldPos, compIdx);
542 }
544 else if (!compName.Contains("ladder") && IsComponentInSelection(memSelections, compName))
545 {
546 for (int i1 = 0; i1 < memSelections.Count(); ++i1)
547 {
549 if (memSelections[i1].GetName() == compName && memSelections[i1].GetVertexCount() == 1)
550 {
551 modelPos = object.GetSelectionPositionMS(compName);
552 worldPos = object.ModelToWorld(modelPos);
553
554 m_FixedOnPosition = false;
555 if (object.GetType() == "Fence" || object.GetType() == "Watchttower" || object.GetType() == "GardenPlot")
556 m_FixedOnPosition = true;
557
558 if (memOffset != 0.0)
559 worldPos[1] = worldPos[1] + memOffset;
560 else
562 }
563
565 if (memSelections[i1].GetName() == compName && memSelections[i1].GetVertexCount() > 1)
566 {
567 for (int j = 0; j < components.Count(); ++j)
568 {
570 {
571 modelPos = object.GetSelectionPositionMS(components[j]);
572 worldPos = object.ModelToWorld(modelPos);
573
574 m_FixedOnPosition = false;
575 if (memOffset != 0.0)
576 worldPos[1] = worldPos[1] + memOffset;
577 else
579 }
580 }
581 }
582 }
583
585 m_CachedObject.Store(object, worldPos, -1);
586 }
588 else if (compName.Contains("ladder") && IsComponentInSelection(memSelections, compName))
589 {
592 float lastDistance = 0;
593
594 for (int i3 = 0; i3 < memSelections.Count(); ++i3)
595 {
596 if (memSelections[i3].GetName() == compName && memSelections[i3].GetVertexCount() > 1)
597 {
598 ladderHandlePointLS = memSelections[i3].GetVertexPosition(lod, 0);
599 ladderHandlePointWS = object.ModelToWorld(ladderHandlePointLS);
602
603 for (int k = 1; k < memSelections[i3].GetVertexCount(); ++k)
604 {
605 ladderHandlePointLS = memSelections[i3].GetVertexPosition(lod, k);
606 ladderHandlePointWS = object.ModelToWorld(ladderHandlePointLS);
607
609 {
612 }
613 }
614
615 m_FixedOnPosition = false;
617 if (memOffset != 0.0)
618 worldPos[1] = worldPos[1] + memOffset;
619 else
621 }
622 }
623
625 m_CachedObject.Store(object, worldPos, -1);
626 }
627 else
628 m_FixedOnPosition = true;
629 }
630 else
631 m_FixedOnPosition = true;
632 }
633 else
634 m_FixedOnPosition = true;
635
637
638 x = pos[0];
639 y = pos[1];
640 }
641
643 isTargetForced = false;
644 }
645
646 // kept for backward compatibility
647 protected bool IsComponentInSelection(array<Selection> selection, string compName)
648 {
649 return MiscGameplayFunctions.IsComponentInSelection(selection, compName);
650 }
651
652 // getters
654 protected void GetPlayer()
655 {
657 }
659 protected void GetActionManager()
660 {
661 if (m_Player && m_Player.IsPlayerSelected())
662 Class.CastTo(m_AM, m_Player.GetActionManager());
663 else
664 m_AM = null;
665 }
666
668 protected void GetActions()
669 {
672 m_Single = null;
674
675 if (!m_AM) return;
676 if (!m_Target) return;
677 if (m_Player.IsSprinting()) return;
678 if (m_Player.IsInVehicle()) return; // TODO: TMP: Car AM rework needed
679
683 m_Continuous = m_AM.GetPossibleAction(ContinuousDefaultActionInput);
684
688 m_ContinuousItemActionsNum = m_AM.GetPossibleActionCount(ContinuousDefaultActionInput);
689
691
692 if (m_Interact)
693 m_DisplayInteractTarget = m_Interact.GetDisplayInteractObject(m_Player, m_Target);
694 else if (m_Single)
695 m_DisplayInteractTarget = m_Single.GetDisplayInteractObject(m_Player, m_Target);
696 else if (m_ContinuousInteract)
698 else
700 }
702 protected void GetTarget()
703 {
704 if (!m_AM)
705 return;
706
708 if (m_Target && m_Target.GetObject() && m_Target.GetObject().IsItemBase())
709 {
710 ItemBase item = ItemBase.Cast(m_Target.GetObject());
712 item.GetInventory().GetCurrentInventoryLocation(invLocation);
713
714 if (!item.IsTakeable() || (m_Player && m_Player.IsInVehicle()) || invLocation.GetType() != InventoryLocationType.GROUND)
715 m_Hidden = true;
716 }
717 }
719 protected string GetActionDesc(ActionBase action)
720 {
721 string desc = "";
722 if (action && action.GetText())
723 desc = action.GetText();
724
725 return desc;
726 }
727
728 //Getting NAME of the entity
729 protected string GetItemDesc(ActionBase action)
730 {
731 string desc = "";
733 if (!tgObject && m_Target)
734 tgObject = m_Target.GetObject();
735
736 if (tgObject)
737 {
738 //BreakOut if item is ruined
739 Object tgParent = m_Target.GetParent();
740 if (!tgObject.IsAlive())
741 {
742 //Fetch parent item name if one is present
743 if (!tgParent || tgObject.DisplayNameRuinAttach())
744 desc = tgObject.GetDisplayName();
745 else
746 desc = tgParent.GetDisplayName();
747 return desc;
748 }
749
751
752 if (tgParent && (tgParent.IsItemBase() || tgParent.IsTransport()))
754
755 if (tgObject.IsItemBase() || tgObject.IsTransport())
757
758 if (targetEntity && targetEntity.ShowZonesHealth())
759 {
760 string zone = "";
761
763
764 //NOTE: relevant fire geometry and view geometry selection names MUST match in order to get a valid damage zone
765 if (targetEntity.IsInherited(TentBase) && TentBase.Cast(targetEntity).GetState() != TentBase.PACKED)
766 {
767 //This is really specific to tents, as they use proxies. Hence object must be used
768 if (DamageSystem.GetDamageZoneFromComponentName(targetEntity, tgObject.GetActionComponentName(m_Target.GetComponentIndex(), LOD.NAME_FIRE), zone))
769 desc = DamageSystem.GetDamageDisplayName(targetEntity, zone);
770 }
771 else
772 {
773 targetEntity.GetActionComponentNameList(m_Target.GetComponentIndex(), selections, LOD.NAME_VIEW);
774
775 //Important to get display name from component tied to multiple selections
776 for (int s = 0; s < selections.Count(); s++)
777 {
778 if (DamageSystem.GetDamageZoneFromComponentName(targetEntity, selections[s], zone))
779 desc = DamageSystem.GetDamageDisplayName(targetEntity, zone);
780 }
781 }
782 }
783
784 //Safety check to output something to widget
785 if (targetEntity && desc == "")
786 desc = targetEntity.GetDisplayName();
787 }
788
789 return desc;
790 }
792 protected int GetItemHealth()
793 {
794 int health = -1;
795
796 if (m_Interact && !m_Interact.HasTarget())
797 return health;
798
800 if (!tgObject && m_Target)
801 tgObject = m_Target.GetObject();
802
803 if (tgObject)
804 {
805 Object tgParent = m_Target.GetParent();
807
808 //Return specific part health, even if display name is from parent
809 if (!tgObject.IsAlive())
810 {
811 health = tgObject.GetHealthLevel();
812 return health;
813 }
814
815 if (tgParent && (tgParent.IsItemBase() || tgParent.IsTransport()))
817
818 if (tgObject.IsItemBase() || tgObject.IsTransport())
820
821 if (targetEntity)
822 {
823 if (!targetEntity.IsDamageDestroyed())
824 {
825 string zone = "";
827
828 if (targetEntity.IsInherited(TentBase) && TentBase.Cast(targetEntity).GetState() != TentBase.PACKED)
829 {
830 //This is really specific to tents, as they use proxies. Hence object must be used
831 if (DamageSystem.GetDamageZoneFromComponentName(targetEntity, tgObject.GetActionComponentName(m_Target.GetComponentIndex(), LOD.NAME_FIRE), zone))
832 health = targetEntity.GetHealthLevel(zone);
833 }
834 else
835 {
836 //NOTE: relevant view geometry and view geometry selection names MUST match in order to get a valid damage zone
837 targetEntity.GetActionComponentNameList(m_Target.GetComponentIndex(), selections, LOD.NAME_VIEW);
838
839 for (int s = 0; s < selections.Count(); s++)
840 {
841 if (DamageSystem.GetDamageZoneFromComponentName(targetEntity, selections[s], zone))
842 {
843 health = targetEntity.GetHealthLevel(zone);
844 break;
845 }
846 }
847 }
848
849 if (zone == "")
850 health = targetEntity.GetHealthLevel();
851 }
852 }
853 else
854 health = tgObject.GetHealthLevel();
855 }
856
857 return health;
858 }
860 protected void GetItemQuantity(out int q_type, out float q_cur, out int q_min, out int q_max)
861 {
863
864 if (m_Interact && !m_Interact.HasTarget())
865 return;
866
868 if (!tgObject && m_Target)
869 tgObject = m_Target.GetObject();
870
872 {
874 if (q_type > 0)
876 }
877 }
878
880 protected void GetItemCargoCount(out int cargoCount)
881 {
883
885 if (!tgObject && m_Target)
886 tgObject = m_Target.GetObject();
887
889 {
890
891 GameInventory inventory = entity.GetInventory();
892 if (inventory)
893 {
895 return;
896 }
897
899 cargoCount = 0;
900 }
901 }
902
903 // setters
904 protected void SetItemDesc(string descText, int cargoCount, string itemWidget, string descWidget)
905 {
907 widget = m_Root.FindAnyWidget(itemWidget);
908
910 PlayerBase playerT = PlayerBase.Cast(m_Target.GetObject());
911 if (playerT)
912 string msg = playerT.GetLastUAMessage();
913
914 if (descText.Length() == 0 && msg.Length() == 0)
915 {
916 widget.Show(false);
917 return;
918 }
919
920 descText.ToUpper();
922 Class.CastTo(itemName, widget.FindAnyWidget(descWidget));
923
925 if (cargoCount > 0)
926 descText = string.Format("[+] %1 %2", descText, msg);
927 else
928 descText = string.Format("%1 %2", descText, msg);
929
930 itemName.SetText(descText);
931 widget.Show(true);
932 }
934 protected void SetItemHealth(int health, string itemWidget, string healthWidget, bool enabled)
935 {
936 Widget widget = m_Root.FindAnyWidget(itemWidget);
937
938 if (enabled)
939 {
941 Class.CastTo(healthMark, widget.FindAnyWidget(healthWidget));
942 int color = 0x00FFFFFF;
943
944 if (health == -1)
945 {
946 healthMark.GetParent().Show(false);
947 widget.Show(enabled);
948 return;
949 }
950
952 healthMark.SetAlpha(0.5);
953 healthMark.GetParent().Show(true);
954 }
955
956 widget.Show(enabled);
957 }
959 protected void SetItemQuantity(int type, float current, int min, int max, string itemWidget, string quantityPBWidget, string quantityTextWidget, bool enabled)
960 {
962
963 widget = m_Root.FindAnyWidget(itemWidget);
964
965 if (enabled)
966 {
971
972 //check for volume vs. count and display progressbar or "bubble" with exact count/max text
973 switch (type)
974 {
975 case QUANTITY_HIDDEN :
976 progressBar.Show(false);
977 textWidget.Show(false);
978 textWidget.GetParent().Show(false);
979 break;
980 case QUANTITY_COUNT :
981 if (max > 1 || current > 1)
982 {
983 string qty_text = string.Format("%1/%2", Math.Round(current).ToString(), max.ToString());
984 progressBar.Show(false);
985 textWidget.SetText(qty_text);
986 textWidget.Show(true);
987 textWidget.GetParent().Show(true);
988 }
989 else
990 {
991 progressBar.Show(false);
992 textWidget.Show(false);
993 textWidget.GetParent().Show(false);
994 }
995 break;
996 case QUANTITY_PROGRESS :
997 float qty_num = Math.Round((current / max) * 100);
998
999 textWidget.Show(false);
1000 progressBar.SetCurrent(qty_num);
1001 progressBar.Show(true);
1002 textWidget.GetParent().Show(true);
1003 break;
1004 }
1005 widget.Show(true);
1006 }
1007 else
1008 widget.Show(false);
1009 }
1011 protected void SetActionWidget(ActionBase action, string descText, string actionWidget, string descWidget)
1012 {
1013 Widget widget = m_Root.FindAnyWidget(actionWidget);
1014
1015 if (action)
1016 {
1017 if (action.HasTarget() && m_AM.GetActionState() < 1) // targeted & action not performing
1018 {
1020 Class.CastTo(actionName, widget.FindAnyWidget(descWidget));
1021
1022 if (action.GetInput().GetInputType() == ActionInputType.AIT_CONTINUOUS)
1023 {
1024 descText = descText + " " + "#action_target_cursor_hold";
1025 actionName.SetText(descText);
1026 }
1027 else
1028 actionName.SetText(descText);
1029
1030 widget.Show(true);
1031
1032 int x, y;
1033 actionName.GetTextSize(x, y);
1034 if (x > m_MaxWidthChild);
1036 }
1037 else
1038 widget.Show(false);
1039 }
1040 else
1041 widget.Show(false);
1042 }
1043
1046 {
1048
1049 widget = m_Root.FindAnyWidget(multiActionsWidget);
1051
1052 if (m_InteractActionsNum > 1)
1053 {
1055 {
1056 widget.Show(true);
1057 widget_not_select.Show(false);
1058 }
1059 else
1060 {
1061 widget.Show(false);
1062 widget_not_select.Show(true);
1063 }
1064 }
1065 else
1066 {
1067 widget.Show(false);
1068 widget_not_select.Show(false);
1069 }
1070 }
1073 {
1075
1076 widget = m_Root.FindAnyWidget(multiActionsWidget);
1078
1080 {
1082 {
1083 widget.Show(true);
1084 widget_not_select.Show(false);
1085 }
1086 else
1087 {
1088 widget.Show(false);
1089 widget_not_select.Show(true);
1090 }
1091 }
1092 else
1093 {
1094 widget.Show(false);
1095 widget_not_select.Show(false);
1096 }
1097
1098 }
1101 {
1103
1104 widget = m_Root.FindAnyWidget(multiActionsWidget);
1106
1107 if (m_ItemActionsNum > 1)
1108 {
1110 {
1111 widget.Show(true);
1112 widget_not_select.Show(false);
1113 }
1114 else
1115 {
1116 widget.Show(false);
1117 widget_not_select.Show(true);
1118 }
1119 }
1120 else
1121 {
1122 widget.Show(false);
1123 widget_not_select.Show(false);
1124 }
1125 }
1128 {
1130
1131 widget = m_Root.FindAnyWidget(multiActionsWidget);
1133
1135 {
1136 if (m_SelectedActionCategory == ContinuousDefaultActionInput)
1137 {
1138 widget.Show(true);
1139 widget_not_select.Show(false);
1140 }
1141 else
1142 {
1143 widget.Show(false);
1144 widget_not_select.Show(true);
1145 }
1146 }
1147 else
1148 {
1149 widget.Show(false);
1150 widget_not_select.Show(false);
1151 }
1152 }
1155 {
1156 Widget widget;
1159
1160 widget = m_Root.FindAnyWidget(actionWidget);
1163
1164 GetDayZGame().GetBacklit().HintShow(m_UseActionWrapper.InputP());
1165
1166 // uses text in floating widget
1167 iconWidget.Show(false);
1168 textWidget.SetText(InputUtils.GetButtonNameFromInput("UAAction", EInputDeviceType.MOUSE_AND_KEYBOARD));
1169 textWidget.Show(true);
1170 }
1172 protected void CheckRefresherFlagVisibility(Object object)
1173 {
1175 Widget w = m_Root.FindAnyWidget("item_flag_icon");
1176 if (Class.CastTo(entity, object) && w)
1177 w.Show(entity.IsRefresherSignalingViable() && m_Player.IsTargetInActiveRefresherRange(entity));
1178 }
1181 {
1183
1184 CargoBase cargo = inventory.GetCargo();
1185 if (cargo && cargo.GetItemCount() > 0)
1186 return 1;
1187
1188 for (int i = 0; i < inventory.AttachmentCount(); i++)
1189 {
1190 EntityAI attachment = inventory.GetAttachmentFromIndex(i);
1191 int attachmentSlotId = attachment.GetInventory().GetSlotId(0);
1192
1193 if (attachment.GetInventory())
1195 }
1196
1198 }
1200 protected IngameHud GetHud()
1201 {
1202 Mission mission = GetGame().GetMission();
1203 if (mission)
1204 {
1205 IngameHud hud = IngameHud.Cast(mission.GetHud());
1206 return hud;
1207 }
1208
1209 return null;
1210 }
1211}
eBleedingSourceType GetType()
ActionInputType
Definition ActionInput.c:2
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
override bool HasFixedActionTargetCursorPosition()
Definition DayZAnimal.c:111
DayZGame g_Game
Definition DayZGame.c:3528
DayZGame GetDayZGame()
Definition DayZGame.c:3530
Mission mission
EDayZProfilesOptions
Icon x
Icon y
InventoryLocationType
types of Inventory Location
proto native UAInputAPI GetUApi()
void Store(Object obj, vector pos, int compIdx)
cache object and its world pos
void Invalidate()
invalidate cached objec
int GetPossibleActionCount(typename inputType)
ActionBase GetPossibleAction(typename inputType)
override ActionTarget FindActionTarget()
void UpdatePCIconsVisibility()
Contains logic for icon set switching (Gamepad/M&K)
void SetItemHealth(int health, string itemWidget, string healthWidget, bool enabled)
string GetItemDesc(ActionBase action)
void SetItemQuantity(int type, float current, int min, int max, string itemWidget, string quantityPBWidget, string quantityTextWidget, bool enabled)
void SetItemDesc(string descText, int cargoCount, string itemWidget, string descWidget)
void SetXboxIcon(string name, string imageset_name, string image_name)
bool IsComponentInSelection(array< Selection > selection, string compName)
void GetItemQuantity(out int q_type, out float q_cur, out int q_min, out int q_max)
const ref array< typename > VISION_OBSTRUCTION_PPEFFECTS_TYPES
void SetInteractXboxIcon(string imageset_name, string image_name)
DEPRECATED.
void SetContinuousXboxIcon(string imageset_name, string image_name)
void GetOnScreenPosition(out float x, out float y)
void SetMultipleItemAction(string multiActionsWidget, string multiActionsWidget_NotSelect)
void SetMultipleContinuousItemAction(string multiActionsWidget, string multiActionsWidget_NotSelect)
float m_MaxWidthChild
widget width
void SetQuantityVisibility(bool state)
void UpdateControllerInputIcons()
Loads icons from the latest keybinds.
void SetHealthVisibility(bool state)
void SetContinuousInteractXboxIcon(string imageset_name, string image_name)
override bool OnUpdate(Widget w)
void GetItemCargoCount(out int cargoCount)
returns number of items in cargo for targeted entity
void SetControllerIcon(string pWidgetName, string pInputName)
void SetActionWidget(ActionBase action, string descText, string actionWidget, string descWidget)
void GetActions()
get actions from Action Manager
void OnWidgetScriptInit(Widget w)
string GetActionDesc(ActionBase action)
void SetMultipleInteractAction(string multiActionsWidget, string multiActionsWidget_NotSelect)
shows arrows near the interact action if there are more than one available
void SetInteractActionIcon(string actionWidget, string actionIconFrameWidget, string actionIconWidget, string actionIconTextWidget)
vector TransformToScreenPos(vector pWorldPos)
transform world pos to screen pos (related to parent widget size)
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
void SetSingleXboxIcon(string imageset_name, string image_name)
int AttachmentsWithInventoryOrCargoCount(notnull GameInventory inventory)
void SetMultipleContinuousInteractAction(string multiActionsWidget, string multiActionsWidget_NotSelect)
ref ATCCachedObject m_CachedObject
ActionManagerClient m_AM
void ShowXboxHidePCIcons(string widget, bool show_xbox_icon)
void BuildFloatingCursor(bool forceRebuild)
represents base for cargo storage for entities
Definition Cargo.c:7
Super root of all classes in Enforce script.
Definition EnScript.c:11
script counterpart to engine's class Inventory
Definition Inventory.c:79
static string GetButtonNameFromInput(string pInputName, int pInputDeviceType)
Definition InputUtils.c:17
static string GetRichtextButtonIconFromInputAction(notnull UAInput pInput, string pLocalizedDescription, int pInputDeviceType=EUAINPUT_DEVICE_CONTROLLER, float pScale=ICON_SCALE_NORMAL, bool pVertical=false)
Definition InputUtils.c:151
InventoryLocation.
static int GetItemHealthColor(int pHealthLevel)
LOD class.
Definition gameplay.c:203
static const string NAME_FIRE
Definition gameplay.c:207
static const string NAME_MEMORY
Definition gameplay.c:208
static const string NAME_VIEW
Definition gameplay.c:206
Definition EnMath.c:7
Mission class.
Definition gameplay.c:668
Hud GetHud()
Definition gameplay.c:701
Static component of PPE manager, used to hold the instance.
Definition PPEManager.c:3
static PPEManager GetPPEManager()
Returns the manager instance singleton.
Definition PPEManager.c:27
static float GetItemQuantity(InventoryItem item)
static int HasItemQuantity(notnull EntityAI item)
map: item x vector(index, width, height)
Definition EnWidgets.c:651
proto native UAInput InputP()
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
static const vector Zero
Definition EnConvert.c:110
proto native CGame GetGame()
const int QUANTITY_PROGRESS
Definition constants.c:484
const int QUANTITY_COUNT
Definition constants.c:483
const int QUANTITY_HIDDEN
Definition constants.c:482
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float Round(float f)
Returns mathematical round of value.
static proto float Ceil(float f)
Returns ceil of value.
static proto float AbsFloat(float f)
Returns absolute value.
proto void GetScreenSize(out int x, out int y)
proto native owned string GetName()
EInputDeviceType
Definition input.c:3