DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
AttachmentCategoriesRow.c
См. документацию.
2{
3 protected string m_CategoryIdentifier;
4 protected string m_RowConfigPath;
5 protected bool m_Refreshing;
6
9
10 void AttachmentCategoriesRow( LayoutHolder parent, int sort = -1 )
11 {
12 m_Refreshing = false;
15
16 m_Body.Insert(m_AttachmentsContainer);
17
18 m_ClosableHeader.GetMainWidget().ClearFlags( WidgetFlags.DRAGGABLE );
19
20 RecomputeOpenedContainers();
21 }
22
24 {
26 }
27
29 {
30 SlotsIcon icon = GetFocusedSlotsIcon();
31 if (icon)
32 {
33 return icon.GetSlotID();
34 }
35 return -1;
36 }
37
38 override bool Select()
39 {
40 Man player = GetGame().GetPlayer();
41 SlotsIcon focused_icon = GetFocusedSlotsIcon();
42 EntityAI focused_item = GetFocusedItem();
43 Container focused_cont = GetFocusedContainer();
44 ItemBase selected_item = ItemBase.Cast( ItemManager.GetInstance().GetSelectedItem() ); // == dragged item
45
46 if( selected_item && focused_item != selected_item)//dropping from micromanagement
47 {
48 if( selected_item.GetInventory().CanRemoveEntity() )
49 {
50 int stack_max;
51
52 if (!focused_icon)
53 {
54 if (focused_cont)
55 {
56 focused_cont.Select();
57 }
58 }
59 else if( !focused_item && m_Entity && m_Entity.GetInventory().CanAddAttachmentEx( selected_item, focused_icon.GetSlotID() ) )
60 {
61 stack_max = InventorySlots.GetStackMaxForSlotId( focused_icon.GetSlotID() );
62 float quantity = selected_item.GetQuantity();
63 if( stack_max == 0 || stack_max >= quantity || !selected_item.CanBeSplit() )
64 {
65 player.PredictiveTakeEntityToTargetAttachmentEx( m_Entity, selected_item, focused_icon.GetSlotID() );
66 return true;
67 }
68 else
69 {
70 selected_item.SplitIntoStackMaxClient( m_Entity, focused_icon.GetSlotID() );
71 return true;
72 }
73 }
74 else if (focused_icon.GetSlotID() != -1)
75 {
76 if (focused_item && focused_item.GetHierarchyParent() && focused_item.GetHierarchyParent().GetInventory().CanAddAttachment(selected_item))
77 {
79 focused_item.GetInventory().GetCurrentInventoryLocation( inv_loc );
80 stack_max = InventorySlots.GetStackMaxForSlotId( inv_loc.GetSlot() );
81 quantity = focused_item.GetQuantity();
82 if( focused_item.CanBeCombined( ItemBase.Cast( selected_item ) ) )
83 {
84 focused_item.CombineItemsClient( selected_item, true );
85 return true;
86 }
87 else if( stack_max == 0 && GameInventory.CanSwapEntitiesEx( focused_item, selected_item ) )
88 {
89 player.PredictiveSwapEntities( selected_item, focused_item );
90 return true;
91 }
92 else if( m_AttachmentCargos.Contains( inv_loc.GetSlot() ) )
93 {
94 if( focused_item.GetInventory().CanAddEntityInCargo( selected_item, selected_item.GetInventory().GetFlipCargo() ) )
95 {
96 SplitItemUtils.TakeOrSplitToInventory( PlayerBase.Cast( player ), focused_item, selected_item );
97 return true;
98 }
99 }
100 }
101 }
102 }
103 }
104 else //clicking
105 {
106 if( focused_item && focused_item.GetInventory().CanRemoveEntity() && (!focused_icon || !focused_icon.IsOutOfReach()) )
107 {
108 EntityAI item_in_hands = GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
109 if( item_in_hands && item_in_hands.GetInventory().CanRemoveEntity() )
110 {
111 if( GameInventory.CanSwapEntitiesEx( item_in_hands, focused_item ) )
112 {
113 player.PredictiveSwapEntities( item_in_hands, focused_item );
114 return true;
115 }
116 }
117 else
118 {
119 if( player.GetHumanInventory().CanAddEntityInHands( focused_item ) )
120 {
121 player.PredictiveTakeEntityToHands( focused_item );
122 return true;
123 }
124 }
125 }
126 }
127
128 return false;
129 }
130
131 override bool TransferItem()
132 {
133 if (CanTakeToInventory())
134 {
135 EntityAI entity = GetFocusedItem();
136 SlotsIcon focused_icon = GetFocusedSlotsIcon();
137 if( entity && !entity.IsLockedInSlot() && (!focused_icon || !focused_icon.IsOutOfReach()) )
138 {
139 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
140 GetGame().GetPlayer().PredictiveTakeEntityToInventory( FindInventoryLocationType.CARGO, entity );
141 return true;
142 }
143 }
144 return false;
145 }
146
148 {
149 if (CanDrop())
150 {
151 ItemBase item = ItemBase.Cast(GetFocusedItem());
152 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
153 SlotsIcon focused_icon = GetFocusedSlotsIcon();
154
155 if (item && !item.IsLockedInSlot() && (focused_icon && !focused_icon.IsOutOfReach()))
156 {
157 if (item.GetTargetQuantityMax() < item.GetQuantity())
158 item.SplitIntoStackMaxClient( null, -1 );
159 else
160 player.PhysicalPredictiveDropItem( item );
161 return true;
162 }
163 }
164 return false;
165 }
166
167 override bool Combine()
168 {
169 if (CanCombine())
170 {
171 Man player = GetGame().GetPlayer();
172 ItemBase prev_item = ItemBase.Cast( GetFocusedItem() );
173 ItemBase selected_item = ItemBase.Cast( player.GetHumanInventory().GetEntityInHands() );
174 SlotsIcon focused_icon = GetFocusedSlotsIcon();
175
176 if( selected_item )
177 {
178 int selected_slot = GetFocusedSlot();
179 int stack_max;
180 if( selected_item && selected_item.GetInventory().CanRemoveEntity() && (focused_icon && !focused_icon.IsOutOfReach()) )
181 {
182 if( !prev_item && m_Entity.GetInventory().CanAddAttachmentEx( selected_item, selected_slot ) )
183 {
184 stack_max = InventorySlots.GetStackMaxForSlotId( selected_slot );
185 float quantity = selected_item.GetQuantity();
186 if( stack_max == 0 || stack_max >= quantity || !selected_item.CanBeSplit() )
187 {
188 player.PredictiveTakeEntityToTargetAttachmentEx( m_Entity, selected_item, selected_slot );
189 return true;
190 }
191 else
192 {
193 selected_item.SplitIntoStackMaxClient( m_Entity, selected_slot );
194 return true;
195 }
196 }
197 else if( selected_slot != -1 )
198 {
199 if( prev_item )
200 {
202 prev_item.GetInventory().GetCurrentInventoryLocation( inv_loc );
203 stack_max = InventorySlots.GetStackMaxForSlotId( inv_loc.GetSlot() );
204 quantity = prev_item.GetQuantity();
205 if( prev_item.CanBeCombined( ItemBase.Cast( selected_item ) ) )
206 {
207 prev_item.CombineItemsClient( selected_item, true );
208 return true;
209 }
210 else if( stack_max == 0 && GameInventory.CanSwapEntitiesEx( prev_item, selected_item ) )
211 {
212 player.PredictiveSwapEntities( selected_item, prev_item );
213 return true;
214 }
215 else if( m_AttachmentCargos.Contains( inv_loc.GetSlot() ) )
216 {
217 if( prev_item.GetInventory().CanAddEntityInCargo( selected_item, selected_item.GetInventory().GetFlipCargo() ) )
218 {
219 SplitItemUtils.TakeOrSplitToInventory( PlayerBase.Cast( player ), prev_item, selected_item );
220 return true;
221 }
222 }
223 }
224 }
225 }
226 }
227 }
228 return false;
229 }
230
231 override bool EquipItem() //TODO: may be possible, but the hint doesn't reflect it anyway
232 {
233 return false;
234 }
235
236 override bool CanCombine()
237 {
238 Man player = GetGame().GetPlayer();
239 ItemBase prev_item = ItemBase.Cast( GetFocusedItem() );
240 ItemBase selected_item = ItemBase.Cast( player.GetHumanInventory().GetEntityInHands() );
241 SlotsIcon focused_icon = GetFocusedSlotsIcon();
242
243 if( selected_item )
244 {
245 int selected_slot = GetFocusedSlot();
246 int stack_max;
247 if( selected_item && selected_item.GetInventory().CanRemoveEntity() && (focused_icon && !focused_icon.IsOutOfReach()) )
248 {
249 if( m_Entity.GetInventory().CanAddAttachmentEx( selected_item, selected_slot ) )
250 {
251 stack_max = InventorySlots.GetStackMaxForSlotId( selected_slot );
252 float quantity = selected_item.GetQuantity();
253 if( stack_max == 0 || stack_max >= quantity || !selected_item.CanBeSplit() )
254 {
255 return true;
256 }
257 else
258 {
259 return true;
260 }
261 }
262 else if( selected_slot != -1 )
263 {
264 if( prev_item )
265 {
267 prev_item.GetInventory().GetCurrentInventoryLocation( inv_loc );
268 stack_max = InventorySlots.GetStackMaxForSlotId( inv_loc.GetSlot() );
269 quantity = prev_item.GetQuantity();
270 if( prev_item.CanBeCombined( ItemBase.Cast( selected_item ) ) )
271 {
272 return true;
273 }
274 }
275 }
276 }
277 }
278 return false;
279 }
280
281 override bool CanCombineAmmo()
282 {
283 return false;
284 }
285
286 override bool IsItemActive()
287 {
288 SlotsIcon icon = GetFocusedSlotsIcon();
289 return GetFocusedItem() != null && (!icon || !icon.IsOutOfReach());
290 }
291
293 {
294 ItemBase item = ItemBase.Cast(GetFocusedItem());
295 SlotsIcon icon = GetFocusedSlotsIcon();
296 return item && ( !icon || !icon.IsOutOfReach()) && item.CanBeSplit();
297 }
298
299 override void OnDropReceivedFromHeader( Widget w, int x, int y, Widget receiver )
300 {
303 SlotsIcon slots_icon;
304 EntityAI receiver_item;
305 int slot_id = -1;
306 bool is_reserved = false;
307 EntityAI attached_entity;
308 receiver.GetUserData(slots_icon);
309 float stackable = 0.0;
311
312 if( slots_icon )
313 {
314 receiver_item = slots_icon.GetEntity();
315 slot_id = slots_icon.GetSlotID();
316 attached_entity = slots_icon.GetSlotParent();
317 is_reserved = slots_icon.IsReserved();
318 }
319
320 EntityAI item = GetItemPreviewItem( w );
321 if( !item )
322 {
323 return;
324 }
325 ItemBase item_base = ItemBase.Cast( item );
326
327 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
328 if( !item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory() )
329 return;
330
331 EntityAI target_att_entity = m_Entity;
332 Weapon_Base wpn;
333 Magazine mag;
334 if( Class.CastTo(wpn, m_Entity ) && Class.CastTo(mag, item ) )
335 {
336 if( player.GetWeaponManager().CanAttachMagazine( wpn, mag ) )
337 {
338 player.GetWeaponManager().AttachMagazine( mag );
339 }
340 }
341 else if( receiver_item && !is_reserved )
342 {
343 if( ( ItemBase.Cast( receiver_item ) ).CanBeCombined( ItemBase.Cast( item ) ) )
344 {
345 ( ItemBase.Cast( receiver_item ) ).CombineItemsClient( ItemBase.Cast( item ) );
346 }
347 else if( GameInventory.CanSwapEntitiesEx( receiver_item, item ) )
348 {
349 if( !receiver_item.GetInventory().CanRemoveEntity() )
350 return;
351 GetGame().GetPlayer().PredictiveSwapEntities( receiver_item, item );
352 }
353 else if( receiver_item.GetInventory().CanAddAttachment( item ) )
354 {
355 player.PredictiveTakeEntityToTargetAttachment(receiver_item, item);
356 }
357 }
358 else if( attached_entity && slot_id != -1 && attached_entity.GetInventory().CanAddAttachmentEx( item, slot_id ) )
359 {
360 item_base = ItemBase.Cast( item );
361 stackable = item_base.GetTargetQuantityMax( slot_id );
362
363 if( stackable == 0 || stackable >= item_base.GetQuantity() )
364 {
365 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, slot_id);
366 }
367 else if( stackable != 0 && stackable < item_base.GetQuantity() )
368 {
369 item_base.SplitIntoStackMaxClient( m_Entity, slot_id );
370 }
371 }
372 else if(attached_entity && slot_id == -1 && attached_entity.GetInventory().FindFreeLocationFor(item,FindInventoryLocationType.ATTACHMENT,il))
373 {
374 item_base = ItemBase.Cast( item );
375 stackable = item_base.GetTargetQuantityMax( il.GetSlot() );
376
377 if( stackable == 0 || stackable >= item_base.GetQuantity() )
378 {
379 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, il.GetSlot());
380 }
381 else if( stackable != 0 && stackable < item_base.GetQuantity() )
382 {
383 item_base.SplitIntoStackMaxClient( m_Entity, il.GetSlot() );
384 }
385 }
386 /*else if( ( m_Entity.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && ( !player.GetInventory().HasEntityInInventory( item ) || !m_Entity.GetInventory().HasEntityInCargo( item )) ) )
387 {
388 SplitItemUtils.TakeOrSplitToInventory( PlayerBase.Cast( GetGame().GetPlayer() ), m_Entity, item );
389 }*/
390 }
391
392 override void UnfocusAll()
393 {
394 int i;
395 for ( i = 1; i < Count(); i++ )
396 {
397 for ( int j = 0; j < ITEMS_IN_ROW; j++ )
398 {
399 Widget w = Get( i ).GetMainWidget().FindAnyWidget( "Cursor" + j );
400 if( w )
401 w.Show( false );
402 }
403 }
404 for ( i = 0; i < m_AttachmentCargos.Count(); i++ )
405 {
406 m_AttachmentCargos.GetElement( i ).Unfocus();
407 m_AttachmentCargos.GetElement( i ).SetActive( false );
408 }
409 }
410
411 override void DraggingOverHeader( Widget w, int x, int y, Widget receiver )
412 {
413 if( w == null )
414 {
415 return;
416 }
417 ItemPreviewWidget iw = ItemPreviewWidget.Cast( w.FindAnyWidget("Render") );
418 if(!iw)
419 {
420 string name = w.GetName();
421 name.Replace("PanelWidget", "Render");
422 iw = ItemPreviewWidget.Cast( w.FindAnyWidget(name) );
423 }
424 if(!iw)
425 {
426 iw = ItemPreviewWidget.Cast( w );
427 }
428
429 if( !iw || !iw.GetItem() || (iw.GetItem() == m_Entity) )
430 {
431 return;
432 }
433
434 ItemBase item;
435 ItemBase receiver_item;
436 name = receiver.GetName();
437 name.Replace("PanelWidget", "Render");
438 ItemPreviewWidget receiver_iw = ItemPreviewWidget.Cast( receiver.FindAnyWidget(name) );
439 if(receiver_iw)
440 receiver_item = ItemBase.Cast( receiver_iw.GetItem() );
441
442 SlotsIcon slots_icon;
443 receiver.GetUserData(slots_icon);
444
445 if( receiver_item )
446 {
447 int stack_max = InventorySlots.GetStackMaxForSlotId( receiver_item.GetInventory().GetSlotId(0) );
448 //int quantity = receiver_item.GetQuantity();
449 //bool combinable = ( quantity < stack_max ) && ( ItemBase.Cast( receiver_item ).CanBeCombined( ItemBase.Cast( iw.GetItem() ) ) );
450 if( receiver_item.CanBeCombined( ItemBase.Cast( iw.GetItem() ) ) )
451 {
453 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
455 }
456 else if( stack_max == 0 && GameInventory.CanSwapEntitiesEx( receiver_item, iw.GetItem() ) )
457 {
459 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
461 }
462 else
463 {
466 }
467 }
468 else if( slots_icon && slots_icon.GetSlotID() != -1 )
469 {
470 item = ItemBase.Cast( iw.GetItem() );
471
472 if( item && m_Entity.GetInventory().CanAddAttachmentEx( item, slots_icon.GetSlotID() ) )
473 {
475 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
477 }
478 else
479 {
482 }
483 }
484 else
485 {
488 }
489 }
490
491 bool DraggingOverGrid( Widget w, int x, int y, Widget reciever, CargoContainer cargo )
492 {
493 if( w == null )
494 {
495 return false;
496 }
497
498 EntityAI item = GetItemPreviewItem( w );
499
500 if( !item )
501 {
502 return false;
503 }
504
505 int color;
506 int idx = 0;
507 int c_x, c_y;
508
509 EntityAI target_entity;
510 CargoBase target_cargo;
511
512 target_entity = cargo.GetEntity() ;
513 if( target_entity )
514 {
515 target_cargo = target_entity.GetInventory().GetCargo();
516 }
517 else
518 return false;
519
520 if( target_cargo && target_entity )
521 {
522 c_x = target_cargo.GetHeight();
523 c_y = target_cargo.GetWidth();
524 }
525 else
526 return false;
527
528 if( c_x > x && c_y > y && target_entity.GetInventory().CanAddEntityInCargoEx( item, idx, x, y, item.GetInventory().GetFlipCargo() ) )
529 {
531 }
532 else
533 {
534 color = ColorManager.RED_COLOR;
535 }
536
537 if( w.FindAnyWidget("Cursor") )
538 {
539 w.FindAnyWidget("Cursor").SetColor( color );
540 }
541 else
542 {
543 string name = w.GetName();
544 name.Replace( "PanelWidget", "Cursor" );
545 if( w.FindAnyWidget( name ) )
546 {
547 w.FindAnyWidget( name ).SetColor( color );
548 }
549 }
550
551 return true;
552 }
553
554 void DropReceived( Widget w, int x, int y, CargoContainer cargo )
555 {
556 EntityAI item = GetItemPreviewItem( w );
557 if( !item )
558 {
559 return;
560 }
561
562 int idx = 0;
563 int c_x, c_y;
564
565 EntityAI target_entity;
566 CargoBase target_cargo;
567
568 target_entity = cargo.GetEntity();
569 if( target_entity )
570 {
571 target_cargo = target_entity.GetInventory().GetCargo();
572 }
573 else
574 return;
575
576 if( target_cargo && target_entity )
577 {
578 c_x = target_cargo.GetHeight();
579 c_y = target_cargo.GetWidth();
580 }
581 else
582 return;
583
585 dst.SetCargoAuto(target_cargo, item, x, y, item.GetInventory().GetFlipCargo());
586
587 if( c_x > x && c_y > y && target_entity.GetInventory().LocationCanAddEntity(dst))
588 {
589 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
590
592
593 Icon icon = cargo.GetIcon( item );
594
595 if( icon )
596 {
597 icon.GetCursorWidget().SetColor( ColorManager.BASE_COLOR );
598 icon.RefreshPos( x, y );
599 icon.Refresh();
600 Refresh();
601 }
602 }
603 }
604
606 {
607 ItemPreviewWidget ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( "Render" ) );
608 if( !ipw )
609 {
610 string name = w.GetName();
611 name.Replace( "PanelWidget", "Render" );
612 ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
613 }
614 if( !ipw )
615 {
616 ipw = ItemPreviewWidget.Cast( w );
617 }
618 if( !ipw || !ipw.IsInherited( ItemPreviewWidget ) )
619 {
620 return null;
621 }
622 return ipw.GetItem();
623 }
624
625 override void Refresh()
626 {
627 if (!m_Refreshing)
628 {
629 if( !m_Closed )
630 {
631 super.Refresh();
633 }
634 }
635 }
636
638 {
639 m_Refreshing = true;
640 int row_count = m_AttachmentsContainer.GetRowCount();
641 int row;
642 for (row = 0; row < row_count; row++)
643 {
644 int col_count = m_AttachmentsContainer.GetColumnCountForRow(row);
645 int col;
646 for (col = 0; col < col_count; col++)
647 {
648 RefreshSlot(row, col, -1, "");
649 }
650 }
651 m_Refreshing = false;
652 }
653
654 //slot_id and slot_name parametr is not used
655 void RefreshSlot( int row, int column, int slot_id, string slot_name )
656 {
657 SlotsIcon icon = m_AttachmentsContainer.GetSlotsIcon(row, column);
658 int slot_id_ = icon.GetSlotID();
659 EntityAI item = m_Entity.GetInventory().FindAttachment( slot_id_ );
661
662 if (!m_Entity.CanDisplayAttachmentSlot(slot_id_))
663 {
664 icon.Clear();
665 icon.GetMainWidget().Show( false );
666 }
667 else if (!item)
668 {
669 icon.ClearRemainSelected();
670
671 cont = m_AttachmentCargos.Get(slot_id_);
672 if (cont)
673 {
674 m_AttachmentCargos.Remove(slot_id_);
675 this.Remove(cont);
676 ( Container.Cast( cont.m_Parent ) ).Remove( cont );
677 }
678 icon.GetMainWidget().Show(true);
679 }
680 else
681 {
682 icon.GetMainWidget().Show( true );
683 if (icon.GetEntity() != item)
684 {
685 icon.Init( item );
686 }
687 else
688 {
689 icon.Refresh();
690 }
691
692 cont = m_AttachmentCargos.Get(slot_id_);
693 if( cont && cont.GetEntity() != item)
694 {
695 m_AttachmentCargos.Remove(slot_id_);
696 ( Container.Cast( cont.m_Parent ) ).Remove( cont );
697 this.Remove(cont);
698 cont = null;
699 }
700
701 if( !cont )
702 {
703 if( item.GetInventory().GetCargo() && m_AttachmentCargos )
704 {
705 cont = new ContainerWithCargo( this, true );
706 cont.GetRootWidget().SetSort( m_AttachmentCargos.Count() + 10 );
707 cont.SetEntity( item );
708 cont.SetSlotIcon( icon );
709
710 m_AttachmentCargos.Insert( slot_id_, cont );
711 icon.SetContainer(cont);
712
713 SetOpenForSlotIcon(cont.IsOpened(),icon);
714 }
715 }
716
717 if (cont)
718 {
719 icon.GetRadialIconPanel().Show( cont.IsDisplayable() );
720 }
721
722 string slot_name_ = InventorySlots.GetSlotName(slot_id_);
723 bool draggable = true;
724 bool can_be_removed = item.GetInventory().CanRemoveEntity();
725 bool in_hands_condition = m_Entity.GetHierarchyRoot() == GetGame().GetPlayer();
726 bool in_vicinity_condition = AttachmentsOutOfReach.IsAttachmentReachable( m_Entity, slot_name_ );
727 if( m_Entity.GetInventory().GetSlotLock( slot_id_ ) && ItemManager.GetInstance().GetDraggedItem() != item )
728 {
729 icon.GetMountedWidget().Show( true );
730 draggable = false;
731 }
732 else
733 {
734 icon.GetMountedWidget().Show( false );
735 }
736
737 if( !m_Entity.CanReleaseAttachment( item ) )
738 {
739 draggable = false;
740 }
741
742 if ((in_hands_condition || in_vicinity_condition) && can_be_removed)
743 {
744 icon.GetOutOfReachWidget().Show( false );
745 }
746 else
747 {
748 icon.GetOutOfReachWidget().Show( true );
749 draggable = false;
750 }
751
752 if( draggable )
753 {
754 icon.GetRender().GetParent().SetFlags( WidgetFlags.DRAGGABLE );
755 }
756 else
757 {
758 icon.GetRender().GetParent().ClearFlags( WidgetFlags.DRAGGABLE );
759 }
760 }
761 }
762
763 void DoubleClick(Widget w, int x, int y, int button)
764 {
765 if (button == MouseState.LEFT && !g_Game.IsLeftCtrlDown())
766 {
767 ItemPreviewWidget iw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
768 if (!iw)
769 {
770 string name = w.GetName();
771 name.Replace("PanelWidget", "Render");
772 iw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
773 }
774
775 if (!iw)
776 iw = ItemPreviewWidget.Cast(w);
777
778 SlotsIcon icon;
779 w.GetUserData(icon);
780
781 if (icon && m_Entity.GetInventory().GetSlotLock(iw.GetUserID()))
782 return;
783
784 if (icon.IsOutOfReach())
785 return;
786
787 ItemBase item = ItemBase.Cast(iw.GetItem());
788 if (item)
789 {
790 if (!item.GetInventory().CanRemoveEntity())
791 return;
792
793 PlayerBase controlledPlayer = PlayerBase.Cast(GetGame().GetPlayer());
794 if (controlledPlayer.GetInventory().HasEntityInInventory(item) && controlledPlayer.GetHumanInventory().CanAddEntityInHands(item))
795 {
796 controlledPlayer.PredictiveTakeEntityToHands(item);
797 }
798 else
799 {
800 if (controlledPlayer.GetInventory().CanAddEntityToInventory(item) && item.GetInventory().CanRemoveEntity())
801 {
802 if (item.GetTargetQuantityMax() < item.GetQuantity())
803 item.SplitIntoStackMaxClient(controlledPlayer, -1);
804 else
805 controlledPlayer.PredictiveTakeEntityToInventory(FindInventoryLocationType.ANY, item);
806 }
807 else
808 {
809 if (controlledPlayer.GetHumanInventory().CanAddEntityInHands(item))
810 {
811 if (item.GetTargetQuantityMax() < item.GetQuantity())
812 item.SplitIntoStackMaxHandsClient(controlledPlayer);
813 else
814 controlledPlayer.PredictiveTakeEntityToHands(item);
815 }
816 }
817 }
818
819 HideOwnedTooltip();
820
821 name = w.GetName();
822 name.Replace("PanelWidget", "Temperature");
823 w.FindAnyWidget(name).Show(false);
824 }
825 }
826 }
827
828 void MouseClick(Widget w, int x, int y, int button)
829 {
830 ItemBase selectedItem;
831 SlotsIcon icon;
832 w.GetUserData(icon);
833 if (icon)
834 selectedItem = ItemBase.Cast(icon.GetEntity());
835
836 if (selectedItem)
837 {
838 switch (button)
839 {
840 case MouseState.RIGHT:
841 #ifdef DIAG_DEVELOPER
842 if (g_Game.IsLeftCtrlDown())
843 ShowActionMenu(selectedItem);
844 #endif
845
846 if (CanSplitEx(selectedItem))
847 {
848 selectedItem.OnRightClick();
849 }
850
851 break;
852
853 case MouseState.MIDDLE:
854 InspectItem(selectedItem);
855 break;
856
857 case MouseState.LEFT:
858 PlayerBase controlledPlayer = PlayerBase.Cast(GetGame().GetPlayer());
859 if (g_Game.IsLeftCtrlDown())
860 {
861 if (icon.IsOutOfReach())
862 return;
863
864 if (controlledPlayer.CanDropEntity(selectedItem))
865 {
866 if (selectedItem.GetTargetQuantityMax() < selectedItem.GetQuantity())
867 selectedItem.SplitIntoStackMaxClient(null, -1);
868 else
869 controlledPlayer.PhysicalPredictiveDropItem(selectedItem);
870 }
871 else
872 {
873 bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(selectedItem, null ) && !controlledPlayer.GetInventory().IsInventoryLocked() && selectedItem.GetInventory().CanRemoveEntity() && !controlledPlayer.IsItemsToDelete();
875 }
876 }
877 else
878 {
880 if (c)
881 c.Toggle();
882 }
883
884 break;
885 }
886 }
887 }
888
889 void Init(int attachments_categories_count, int i, string attachment_category, string config_path_attachment_categories, EntityAI entity, int parent_m_Body_count )
890 {
891 m_Entity = entity;
892 Header header = GetHeader();
893
894 m_CategoryIdentifier = attachment_category;
895
896 array<string> player_ghosts_slots2 = new array<string>();
897 string categoryName;
898
899 m_RowConfigPath = config_path_attachment_categories + " " + attachment_category + " attachmentSlots";
900 string config_path_category_name = config_path_attachment_categories + " " + attachment_category + " name";
901 GetGame().ConfigGetTextArray(m_RowConfigPath, player_ghosts_slots2);
902 GetGame().ConfigGetText(config_path_category_name, categoryName);
903 header.SetName(categoryName);
904
905 m_AttachmentsContainer.SetHeader(header);
906 SetHeader(null);
907
908 int count = player_ghosts_slots2.Count();
909 int lastRow = count / ITEMS_IN_ROW;
910 SlotsContainer slotsContainer;
911
912 for ( int j = 0; j < count; j++ )
913 {
914 string slotName = player_ghosts_slots2.Get(j);
915 string iconName; //must be in format "set:<setname> image:<imagename>"
916 string path = "CfgSlots" + " Slot_" + slotName;
917
919
920 GetGame().ConfigGetText(path + " ghostIcon", iconName);
921 GetGame().ConfigGetText(path + " name", slotName);
922
923 int row = j / ITEMS_IN_ROW;
924 int column = j % ITEMS_IN_ROW;
925 if (column == 0)
926 {
927 slotsContainer = new SlotsContainer(m_AttachmentsContainer, m_Entity);
928 slotsContainer.GetRootWidget().SetAlpha(0.7);
929 if (row == lastRow)
930 slotsContainer.SetColumnCount(count % ITEMS_IN_ROW);
931 else
932 slotsContainer.SetColumnCount(ITEMS_IN_ROW);
933
934 m_AttachmentsContainer.Insert(slotsContainer);
935 slotsContainer.GetRootWidget().SetSort(row);
936 }
937
938 SlotsIcon icon = slotsContainer.GetSlotIcon(column);
939 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetMainWidget(), this, "OnDropReceivedFromHeader");
940 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetGhostSlot(), this, "OnDropReceivedFromHeader");
941 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetPanelWidget(), this, "OnDropReceivedFromHeader");
942
943 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetMainWidget(), this, "DraggingOverHeader");
944 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetGhostSlot(), this, "DraggingOverHeader");
945 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetPanelWidget(), this, "DraggingOverHeader");
946
947 WidgetEventHandler.GetInstance().RegisterOnDrop(icon.GetMainWidget(), this, "OnIconDrop");
948 WidgetEventHandler.GetInstance().RegisterOnDrop(icon.GetPanelWidget(), this, "OnIconDrop");
949
952
954 icon.SetSlotID(slotId);
956
957 icon.Clear();
958 }
960 }
961
962 override void UpdateInterval()
963 {
964 super.UpdateInterval();
966 }
967}
const int ITEMS_IN_ROW
Определения Attachments.c:1
EntityAI m_Entity
Определения ActionDebug.c:11
void Remove(Object object)
Определения ActionTargets.c:207
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
map
Определения ControlsXboxNew.c:4
DayZGame g_Game
Определения DayZGame.c:3868
string GetHeader()
Определения ErrorProperties.c:76
Icon x
Icon y
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
PlayerBase GetPlayer()
Определения ModifierBase.c:51
string path
Определения OptionSelectorMultistate.c:142
override float Get()
Определения PlayerStatBase.c:134
@ Count
Определения RandomGeneratorSyncManager.c:8
void MouseClick(Widget w, int x, int y, int button)
Определения AttachmentCategoriesRow.c:828
string m_RowConfigPath
Определения AttachmentCategoriesRow.c:4
override void UpdateInterval()
Определения AttachmentCategoriesRow.c:962
override void Refresh()
Определения AttachmentCategoriesRow.c:625
override bool Select()
Определения AttachmentCategoriesRow.c:38
override bool TransferItemToVicinity()
Определения AttachmentCategoriesRow.c:147
override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
Определения AttachmentCategoriesRow.c:299
override bool IsItemWithQuantityActive()
Определения AttachmentCategoriesRow.c:292
override bool IsItemActive()
Определения AttachmentCategoriesRow.c:286
override bool CanCombineAmmo()
Определения AttachmentCategoriesRow.c:281
ref AttachmentsGroupContainer m_AttachmentsContainer
Определения AttachmentCategoriesRow.c:7
override bool Combine()
Определения AttachmentCategoriesRow.c:167
void Init(int attachments_categories_count, int i, string attachment_category, string config_path_attachment_categories, EntityAI entity, int parent_m_Body_count)
Определения AttachmentCategoriesRow.c:889
override void UnfocusAll()
Определения AttachmentCategoriesRow.c:392
void DoubleClick(Widget w, int x, int y, int button)
Определения AttachmentCategoriesRow.c:763
override bool TransferItem()
Определения AttachmentCategoriesRow.c:131
ref map< int, ref ContainerWithCargo > m_AttachmentCargos
Определения AttachmentCategoriesRow.c:8
string m_CategoryIdentifier
Определения AttachmentCategoriesRow.c:3
void AttachmentCategoriesRow(LayoutHolder parent, int sort=-1)
Определения AttachmentCategoriesRow.c:10
void RefreshSlot(int row, int column, int slot_id, string slot_name)
Определения AttachmentCategoriesRow.c:655
void DropReceived(Widget w, int x, int y, CargoContainer cargo)
Определения AttachmentCategoriesRow.c:554
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
Определения AttachmentCategoriesRow.c:411
bool DraggingOverGrid(Widget w, int x, int y, Widget reciever, CargoContainer cargo)
Определения AttachmentCategoriesRow.c:491
string GetCategoryIdentifier()
Определения AttachmentCategoriesRow.c:23
override bool CanCombine()
Определения AttachmentCategoriesRow.c:236
override bool EquipItem()
Определения AttachmentCategoriesRow.c:231
EntityAI GetItemPreviewItem(Widget w)
Определения AttachmentCategoriesRow.c:605
static bool IsAttachmentReachable(EntityAI e, string att_slot_name="", int slot_id=-1, float range=1.5)
Определения AttachmentsOutOfReach.c:5
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native DayZPlayer GetPlayer()
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
override bool InspectItem()
Определения ContainerWithCargo.c:184
void ContainerWithCargo(LayoutHolder parent, int sort=-1)
Определения ContainerWithCargo.c:6
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
override bool Select()
Определения CargoContainer.c:852
Определения CargoContainer.c:3
Определения Building.c:6
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
Определения Inventory.c:628
script counterpart to engine's class Inventory
Определения Inventory.c:79
void SetName(string name)
Определения Header.c:33
Определения Header.c:2
Widget GetCursorWidget()
Определения Icon.c:88
override void Refresh()
Определения Icon.c:1216
void RefreshPos(int row, int column)
Определения Icon.c:1255
Определения Icon.c:2
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
InventoryLocation.
Определения InventoryLocation.c:29
static proto native owned string GetSlotDisplayName(int id)
converts slot_id to string
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
static proto native int GetStackMaxForSlotId(int 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
EntityAI GetSelectedItem()
Определения ItemManager.c:85
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
SlotsIcon GetSlotIcon(int index)
Определения SlotsContainer.c:207
Определения SlotsContainer.c:2
void ClearRemainSelected()
Определения SlotsIcon.c:549
override void Refresh()
Определения SlotsIcon.c:345
Container GetContainer()
Определения SlotsIcon.c:149
Widget GetPanelWidget()
Определения SlotsIcon.c:205
ItemPreviewWidget GetRender()
Определения SlotsIcon.c:230
EntityAI GetEntity()
Определения SlotsIcon.c:365
void Init(EntityAI obj, bool reservation=false)
Определения SlotsIcon.c:501
void SetSlotID(int slot_ID)
Определения SlotsIcon.c:195
bool IsOutOfReach()
Определения SlotsIcon.c:729
EntityAI GetSlotParent()
Определения SlotsIcon.c:185
void SetSlotDisplayName(string text)
Определения SlotsIcon.c:144
bool IsReserved()
Определения SlotsIcon.c:200
void SetContainer(Container container)
Определения SlotsIcon.c:139
int GetSlotID()
Определения SlotsIcon.c:190
void Clear()
Определения SlotsIcon.c:612
Widget GetMountedWidget()
Определения SlotsIcon.c:225
Widget GetOutOfReachWidget()
Определения SlotsIcon.c:265
Widget GetRadialIconPanel()
Определения SlotsIcon.c:300
ImageWidget GetGhostSlot()
Определения SlotsIcon.c:235
Определения 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
static const int IMAGESETGROUP_INVENTORY
Определения StaticGUIUtils.c:3
static string VerifyIconImageString(int imageset_group=IMAGESETGROUP_INVENTORY, string icon_name="")
Checks for improperly formated, legacy image names and corrects them to default format.
Определения StaticGUIUtils.c:7
Определения StaticGUIUtils.c:2
shorthand
Определения BoltActionRifle_Base.c:6
void RegisterOnDropReceived(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:91
void RegisterOnDraggingOver(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:112
void RegisterOnDrop(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:105
static WidgetEventHandler GetInstance()
Определения WidgetEventHandler.c:22
void RegisterOnMouseButtonUp(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:77
void RegisterOnDoubleClick(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:140
Определения 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
WidgetFlags
Определения EnWidgets.c:58