DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ContainerWithCargoAndAttachments.c
См. документацию.
1class ContainerWithCargoAndAttachments extends ClosableContainer
2{
3 protected ref Attachments m_Atts;
4 protected ref CargoContainer m_CargoGrid;
5
10
11 void ContainerWithCargoAndAttachments( LayoutHolder parent, int sort = -1 )
12 {
13 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( m_MainWidget, this, "DraggingOverHeader2" );
14 }
15
17 {
18 if ( m_Entity )
19 {
20 m_Entity.GetOnItemAttached().Remove( AttachmentAdded );
21 m_Entity.GetOnItemDetached().Remove( AttachmentRemoved );
22 }
23
24 if ( m_Atts )
25 delete m_Atts;
26
28 {
29 delete att;
30 }
31
34
37
39 m_AttachmentCargos.Clear();
40 }
41
43 {
44 int currentIndex = -1;
45 map<int, int> bodyAttachmentSortIndex = new map<int, int>;
46
47 m_Body.Clear();
48
49 if(m_Atts)
50 {
51 currentIndex = m_Body.Insert(m_Atts.GetWrapper());
52 }
53
54 if(m_CargoGrid)
55 {
56 currentIndex = m_Body.Insert(m_CargoGrid);
57 }
58
59 GameInventory inv = m_Entity.GetInventory();
60 for (int i = 0; i < inv.AttachmentCount(); i++)
61 {
62 int slotIndex = -1;
63 int sortIndex = -1;
65 if(ent)
66 {
68 if(att)
69 {
70 if(m_Atts && m_Atts.GetSlotsSorted().Count())
71 {
72 sortIndex = m_Atts.GetSlotsSorted().Find(att.m_Attachments.GetAttachmentSlotID());
73 }
74
75 if(bodyAttachmentSortIndex.Find(currentIndex, slotIndex))
76 {
77 if(slotIndex > sortIndex)
78 {
79 m_Body.InsertAt(att, currentIndex);
80 bodyAttachmentSortIndex.Set(currentIndex, sortIndex);
81 }
82 else
83 {
84 currentIndex = m_Body.Insert(att);
85 bodyAttachmentSortIndex.Insert(currentIndex, sortIndex);
86 }
87 }
88 else
89 {
90 currentIndex = m_Body.Insert(att);
91 bodyAttachmentSortIndex.Insert(currentIndex, sortIndex);
92 }
93 }
94
95 CargoContainer cargo = m_AttachmentCargos.Get(ent);
96 if(cargo)
97 {
98 if(m_Atts && m_Atts.GetSlotsSorted().Count())
99 {
100 sortIndex = m_Atts.GetSlotsSorted().Find(cargo.GetAttachmentSlotID());
101 }
102
103 if (bodyAttachmentSortIndex.Find(currentIndex, slotIndex))
104 {
105 if(slotIndex > sortIndex)
106 {
107 m_Body.InsertAt(cargo, currentIndex);
108 bodyAttachmentSortIndex.Set(currentIndex, sortIndex);
109 }
110 else
111 {
112 currentIndex = m_Body.Insert(cargo);
113 bodyAttachmentSortIndex.Insert(currentIndex, sortIndex);
114 }
115 }
116 else
117 {
118 currentIndex = m_Body.Insert(cargo);
119 bodyAttachmentSortIndex.Insert(currentIndex, sortIndex);
120 }
121 }
122 }
123 }
124
125 bodyAttachmentSortIndex.Clear();
126 }
127
128 void AttachmentAddedEx(EntityAI item, string slot, EntityAI parent, bool immedUpdate = true)
129 {
130 int slot_id = InventorySlots.GetSlotIdFromString( slot );
131 int sort = -1;
132 bool updateNeeded = false;
133 ref Attachments att_cont = null;
134 ref CargoContainer cont = null;
135
136 if ( item.GetInventory().GetAttachmentSlotsCount() > 0 && item.CanDisplayAnyAttachmentSlot() )
137 {
138 updateNeeded = true;
139
140 att_cont = new Attachments( this, item );
141 sort = (m_AttachmentSlotsSorted.Find( slot_id ) * 2) + SORT_ATTACHMENTS_NEXT_OFFSET;
142 att_cont.InitAttachmentGrid( sort );
143 att_cont.SetAttachmentSlotID(slot_id);
144
145 m_AttachmentAttachments.Insert( item, att_cont );
146 m_AttachmentAttachmentsContainers.Insert( item, att_cont.GetWrapper() );
147
148 att_cont.UpdateInterval();
149 }
150
151 if ( item.GetInventory().GetCargo() )
152 {
153 updateNeeded = true;
154
155 cont = new CargoContainer( this, true );
156 sort = (m_AttachmentSlotsSorted.Find( slot_id ) * 2) + SORT_CARGO_NEXT_OFFSET;
157 cont.GetRootWidget().SetSort( sort );
158 cont.SetEntity( item, false );
159 cont.SetAttachmentSlotID(slot_id);
160 Insert( cont, m_Atts.GetAttachmentHeight() + m_AttachmentCargos.Count() + 1 );
161
162 m_AttachmentCargos.Insert( item, cont );
163 }
164
165 if (updateNeeded)
166 {
167 if (att_cont)
168 {
169 att_cont.ShowFalseAttachmentsHeader(true);
170 if (cont)
171 {
172 cont.ShowFalseCargoHeader(false);
173 cont.UpdateSize();
174 cont.SetAlternateFalseTextHeaderWidget(att_cont.GetFalseHeaderTextWidget());
175 }
176 }
177 else if (cont)
178 {
179 cont.SetAlternateFalseTextHeaderWidget(null); //just to be safe..
180 cont.UpdateSize();
181 }
182
184 RecomputeOpenedContainers();
185
186 Inventory.GetInstance().UpdateConsoleToolbar();
187
188 if (m_Parent && immedUpdate)
189 m_Parent.Refresh();
190 }
191 }
192
193 void AttachmentAdded(EntityAI item, string slot, EntityAI parent)
194 {
195 AttachmentAddedEx(item, slot, parent);
196 }
197
198 void AttachmentRemoved(EntityAI item, string slot, EntityAI parent)
199 {
200 int slot_id = InventorySlots.GetSlotIdFromString( slot );
201
202 CargoContainer old_cont = m_AttachmentCargos.Get( item );
203 if( old_cont )
204 {
205 m_AttachmentCargos.Remove( item );
206 delete old_cont;
207
208 if( m_Parent )
209 m_Parent.Refresh();
210 Inventory.GetInstance().UpdateConsoleToolbar();
211 }
212
213
214 AttachmentsWrapper old_att_cont = m_AttachmentAttachmentsContainers.Get( item );
215 if( old_att_cont )
216 {
218 m_AttachmentAttachments.Remove( item );
219 delete old_att_cont;
220
221 if( m_Parent )
222 m_Parent.Refresh();
223 Inventory.GetInstance().UpdateConsoleToolbar();
224 }
225
227 RecomputeOpenedContainers();
228 }
229
230 override void UpdateInterval()
231 {
232 if ( m_Entity )
233 {
234 if (m_CargoGrid)
235 {
236 bool hideCargo = m_Entity.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) || !m_Entity.CanDisplayCargo() || m_ForcedHide;
237 if (m_CargoGrid.IsVisible() && hideCargo)
238 {
239 HideCargo();
240 }
241 else if (!m_CargoGrid.IsVisible() && !hideCargo)
242 {
243 ShowCargo();
244 }
245
246 m_CargoGrid.UpdateInterval();
247 }
248
249 if ( m_SlotIcon )
250 {
251 bool hide = m_LockCargo || ItemManager.GetInstance().GetDraggedItem() == m_Entity;
252 if (!hide)
253 {
254 SetOpenForSlotIcon(IsOpened());
255 }
256 m_SlotIcon.GetRadialIconPanel().Show( !hide );
257
258 }
259
260 super.UpdateInterval();
261 }
262 }
263
265 {
266 return m_Entity;
267 }
268
269 override void UnfocusAll()
270 {
271 if( m_Atts )
272 {
273 m_Atts.UnfocusAll();
274 }
275
276 if( m_CargoGrid )
277 {
278 m_CargoGrid.UnfocusAll();
279 }
280
281 foreach( EntityAI e1, CargoContainer cargo : m_AttachmentCargos )
282 {
283 cargo.UnfocusAll();
284
285 }
286
287 foreach( EntityAI e2, Attachments att : m_AttachmentAttachments )
288 {
289 att.UnfocusAll();
290 }
291 }
292
293 override bool IsLastIndex()
294 {
295 return m_ActiveIndex == ( m_OpenedContainers.Count() - 1 );
296 }
297
299 {
300 return IsFirstIndex();
301 }
302
304 {
305 return IsLastIndex();
306 }
307
308 override void MoveGridCursor( int direction )
309 {
310 Container c = GetFocusedContainer();
311 if ( c )
312 {
313 c.MoveGridCursor( direction );
314 Inventory.GetInstance().UpdateConsoleToolbar();
315 }
316 }
317
318 void SetEntity( EntityAI entity, bool immedUpdate = true )
319 {
320 m_Entity = entity;
321
322 m_Atts = new Attachments( this, m_Entity );
323 m_Atts.InitAttachmentGrid( SORT_ATTACHMENTS_OWN );
324 m_AttachmentSlotsSorted = m_Atts.GetSlotsSorted();
325
326 m_Entity.GetOnItemAttached().Insert( AttachmentAdded );
327 m_Entity.GetOnItemDetached().Insert( AttachmentRemoved );
328
329 m_ClosableHeader.SetItemPreview( m_Entity );
330 CheckHeaderDragability();
331
332 if ( m_Entity.GetInventory().GetCargo() )
333 {
334 m_CargoGrid = new CargoContainer( this, false );
335 m_CargoGrid.GetRootWidget().SetSort( SORT_CARGO_OWN );
336 m_CargoGrid.SetEntity( m_Entity, 0, immedUpdate );
337 m_CargoGrid.UpdateHeaderText(); // TODO: refresh?
338 Insert( m_CargoGrid );
339 }
340 else
341 {
342 string name = m_Entity.GetDisplayName();
343 name.ToUpper();
344 m_ClosableHeader.SetName( name );
345 }
346
350
351 (Container.Cast( m_Parent )).Insert( this );
352
353 foreach ( int slot_id : m_AttachmentSlotsSorted )
354 {
355 EntityAI item = m_Entity.GetInventory().FindAttachment( slot_id );
356 if ( item )
357 AttachmentAddedEx( item, InventorySlots.GetSlotName( slot_id ), m_Entity, false );
358 }
359
361
362 if (m_CargoGrid)
363 {
364 bool hideCargo = m_Entity.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) || !m_Entity.CanDisplayCargo() || m_ForcedHide;
365 if (m_CargoGrid.IsVisible() && hideCargo)
366 {
367 HideCargo();
368 }
369 else if (!m_CargoGrid.IsVisible() && !hideCargo)
370 {
371 ShowCargo();
372 }
373 }
374
375 if( IsDisplayable() )
376 SetOpenState( true );
377 else
378 SetOpenState( false );
379
380 if (immedUpdate)
381 m_Parent.m_Parent.Refresh();
382
383 RecomputeOpenedContainers();
384 }
385
387 {
388 if( m_CargoGrid )
389 {
390 if(m_CargoGrid.IsVisible())
391 {
392 m_CargoGrid.OnHide();
393 RecomputeOpenedContainers();
394 }
395 }
396 }
397
399 {
400 if( m_CargoGrid )
401 {
402 if(!m_CargoGrid.IsVisible())
403 {
404 m_CargoGrid.OnShow();
405 RecomputeOpenedContainers();
406 }
407 }
408 }
409
411 {
412 return m_Entity;
413 }
414
416 {
417 string name = w.GetName();
418 name.Replace( "PanelWidget", "Render" );
419 return ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
420 }
421
423 {
424 ItemPreviewWidget ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( "Render" ) );
425 if( !ipw )
426 {
427 string name = w.GetName();
428 name.Replace( "PanelWidget", "Render" );
429 ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
430 }
431 if( !ipw )
432 {
433 ipw = ItemPreviewWidget.Cast( w );
434 }
435 if( !ipw || !ipw.IsInherited( ItemPreviewWidget ) )
436 {
437 return NULL;
438 }
439 return ipw.GetItem();
440 }
441
443 {
444 ItemPreviewWidget ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( "Render" ) );
445 if( !ipw )
446 {
447 string name = w.GetName();
448 name.Replace( "PanelWidget", "Render" );
449 ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
450 }
451 if( !ipw )
452 {
453 ipw = ItemPreviewWidget.Cast( w );
454 }
455 return ipw;
456 }
457
458 void MouseClick2(Widget w, int x, int y, int button)
459 {
460 SlotsIcon icon;
461 w.GetUserData(icon);
462
463 ItemBase selectedItem;
464 if (icon)
465 selectedItem = ItemBase.Cast(icon.GetEntity());
466
467 if (selectedItem)
468 {
469 bool isReserved = icon.IsReserved();
470
471 switch (button)
472 {
473 case MouseState.RIGHT:
474 #ifdef DIAG_DEVELOPER
475 if (GetDayZGame().IsLeftCtrlDown())
476 ShowActionMenu(selectedItem);
477 #endif
478
479 if (isReserved)
480 {
481 EntityAI attachmentParent = icon.GetSlotParent();
482 GetGame().GetPlayer().GetHumanInventory().ClearUserReservedLocationSynced(selectedItem);
483 attachmentParent.GetOnAttachmentReleaseLock().Invoke(selectedItem, icon.GetSlotID());
484 }
485 else if (CanSplitEx(selectedItem))
486 {
487 selectedItem.OnRightClick();
488 }
489
490 break;
491
492 case MouseState.MIDDLE:
493 if (!isReserved)
494 InspectItem(selectedItem);
495
496 break;
497
498 case MouseState.LEFT:
499 if (!isReserved)
500 {
501 PlayerBase controlledPlayer = PlayerBase.Cast(GetGame().GetPlayer());
502 if (g_Game.IsLeftCtrlDown())
503 {
504 if (controlledPlayer.CanDropEntity(selectedItem))
505 {
506 if (selectedItem.CanBeSplit() && selectedItem.GetTargetQuantityMax() < selectedItem.GetQuantity())
507 selectedItem.SplitIntoStackMaxClient(null, -1);
508 else
509 controlledPlayer.PhysicalPredictiveDropItem(selectedItem);
510 }
511 }
512 else
513 {
514 bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(selectedItem, null ) && !controlledPlayer.GetInventory().IsInventoryLocked() && selectedItem.GetInventory().CanRemoveEntity() && !controlledPlayer.IsItemsToDelete();
516 }
517 }
518
519 break;
520 }
521 }
522 }
523
525 void DropReceived(Widget w, int x, int y, CargoContainer cargo)
526 {
528 if (!item)
529 return;
530
531 #ifndef PLATFORM_CONSOLE
532 int c_x, c_y;
533 #endif
534
535 EntityAI targetEntity = m_Entity;
536 CargoBase targetCargo;
537
538 if (cargo != m_CargoGrid)
539 {
540 targetEntity = m_AttachmentCargos.GetKeyByValue(cargo);
541 }
542
543 if (targetEntity)
544 {
545 targetCargo = targetEntity.GetInventory().GetCargo();
546 #ifdef PLATFORM_CONSOLE
547 if (m_CargoGrid && m_CargoGrid.HasItem(item))
548 return;
549 #endif
550 }
551
552 if (!targetCargo || !targetEntity)
553 return;
554
556 #ifdef PLATFORM_CONSOLE
557 x = 0;
558 y = targetCargo.GetItemCount();
559 targetEntity.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.CARGO, dst);
560 #else
561 c_x = targetCargo.GetHeight();
562 c_y = targetCargo.GetWidth();
563
564 dst.SetCargoAuto(targetCargo, item, x, y, item.GetInventory().GetFlipCargo());
565 #endif
566
568 item.GetInventory().GetCurrentInventoryLocation(src);
569 if (src.CompareLocationOnly(dst) && src.GetFlip() == dst.GetFlip())
570 return;
571
572 #ifdef PLATFORM_CONSOLE
573 if (dst.IsValid() && targetEntity.GetInventory().LocationCanAddEntity(dst))
574 #else
575 if (c_x > x && c_y > y && targetEntity.GetInventory().LocationCanAddEntity(dst))
576 #endif
577 {
578 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
579
581
582 Icon icon = cargo.GetIcon(item);
583 if (icon)
584 {
585 if (w && w.FindAnyWidget("Cursor"))
586 w.FindAnyWidget("Cursor").SetColor(ColorManager.BASE_COLOR);
587
588 icon.Refresh();
589 Refresh();
590 }
591 }
592
595 }
596
597 void TakeAsAttachment( Widget w, Widget receiver )
598 {
601 SlotsIcon slots_icon;
602 EntityAI receiver_item;
603 int slot_id = -1;
604 bool is_reserved = false;
605 EntityAI attached_entity;
606 receiver.GetUserData(slots_icon);
607 //string name = receiver.GetName();
608 //name.Replace("PanelWidget", "Render");
609
610 //ItemPreviewWidget receiver_iw = ItemPreviewWidget.Cast( receiver.FindAnyWidget(name) );
611 if( slots_icon )
612 {
613 receiver_item = slots_icon.GetEntity();
614 slot_id = slots_icon.GetSlotID();
615 attached_entity = slots_icon.GetSlotParent();
616 is_reserved = slots_icon.IsReserved();
617 }
618
619 EntityAI item = GetItemPreviewItem( w );
620 if( !item )
621 {
622 return;
623 }
624 ItemBase item_base = ItemBase.Cast( item );
626 float stackable;
627
628 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
629 if( !item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory() )
630 return;
631
632 EntityAI target_att_entity = m_Entity;
633 Weapon_Base wpn;
634 Magazine mag;
635 if( Class.CastTo(wpn, m_Entity ) && Class.CastTo(mag, item ) )
636 {
637 if( player.GetWeaponManager().CanAttachMagazine( wpn, mag ) )
638 {
639 player.GetWeaponManager().AttachMagazine( mag );
640 }
641 }
642 else if( receiver_item && !is_reserved )
643 {
644 if( ( ItemBase.Cast( receiver_item ) ).CanBeCombined( ItemBase.Cast( item ) ) )
645 {
646 ( ItemBase.Cast( receiver_item ) ).CombineItemsClient( ItemBase.Cast( item ) );
647 }
648 else if( GameInventory.CanSwapEntitiesEx( receiver_item, item ) )
649 {
650 if( !receiver_item.GetInventory().CanRemoveEntity() )
651 return;
652 GetGame().GetPlayer().PredictiveSwapEntities( receiver_item, item );
653 }
654 else if( receiver_item.GetInventory().CanAddAttachment( item ) )
655 {
656 player.PredictiveTakeEntityToTargetAttachment(receiver_item, item);
657 }
658 }
659 else if( attached_entity && attached_entity.GetInventory().CanAddAttachmentEx( item, slot_id ) )
660 {
661 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, slot_id);
662 }
663 else if(attached_entity && attached_entity.GetInventory().CanAddAttachment(item))
664 {
665 attached_entity.GetInventory().FindFreeLocationFor(item,FindInventoryLocationType.ATTACHMENT,il);
666 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, il.GetSlot());
667 }
668 else if( m_Entity.GetInventory().CanAddAttachment(item) )
669 {
670 m_Entity.GetInventory().FindFreeLocationFor(item,FindInventoryLocationType.ATTACHMENT,il);
671 player.PredictiveTakeEntityToTargetAttachmentEx(m_Entity, item, il.GetSlot());
672 }
673 else if( m_Entity.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && !m_Entity.GetInventory().HasEntityInCargo( item ) )
674 {
676 }
677 /*else if( !player.GetInventory().HasEntityInInventory( item ) || !m_Entity.GetInventory().HasEntityInCargo( item ) )
678 {
679 SplitItemUtils.TakeOrSplitToInventory( PlayerBase.Cast( GetGame().GetPlayer() ), m_Entity, item );
680 }*/
681 }
682
683 override void OnDropReceivedFromHeader( Widget w, int x, int y, Widget receiver )
684 {
685 TakeAsAttachment( w, receiver );
686 }
687
688 void OnDropReceivedFromHeader2( Widget w, int x, int y, Widget receiver )
689 {
690 TakeAsAttachment( w, receiver );
691 }
692
693 void DoubleClick(Widget w, int x, int y, int button)
694 {
695 if( button == MouseState.LEFT && !g_Game.IsLeftCtrlDown())
696 {
697 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
698 if( w == NULL || player.GetInventory().IsInventoryLocked() )
699 {
700 return;
701 }
702 ItemPreviewWidget iw = ItemPreviewWidget.Cast( w.FindAnyWidget( "Render" ) );
703 if( !iw )
704 {
705 string name = w.GetName();
706 name.Replace( "PanelWidget", "Render" );
707 iw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
708 }
709
710 if( !iw )
711 {
712 iw = ItemPreviewWidget.Cast( w );
713 }
714
715 EntityAI item = iw.GetItem();
716
717 if( !item )
718 {
719 return;
720 }
721
722 SlotsIcon icon;
723 iw.GetUserData(icon);
724
725 if(icon && icon.IsReserved())
726 {
727 return;
728 }
729
730 if( !item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory() )
731 return;
732
733 if( player.GetInventory().HasEntityInInventory( item ) && player.GetHumanInventory().CanAddEntityInHands( item ) )
734 {
735 player.PredictiveTakeEntityToHands( item );
736 }
737 else
738 {
739 if(player.GetInventory().CanAddEntityToInventory( item ) && item.GetInventory().CanRemoveEntity())
740 {
741 player.PredictiveTakeEntityToInventory( FindInventoryLocationType.ANY, InventoryItem.Cast( item ) );
742 }
743 else
744 {
745 if( player.GetHumanInventory().CanAddEntityInHands( item ) )
746 {
747 player.PredictiveTakeEntityToHands( item );
748 }
749 }
750 }
751
752 HideOwnedTooltip();
753
754 name = w.GetName();
755 name.Replace( "PanelWidget", "Temperature" );
756 w.FindAnyWidget( name ).Show( false );
757 }
758 }
759
760 bool DraggingOverGrid( Widget w, int x, int y, Widget reciever, CargoContainer cargo )
761 {
762 if( w == NULL )
763 {
764 return false;
765 }
766
767 EntityAI item = GetItemPreviewItem( w );
768
769 if( !item )
770 {
771 return false;
772 }
773
774 int color;
775 int idx = 0;
776 int c_x, c_y;
777
778 EntityAI target_entity;
779 CargoBase target_cargo;
780
781 if( cargo == m_CargoGrid )
782 {
783 target_entity = m_Entity;
784 target_cargo = m_Entity.GetInventory().GetCargo();
785 }
786 else
787 {
788 target_entity = m_AttachmentCargos.GetKeyByValue( cargo );
789 if( target_entity )
790 {
791 target_cargo = target_entity.GetInventory().GetCargo();
792 }
793 else
794 return false;
795 }
796
797 if( target_cargo && target_entity )
798 {
799 c_x = target_cargo.GetHeight();
800 c_y = target_cargo.GetWidth();
801 }
802 else
803 return false;
804
805 if( c_x > x && c_y > y && target_entity.GetInventory().CanAddEntityInCargoEx( item, idx, x, y, item.GetInventory().GetFlipCargo() ) )
806 {
808 if( target_entity.GetHierarchyRootPlayer() == GetGame().GetPlayer() )
809 {
810 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
811 }
812 else
813 {
814 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
815 }
816 }
817 else
818 {
819 color = ColorManager.RED_COLOR;
820 }
821
822 if( w.FindAnyWidget("Cursor") )
823 {
824 w.FindAnyWidget("Cursor").SetColor( color );
825 }
826 else
827 {
828 string name = w.GetName();
829 name.Replace( "PanelWidget", "Cursor" );
830 if( w.FindAnyWidget( name ) )
831 {
832 w.FindAnyWidget( name ).SetColor( color );
833 }
834 }
835
836 return true;
837 }
838
839 override void DraggingOver( Widget w, int x, int y, Widget receiver )
840 {
841 DraggingOverHeader( w, x, y, receiver );
842 }
843
844 override void DraggingOverHeader( Widget w, int x, int y, Widget receiver )
845 {
846 if( w == NULL )
847 {
848 return;
849 }
850 EntityAI item = GetItemPreviewItem( w );
851 if( !item )
852 {
853 return;
854 }
855
856 SlotsIcon slots_icon;
857 receiver.GetUserData(slots_icon);
858
859 EntityAI attached_entity;
860 EntityAI receiver_item;
861 bool is_reserved = false;
862 int slot_id = -1;
863
864 if(slots_icon)
865 {
866 attached_entity = slots_icon.GetSlotParent();
867 slot_id = slots_icon.GetSlotID();
868 receiver_item = slots_icon.GetEntity();
869 is_reserved = slots_icon.IsReserved();
870 }
871
872
873 Weapon_Base wpn;
874 Magazine mag;
875 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
876 if( m_Entity )
877 {
878 if( Class.CastTo(wpn, m_Entity ) && Class.CastTo(mag, item ) )
879 {
880 if( player.GetWeaponManager().CanAttachMagazine( wpn, mag ) )
881 {
883 if( m_Entity.GetHierarchyRootPlayer() == GetGame().GetPlayer() )
884 {
885 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
886 }
887 else
888 {
889 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
890 }
892 }
893 }
894 else if( receiver_item && !is_reserved )
895 {
896 ItemBase receiver_itemIB = ItemBase.Cast( receiver_item );
897 ItemBase itemIB = ItemBase.Cast( item );
898 if( receiver_itemIB && itemIB && receiver_itemIB.CanBeCombined( itemIB ) )
899 {
901 if( m_Entity.GetHierarchyRootPlayer() == GetGame().GetPlayer() )
902 {
903 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
904 }
905 else
906 {
907 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
908 }
910 }
911 else if( GameInventory.CanSwapEntitiesEx( receiver_item, item ) )
912 {
914 if( m_Entity.GetHierarchyRootPlayer() == GetGame().GetPlayer() )
915 {
916 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
917 }
918 else
919 {
920 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
921 }
923 }
924 else if( receiver_itemIB.GetInventory().CanAddAttachment( item ) )
925 {
927 if( receiver_itemIB.GetHierarchyRootPlayer() == GetGame().GetPlayer() )
928 {
929 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
930 }
931 else
932 {
933 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
934 }
936 }
937 }
938 else if( attached_entity && attached_entity.GetInventory().CanAddAttachmentEx( item, slot_id ) )
939 {
941 if( attached_entity.GetHierarchyRootPlayer() == GetGame().GetPlayer() )
942 {
943 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
944 }
945 else
946 {
947 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
948 }
950 }
951 else if( m_Entity.GetInventory().CanAddAttachment( item ) )
952 {
954 if( m_Entity.GetHierarchyRootPlayer() == GetGame().GetPlayer() )
955 {
956 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
957 }
958 else
959 {
960 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
961 }
963 }
964 else if( ( m_Entity.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && !m_Entity.GetInventory().HasEntityInCargo( item ) ) /*|| player.GetHumanInventory().HasEntityInHands( item )*/ )
965 {
967 if( m_Entity.GetHierarchyRootPlayer() == GetGame().GetPlayer() )
968 {
969 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
970 }
971 else
972 {
973 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
974 }
976 }
977 else
978 {
981 }
982 }
983 }
984
985 CargoContainer GetCargo()
986 {
987 return m_CargoGrid;
988 }
989
994
999}
void Inventory(LayoutHolder parent)
Определения Inventory.c:74
EntityAI m_Entity
Определения ActionDebug.c:11
bool IsOpened()
Определения BaseBuildingBase.c:1635
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
map
Определения ControlsXboxNew.c:4
DayZGame g_Game
Определения DayZGame.c:3868
DayZGame GetDayZGame()
Определения DayZGame.c:3870
Icon x
Icon y
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
PlayerBase GetPlayer()
Определения ModifierBase.c:51
Widget m_Parent
Определения SizeToChild.c:92
void Refresh()
Определения SizeToChild.c:108
int GetAttachmentSlotID()
Определения Attachments.c:616
Определения Attachments.c:4
Attachments m_Attachments
Определения AttachmentsWrapper.c:3
proto native DayZPlayer GetPlayer()
proto native int GetItemCount()
proto native int GetWidth()
proto native int GetHeight()
represents base for cargo storage for entities
Определения Cargo.c:7
Super root of all classes in Enforce script.
Определения EnScript.c:11
Widget GetItemPreviewWidget(Widget w)
ref map< EntityAI, ref CargoContainer > m_AttachmentCargos
void TakeAsAttachment(Widget w, Widget receiver)
void AttachmentAddedEx(EntityAI item, string slot, EntityAI parent, bool immedUpdate=true)
override bool IsFirstContainerFocused()
void DoubleClick(Widget w, int x, int y, int button)
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
Определения ContainerWithCargo.c:429
override bool IsLastContainerFocused()
void AttachmentRemoved(EntityAI item, string slot, EntityAI parent)
void OnDropReceivedFromHeader2(Widget w, int x, int y, Widget receiver)
override void DraggingOver(Widget w, int x, int y, Widget receiver)
ref map< EntityAI, ref Attachments > m_AttachmentAttachments
override bool InspectItem()
Определения ContainerWithCargo.c:184
ref map< EntityAI, ref AttachmentsWrapper > m_AttachmentAttachmentsContainers
void AttachmentAdded(EntityAI item, string slot, EntityAI parent)
void ContainerWithCargoAndAttachments(LayoutHolder parent, int sort=-1)
ref CargoContainer m_CargoGrid
Определения ContainerWithCargo.c:3
map< EntityAI, ref AttachmentsWrapper > GetAttachmentAttachmentsContainers()
override bool IsLastIndex()
override void UpdateInterval()
override void MoveGridCursor(int direction)
map< EntityAI, ref CargoContainer > GetAttachmentCargos()
void MouseClick2(Widget w, int x, int y, int button)
bool DraggingOverGrid(Widget w, int x, int y, Widget reciever, CargoContainer cargo)
CargoContainer GetCargo()
void ~ContainerWithCargoAndAttachments()
ItemPreviewWidget GetItemPreviewWidgetDragOrDrop(Widget w)
ref Attachments m_Atts
EntityAI GetItemPreviewItem(Widget w)
ref array< int > m_AttachmentSlotsSorted
override EntityAI GetFocusedContainerEntity()
override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
override void UnfocusAll()
void SetEntity(EntityAI entity, bool immedUpdate=true)
void DropReceived(Widget w, int x, int y, CargoContainer cargo)
NOTE Used for mouse only.
override bool IsDisplayable()
Определения ContainerWithCargo.c:19
void SetColor(Widget w, int color)
Определения ColorManager.c:32
static int BASE_COLOR
Определения ColorManager.c:15
static int COMBINE_COLOR
Определения ColorManager.c:20
static int SWAP_COLOR
Определения ColorManager.c:18
static int GREEN_COLOR
Определения ColorManager.c:17
static int RED_COLOR
Определения ColorManager.c:16
static ColorManager GetInstance()
Определения ColorManager.c:27
Определения ColorManager.c:2
Определения CargoContainer.c:3
Определения Building.c:6
proto native EntityAI GetAttachmentFromIndex(int index)
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
Определения Inventory.c:628
proto native int AttachmentCount()
Returns count of attachments attached to this item.
script counterpart to engine's class Inventory
Определения Inventory.c:79
override void Refresh()
Определения Icon.c:1216
Определения Icon.c:2
Определения ItemBase.c:15
proto native bool IsValid()
verify current set inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native void SetCargoAuto(notnull CargoBase cargo, EntityAI e, int row, int col, bool flip)
based on Cargo.IsProxyCargo uses SetProxyCargo or SetCargo respectively
proto native bool CompareLocationOnly(notnull InventoryLocation other)
proto native bool GetFlip()
returns flip status of cargo
InventoryLocation.
Определения InventoryLocation.c:29
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
static proto native owned string GetSlotName(int id)
converts slot_id to string
provides access to slot configuration
Определения InventorySlots.c:6
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Определения Rag.c:61
override bool CanBeSplit()
Определения Rag.c:34
Определения InventoryItem.c:731
EntityAI GetDraggedItem()
Определения ItemManager.c:368
void ShowSourceDropzone(EntityAI item)
Определения ItemManager.c:302
Widget GetLeftDropzone()
Определения ItemManager.c:336
Widget GetRightDropzone()
Определения ItemManager.c:344
void HideDropzones()
Определения ItemManager.c:287
void SetWidgetDraggable(Widget w, bool draggable)
Определения ItemManager.c:693
void SetIsDragging(bool is_dragging)
Определения ItemManager.c:383
static ItemManager GetInstance()
Определения ItemManager.c:282
Определения ItemManager.c:2
proto native EntityAI GetItem()
Определения gameplay.c:277
Определения Container.c:2
Определения PlayerBaseClient.c:2
EntityAI GetEntity()
Определения SlotsIcon.c:365
EntityAI GetSlotParent()
Определения SlotsIcon.c:185
bool IsReserved()
Определения SlotsIcon.c:200
int GetSlotID()
Определения SlotsIcon.c:190
Определения SlotsIcon.c:2
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)
Определения SplitItemUtils.c:34
static void TakeOrSplitToInventory(notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)
Определения SplitItemUtils.c:3
Определения SplitItemUtils.c:2
shorthand
Определения BoltActionRifle_Base.c:6
void RegisterOnDraggingOver(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:112
static WidgetEventHandler GetInstance()
Определения WidgetEventHandler.c:22
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
MouseState
Определения EnSystem.c:311